commit af103e9c41a3099d62f4ff5afa99b3f25e9c1508 Author: Mark Crane Date: Mon Jun 4 14:58:40 2012 +0000 Add a missing file sip_profile_copy.php to the dev branch. diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000000..18fc58133c --- /dev/null +++ b/.htaccess @@ -0,0 +1,5 @@ +RewriteEngine On + + +RewriteRule ^([A-Fa-f0-9]{12})(\.(xml|cfg))?$ mod/provision/index.php?mac=$1 [QSA] +RewriteRule ^([A-Fa-f0-9]{2}[:-][A-Fa-f0-9]{2}[:-][A-Fa-f0-9]{2}[:-][A-Fa-f0-9]{2}[:-][A-Fa-f0-9]{2}[:-][A-Fa-f0-9]{2}[:-])(\.(xml|cfg))?$ mod/provision/index.php?mac=$1 [QSA] diff --git a/app/adminer/adminer.php b/app/adminer/adminer.php new file mode 100644 index 0000000000..fa6a60d3a0 --- /dev/null +++ b/app/adminer/adminer.php @@ -0,0 +1,1452 @@ + +function toggle(id){var el=document.getElementById(id);el.className=(el.className=='hidden'?'':'hidden');return true;} +function cookie(assign,days){var date=new Date();date.setDate(date.getDate()+days);document.cookie=assign+'; expires='+date;} +function verifyVersion(){cookie('adminer_version=0',1);var script=document.createElement('script');script.src=location.protocol+'//www.adminer.org/version.php';document.body.appendChild(script);} +function selectValue(select){var selected=select.options[select.selectedIndex];return((selected.attributes.value||{}).specified?selected.value:selected.text);} +function formCheck(el,name){var elems=el.form.elements;for(var i=0;i.*<\/noscript>/i,'');}}} +function nodePosition(el){var pos=0;while(el=el.previousSibling){pos++;} +return pos;} +function pageClick(href,page,event){if(!isNaN(page)&&page){href+=(page!=1?'&page='+(page-1):'');if(!ajaxSend(href)){location.href=href;}}} +function selectAddRow(field){field.onchange=function(){};var row=field.parentNode.cloneNode(true);var selects=row.getElementsByTagName('select');for(var i=0;i=0){input.maxLength=input.origMaxLength;}} +function ajax(url,callback,data){var xmlhttp=(window.XMLHttpRequest?new XMLHttpRequest():(window.ActiveXObject?new ActiveXObject('Microsoft.XMLHTTP'):false));if(xmlhttp){xmlhttp.open((data?'POST':'GET'),url);if(data){xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');} +xmlhttp.setRequestHeader('X-Requested-With','XMLHttpRequest');xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){callback(xmlhttp);}};xmlhttp.send(data);} +return xmlhttp;} +function ajaxSetHtml(url){return ajax(url,function(xmlhttp){if(xmlhttp.status){var data=eval('('+xmlhttp.responseText+')');for(var key in data){setHtml(key,data[key]);}}});} +function replaceFavicon(href){var favicon=document.getElementById('favicon');favicon.href=href;favicon.parentNode.appendChild(favicon);} +var ajaxState=0;function ajaxSend(url,data,popState){if(!history.pushState){return false;} +var currentState=++ajaxState;onblur=function(){replaceFavicon(location.pathname+'?file=loader.gif&version=3.2.2');};setHtml('loader','');return ajax(url,function(xmlhttp){if(currentState==ajaxState){var title=xmlhttp.getResponseHeader('X-AJAX-Title');if(title){document.title=decodeURIComponent(title);} +var redirect=xmlhttp.getResponseHeader('X-AJAX-Redirect');if(redirect){return ajaxSend(redirect,'',popState);} +onblur=function(){};replaceFavicon(location.pathname+'?file=favicon.ico&version=3.2.2');if(!xmlhttp.status){setHtml('loader','');}else{if(!popState){if(data||url!=location.href){history.pushState(data,'',url);} +scrollTo(0,0);} +setHtml('content',xmlhttp.responseText);var content=document.getElementById('content');var scripts=content.getElementsByTagName('script');var length=scripts.length;for(var i=0;i=allowed){return false;} +var match=/(\d+)(\.\d+)?/.exec(button.name);var x=match[0]+(match[2]?added.substr(match[2].length):added)+'1';var row=button.parentNode.parentNode;var row2=row.cloneNode(true);var tags=row.getElementsByTagName('select');var tags2=row2.getElementsByTagName('select');for(var i=0;idivs[i].offsetTop+top*em);} +if(!lineSet[id]){var line=document.getElementById(divs[i].id.replace(/^....(.+)-\d+$/,'refl$1'));var shift=ev.clientY-y-that.offsetTop;line.style.left=(left+left1)+'em';if(isTop){line.style.top=(line.offsetTop+shift)/em+'em';} +if(divs[i].parentNode!=div2.parentNode){line=line.getElementsByTagName('div')[0];line.style.height=(line.offsetHeight+(isTop?-1:1)*shift)/em+'em';} +lineSet[id]=true;}}} +that.style.left=left+'em';that.style.top=top+'em';}} +function schemaMouseup(ev,db){if(that!==undefined){ev=ev||event;tablePos[that.firstChild.firstChild.firstChild.data]=[(ev.clientY-y)/em,(ev.clientX-x)/em];that=undefined;var s='';for(var key in tablePos){s+='_'+key+':'+Math.round(tablePos[key][0]*10000)/10000+'x'+Math.round(tablePos[key][1]*10000)/10000;} +s=encodeURIComponent(s.substr(1));var link=document.getElementById('schema-link');link.href=link.href.replace(/[^=]+$/,'')+s;cookie('adminer_schema-'+db+'='+s,30);}}$y){unset($ub[$d][$Ma]);if(is_array($y)){$ub[$d][stripslashes($Ma)]=$y;$ub[]=&$ub[$d][stripslashes($Ma)];}else{$ub[$d][stripslashes($Ma)]=($_e?$y:stripslashes($y));}}}}}function +bracket_escape($N,$pf=false){static$Xd=array(':'=>':1',']'=>':2','['=>':3');return +strtr($N,($pf?array_flip($Xd):$Xd));}function +h($I){return +htmlspecialchars($I,ENT_QUOTES);}function +nbsp($I){return(trim($I)!=""?h($I):" ");}function +nl_br($I){return +str_replace("\n","
",$I);}function +checkbox($f,$q,$ab,$Ud="",$ae=""){static$S=0;$S++;$c="";return($Ud!=""?"":$c);}function +optionlist($Wc,$Mf=null,$oe=false){$c="";foreach($Wc +as$Ma=>$y){$ge=array($Ma=>$y);if(is_array($y)){$c.='';$ge=$y;}foreach($ge +as$d=>$b){$c.=''.h($b);}if(is_array($y)){$c.='';}}return$c;}function +adminer_html_select($f,$Wc,$q="",$Qb=true){if($Qb){return"";}$c="";foreach($Wc +as$d=>$b){$c.="";}return$c;}function +confirm($Qc="",$Sf=false){return" onclick=\"".($Sf?"eventStop(event); ":"")."return confirm('".lang(0).($Qc?" (' + $Qc + ')":"")."');\"";}function +js_escape($I){return +addcslashes($I,"\r\n'\\/");}function +ini_bool($Rf){$b=ini_get($Rf);return(eregi('^(on|true|yes)$',$b)||(int)$b);}function +sid(){static$c;if(!isset($c)){$c=(SID&&!($_COOKIE&&ini_bool("session.use_cookies")));}return$c;}function +q($I){global$g;return$g->quote($I);}function +get_vals($j,$C=0){global$g;$c=array();$i=$g->query($j);if(is_object($i)){while($a=$i->fetch_row()){$c[]=$a[$C];}}return$c;}function +get_key_vals($j,$G=null){global$g;if(!is_object($G)){$G=$g;}$c=array();$i=$G->query($j);if(is_object($i)){while($a=$i->fetch_row()){$c[$a[0]]=$a[1];}}return$c;}function +get_rows($j,$G=null,$n="

"){global$g;if(!is_object($G)){$G=$g;}$c=array();$i=$G->query($j);if(is_object($i)){while($a=$i->fetch_assoc()){$c[]=$a;}}elseif(!$i&&$g->error&&$n&&defined("PAGE_HEADER")){echo$n.error()."\n";}return$c;}function +unique_array($a,$J){foreach($J +as$x){if(ereg("PRIMARY|UNIQUE",$x["type"])){$c=array();foreach($x["columns"]as$d){if(!isset($a[$d])){continue +2;}$c[$d]=$a[$d];}return$c;}}$c=array();foreach($a +as$d=>$b){if(!preg_match('~^(COUNT\\((\\*|(DISTINCT )?`(?:[^`]|``)+`)\\)|(AVG|GROUP_CONCAT|MAX|MIN|SUM)\\(`(?:[^`]|``)+`\\))$~',$d)){$c[$d]=$b;}}return$c;}function +where($s){global$v;$c=array();foreach((array)$s["where"]as$d=>$b){$c[]=idf_escape(bracket_escape($d,1)).(ereg('\\.',$b)||$v=="mssql"?" LIKE ".exact_value(addcslashes($b,"%_")):" = ".exact_value($b));}foreach((array)$s["null"]as$d){$c[]=idf_escape($d)." IS NULL";}return +implode(" AND ",$c);}function +where_check($b){parse_str($b,$fe);remove_slashes(array(&$fe));return +where($fe);}function +where_link($l,$C,$q,$If="="){return"&where%5B$l%5D%5Bcol%5D=".urlencode($C)."&where%5B$l%5D%5Bop%5D=".urlencode((isset($q)?$If:"IS NULL"))."&where%5B$l%5D%5Bval%5D=".urlencode($q);}function +cookie($f,$q){global$Ac;$xc=array($f,(ereg("\n",$q)?"":$q),time()+2592000,preg_replace('~\\?.*~','',$_SERVER["REQUEST_URI"]),"",$Ac);if(version_compare(PHP_VERSION,'5.2.0')>=0){$xc[]=true;}return +call_user_func_array('setcookie',$xc);}function +restart_session(){if(!ini_bool("session.use_cookies")){session_start();}}function&get_session($d){return$_SESSION[$d][DRIVER][SERVER][$_GET["username"]];}function +set_session($d,$b){$_SESSION[$d][DRIVER][SERVER][$_GET["username"]]=$b;}function +auth_url($Ib,$F,$P){global$na;preg_match('~([^?]*)\\??(.*)~',remove_from_uri(implode("|",array_keys($na))."|username|".session_name()),$k);return"$k[1]?".(sid()?SID."&":"").($Ib!="server"||$F!=""?urlencode($Ib)."=".urlencode($F)."&":"")."username=".urlencode($P).($k[2]?"&$k[2]":"");}function +is_ajax(){return($_SERVER["HTTP_X_REQUESTED_WITH"]=="XMLHttpRequest");}function +redirect($ga,$va=null){if(isset($va)){restart_session();$_SESSION["messages"][preg_replace('~^[^?]*~','',(isset($ga)?$ga:$_SERVER["REQUEST_URI"]))][]=$va;}if(isset($ga)){if($ga==""){$ga=".";}header((is_ajax()?"X-AJAX-Redirect":"Location").": $ga");exit;}}function +query_redirect($j,$ga,$va,$fd=true,$Ef=true,$bf=false){global$g,$n,$o;if($Ef){$bf=!$g->query($j);}$xd="";if($j){$xd=$o->messageQuery("$j;");}if($bf){$n=error().$xd;return +false;}if($fd){redirect($ga,$va.$xd);}return +true;}function +queries($j=null){global$g;static$jb=array();if(!isset($j)){return +implode(";\n",$jb);}$jb[]=(ereg(';$',$j)?"DELIMITER ;;\n$j;\nDELIMITER ":$j);return$g->query($j);}function +apply_queries($j,$E,$Df='table'){foreach($E +as$h){if(!queries("$j ".$Df($h))){return +false;}}return +true;}function +queries_redirect($ga,$va,$fd){return +query_redirect(queries(),$ga,$va,$fd,false,!$fd);}function +remove_from_uri($Za=""){return +substr(preg_replace("~(?<=[?&])($Za".(SID?"":"|".session_name()).")=[^&]*&~",'',"$_SERVER[REQUEST_URI]&"),0,-1);}function +pagination($ca,$zf){return" ".($ca==$zf?$ca+1:''.($ca+1)."");}function +get_file($d,$sd=false){$Ia=$_FILES[$d];if(!$Ia||$Ia["error"]){return$Ia["error"];}$c=file_get_contents($sd&&ereg('\\.gz$',$Ia["name"])?"compress.zlib://$Ia[tmp_name]":($sd&&ereg('\\.bz2$',$Ia["name"])?"compress.bzip2://$Ia[tmp_name]":$Ia["tmp_name"]));if($sd){$Fb=substr($c,0,3);if(function_exists("iconv")&&ereg("^\xFE\xFF|^\xFF\xFE",$Fb,$Xf)){$c=iconv("utf-16","utf-8",$c);}elseif($Fb=="\xEF\xBB\xBF"){$c=substr($c,3);}}return$c;}function +upload_error($n){$gf=($n==UPLOAD_ERR_INI_SIZE?ini_get("upload_max_filesize"):null);return($n?lang(1).($gf?" ".lang(2,$gf):""):lang(3));}function +odd($c=' class="odd"'){static$l=0;if(!$c){$l=-1;}return($l++% +2?$c:'');}function +json_row($d,$b=null){static$Ba=true;if($Ba){echo"{";}if($d!=""){echo($Ba?"":",")."\n\t\"".addcslashes($d,"\r\n\"\\").'": '.(isset($b)?'"'.addcslashes($b,"\r\n\"\\").'"':'undefined');$Ba=false;}else{echo"\n}\n";$Ba=true;}}function +is_utf8($b){return(preg_match('~~u',$b)&&!preg_match('~[\\0-\\x8\\xB\\xC\\xE-\\x1F]~',$b));}function +repeat_pattern($ba,$W){return +str_repeat("$ba{0,65535}",$W/65535)."$ba{0,".($W +% +65535)."}";}function +shorten_utf8($I,$W=80,$Af=""){if(!preg_match("(^(".repeat_pattern("[\t\r\n -\x{FFFF}]",$W).")($)?)u",$I,$k)){preg_match("(^(".repeat_pattern("[\t\r\n -~]",$W).")($)?)",$I,$k);}return +h($k[1]).$Af.(isset($k[2])?"":"...");}function +friendly_url($b){return +preg_replace('~[^a-z0-9_]~i','-',$b);}function +hidden_fields($ub,$Qf=array()){while(list($d,$b)=each($ub)){if(is_array($b)){foreach($b +as$Ma=>$y){$ub[$d."[$Ma]"]=$y;}}elseif(!in_array($d,$Qf)){echo'';}}}function +hidden_fields_get(){echo(sid()?'':''),(SERVER!==null?'':""),'';}function +column_foreign_keys($h){global$o;$c=array();foreach($o->foreignKeys($h)as$A){foreach($A["source"]as$b){$c[$b][]=$A;}}return$c;}function +enum_input($z,$Ra,$e,$q,$hc=null){global$o;preg_match_all("~'((?:[^']|'')*)'~",$e["length"],$oa);$c=(isset($hc)?"":"");foreach($oa[1]as$l=>$b){$b=stripcslashes(str_replace("''","'",$b));$ab=(is_int($q)?$q==$l+1:(is_array($q)?in_array($l+1,$q):$q===$b));$c.=" ';}return$c;}function +input($e,$q,$K){global$R,$o,$v;$f=h(bracket_escape($e["field"]));echo"";$De=($v=="mssql"&&$e["auto_increment"]);if($De&&!$_POST["save"]){$K=null;}$da=(isset($_GET["select"])||$De?array("orig"=>lang(5)):array())+$o->editFunctions($e);$Ra=" name='fields[$f]'";if($e["type"]=="enum"){echo +nbsp($da[""])."".$o->editInput($_GET["edit"],$e,$Ra,$q);}else{$Ba=0;foreach($da +as$d=>$b){if($d===""||!$b){break;}$Ba++;}$Qb=($Ba?" onchange=\"var f = this.form['function[".js_escape($f)."]']; if ($Ba > f.selectedIndex) f.selectedIndex = $Ba;\"":"");$Ra.=$Qb;echo(count($da)>1?adminer_html_select("function[$f]",$da,!isset($K)||in_array($K,$da)||isset($da[$K])?$K:"","functionChange(this);"):nbsp(reset($da))).'';$Ae=$o->editInput($_GET["edit"],$e,$Ra,$q);if($Ae!=""){echo$Ae;}elseif($e["type"]=="set"){preg_match_all("~'((?:[^']|'')*)'~",$e["length"],$oa);foreach($oa[1]as$l=>$b){$b=stripcslashes(str_replace("''","'",$b));$ab=(is_int($q)?($q>>$l)&1:in_array($b,explode(",",$q),true));echo" ';}}elseif(ereg('blob|bytea|raw|file',$e["type"])&&ini_bool("file_uploads")){echo"";}elseif(ereg('text|lob',$e["type"])){echo"';}else{$nd=(!ereg('int',$e["type"])&&preg_match('~^(\\d+)(,(\\d+))?$~',$e["length"],$k)?((ereg("binary",$e["type"])?2:1)*$k[1]+($k[3]?1:0)+($k[2]&&!$e["unsigned"]?1:0)):($R[$e["type"]]?$R[$e["type"]]+($e["unsigned"]?0:1):0));echo"20?" size='40'":"")."$Ra>";}}}function +process_input($e){global$o;$N=bracket_escape($e["field"]);$K=$_POST["function"][$N];$q=$_POST["fields"][$N];if($e["type"]=="enum"){if($q==-1){return +false;}if($q==""){return"NULL";}return+$q;}if($e["auto_increment"]&&$q==""){return +null;}if($K=="orig"){return +false;}if($K=="NULL"){return"NULL";}if($e["type"]=="set"){return +array_sum((array)$q);}if(ereg('blob|bytea|raw|file',$e["type"])&&ini_bool("file_uploads")){$Ia=get_file("fields-$N");if(!is_string($Ia)){return +false;}return +q($Ia);}return$o->processInput($e,$q,$K);}function +search_tables(){global$o,$g;$_GET["where"][0]["op"]="LIKE %%";$_GET["where"][0]["val"]=$_POST["query"];$ta=false;foreach(table_status()as$h=>$D){$f=$o->tableName($D);if(isset($D["Engine"])&&$f!=""&&(!$_POST["tables"]||in_array($h,$_POST["tables"]))){$i=$g->query("SELECT".limit("1 FROM ".table($h)," WHERE ".implode(" AND ",$o->selectSearchProcess(fields($h),array())),1));if($i->fetch_row()){if(!$ta){echo"

    \n";$ta=true;}echo"
  • $f\n";}}}echo($ta?"
":"

".lang(6))."\n";}function +dump_headers($Sc,$_d=false){global$o;$c=$o->dumpHeaders($Sc,$_d);$Na=$_POST["output"];if($Na!="text"){header("Content-Disposition: attachment; filename=".($Sc!=""?friendly_url($Sc):"dump").".$c".($Na!="file"&&!ereg('[^0-9a-z]',$Na)?".$Na":""));}session_write_close();return$c;}function +dump_csv($a){foreach($a +as$d=>$b){if(preg_match("~[\"\n,;\t]~",$b)||$b===""){$a[$d]='"'.str_replace('"','""',$b).'"';}}echo +implode(($_POST["format"]=="csv"?",":($_POST["format"]=="tsv"?"\t":";")),$a)."\r\n";}function +apply_sql_function($K,$C){return($K?($K=="unixepoch"?"DATETIME($C, '$K')":($K=="count distinct"?"COUNT(DISTINCT ":strtoupper("$K("))."$C)"):$C);}function +password_file(){$Rc=ini_get("upload_tmp_dir");if(!$Rc){if(function_exists('sys_get_temp_dir')){$Rc=sys_get_temp_dir();}else{$ja=@tempnam("","");if(!$ja){return +false;}$Rc=dirname($ja);unlink($ja);}}$ja="$Rc/adminer.key";$c=@file_get_contents($ja);if($c){return$c;}$Pa=@fopen($ja,"w");if($Pa){$c=md5(uniqid(mt_rand(),true));fwrite($Pa,$c);fclose($Pa);}return$c;}function +is_mail($xf){$Ne='[-a-z0-9!#$%&\'*+/=?^_`{|}~]';$vc='[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])';$ba="$Ne+(\\.$Ne+)*@($vc?\\.)+$vc";return +preg_match("(^$ba(,\\s*$ba)*\$)i",$xf);}function +is_url($I){$vc='[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])';return(preg_match("~^(https?)://($vc?\\.)+$vc(:\\d+)?(/.*)?(\\?.*)?(#.*)?\$~i",$I,$k)?strtolower($k[1]):"");}function +print_fieldset($S,$Of,$Kf=false){echo"

$Of
\n";}function +selectSearchPrint($s,$B,$J){print_fieldset("search",lang(36),$s);foreach($J +as$l=>$x){if($x["type"]=="FULLTEXT"){echo"(".implode(", ",array_map('h',$x["columns"])).") AGAINST"," ",checkbox("boolean[$l]",1,isset($_GET["boolean"][$l]),"BOOL"),"
\n";}}$l=0;foreach((array)$_GET["where"]as$b){if("$b[col]$b[val]"!=""&&in_array($b["op"],$this->operators)){echo"
",adminer_html_select("where[$l][op]",$this->operators,$b["op"]),"
\n";$l++;}}echo"
",adminer_html_select("where[$l][op]",$this->operators,"="),"
\n","\n";}function +selectOrderPrint($Xa,$B,$J){print_fieldset("sort",lang(38),$Xa);$l=0;foreach((array)$_GET["order"]as$d=>$b){if(isset($B[$b])){echo"
",checkbox("desc[$l]",1,isset($_GET["desc"][$d]),lang(39))."
\n";$l++;}}echo"
","
\n";echo"\n";}function +selectLimitPrint($O){echo"
".lang(40)."
";echo"","
\n";}function +selectLengthPrint($Db){if(isset($Db)){echo"
".lang(41)."
",'',"
\n";}}function +selectActionPrint(){echo"
".lang(42)."
","","
\n";}function +selectEmailPrint($bg,$B){}function +selectColumnsProcess($B,$J){global$da,$lb;$Q=array();$pa=array();foreach((array)$_GET["columns"]as$d=>$b){if($b["fun"]=="count"||(isset($B[$b["col"]])&&(!$b["fun"]||in_array($b["fun"],$da)||in_array($b["fun"],$lb)))){$Q[$d]=apply_sql_function($b["fun"],(isset($B[$b["col"]])?idf_escape($b["col"]):"*"));if(!in_array($b["fun"],$lb)){$pa[]=$Q[$d];}}}return +array($Q,$pa);}function +selectSearchProcess($p,$J){global$v;$c=array();foreach($J +as$l=>$x){if($x["type"]=="FULLTEXT"&&$_GET["fulltext"][$l]!=""){$c[]="MATCH (".implode(", ",array_map('idf_escape',$x["columns"])).") AGAINST (".q($_GET["fulltext"][$l]).(isset($_GET["boolean"][$l])?" IN BOOLEAN MODE":"").")";}}foreach((array)$_GET["where"]as$b){if("$b[col]$b[val]"!=""&&in_array($b["op"],$this->operators)){$Ub=" $b[op]";if(ereg('IN$',$b["op"])){$Tb=process_length($b["val"]);$Ub.=" (".($Tb!=""?$Tb:"NULL").")";}elseif(!$b["op"]){$Ub.=$b["val"];}elseif($b["op"]=="LIKE %%"){$Ub=" LIKE ".$this->processInput($p[$b["col"]],"%$b[val]%");}elseif(!ereg('NULL$',$b["op"])){$Ub.=" ".$this->processInput($p[$b["col"]],$b["val"]);}if($b["col"]!=""){$c[]=idf_escape($b["col"]).$Ub;}else{$mb=array();foreach($p +as$f=>$e){if(is_numeric($b["val"])||!ereg('int|float|double|decimal',$e["type"])){$f=idf_escape($f);$mb[]=($v=="sql"&&ereg('char|text|enum|set',$e["type"])&&!ereg('^utf8',$e["collation"])?"CONVERT($f USING utf8)":$f);}}$c[]=($mb?"(".implode("$Ub OR ",$mb)."$Ub)":"0");}}}return$c;}function +selectOrderProcess($p,$J){$c=array();foreach((array)$_GET["order"]as$d=>$b){if(isset($p[$b])||preg_match('~^((COUNT\\(DISTINCT |[A-Z0-9_]+\\()(`(?:[^`]|``)+`|"(?:[^"]|"")+")\\)|COUNT\\(\\*\\))$~',$b)){$c[]=(isset($p[$b])?idf_escape($b):$b).(isset($_GET["desc"][$d])?" DESC":"");}}return$c;}function +selectLimitProcess(){return(isset($_GET["limit"])?$_GET["limit"]:"30");}function +selectLengthProcess(){return(isset($_GET["text_length"])?$_GET["text_length"]:"100");}function +selectEmailProcess($s,$vf){return +false;}function +messageQuery($j){global$v;static$Qc=0;restart_session();$S="sql-".($Qc++);$eb=&get_session("queries");if(strlen($j)>1e6){$j=ereg_replace('[\x80-\xFF]+$','',substr($j,0,1e6))."\n...";}$eb[$_GET["db"]][]=$j;return" ".lang(43)."';}function +editFunctions($e){global$Nb;$c=($e["null"]?"NULL/":"");foreach($Nb +as$d=>$da){if(!$d||(!isset($_GET["call"])&&(isset($_GET["select"])||where($_GET)))){foreach($da +as$ba=>$b){if(!$ba||ereg($ba,$e["type"])){$c.="/$b";}}if($d&&!ereg('set|blob|bytea|raw|file',$e["type"])){$c.="/=";}}}return +explode("/",$c);}function +editInput($h,$e,$Ra,$q){if($e["type"]=="enum"){return(isset($_GET["select"])?" ":"").($e["null"]?" ":"").enum_input("radio",$Ra,$e,$q,0);}return"";}function +processInput($e,$q,$K=""){if($K=="="){return$q;}$f=$e["field"];$c=($e["type"]=="bit"&&ereg('^[0-9]+$',$q)?$q:q($q));if(ereg('^(now|getdate|uuid)$',$K)){$c="$K()";}elseif(ereg('^current_(date|timestamp)$',$K)){$c=$K;}elseif(ereg('^([+-]|\\|\\|)$',$K)){$c=idf_escape($f)." $K $c";}elseif(ereg('^[+-] interval$',$K)){$c=idf_escape($f)." $K ".(preg_match("~^(\\d+|'[0-9.: -]') [A-Z_]+$~i",$q)?$q:$c);}elseif(ereg('^(addtime|subtime|concat)$',$K)){$c="$K(".idf_escape($f).", $c)";}elseif(ereg('^(md5|sha1|password|encrypt|hex)$',$K)){$c="$K($c)";}if(ereg("binary",$e["type"])){$c="unhex($c)";}return$c;}function +dumpOutput(){$c=array('text'=>lang(44),'file'=>lang(45));if(function_exists('gzencode')){$c['gz']='gzip';}if(function_exists('bzcompress')){$c['bz2']='bzip2';}return$c;}function +dumpFormat(){return +array('sql'=>'SQL','csv'=>'CSV,','csv;'=>'CSV;','tsv'=>'TSV');}function +dumpTable($h,$V,$bd=false){if($_POST["format"]!="sql"){echo"\xef\xbb\xbf";if($V){dump_csv(array_keys(fields($h)));}}elseif($V){$la=create_sql($h,$_POST["auto_increment"]);if($la){if($V=="DROP+CREATE"){echo"DROP ".($bd?"VIEW":"TABLE")." IF EXISTS ".table($h).";\n";}if($bd){$la=preg_replace('~^([A-Z =]+) DEFINER=`'.preg_replace('~@(.*)~','`@`(%|\\1)',logged_user()).'`~','\\1',$la);}echo($V!="CREATE+ALTER"?$la:($bd?substr_replace($la," OR REPLACE",6,0):substr_replace($la," IF NOT EXISTS",12,0))).";\n\n";}if($V=="CREATE+ALTER"&&!$bd){$j="SELECT COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE, COLLATION_NAME, COLUMN_TYPE, EXTRA, COLUMN_COMMENT FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = ".q($h)." ORDER BY ORDINAL_POSITION";echo"DELIMITER ;; +CREATE PROCEDURE adminer_alter (INOUT alter_command text) BEGIN + DECLARE _column_name, _collation_name, after varchar(64) DEFAULT ''; + DECLARE _column_type, _column_default text; + DECLARE _is_nullable char(3); + DECLARE _extra varchar(30); + DECLARE _column_comment varchar(255); + DECLARE done, set_after bool DEFAULT 0; + DECLARE add_columns text DEFAULT '";$p=array();$Jb="";foreach(get_rows($j)as$a){$za=$a["COLUMN_DEFAULT"];$a["default"]=(isset($za)?q($za):"NULL");$a["after"]=q($Jb);$a["alter"]=escape_string(idf_escape($a["COLUMN_NAME"])." $a[COLUMN_TYPE]".($a["COLLATION_NAME"]?" COLLATE $a[COLLATION_NAME]":"").(isset($za)?" DEFAULT ".($za=="CURRENT_TIMESTAMP"?$za:$a["default"]):"").($a["IS_NULLABLE"]=="YES"?"":" NOT NULL").($a["EXTRA"]?" $a[EXTRA]":"").($a["COLUMN_COMMENT"]?" COMMENT ".q($a["COLUMN_COMMENT"]):"").($Jb?" AFTER ".idf_escape($Jb):" FIRST"));echo", ADD $a[alter]";$p[]=$a;$Jb=$a["COLUMN_NAME"];}echo"'; + DECLARE columns CURSOR FOR $j; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; + SET @alter_table = ''; + OPEN columns; + REPEAT + FETCH columns INTO _column_name, _column_default, _is_nullable, _collation_name, _column_type, _extra, _column_comment; + IF NOT done THEN + SET set_after = 1; + CASE _column_name";foreach($p +as$a){echo" + WHEN ".q($a["COLUMN_NAME"])." THEN + SET add_columns = REPLACE(add_columns, ', ADD $a[alter]', ''); + IF NOT (_column_default <=> $a[default]) OR _is_nullable != '$a[IS_NULLABLE]' OR _collation_name != '$a[COLLATION_NAME]' OR _column_type != ".q($a["COLUMN_TYPE"])." OR _extra != '$a[EXTRA]' OR _column_comment != ".q($a["COLUMN_COMMENT"])." OR after != $a[after] THEN + SET @alter_table = CONCAT(@alter_table, ', MODIFY $a[alter]'); + END IF;";}echo" + ELSE + SET @alter_table = CONCAT(@alter_table, ', DROP ', _column_name); + SET set_after = 0; + END CASE; + IF set_after THEN + SET after = _column_name; + END IF; + END IF; + UNTIL done END REPEAT; + CLOSE columns; + IF @alter_table != '' OR add_columns != '' THEN + SET alter_command = CONCAT(alter_command, 'ALTER TABLE ".table($h)."', SUBSTR(CONCAT(add_columns, @alter_table), 2), ';\\n'); + END IF; +END;; +DELIMITER ; +CALL adminer_alter(@adminer_alter); +DROP PROCEDURE adminer_alter; + +";}}}function +dumpData($h,$V,$j){global$g,$v;$Ke=($v=="sqlite"?0:1048576);if($V){if($_POST["format"]=="sql"&&$V=="TRUNCATE+INSERT"){echo +truncate_sql($h).";\n";}if($_POST["format"]=="sql"){$p=fields($h);}$i=$g->query($j,1);if($i){$sc="";$kb="";while($a=$i->fetch_assoc()){if($_POST["format"]!="sql"){if($V=="table"){dump_csv(array_keys($a));$V="INSERT";}dump_csv($a);}else{if(!$sc){$sc="INSERT INTO ".table($h)." (".implode(", ",array_map('idf_escape',array_keys($a))).") VALUES";}foreach($a +as$d=>$b){$a[$d]=(isset($b)?(ereg('int|float|double|decimal',$p[$d]["type"])?$b:q($b)):"NULL");}$ma=implode(",\t",$a);if($V=="INSERT+UPDATE"){$r=array();foreach($a +as$d=>$b){$r[]=idf_escape($d)." = $b";}echo"$sc ($ma) ON DUPLICATE KEY UPDATE ".implode(", ",$r).";\n";}else{$ma=($Ke?"\n":" ")."($ma)";if(!$kb){$kb=$sc.$ma;}elseif(strlen($kb)+2+strlen($ma)<$Ke){$kb.=",$ma";}else{$kb.=";\n";echo$kb;$kb=$sc.$ma;}}}}if($_POST["format"]=="sql"&&$V!="INSERT+UPDATE"&&$kb){$kb.=";\n";echo$kb;}}elseif($_POST["format"]=="sql"){echo"-- ".str_replace("\n"," ",$g->error)."\n";}}}function +dumpHeaders($Sc,$_d=false){$Na=$_POST["output"];$Hb=($_POST["format"]=="sql"?"sql":($_d?"tar":"csv"));header("Content-Type: ".($Na=="bz2"?"application/x-bzip":($Na=="gz"?"application/x-gzip":($Hb=="tar"?"application/x-tar":($Hb=="sql"||$Na!="file"?"text/plain":"text/csv")."; charset=utf-8"))));if($Na=="bz2"){ob_start('bzcompress',1e6);}if($Na=="gz"){ob_start('gzencode',1e6);}return$Hb;}function +homepage(){echo'

'.($_GET["ns"]==""?''.lang(46)."\n":"");if(support("scheme")){echo"".($_GET["ns"]!=""?lang(47):lang(48))."\n";}return +true;}function +navigation($Zb){global$tc,$g,$M,$v,$na;echo'

+',$this->name(),' +',$tc,' +',(version_compare($tc,$_COOKIE["adminer_version"])<0?h($_COOKIE["adminer_version"]):""),' +

+';if($Zb=="auth"){$Ba=true;foreach((array)$_SESSION["pwds"]as$Ib=>$Uf){foreach($Uf +as$F=>$Nf){foreach($Nf +as$P=>$T){if(isset($T)){if($Ba){echo"

\n";$Ba=false;}echo"($na[$Ib]) ".h($P.($F!=""?"@$F":""))."
\n";}}}}}else{$_=get_databases();echo'

+

+';if(DB==""||!$Zb){echo"".lang(43)."\n";if(support("dump")){echo"".lang(49)."\n";}}echo' + +

+
+
+

+';hidden_fields_get();echo($_?adminer_html_select("db",array(""=>"(".lang(51).")")+$_,DB,"this.form.submit();"):''),' +';if($Zb!="db"&&DB!=""&&$g->select_db(DB)){if(support("scheme")){echo"
".adminer_html_select("ns",array(""=>"(".lang(52).")")+schemas(),$_GET["ns"],"this.form.submit();");if($_GET["ns"]!=""){set_schema($_GET["ns"]);}}if($_GET["ns"]!==""&&!$Zb){echo'

".lang(53)."\n";$E=tables_list();if(!$E){echo"

".lang(6)."\n";}else{$this->tablesPrint($E);$Ja=array();foreach($E +as$h=>$z){$Ja[]=preg_quote($h,'/');}echo"\n";}}}echo(isset($_GET["sql"])?'':(isset($_GET["schema"])?'':(isset($_GET["dump"])?'':""))),"

\n";}}function +tablesPrint($E){echo"

\n";foreach($E +as$h=>$z){echo'".lang(54)." ",'".$this->tableName(array("Name"=>$h))."
\n";}}}$o=(function_exists('adminer_object')?adminer_object():new +Adminer);if(!isset($o->operators)){$o->operators=$gc;}function +page_header($Je,$n="",$pc=array(),$Ie=""){global$ua,$o,$g,$na;header("Content-Type: text/html; charset=utf-8");$o->headers();$He=$Je.($Ie!=""?": ".h($Ie):"");$Le=strip_tags($He.(SERVER!=""&&SERVER!="localhost"?h(" - ".SERVER):"")." - ".$o->name());if(is_ajax()){header("X-AJAX-Title: ".rawurlencode($Le));}else{echo' + + + + +',$Le,' + + + + +';if($o->head()&&file_exists("adminer.css")){echo' +';}echo' +"> + + +

+'.$na[DRIVER].' » ';$w=substr(preg_replace('~(db|ns)=[^&]*&~','',ME),0,-1);$F=(SERVER!=""?h(SERVER):lang(20));if($pc===false){echo"$F\n";}else{echo"$F » ";if($_GET["ns"]!=""||(DB!=""&&is_array($pc))){echo''.h(DB).' » ';}if(is_array($pc)){if($_GET["ns"]!=""){echo''.h($_GET["ns"]).' » ';}foreach($pc +as$d=>$b){$rc=(is_array($b)?$b[1]:$b);if($rc!=""){echo''.h($rc).' » ';}}}echo"$Je\n";}}echo"\n","

$He

\n";restart_session();$Me=preg_replace('~^[^?]*~','',$_SERVER["REQUEST_URI"]);$Qe=$_SESSION["messages"][$Me];if($Qe){echo"
".implode("
\n
",$Qe)."
\n";unset($_SESSION["messages"][$Me]);}$_=&get_session("dbs");if(DB!=""&&$_&&!in_array(DB,$_,true)){$_=null;}if($n){echo"
$n
\n";}define("PAGE_HEADER",1);}function +page_footer($Zb=""){global$o;if(!is_ajax()){echo'
+ +';switch_lang();echo' +';}}function +int32($fa){while($fa>=2147483648){$fa-=4294967296;}while($fa<=-2147483649){$fa+=4294967296;}return(int)$fa;}function +long2str($y,$Hd){$ma='';foreach($y +as$b){$ma.=pack('V',$b);}if($Hd){return +substr($ma,0,end($y));}return$ma;}function +str2long($ma,$Hd){$y=array_values(unpack('V*',str_pad($ma,4*ceil(strlen($ma)/4),"\0")));if($Hd){$y[]=strlen($ma);}return$y;}function +xxtea_mx($Ca,$xa,$Fa,$Ma){return +int32((($Ca>>5&0x7FFFFFF)^$xa<<2)+(($xa>>3&0x1FFFFFFF)^$Ca<<4))^int32(($Fa^$xa)+($Ma^$Ca));}function +encrypt_string($Fc,$d){if($Fc==""){return"";}$d=array_values(unpack("V*",pack("H*",md5($d))));$y=str2long($Fc,true);$fa=count($y)-1;$Ca=$y[$fa];$xa=$y[0];$aa=floor(6+52/($fa+1));$Fa=0;while($aa-->0){$Fa=int32($Fa+0x9E3779B9);$Ec=$Fa>>2&3;for($wa=0;$wa<$fa;$wa++){$xa=$y[$wa+1];$Mb=xxtea_mx($Ca,$xa,$Fa,$d[$wa&3^$Ec]);$Ca=int32($y[$wa]+$Mb);$y[$wa]=$Ca;}$xa=$y[0];$Mb=xxtea_mx($Ca,$xa,$Fa,$d[$wa&3^$Ec]);$Ca=int32($y[$fa]+$Mb);$y[$fa]=$Ca;}return +long2str($y,false);}function +decrypt_string($Fc,$d){if($Fc==""){return"";}$d=array_values(unpack("V*",pack("H*",md5($d))));$y=str2long($Fc,false);$fa=count($y)-1;$Ca=$y[$fa];$xa=$y[0];$aa=floor(6+52/($fa+1));$Fa=int32($aa*0x9E3779B9);while($Fa){$Ec=$Fa>>2&3;for($wa=$fa;$wa>0;$wa--){$Ca=$y[$wa-1];$Mb=xxtea_mx($Ca,$xa,$Fa,$d[$wa&3^$Ec]);$xa=int32($y[$wa]-$Mb);$y[$wa]=$xa;}$Ca=$y[$fa];$Mb=xxtea_mx($Ca,$xa,$Fa,$d[$wa&3^$Ec]);$xa=int32($y[0]-$Mb);$y[0]=$xa;$Fa=int32($Fa-0x9E3779B9);}return +long2str($y,true);}$g='';$M=$_SESSION["token"];if(!$_SESSION["token"]){$_SESSION["token"]=rand(1,1e6);}$_b=array();if($_COOKIE["adminer_permanent"]){foreach(explode(" ",$_COOKIE["adminer_permanent"])as$b){list($d)=explode(":",$b);$_b[$d]=$b;}}if(isset($_POST["server"])){session_regenerate_id();$_SESSION["pwds"][$_POST["driver"]][$_POST["server"]][$_POST["username"]]=$_POST["password"];if($_POST["permanent"]){$d=base64_encode($_POST["driver"])."-".base64_encode($_POST["server"])."-".base64_encode($_POST["username"]);$Vc=$o->permanentLogin();$_b[$d]="$d:".base64_encode($Vc?encrypt_string($_POST["password"],$Vc):"");cookie("adminer_permanent",implode(" ",$_b));}if(count($_POST)==($_POST["permanent"]?5:4)||DRIVER!=$_POST["driver"]||SERVER!=$_POST["server"]||$_GET["username"]!==$_POST["username"]){redirect(auth_url($_POST["driver"],$_POST["server"],$_POST["username"]));}}elseif($_POST["logout"]){if($M&&$_POST["token"]!=$M){page_header(lang(50),lang(57));page_footer("db");exit;}else{foreach(array("pwds","dbs","queries")as$d){set_session($d,null);}$d=base64_encode(DRIVER)."-".base64_encode(SERVER)."-".base64_encode($_GET["username"]);if($_b[$d]){unset($_b[$d]);cookie("adminer_permanent",implode(" ",$_b));}redirect(substr(preg_replace('~(username|db|ns)=[^&]*&~','',ME),0,-1),lang(58));}}elseif($_b&&!$_SESSION["pwds"]){session_regenerate_id();$Vc=$o->permanentLogin();foreach($_b +as$d=>$b){list(,$Pf)=explode(":",$b);list($Ib,$F,$P)=array_map('base64_decode',explode("-",$d));$_SESSION["pwds"][$Ib][$F][$P]=decrypt_string(base64_decode($Pf),$Vc);}}function +auth_error($ze=null){global$g,$o,$M;$Tc=session_name();$n="";if(!$_COOKIE[$Tc]&&$_GET[$Tc]&&ini_bool("session.use_only_cookies")){$n=lang(59);}elseif(isset($_GET["username"])){if(($_COOKIE[$Tc]||$_GET[$Tc])&&!$M){$n=lang(60);}else{$T=&get_session("pwds");if(isset($T)){$n=h($ze?$ze->getMessage():(is_string($g)?$g:lang(61)));$T=null;}}}page_header(lang(23),$n,null);echo"
\n";$o->loginForm();echo"
";hidden_fields($_POST,array("driver","server","username","password","permanent"));echo"
\n","
\n";page_footer("auth");}if(isset($_GET["username"])){if(!class_exists("Min_DB")){unset($_SESSION["pwds"][DRIVER]);page_header(lang(62),lang(63,implode(", ",$oc)),false);page_footer("auth");exit;}$g=connect();}if(is_string($g)||!$o->login($_GET["username"],get_session("pwds"))){auth_error();exit;}$M=$_SESSION["token"];if(isset($_POST["server"])&&$_POST["token"]){$_POST["token"]=$M;}$n=($_POST?($_POST["token"]==$M?"":lang(57)):($_SERVER["REQUEST_METHOD"]!="POST"?"":lang(64,'"post_max_size"')));function +connect_error(){global$g,$M,$n,$na;$_=array();if(DB!=""){page_header(lang(65).": ".h(DB),lang(66),true);}else{if($_POST["db"]&&!$n){queries_redirect(substr(ME,0,-1),lang(67),drop_databases($_POST["db"]));}page_header(lang(68),$n,false);echo"

".lang(69)."\n";foreach(array('privileges'=>lang(70),'processlist'=>lang(71),'variables'=>lang(72),'status'=>lang(73),)as$d=>$b){if(support($d)){echo"$b\n";}}echo"

".lang(74,$na[DRIVER],"$g->server_info","$g->extension")."\n","

".lang(75,"".h(logged_user())."")."\n";if($_GET["refresh"]){set_session("dbs",null);}$_=get_databases();if($_){$Ed=support("scheme");$Z=collations();echo"

\n","\n","\n";foreach($_ +as$t){$Jd=h(ME)."db=".urlencode($t);echo"
 ".lang(65)."".lang(76)."".lang(77)."
".checkbox("db[]",$t,in_array($t,(array)$_POST["db"])),"".h($t)."","".nbsp(db_collation($t,$Z))."","?","\n";}echo"
\n","

\n";echo"\n","".lang(79)."\n","

\n";}}page_footer("db");if($_){echo"\n";}}if(isset($_GET["status"])){$_GET["variables"]=$_GET["status"];}if(!(DB!=""?$g->select_db(DB):isset($_GET["sql"])||isset($_GET["dump"])||isset($_GET["database"])||isset($_GET["processlist"])||isset($_GET["privileges"])||isset($_GET["user"])||isset($_GET["variables"])||$_GET["script"]=="connect")){if(DB!=""){set_session("dbs",null);}connect_error();exit;}if(support("scheme")&&DB!=""&&$_GET["ns"]!==""){if(!isset($_GET["ns"])){redirect(preg_replace('~ns=[^&]*&~','',ME)."ns=".get_schema());}if(!set_schema($_GET["ns"])){page_header(lang(80).": ".h($_GET["ns"]),lang(81),true);page_footer("ns");exit;}}function +select($i,$G=null,$ye=""){$Ja=array();$J=array();$B=array();$xe=array();$R=array();odd('');for($l=0;$a=$i->fetch_row();$l++){if(!$l){echo"\n","";for($ra=0;$rafetch_field();$Da=$e->orgtable;$Bc=$e->orgname;if($Da!=""){if(!isset($J[$Da])){$J[$Da]=array();foreach(indexes($Da,$G)as$x){if($x["type"]=="PRIMARY"){$J[$Da]=array_flip($x["columns"]);break;}}$B[$Da]=$J[$Da];}if(isset($B[$Da][$Bc])){unset($B[$Da][$Bc]);$J[$Da][$Bc]=$ra;$Ja[$ra]=$Da;}}if($e->charsetnr==63){$xe[$ra]=true;}$R[$ra]=$e->type;$f=h($e->name);echo"name!=$Bc?" title='".h(($Da!=""?"$Da.":"").$Bc)."'":"").">".($ye?"$f":$f);}echo"\n";}echo"";foreach($a +as$d=>$b){if(!isset($b)){$b="NULL";}else{if($xe[$d]&&!is_utf8($b)){$b="".lang(32,strlen($b))."";}elseif(!strlen($b)){$b=" ";}else{$b=h($b);if($R[$d]==254){$b="$b";}}if(isset($Ja[$d])&&!$B[$Ja[$d]]){$w="edit=".urlencode($Ja[$d]);foreach($J[$Ja[$d]]as$Pc=>$ra){$w.="&where".urlencode("[".bracket_escape($Pc)."]")."=".urlencode($a[$ra]);}$b="$b";}}echo"
$b";}}echo($l?"
":"

".lang(82))."\n";}function +referencable_primary($Tf){$c=array();foreach(table_status()as$Ea=>$h){if($Ea!=$Tf&&fk_support($h)){foreach(fields($Ea)as$e){if($e["primary"]){if($c[$Ea]){unset($c[$Ea]);break;}$c[$Ea]=$e;}}}}return$c;}function +textarea($f,$q,$H=10,$mb=80){echo"";}function +format_time($Fb,$Cc){return" (".lang(83,max(0,$Cc[0]-$Fb[0]+$Cc[1]-$Fb[1])).")";}function +edit_type($d,$e,$Z,$ha=array()){global$La,$R,$ob,$fb;echo' +',"',($ob?"':''),($ha?" ":" ");}function +process_length($W){global$Gb;return(preg_match("~^\\s*(?:$Gb)(?:\\s*,\\s*(?:$Gb))*\\s*\$~",$W)&&preg_match_all("~$Gb~",$W,$oa)?implode(",",$oa[0]):preg_replace('~[^0-9,+-]~','',$W));}function +process_type($e,$Dc="COLLATE"){global$ob;return" $e[type]".($e["length"]!=""?"(".process_length($e["length"]).")":"").(ereg('int|float|double|decimal',$e["type"])&&in_array($e["unsigned"],$ob)?" $e[unsigned]":"").(ereg('char|text|enum|set',$e["type"])&&$e["collation"]?" $Dc ".q($e["collation"]):"");}function +process_field($e,$Uc){return +array(idf_escape($e["field"]),process_type($Uc),($e["null"]?" NULL":" NOT NULL"),(isset($e["default"])?" DEFAULT ".($e["type"]=="timestamp"&&eregi("^CURRENT_TIMESTAMP$",$e["default"])?$e["default"]:q($e["default"])):""),($e["on_update"]?" ON UPDATE $e[on_update]":""),(support("comment")&&$e["comment"]!=""?" COMMENT ".q($e["comment"]):""),($e["auto_increment"]?auto_increment():null),);}function +type_class($z){foreach(array('char'=>'text','date'=>'time|year','binary'=>'blob','enum'=>'set',)as$d=>$b){if(ereg("$d|$b",$z)){return" class='$d'";}}}function +edit_fields($p,$Z,$z="TABLE",$we=0,$ha=array(),$Kb=false){global$jc;foreach($p +as$e){if($e["comment"]!=""){$Kb=true;break;}}echo' +';if($z=="PROCEDURE"){echo' ';}echo'',($z=="TABLE"?lang(87):lang(88)),'',lang(89),' +',lang(90),'',lang(91);if($z=="TABLE"){echo'NULL +AI +',lang(93),(support("comment")?"

".lang(94).": ".h($_a)."\n";}if($p){echo"\n","\n";foreach($p +as$e){echo"
".lang(101)."".lang(89).(support("comment")?"".lang(94):"")."
".h($e["field"]),"".h($e["full_type"]).($e["null"]?" NULL":"").($e["auto_increment"]?" ".lang(92)."":""),(support("comment")?"".nbsp($e["comment"]):""),"\n";}echo"
\n";if(!is_view($D)){echo"

".lang(102)."

\n";$J=indexes($m);if($J){echo"\n";foreach($J +as$f=>$x){ksort($x["columns"]);$zb=array();foreach($x["columns"]as$d=>$b){$zb[]="".h($b)."".($x["lengths"][$d]?"(".$x["lengths"][$d].")":"");}echo"
$x[type]".implode(", ",$zb)."\n";}echo"
\n";}echo'

'.lang(103)."\n";if(fk_support($D)){echo"

".lang(84)."

\n";$ha=foreign_keys($m);if($ha){echo"\n","\n";foreach($ha +as$f=>$A){$w=($A["db"]!=""?"".h($A["db"]).".":"").h($A["table"]);echo"","
".lang(104)."".lang(105)."".lang(86)."".lang(106).($v!="sqlite"?" ":"")."
".implode(", ",array_map('h',$A["source"]))."","$w","(".implode(", ",array_map('h',$A["target"])).")","$A[on_delete]\n","$A[on_update]\n";if($v!="sqlite"){echo''.lang(107).'';}}echo"
\n";}if($v!="sqlite"){echo'

'.lang(108)."\n";}}if(support("trigger")){echo"

".lang(109)."

\n";$Mc=triggers($m);if($Mc){echo"\n";foreach($Mc +as$d=>$b){echo"
$b[0]$b[1]".h($d)."".lang(107)."\n";}echo"
\n";}echo'

'.lang(110)."\n";}}}}elseif(isset($_GET["schema"])){page_header(lang(111),"",array(),DB);$sb=array();$ve=array();$f="adminer_schema";$hf=($_GET["schema"]?$_GET["schema"]:$_COOKIE[($_COOKIE["$f-".DB]?"$f-".DB:$f)]);preg_match_all('~([^:]+):([-0-9.]+)x([-0-9.]+)(_|$)~',$hf,$oa,PREG_SET_ORDER);foreach($oa +as$l=>$k){$sb[$k[1]]=array($k[2],$k[3]);$ve[]="\n\t'".js_escape($k[1])."': [ $k[2], $k[3] ]";}$Wb=0;$cf=-1;$Ka=array();$df=array();$We=array();foreach(table_status()as$a){if(!isset($a["Engine"])){continue;}$uc=0;$Ka[$a["Name"]]["fields"]=array();foreach(fields($a["Name"])as$f=>$e){$uc+=1.25;$e["pos"]=$uc;$Ka[$a["Name"]]["fields"][$f]=$e;}$Ka[$a["Name"]]["pos"]=($sb[$a["Name"]]?$sb[$a["Name"]]:array($Wb,0));foreach($o->foreignKeys($a["Name"])as$b){if(!$b["db"]){$Aa=$cf;if($sb[$a["Name"]][1]||$sb[$b["table"]][1]){$Aa=min(floatval($sb[$a["Name"]][1]),floatval($sb[$b["table"]][1]))-1;}else{$cf-=.1;}while($We[(string)$Aa]){$Aa-=.0001;}$Ka[$a["Name"]]["references"][$b["table"]][(string)$Aa]=array($b["source"],$b["target"]);$df[$b["table"]][$a["Name"]][(string)$Aa]=$b["target"];$We[(string)$Aa]=true;}}$Wb=max($Wb,$Ka[$a["Name"]]["pos"][0]+2.5+$uc);}echo'

+ +';foreach($Ka +as$f=>$h){echo"
",''.h($f)."
\n";foreach($h["fields"]as$e){$b=''.h($e["field"]).'';echo($e["primary"]?"$b":$b)."
\n";}foreach((array)$h["references"]as$Vb=>$_c){foreach($_c +as$Aa=>$hd){$wc=$Aa-$sb[$f][1];$l=0;foreach($hd[0]as$Ga){echo"
\n";}}}foreach((array)$df[$f]as$Vb=>$_c){foreach($_c +as$Aa=>$B){$wc=$Aa-$sb[$f][1];$l=0;foreach($B +as$ea){echo"
\n";}}}echo"
\n";}foreach($Ka +as$f=>$h){foreach((array)$h["references"]as$Vb=>$_c){foreach($_c +as$Aa=>$hd){$ed=$Wb;$ud=-10;foreach($hd[0]as$d=>$Ga){$Te=$h["pos"][0]+$h["fields"][$Ga]["pos"];$Xe=$Ka[$Vb]["pos"][0]+$Ka[$Vb]["fields"][$hd[1][$d]]["pos"];$ed=min($ed,$Te,$Xe);$ud=max($ud,$Te,$Xe);}echo"
\n";}}}echo'
+

',lang(112),' +';}elseif(isset($_GET["dump"])){$m=$_GET["dump"];if($_POST){$Ye="";foreach(array("output","format","db_style","routines","events","table_style","auto_increment","triggers","data_style")as$d){$Ye.="&$d=".urlencode($_POST[$d]);}cookie("adminer_export",substr($Ye,1));$Hb=dump_headers(($m!=""?$m:DB),(DB==""||count((array)$_POST["tables"]+(array)$_POST["data"])>1));$tb=($_POST["format"]=="sql");if($tb){echo"-- Adminer $tc ".$na[DRIVER]." dump + +".($v!="sql"?"":"SET NAMES utf8; +SET foreign_key_checks = 0; +SET time_zone = ".q($g->result("SELECT @@time_zone"))."; +SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; + +");}$V=$_POST["db_style"];$_=array(DB);if(DB==""){$_=$_POST["databases"];if(is_string($_)){$_=explode("\n",rtrim(str_replace("\r","",$_),"\n"));}}foreach((array)$_ +as$t){if($g->select_db($t)){if($tb&&ereg('CREATE',$V)&&($la=$g->result("SHOW CREATE DATABASE ".idf_escape($t),1))){if($V=="DROP+CREATE"){echo"DROP DATABASE IF EXISTS ".idf_escape($t).";\n";}echo($V=="CREATE+ALTER"?preg_replace('~^CREATE DATABASE ~','\\0IF NOT EXISTS ',$la):$la).";\n";}if($tb){if($V){echo +use_sql($t).";\n\n";}if(in_array("CREATE+ALTER",array($V,$_POST["table_style"]))){echo"SET @adminer_alter = '';\n\n";}$qb="";if($_POST["routines"]){foreach(array("FUNCTION","PROCEDURE")as$Ta){foreach(get_rows("SHOW $Ta STATUS WHERE Db = ".q($t),null,"-- ")as$a){$qb.=($V!='DROP+CREATE'?"DROP $Ta IF EXISTS ".idf_escape($a["Name"]).";;\n":"").$g->result("SHOW CREATE $Ta ".idf_escape($a["Name"]),2).";;\n\n";}}}if($_POST["events"]){foreach(get_rows("SHOW EVENTS",null,"-- ")as$a){$qb.=($V!='DROP+CREATE'?"DROP EVENT IF EXISTS ".idf_escape($a["Name"]).";;\n":"").$g->result("SHOW CREATE EVENT ".idf_escape($a["Name"]),3).";;\n\n";}}if($qb){echo"DELIMITER ;;\n\n$qb"."DELIMITER ;\n\n";}}if($_POST["table_style"]||$_POST["data_style"]){$X=array();foreach(table_status()as$a){$h=(DB==""||in_array($a["Name"],(array)$_POST["tables"]));$Ze=(DB==""||in_array($a["Name"],(array)$_POST["data"]));if($h||$Ze){if(!is_view($a)){if($Hb=="tar"){ob_start();}$o->dumpTable($a["Name"],($h?$_POST["table_style"]:""));if($Ze){$o->dumpData($a["Name"],$_POST["data_style"],"SELECT * FROM ".table($a["Name"]));}if($tb&&$_POST["triggers"]&&$h&&($Mc=trigger_sql($a["Name"],$_POST["table_style"]))){echo"\nDELIMITER ;;\n$Mc\nDELIMITER ;\n";}if($Hb=="tar"){echo +tar_file((DB!=""?"":"$t/")."$a[Name].csv",ob_get_clean());}elseif($tb){echo"\n";}}elseif($tb){$X[]=$a["Name"];}}}foreach($X +as$cc){$o->dumpTable($cc,$_POST["table_style"],true);}if($Hb=="tar"){echo +pack("x512");}}if($V=="CREATE+ALTER"&&$tb){$j="SELECT TABLE_NAME, ENGINE, TABLE_COLLATION, TABLE_COMMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = DATABASE()";echo"DELIMITER ;; +CREATE PROCEDURE adminer_alter (INOUT alter_command text) BEGIN + DECLARE _table_name, _engine, _table_collation varchar(64); + DECLARE _table_comment varchar(64); + DECLARE done bool DEFAULT 0; + DECLARE tables CURSOR FOR $j; + DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; + OPEN tables; + REPEAT + FETCH tables INTO _table_name, _engine, _table_collation, _table_comment; + IF NOT done THEN + CASE _table_name";foreach(get_rows($j)as$a){$_a=q($a["ENGINE"]=="InnoDB"?preg_replace('~(?:(.+); )?InnoDB free: .*~','\\1',$a["TABLE_COMMENT"]):$a["TABLE_COMMENT"]);echo" + WHEN ".q($a["TABLE_NAME"])." THEN + ".(isset($a["ENGINE"])?"IF _engine != '$a[ENGINE]' OR _table_collation != '$a[TABLE_COLLATION]' OR _table_comment != $_a THEN + ALTER TABLE ".idf_escape($a["TABLE_NAME"])." ENGINE=$a[ENGINE] COLLATE=$a[TABLE_COLLATION] COMMENT=$_a; + END IF":"BEGIN END").";";}echo" + ELSE + SET alter_command = CONCAT(alter_command, 'DROP TABLE `', REPLACE(_table_name, '`', '``'), '`;\\n'); + END CASE; + END IF; + UNTIL done END REPEAT; + CLOSE tables; +END;; +DELIMITER ; +CALL adminer_alter(@adminer_alter); +DROP PROCEDURE adminer_alter; +";}if(in_array("CREATE+ALTER",array($V,$_POST["table_style"]))&&$tb){echo"SELECT @adminer_alter;\n";}}}if($tb){echo"-- ".$g->result("SELECT NOW()")."\n";}exit;}page_header(lang(113),"",($_GET["export"]!=""?array("table"=>$_GET["export"]):array()),DB);echo' +

+ +';$Ge=array('','USE','DROP+CREATE','CREATE');$se=array('','DROP+CREATE','CREATE');$Vd=array('','TRUNCATE+INSERT','INSERT');if($v=="sql"){$Ge[]='CREATE+ALTER';$se[]='CREATE+ALTER';$Vd[]='INSERT+UPDATE';}parse_str($_COOKIE["adminer_export"],$a);if(!$a){$a=array("output"=>"text","format"=>"sql","db_style"=>(DB!=""?"":"CREATE"),"table_style"=>"DROP+CREATE","data_style"=>"INSERT");}if(!isset($a["events"])){$a["routines"]=$a["events"]=($_GET["dump"]=="");$a["auto_increment"]=$a["triggers"]=$a["table_style"];}echo"
".lang(114)."".adminer_html_select("output",$o->dumpOutput(),$a["output"],0)."\n";echo"
".lang(115)."".adminer_html_select("format",$o->dumpFormat(),$a["format"],0)."\n";echo($v=="sqlite"?"":"
".lang(65)."".adminer_html_select('db_style',$Ge,$a["db_style"]).(support("routine")?checkbox("routines",1,$a["routines"],lang(116)):"").(support("event")?checkbox("events",1,$a["events"],lang(117)):"")),"
".lang(77)."".adminer_html_select('table_style',$se,$a["table_style"]).checkbox("auto_increment",1,$a["auto_increment"],lang(92)).(support("trigger")?checkbox("triggers",1,$a["triggers"],lang(109)):""),"
".lang(118)."".adminer_html_select('data_style',$Vd,$a["data_style"]),'
+

+ + +';$kd=array();if(DB!=""){$ab=($m!=""?"":" checked");echo"","\n";$X="";foreach(table_status()as$a){$f=$a["Name"];$zc=ereg_replace("_.*","",$f);$ab=($m==""||$m==(substr($m,-1)=="%"?"$zc%":$f));$zb="\n";$_=get_databases();if($_){foreach($_ +as$t){if(!information_schema($t)){$zc=ereg_replace("_.*","",$t);echo"
","","
".checkbox("tables[]",$f,$ab,$f,"formUncheck('check-tables');");if(is_view($a)){$X.="$zb\n";}else{echo"$zb\n";}$kd[$zc]++;}echo$X;}else{echo"
".checkbox("databases[]",$t,$m==""||$m=="$zc%",$t,"formUncheck('check-databases');")."\n";$kd[$zc]++;}}}else{echo"
";}}echo'
+

+';$Ba=true;foreach($kd +as$d=>$b){if($d!=""&&$b>1){echo($Ba?"

":" ")."".h($d)."";$Ba=false;}}}elseif(isset($_GET["privileges"])){page_header(lang(70));$i=$g->query("SELECT User, Host FROM mysql.user ORDER BY Host, User");if(!$i){echo'

+';hidden_fields_get();echo +lang(21),': +',lang(20),': + + +

+';$i=$g->query("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', 1) AS User, SUBSTRING_INDEX(CURRENT_USER, '@', -1) AS Host");}echo"\n","\n";while($a=$i->fetch_assoc()){echo'
 ".lang(21)."".lang(20)."
'.lang(119).''.h($a["User"])."".h($a["Host"])."\n";}echo"
\n",'

'.lang(120)."";}elseif(isset($_GET["sql"])){if(!$n&&$_POST["export"]){dump_headers("sql");$o->dumpTable("","");$o->dumpData("","table",$_POST["query"]);exit;}restart_session();$Ff=&get_session("queries");$eb=&$Ff[DB];if(!$n&&$_POST["clear"]){$eb=array();redirect(remove_from_uri("history"));}page_header(lang(43),$n);if(!$n&&$_POST){$Pa=false;$j=$_POST["query"];if($_POST["webfile"]){$Pa=@fopen((file_exists("adminer.sql")?"adminer.sql":(file_exists("adminer.sql.gz")?"compress.zlib://adminer.sql.gz":"compress.bzip2://adminer.sql.bz2")),"rb");$j=($Pa?fread($Pa,1e6):false);}elseif($_FILES&&$_FILES["sql_file"]["error"]!=4){$j=get_file("sql_file",true);}if(is_string($j)){if(function_exists('memory_get_usage')){@ini_set("memory_limit",2*strlen($j)+memory_get_usage()+8e6);}if($j!=""&&strlen($j)<1e6){$aa=$j.(ereg(';$',$j)?"":";");if(!$eb||end($eb)!=$aa){$eb[]=$aa;}}$yc="(?:\\s|/\\*.*\\*/|(?:#|-- )[^\n]*\n|--\n)";if(!ini_bool("session.use_cookies")){session_write_close();}$ld=";";$L=0;$hc=true;$G=connect();if(is_object($G)&&DB!=""){$G->select_db(DB);}$Ab=0;$Zc=array();$Gf='[\'`"]'.($v=="pgsql"?'|\\$[^$]*\\$':($v=="mssql"||$v=="sqlite"?'|\\[':'')).'|/\\*|-- |#';$Hf=explode(" ",microtime());parse_str($_COOKIE["adminer_export"],$Xb);$Rd=$o->dumpFormat();unset($Rd["sql"]);while($j!=""){if(!$L&&$v=="sql"&&preg_match("~^$yc*DELIMITER\\s+(.+)~i",$j,$k)){$ld=$k[1];$j=substr($j,strlen($k[0]));}else{preg_match('('.preg_quote($ld)."|$Gf|\$)",$j,$k,PREG_OFFSET_CAPTURE,$L);$ta=$k[0][0];$L=$k[0][1]+strlen($ta);if(!$ta&&$Pa&&!feof($Pa)){$j.=fread($Pa,1e5);}else{if(!$ta&&rtrim($j)==""){break;}if($ta&&$ta!=$ld){while(preg_match('('.($ta=='/*'?'\\*/':($ta=='['?']':(ereg('^-- |^#',$ta)?"\n":preg_quote($ta)."|\\\\."))).'|$)s',$j,$k,PREG_OFFSET_CAPTURE,$L)){$ma=$k[0][0];$L=$k[0][1]+strlen($ma);if(!$ma&&$Pa&&!feof($Pa)){$j.=fread($Pa,1e6);}elseif($ma[0]!="\\"){break;}}}else{$hc=false;$aa=substr($j,0,$k[0][1]);$Ab++;$zb="

".shorten_utf8(trim($aa),1000)."
\n";if(!$_POST["only_errors"]){echo$zb;ob_flush();flush();}$Fb=explode(" ",microtime());if($g->multi_query($aa)){if(is_object($G)&&preg_match("~^$yc*USE\\b~isU",$aa)){$G->query($aa);}do{$i=$g->store_result();$Cc=explode(" ",microtime());$Qd=format_time($Fb,$Cc).(strlen($aa)<1000?" ".lang(31)."":"");if(!is_object($i)){if(preg_match("~^$yc*(CREATE|DROP|ALTER)$yc+(DATABASE|SCHEMA)\\b~isU",$aa)){restart_session();set_session("dbs",null);session_write_close();}if(!$_POST["only_errors"]){echo"

".lang(121,$g->affected_rows)."$Qd\n";}}else{select($i,$G);if(!$_POST["only_errors"]){echo"

\n","

".($i->num_rows?lang(122,$i->num_rows):"").$Qd;$S="export-$Ab";$Od=", ".lang(113)."";if($G&&preg_match("~^($yc|\\()*SELECT\\b~isU",$aa)&&($Cf=explain($G,$aa))){$S="explain-$Ab";echo", EXPLAIN$Od\n","

\n";}else{echo"$Od\n";}echo"
\n";}}$Fb=$Cc;}while($g->next_result());}elseif($g->error){echo($_POST["only_errors"]?$zb:""),"

".lang(123).": ".error()."\n";$Zc[]=" $Ab";if($_POST["error_stops"]){break;}}$j=substr($j,$L);$L=0;}}}}if($hc){echo"

".lang(124)."\n";}elseif($_POST["only_errors"]){echo"

".lang(125,$Ab-count($Zc)).format_time($Hf,explode(" ",microtime()))."\n";}elseif($Zc&&$Ab>1){echo"

".lang(123).": ".implode("",$Zc)."\n";}}else{echo"

".upload_error($j)."\n";}}echo' +

+

';$aa=$_GET["sql"];if($_POST){$aa=$_POST["query"];}elseif($_GET["history"]=="all"){$aa=$eb;}elseif($_GET["history"]!=""){$aa=$eb[$_GET["history"]];}textarea("query",$aa,20);echo($_POST?"":"\n"),"

".(ini_bool("file_uploads")?lang(126).': (< '.ini_get("upload_max_filesize").'B)':lang(127)),'

+ + +',checkbox("error_stops",1,$_POST["error_stops"],lang(129))."\n",checkbox("only_errors",1,$_POST["only_errors"],lang(130))."\n";print_fieldset("webfile",lang(131),$_POST["webfile"]);$td=array();foreach(array("gz"=>"zlib","bz2"=>"bz2")as$d=>$b){if(extension_loaded($b)){$td[]=".$d";}}echo +lang(132,"adminer.sql".($td?"[".implode("|",$td)."]":"").""),' ',"\n";if($eb){print_fieldset("history",lang(134),$_GET["history"]!="");foreach($eb +as$d=>$b){echo''.lang(31)." ".shorten_utf8(ltrim(str_replace("\n"," ",str_replace("\r","",preg_replace('~^(#|-- ).*~m','',$b)))),80,"")."
\n";}echo"\n","".lang(136)."\n","\n";}echo' +

+';}elseif(isset($_GET["edit"])){$m=$_GET["edit"];$s=(isset($_GET["select"])?(count($_POST["check"])==1?where_check($_POST["check"][0]):""):where($_GET));$qa=(isset($_GET["select"])?$_POST["edit"]:$s);$p=fields($m);foreach($p +as$f=>$e){if(!isset($e["privileges"][$qa?"update":"insert"])||$o->fieldName($e)==""){unset($p[$f]);}}if($_POST&&!$n&&!isset($_GET["select"])){$ga=$_POST["referer"];if($_POST["insert"]){$ga=($qa?null:$_SERVER["REQUEST_URI"]);}elseif(!ereg('^.+&select=.+$',$ga)){$ga=ME."select=".urlencode($m);}if(isset($_POST["delete"])){query_redirect("DELETE".limit1("FROM ".table($m)," WHERE $s"),$ga,lang(137));}else{$r=array();foreach($p +as$f=>$e){$b=process_input($e);if($b!==false&&$b!==null){$r[idf_escape($f)]=($qa?"\n".idf_escape($f)." = $b":$b);}}if($qa){if(!$r){redirect($ga);}query_redirect("UPDATE".limit1(table($m)." SET".implode(",",$r),"\nWHERE $s"),$ga,lang(138));}else{$i=insert_into($m,$r);$ue=($i?last_id():0);queries_redirect($ga,lang(139,($ue?" $ue":"")),$i);}}}$Ea=$o->tableName(table_status($m));page_header(($qa?lang(31):lang(140)),$n,array("select"=>array($m,$Ea)),$Ea);$a=null;if($_POST["save"]){$a=(array)$_POST["fields"];}elseif($s){$Q=array();foreach($p +as$f=>$e){if(isset($e["privileges"]["select"])){$Q[]=($_POST["clone"]&&$e["auto_increment"]?"'' AS ":(ereg("enum|set",$e["type"])?"1*".idf_escape($f)." AS ":"")).idf_escape($f);}}$a=array();if($Q){$H=get_rows("SELECT".limit(implode(", ",$Q)." FROM ".table($m)," WHERE $s",(isset($_GET["select"])?2:1)));$a=(isset($_GET["select"])&&count($H)!=1?null:reset($H));}}echo' +
+';if($p){echo"\n";foreach($p +as$f=>$e){echo"
".$o->fieldName($e);$za=$_GET["set"][bracket_escape($f)];$q=(isset($a)?($a[$f]!=""&&ereg("enum|set",$e["type"])?+$a[$f]:$a[$f]):(!$qa&&$e["auto_increment"]?"":(isset($_GET["select"])?false:(isset($za)?$za:$e["default"]))));if(!$_POST["save"]&&is_string($q)){$q=$o->editVal($q,$e);}$K=($_POST["save"]?(string)$_POST["function"][$f]:($s&&$e["on_update"]=="CURRENT_TIMESTAMP"?"now":($q===false?null:(isset($q)?'':'NULL'))));if($e["type"]=="timestamp"&&$q=="CURRENT_TIMESTAMP"){$q="";$K="now";}input($e,$q,$K);echo"\n";}echo"
\n";}echo'

+';if($p){echo"\n";if(!isset($_GET["select"])){echo'\n";}}echo($qa?"\n":($_POST||!$p?"":"\n"));if(isset($_GET["select"])){hidden_fields(array("check"=>(array)$_POST["check"],"clone"=>$_POST["clone"],"all"=>$_POST["all"]));}echo' + + +

+';}elseif(isset($_GET["create"])){$m=$_GET["create"];$pe=array('HASH','LINEAR HASH','KEY','LINEAR KEY','RANGE','LIST');$ce=referencable_primary($m);$ha=array();foreach($ce +as$Ea=>$e){$ha[str_replace("`","``",$Ea)."`".str_replace("`","``",$e["field"])]=$Ea;}$Kc=array();$Jc=array();if($m!=""){$Kc=fields($m);$Jc=table_status($m);}if($_POST&&!$_POST["fields"]){$_POST["fields"]=array();}if($_POST&&!$n&&!$_POST["add"]&&!$_POST["drop_col"]&&!$_POST["up"]&&!$_POST["down"]){if($_POST["drop"]){query_redirect("DROP TABLE ".table($m),substr(ME,0,-1),lang(145));}else{$p=array();$Oa=array();ksort($_POST["fields"]);$vd=reset($Kc);$Jb="FIRST";foreach($_POST["fields"]as$d=>$e){$A=$ha[$e["type"]];$Uc=(isset($A)?$ce[$A]:$e);if($e["field"]!=""){if(!$e["has_default"]){$e["default"]=null;}$za=eregi_replace(" *on update CURRENT_TIMESTAMP","",$e["default"]);if($za!=$e["default"]){$e["on_update"]="CURRENT_TIMESTAMP";$e["default"]=$za;}if($d==$_POST["auto_increment_col"]){$e["auto_increment"]=true;}$qe=process_field($e,$Uc);if($qe!=process_field($vd,$vd)){$p[]=array($e["orig"],$qe,$Jb);}if(isset($A)){$Oa[idf_escape($e["field"])]=($m!=""?"ADD":" ")." FOREIGN KEY (".idf_escape($e["field"]).") REFERENCES ".table($ha[$e["type"]])." (".idf_escape($Uc["field"]).")".(in_array($e["on_delete"],$fb)?" ON DELETE $e[on_delete]":"");}$Jb="AFTER ".idf_escape($e["field"]);}elseif($e["orig"]!=""){$p[]=array($e["orig"]);}if($e["orig"]!=""){$vd=next($Kc);}}$vb="";if(in_array($_POST["partition_by"],$pe)){$yd=array();if($_POST["partition_by"]=='RANGE'||$_POST["partition_by"]=='LIST'){foreach(array_filter($_POST["partition_names"])as$d=>$b){$q=$_POST["partition_values"][$d];$yd[]="\nPARTITION ".idf_escape($b)." VALUES ".($_POST["partition_by"]=='RANGE'?"LESS THAN":"IN").($q!=""?" ($q)":" MAXVALUE");}}$vb.="\nPARTITION BY $_POST[partition_by]($_POST[partition])".($yd?" (".implode(",",$yd)."\n)":($_POST["partitions"]?" PARTITIONS ".(+$_POST["partitions"]):""));}elseif($m!=""&&support("partitioning")){$vb.="\nREMOVE PARTITIONING";}$va=lang(146);if($m==""){cookie("adminer_engine",$_POST["Engine"]);$va=lang(147);}queries_redirect(ME."table=".urlencode($_POST["name"]),$va,alter_table($m,$_POST["name"],$p,$Oa,$_POST["Comment"],($_POST["Engine"]&&$_POST["Engine"]!=$Jc["Engine"]?$_POST["Engine"]:""),($_POST["Collation"]&&$_POST["Collation"]!=$Jc["Collation"]?$_POST["Collation"]:""),($_POST["Auto_increment"]!=""?+$_POST["Auto_increment"]:""),$vb));}}page_header(($m!=""?lang(28):lang(148)),$n,array("table"=>$m),$m);$a=array("Engine"=>$_COOKIE["adminer_engine"],"fields"=>array(array("field"=>"","type"=>(isset($R["int"])?"int":(isset($R["integer"])?"integer":"")))),"partition_names"=>array(""),);if($_POST){$a=$_POST;if($a["auto_increment_col"]){$a["fields"][$a["auto_increment_col"]]["auto_increment"]=true;}process_fields($a["fields"]);}elseif($m!=""){$a=$Jc;$a["name"]=$m;$a["fields"]=array();if(!$_GET["auto_increment"]){$a["Auto_increment"]="";}foreach($Kc +as$e){$e["has_default"]=isset($e["default"]);if($e["on_update"]){$e["default"].=" ON UPDATE $e[on_update]";}$a["fields"][]=$e;}if(support("partitioning")){$Yb="FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = ".q(DB)." AND TABLE_NAME = ".q($m);$i=$g->query("SELECT PARTITION_METHOD, PARTITION_ORDINAL_POSITION, PARTITION_EXPRESSION $Yb ORDER BY PARTITION_ORDINAL_POSITION DESC LIMIT 1");list($a["partition_by"],$a["partitions"],$a["partition"])=$i->fetch_row();$a["partition_names"]=array();$a["partition_values"]=array();foreach(get_rows("SELECT PARTITION_NAME, PARTITION_DESCRIPTION $Yb AND PARTITION_NAME != '' ORDER BY PARTITION_ORDINAL_POSITION")as$dd){$a["partition_names"][]=$dd["PARTITION_NAME"];$a["partition_values"][]=$dd["PARTITION_DESCRIPTION"];}$a["partition_names"][]="";}}$Z=collations();$qd=floor(extension_loaded("suhosin")?(min(ini_get("suhosin.request.max_vars"),ini_get("suhosin.post.max_vars"))-13)/10:0);if($qd&&count($a["fields"])>$qd){echo"

".h(lang(149,'suhosin.post.max_vars','suhosin.request.max_vars'))."\n";}$wd=engines();foreach($wd +as$yb){if(!strcasecmp($yb,$a["Engine"])){$a["Engine"]=$yb;break;}}echo' +

+

+',lang(150),': +';if($m==""&&!$_POST){?>"(".lang(151).")")+$wd,$a["Engine"]):""),' ',($Z&&!ereg("sqlite|mssql",$v)?adminer_html_select("Collation",array(""=>"(".lang(85).")")+$Z,$a["Collation"]):""),' + +';$Kb=edit_fields($a["fields"],$Z,"TABLE",$qd,$ha,$a["Comment"]!="");echo'
+

+',lang(92),': + +',(support("comment")?checkbox("","",$Kb,lang(94),"columnShow(this.checked, 6); toggle('Comment'); if (this.checked) this.form['Comment'].focus();").' ':''),'

+ +';if($_GET["create"]!=""){echo'';}echo' +';if(support("partitioning")){$me=ereg('RANGE|LIST',$a["partition_by"]);print_fieldset("partition",lang(152),$a["partition_by"]);echo'

+',adminer_html_select("partition_by",array(-1=>"")+$pe,$a["partition_by"],"partitionByChange(this);"),'() +',lang(153),': + + +';foreach($a["partition_names"]as$d=>$b){echo'',' + +';}echo'

+';}elseif(isset($_GET["indexes"])){$m=$_GET["indexes"];$Nc=array("PRIMARY","UNIQUE","INDEX");$D=table_status($m);if(eregi("MyISAM|M?aria",$D["Engine"])){$Nc[]="FULLTEXT";}$J=indexes($m);if($v=="sqlite"){unset($Nc[0]);unset($J[""]);}if($_POST&&!$n&&!$_POST["add"]){$u=array();foreach($_POST["indexes"]as$x){if(in_array($x["type"],$Nc)){$B=array();$ec=array();$r=array();ksort($x["columns"]);foreach($x["columns"]as$d=>$C){if($C!=""){$W=$x["lengths"][$d];$r[]=idf_escape($C).($W?"(".(+$W).")":"");$B[]=$C;$ec[]=($W?$W:null);}}if($B){foreach($J +as$f=>$Bb){ksort($Bb["columns"]);ksort($Bb["lengths"]);if($x["type"]==$Bb["type"]&&array_values($Bb["columns"])===$B&&(!$Bb["lengths"]||array_values($Bb["lengths"])===$ec)){unset($J[$f]);continue +2;}}$u[]=array($x["type"],"(".implode(", ",$r).")");}}}foreach($J +as$f=>$Bb){$u[]=array($Bb["type"],idf_escape($f),"DROP");}if(!$u){redirect(ME."table=".urlencode($m));}queries_redirect(ME."table=".urlencode($m),lang(156),alter_indexes($m,$u));}page_header(lang(102),$n,array("table"=>$m),$m);$p=array_keys(fields($m));$a=array("indexes"=>$J);if($_POST){$a=$_POST;if($_POST["add"]){foreach($a["indexes"]as$d=>$x){if($x["columns"][count($x["columns"])]!=""){$a["indexes"][$d]["columns"][]="";}}$x=end($a["indexes"]);if($x["type"]||array_filter($x["columns"],'strlen')||array_filter($x["lengths"],'strlen')){$a["indexes"][]=array("columns"=>array(1=>""));}}}else{foreach($a["indexes"]as$d=>$x){$a["indexes"][$d]["columns"][]="";}$a["indexes"][]=array("columns"=>array(1=>""));}echo' +
+ + +';$ra=1;foreach($a["indexes"]as$x){echo"
',lang(157),'',lang(158),'
".adminer_html_select("indexes[$ra][type]",array(-1=>"")+$Nc,$x["type"],($ra==count($a["indexes"])?"indexesAddRow(this);":1))."";ksort($x["columns"]);$l=1;foreach($x["columns"]as$d=>$C){echo"".adminer_html_select("indexes[$ra][columns][$l]",array(-1=>"")+$p,$C,($l==count($x["columns"])?"indexesAddColumn(this);":1))," ";$l++;}$ra++;}echo'
+

+ +

+ +

+';}elseif(isset($_GET["database"])){if($_POST&&!$n&&!isset($_POST["add_x"])){restart_session();if($_POST["drop"]){$_GET["db"]="";queries_redirect(remove_from_uri("db|database"),lang(159),drop_databases(array(DB)));}elseif(DB!==$_POST["name"]){if(DB!=""){$_GET["db"]=$_POST["name"];queries_redirect(preg_replace('~db=[^&]*&~','',ME)."db=".urlencode($_POST["name"]),lang(160),rename_database($_POST["name"],$_POST["collation"]));}else{$_=explode("\n",str_replace("\r","",$_POST["name"]));$ee=true;$xb="";foreach($_ +as$t){if(count($_)==1||$t!=""){if(!create_database($t,$_POST["collation"])){$ee=false;}$xb=$t;}}queries_redirect(ME."db=".urlencode($xb),lang(161),$ee);}}else{if(!$_POST["collation"]){redirect(substr(ME,0,-1));}query_redirect("ALTER DATABASE ".idf_escape($_POST["name"]).(eregi('^[a-z0-9_]+$',$_POST["collation"])?" COLLATE $_POST[collation]":""),substr(ME,0,-1),lang(162));}}page_header(DB!=""?lang(46):lang(163),$n,array(),DB);$Z=collations();$f=DB;$Dc=null;if($_POST){$f=$_POST["name"];$Dc=$_POST["collation"];}elseif(DB!=""){$Dc=db_collation(DB,$Z);}elseif($v=="sql"){foreach(get_vals("SHOW GRANTS")as$ka){if(preg_match('~ ON (`(([^\\\\`]|``|\\\\.)*)%`\\.\\*)?~',$ka,$k)&&$k[1]){$f=stripcslashes(idf_unescape("`$k[2]`"));break;}}}echo' +
+

+',($_POST["add_x"]||strpos($f,"\n")?'
':'')."\n".($Z?adminer_html_select("collation",array(""=>"(".lang(85).")")+$Z,$Dc):"");?> + + +';if(DB!=""){echo"\n";}elseif(!$_POST["add_x"]&&$_GET["db"]==""){echo"\n";}echo' +

+';}elseif(isset($_GET["scheme"])){if($_POST&&!$n){$w=preg_replace('~ns=[^&]*&~','',ME)."ns=";if($_POST["drop"]){query_redirect("DROP SCHEMA ".idf_escape($_GET["ns"]),$w,lang(164));}else{$w.=urlencode($_POST["name"]);if($_GET["ns"]==""){query_redirect("CREATE SCHEMA ".idf_escape($_POST["name"]),$w,lang(165));}elseif($_GET["ns"]!=$_POST["name"]){query_redirect("ALTER SCHEMA ".idf_escape($_GET["ns"])." RENAME TO ".idf_escape($_POST["name"]),$w,lang(166));}else{redirect($w);}}}page_header($_GET["ns"]!=""?lang(47):lang(48),$n);$a=array("name"=>$_GET["ns"]);if($_POST){$a=$_POST;}echo' +
+

+ +';if($_GET["ns"]!=""){echo"\n";}echo' +

+';}elseif(isset($_GET["call"])){$Va=$_GET["call"];page_header(lang(167).": ".h($Va),$n);$Ta=routine($Va,(isset($_GET["callf"])?"FUNCTION":"PROCEDURE"));$Tb=array();$qb=array();foreach($Ta["fields"]as$l=>$e){if(substr($e["inout"],-3)=="OUT"){$qb[$l]="@".idf_escape($e["field"])." AS ".idf_escape($e["field"]);}if(!$e["inout"]||substr($e["inout"],0,2)=="IN"){$Tb[]=$l;}}if(!$n&&$_POST){$de=array();foreach($Ta["fields"]as$d=>$e){if(in_array($d,$Tb)){$b=process_input($e);if($b===false){$b="''";}if(isset($qb[$d])){$g->query("SET @".idf_escape($e["field"])." = $b");}}$de[]=(isset($qb[$d])?"@".idf_escape($e["field"]):$b);}$j=(isset($_GET["callf"])?"SELECT":"CALL")." ".idf_escape($Va)."(".implode(", ",$de).")";echo"

".h($j)." ".lang(31)."\n";if(!$g->multi_query($j)){echo"

".error()."\n";}else{do{$i=$g->store_result();if(is_object($i)){select($i);}else{echo"

".lang(168,$g->affected_rows)."\n";}}while($g->next_result());if($qb){select($g->query("SELECT ".implode(", ",$qb)));}}}echo' +

+';if($Tb){echo"\n";foreach($Tb +as$d){$e=$Ta["fields"][$d];$f=$e["field"];echo"
".$o->fieldName($e);$q=$_POST["fields"][$f];if($q!=""){if($e["type"]=="enum"){$q=+$q;}if($e["type"]=="set"){$q=array_sum($q);}}input($e,$q,(string)$_POST["function"][$f]);echo"\n";}echo"
\n";}echo'

+ + +

+';}elseif(isset($_GET["foreign"])){$m=$_GET["foreign"];if($_POST&&!$n&&!$_POST["add"]&&!$_POST["change"]&&!$_POST["change-js"]){if($_POST["drop"]){query_redirect("ALTER TABLE ".table($m)."\nDROP ".($v=="sql"?"FOREIGN KEY ":"CONSTRAINT ").idf_escape($_GET["name"]),ME."table=".urlencode($m),lang(169));}else{$Ga=array_filter($_POST["source"],'strlen');ksort($Ga);$ea=array();foreach($Ga +as$d=>$b){$ea[$d]=$_POST["target"][$d];}query_redirect("ALTER TABLE ".table($m).($_GET["name"]!=""?"\nDROP FOREIGN KEY ".idf_escape($_GET["name"]).",":"")."\nADD FOREIGN KEY (".implode(", ",array_map('idf_escape',$Ga)).") REFERENCES ".table($_POST["table"])." (".implode(", ",array_map('idf_escape',$ea)).")".(in_array($_POST["on_delete"],$fb)?" ON DELETE $_POST[on_delete]":"").(in_array($_POST["on_update"],$fb)?" ON UPDATE $_POST[on_update]":""),ME."table=".urlencode($m),($_GET["name"]!=""?lang(170):lang(171)));$n=lang(172)."
$n";}}page_header(lang(173),$n,array("table"=>$m),$m);$a=array("table"=>$m,"source"=>array(""));if($_POST){$a=$_POST;ksort($a["source"]);if($_POST["add"]){$a["source"][]="";}elseif($_POST["change"]||$_POST["change-js"]){$a["target"]=array();}}elseif($_GET["name"]!=""){$ha=foreign_keys($m);$a=$ha[$_GET["name"]];$a["source"][]="";}$Ga=array_keys(fields($m));$ea=($m===$a["table"]?$Ga:array_keys(fields($a["table"])));$je=array();foreach(table_status()as$f=>$D){if(fk_support($D)){$je[]=$f;}}echo' +
+

+';if($a["db"]==""){echo +lang(174),': +',adminer_html_select("table",$je,$a["table"],"this.form['change-js'].value = '1'; this.form.submit();"),' +

+ + +';$ra=0;foreach($a["source"]as$d=>$b){echo"","
',lang(104),'',lang(105),'
".adminer_html_select("source[".(+$d)."]",array(-1=>"")+$Ga,$b,($ra==count($a["source"])-1?"foreignAddRow(this);":1)),"".adminer_html_select("target[".(+$d)."]",$ea,$a["target"][$d]);$ra++;}echo'
+

+',lang(86),': ',adminer_html_select("on_delete",array(-1=>"")+$fb,$a["on_delete"]),' ',lang(106),': ',adminer_html_select("on_update",array(-1=>"")+$fb,$a["on_update"]),'

+ +

+';}if($_GET["name"]!=""){echo'';}echo' +

+';}elseif(isset($_GET["view"])){$m=$_GET["view"];$hb=false;if($_POST&&!$n){$hb=drop_create("DROP VIEW ".table($m),"CREATE VIEW ".table($_POST["name"])." AS\n$_POST[select]",($_POST["drop"]?substr(ME,0,-1):ME."table=".urlencode($_POST["name"])),lang(177),lang(178),lang(179),$m);}page_header(($m!=""?lang(27):lang(180)),$n,array("table"=>$m),$m);$a=array();if($_POST){$a=$_POST;}elseif($m!=""){$a=view($m);$a["name"]=$m;}echo' +
+

',lang(181),': +

';textarea("select",$a["select"]);echo'

+';if($hb){echo'';}echo' +';if($_GET["view"]!=""){echo'';}echo' +

+';}elseif(isset($_GET["event"])){$ib=$_GET["event"];$ie=array("YEAR","QUARTER","MONTH","DAY","HOUR","MINUTE","WEEK","SECOND","YEAR_MONTH","DAY_HOUR","DAY_MINUTE","DAY_SECOND","HOUR_MINUTE","HOUR_SECOND","MINUTE_SECOND");$Md=array("ENABLED"=>"ENABLE","DISABLED"=>"DISABLE","SLAVESIDE_DISABLED"=>"DISABLE ON SLAVE");if($_POST&&!$n){if($_POST["drop"]){query_redirect("DROP EVENT ".idf_escape($ib),substr(ME,0,-1),lang(182));}elseif(in_array($_POST["INTERVAL_FIELD"],$ie)&&isset($Md[$_POST["STATUS"]])){$he="\nON SCHEDULE ".($_POST["INTERVAL_VALUE"]?"EVERY ".q($_POST["INTERVAL_VALUE"])." $_POST[INTERVAL_FIELD]".($_POST["STARTS"]?" STARTS ".q($_POST["STARTS"]):"").($_POST["ENDS"]?" ENDS ".q($_POST["ENDS"]):""):"AT ".q($_POST["STARTS"]))." ON COMPLETION".($_POST["ON_COMPLETION"]?"":" NOT")." PRESERVE";queries_redirect(substr(ME,0,-1),($ib!=""?lang(183):lang(184)),queries(($ib!=""?"ALTER EVENT ".idf_escape($ib).$he.($ib!=$_POST["EVENT_NAME"]?"\nRENAME TO ".idf_escape($_POST["EVENT_NAME"]):""):"CREATE EVENT ".idf_escape($_POST["EVENT_NAME"]).$he)."\n".$Md[$_POST["STATUS"]]." COMMENT ".q($_POST["EVENT_COMMENT"]).rtrim(" DO\n$_POST[EVENT_DEFINITION]",";").";"));}}page_header(($ib!=""?lang(185).": ".h($ib):lang(186)),$n);$a=array();if($_POST){$a=$_POST;}elseif($ib!=""){$H=get_rows("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = ".q(DB)." AND EVENT_NAME = ".q($ib));$a=reset($H);}echo' +
+ +
',lang(181),' +
',lang(187),' +
',lang(188),' +
',lang(189),' ',adminer_html_select("INTERVAL_FIELD",$ie,$a["INTERVAL_FIELD"]),'
',lang(73),'',adminer_html_select("STATUS",$Md,$a["STATUS"]),'
',lang(94),' +
 ',checkbox("ON_COMPLETION","PRESERVE",$a["ON_COMPLETION"]=="PRESERVE",lang(190)),'
+

';textarea("EVENT_DEFINITION",$a["EVENT_DEFINITION"]);echo'

+ +';if($ib!=""){echo'';}echo' +

+';}elseif(isset($_GET["procedure"])){$Va=$_GET["procedure"];$Ta=(isset($_GET["function"])?"FUNCTION":"PROCEDURE");$hb=false;if($_POST&&!$n&&!$_POST["add"]&&!$_POST["drop_col"]&&!$_POST["up"]&&!$_POST["down"]){$r=array();$p=(array)$_POST["fields"];ksort($p);foreach($p +as$e){if($e["field"]!=""){$r[]=(in_array($e["inout"],$jc)?"$e[inout] ":"").idf_escape($e["field"]).process_type($e,"CHARACTER SET");}}$hb=drop_create("DROP $Ta ".idf_escape($Va),"CREATE $Ta ".idf_escape($_POST["name"])." (".implode(", ",$r).")".(isset($_GET["function"])?" RETURNS".process_type($_POST["returns"],"CHARACTER SET"):"").rtrim("\n$_POST[definition]",";").";",substr(ME,0,-1),lang(191),lang(192),lang(193),$Va);}page_header(($Va!=""?(isset($_GET["function"])?lang(194):lang(195)).": ".h($Va):(isset($_GET["function"])?lang(196):lang(197))),$n);$Z=get_vals("SHOW CHARACTER SET");sort($Z);$a=array("fields"=>array());if($_POST){$a=$_POST;$a["fields"]=(array)$a["fields"];process_fields($a["fields"]);}elseif($Va!=""){$a=routine($Va,$Ta);$a["name"]=$Va;}echo' +
+

',lang(181),': + +';edit_fields($a["fields"],$Z,$Ta);if(isset($_GET["function"])){echo"
".lang(198);edit_type("returns",$a["returns"],$Z);}echo'
+

';textarea("definition",$a["definition"]);echo'

+ +';if($Va!=""){echo'';}if($hb){echo'';}echo' +

+';}elseif(isset($_GET["sequence"])){$Eb=$_GET["sequence"];if($_POST&&!$n){$w=substr(ME,0,-1);if($_POST["drop"]){query_redirect("DROP SEQUENCE ".idf_escape($Eb),$w,lang(199));}elseif($Eb==""){query_redirect("CREATE SEQUENCE ".idf_escape($_POST["name"]),$w,lang(200));}elseif($Eb!=$_POST["name"]){query_redirect("ALTER SEQUENCE ".idf_escape($Eb)." RENAME TO ".idf_escape($_POST["name"]),$w,lang(201));}else{redirect($w);}}page_header($Eb!=""?lang(202).": ".h($Eb):lang(203),$n);$a=array("name"=>$Eb);if($_POST){$a=$_POST;}echo' +
+

+ +';if($Eb!=""){echo"\n";}echo' +

+';}elseif(isset($_GET["type"])){$Oc=$_GET["type"];if($_POST&&!$n){$w=substr(ME,0,-1);if($_POST["drop"]){query_redirect("DROP TYPE ".idf_escape($Oc),$w,lang(204));}else{query_redirect("CREATE TYPE ".idf_escape($_POST["name"])." $_POST[as]",$w,lang(205));}}page_header($Oc!=""?lang(206).": ".h($Oc):lang(207),$n);$a["as"]="AS ";if($_POST){$a=$_POST;}echo' +
+

+';if($Oc!=""){echo"\n";}else{echo"\n";textarea("as",$a["as"]);echo"

\n";}echo' +

+';}elseif(isset($_GET["trigger"])){$m=$_GET["trigger"];$Ic=trigger_options();$te=array("INSERT","UPDATE","DELETE");$hb=false;if($_POST&&!$n&&in_array($_POST["Timing"],$Ic["Timing"])&&in_array($_POST["Event"],$te)&&in_array($_POST["Type"],$Ic["Type"])){$re=" $_POST[Timing] $_POST[Event]";$Cb=" ON ".table($m);$hb=drop_create("DROP TRIGGER ".idf_escape($_GET["name"]).($v=="pgsql"?$Cb:""),"CREATE TRIGGER ".idf_escape($_POST["Trigger"]).($v=="mssql"?$Cb.$re:$re.$Cb).rtrim(" $_POST[Type]\n$_POST[Statement]",";").";",ME."table=".urlencode($m),lang(208),lang(209),lang(210),$_GET["name"]);}page_header(($_GET["name"]!=""?lang(211).": ".h($_GET["name"]):lang(212)),$n,array("table"=>$m));$a=array("Trigger"=>$m."_bi");if($_POST){$a=$_POST;}elseif($_GET["name"]!=""){$a=trigger($_GET["name"]);}echo' +
+ +
',lang(213),'',adminer_html_select("Timing",$Ic["Timing"],$a["Timing"],"if (/^".h(preg_quote($m,"/"))."_[ba][iud]$/.test(this.form['Trigger'].value)) this.form['Trigger'].value = '".h(js_escape($m))."_' + selectValue(this).charAt(0).toLowerCase() + selectValue(this.form['Event']).charAt(0).toLowerCase();"),'
',lang(214),'',adminer_html_select("Event",$te,$a["Event"],"this.form['Timing'].onchange();"),'
',lang(89),'',adminer_html_select("Type",$Ic["Type"],$a["Type"]),'
+

',lang(181),': +

';textarea("Statement",$a["Statement"]);echo'

+ +';if($_GET["name"]!=""){echo'';}if($hb){echo'';}echo' +

+';}elseif(isset($_GET["user"])){$Fd=$_GET["user"];$sa=array(""=>array("All privileges"=>""));foreach(get_rows("SHOW PRIVILEGES")as$a){foreach(explode(",",($a["Privilege"]=="Grant option"?"":$a["Context"]))as$Gc){$sa[$Gc][$a["Privilege"]]=$a["Comment"];}}$sa["Server Admin"]+=$sa["File access on server"];$sa["Databases"]["Create routine"]=$sa["Procedures"]["Create routine"];unset($sa["Procedures"]["Create routine"]);$sa["Columns"]=array();foreach(array("Select","Insert","Update","References")as$b){$sa["Columns"][$b]=$sa["Tables"][$b];}unset($sa["Server Admin"]["Usage"]);foreach($sa["Tables"]as$d=>$b){unset($sa["Databases"][$d]);}$nc=array();if($_POST){foreach($_POST["objects"]as$d=>$b){$nc[$b]=(array)$nc[$b]+(array)$_POST["grants"][$d];}}$nb=array();$Xc="";if(isset($_GET["host"])&&($i=$g->query("SHOW GRANTS FOR ".q($Fd)."@".q($_GET["host"])))){while($a=$i->fetch_row()){if(preg_match('~GRANT (.*) ON (.*) TO ~',$a[0],$k)&&preg_match_all('~ *([^(,]*[^ ,(])( *\\([^)]+\\))?~',$k[1],$oa,PREG_SET_ORDER)){foreach($oa +as$b){if($b[1]!="USAGE"){$nb["$k[2]$b[2]"][$b[1]]=true;}if(ereg(' WITH GRANT OPTION',$a[0])){$nb["$k[2]$b[2]"]["GRANT OPTION"]=true;}}}if(preg_match("~ IDENTIFIED BY PASSWORD '([^']+)~",$a[0],$k)){$Xc=$k[1];}}}if($_POST&&!$n){$ac=(isset($_GET["host"])?q($Fd)."@".q($_GET["host"]):"''");$pb=q($_POST["user"])."@".q($_POST["host"]);$Ad=q($_POST["pass"]);if($_POST["drop"]){query_redirect("DROP USER $ac",ME."privileges=",lang(215));}else{if($ac!=$pb){$n=!queries(($g->server_info<5?"GRANT USAGE ON *.* TO":"CREATE USER")." $pb IDENTIFIED BY".($_POST["hashed"]?" PASSWORD":"")." $Ad");}elseif($_POST["pass"]!=$Xc||!$_POST["hashed"]){queries("SET PASSWORD FOR $pb = ".($_POST["hashed"]?$Ad:"PASSWORD($Ad)"));}if(!$n){$qc=array();foreach($nc +as$bb=>$ka){if(isset($_GET["grant"])){$ka=array_filter($ka);}$ka=array_keys($ka);if(isset($_GET["grant"])){$qc=array_diff(array_keys(array_filter($nc[$bb],'strlen')),$ka);}elseif($ac==$pb){$Sd=array_keys((array)$nb[$bb]);$qc=array_diff($Sd,$ka);$ka=array_diff($ka,$Sd);unset($nb[$bb]);}if(preg_match('~^(.+)\\s*(\\(.*\\))?$~U',$bb,$k)&&(!grant("REVOKE",$qc,$k[2]," ON $k[1] FROM $pb")||!grant("GRANT",$ka,$k[2]," ON $k[1] TO $pb"))){$n=true;break;}}}if(!$n&&isset($_GET["host"])){if($ac!=$pb){queries("DROP USER $ac");}elseif(!isset($_GET["grant"])){foreach($nb +as$bb=>$qc){if(preg_match('~^(.+)(\\(.*\\))?$~U',$bb,$k)){grant("REVOKE",array_keys($qc),$k[2]," ON $k[1] FROM $pb");}}}}queries_redirect(ME."privileges=",(isset($_GET["host"])?lang(216):lang(217)),!$n);if($ac!=$pb){$g->query("DROP USER $pb");}}}page_header((isset($_GET["host"])?lang(21).": ".h("$Fd@$_GET[host]"):lang(120)),$n,array("privileges"=>array('',lang(70))));if($_POST){$a=$_POST;$nb=$nc;}else{$a=$_GET+array("host"=>$g->result("SELECT SUBSTRING_INDEX(CURRENT_USER, '@', -1)"));$a["pass"]=$Xc;if($Xc!=""){$a["hashed"]=true;}$nb[""]=true;}echo'
+ +
',lang(21),' +
',lang(20),' +
',lang(22),' +';if(!$a["hashed"]){echo'';}echo +checkbox("hashed",1,$a["hashed"],lang(218),"typePassword(this.form['pass'], this.checked);"),'
+ +';echo"\n","\n";foreach(array(""=>"","Server Admin"=>lang(20),"Databases"=>lang(65),"Tables"=>lang(100),"Columns"=>lang(101),"Procedures"=>lang(219),)as$Gc=>$rc){foreach((array)$sa[$Gc]as$mc=>$_a){echo"$rc'.h($mc);$l=0;foreach($nb +as$bb=>$ka){$f="'grants[$l][".h(strtoupper($mc))."]'";$q=$ka[strtoupper($mc)];if($Gc=="Server Admin"&&$bb!=(isset($nb["*.*"])?"*.*":"")){echo"
".lang(70)."";$l=0;foreach($nb +as$bb=>$ka){echo''.($bb!="*.*"?"":"*.*");$l++;}echo"
 ";}elseif(isset($_GET["grant"])){echo"";}else{echo"";}$l++;}}}echo"
\n",'

+ +';if(isset($_GET["host"])){echo'';}echo' +

+';}elseif(isset($_GET["processlist"])){if($_POST&&!$n){$Id=0;foreach((array)$_POST["kill"]as$b){if(queries("KILL ".(+$b))){$Id++;}}queries_redirect(ME."processlist=",lang(222,$Id),$Id||!$_POST["kill"]);}page_header(lang(71),$n);echo' +
+ +';$l=-1;foreach(get_rows("SHOW FULL PROCESSLIST")as$l=>$a){if(!$l){echo"\n";}echo"
 ".implode("",array_keys($a))."
".checkbox("kill[]",$a["Id"],0);foreach($a +as$d=>$b){echo"".($d=="Info"&&$b!=""?"".shorten_utf8($b,100,"").' '.lang(31).'':nbsp($b));}echo"\n";}echo'
+

',($l+1)."/".lang(223,$g->result("SELECT @@max_connections")),'

+ + +

+';}elseif(isset($_GET["select"])){$m=$_GET["select"];$D=table_status($m);$J=indexes($m);$p=fields($m);$ha=column_foreign_keys($m);if($D["Oid"]=="t"){$J[]=array("type"=>"PRIMARY","columns"=>array("oid"));}$Td=array();$B=array();$Db=null;foreach($p +as$d=>$e){$f=$o->fieldName($e);if(isset($e["privileges"]["select"])&&$f!=""){$B[$d]=html_entity_decode(strip_tags($f));if(ereg('text|lob',$e["type"])){$Db=$o->selectLengthProcess();}}$Td+=$e["privileges"];}list($Q,$pa)=$o->selectColumnsProcess($B,$J);$s=$o->selectSearchProcess($p,$J);$Xa=$o->selectOrderProcess($p,$J);$O=$o->selectLimitProcess();$Yb=($Q?implode(", ",$Q):($D["Oid"]=="t"?"oid, ":"")."*")."\nFROM ".table($m);$Ld=($pa&&count($pa)$a){echo$g->result("SELECT".limit(idf_escape(key($a))." FROM ".table($m)," WHERE ".where_check($gb).($s?" AND ".implode(" AND ",$s):"").($Xa?" ORDER BY ".implode(", ",$Xa):""),1));}exit;}if($_POST&&!$n){$ne="(".implode(") OR (",array_map('where_check',(array)$_POST["check"])).")";$Qa=$ad=null;foreach($J +as$x){if($x["type"]=="PRIMARY"){$Qa=array_flip($x["columns"]);$ad=($Q?$Qa:array());break;}}foreach($Q +as$d=>$b){$b=$_GET["columns"][$d];if(!$b["fun"]){unset($ad[$b["col"]]);}}if($_POST["export"]){dump_headers($m);$o->dumpTable($m,"");if(!is_array($_POST["check"])||$ad===array()){$bc=$s;if(is_array($_POST["check"])){$bc[]="($ne)";}$j="SELECT $Yb".($bc?"\nWHERE ".implode(" AND ",$bc):"").$Ld;}else{$Zd=array();foreach($_POST["check"]as$b){$Zd[]="(SELECT".limit($Yb,"\nWHERE ".($s?implode(" AND ",$s)." AND ":"").where_check($b).$Ld,1).")";}$j=implode(" UNION ALL ",$Zd);}$o->dumpData($m,"table",$j);exit;}if(!$o->selectEmailProcess($s,$ha)){if($_POST["save"]||$_POST["delete"]){$i=true;$wb=0;$j=table($m);$r=array();if(!$_POST["delete"]){foreach($B +as$f=>$b){$b=process_input($p[$f]);if($b!==null){if($_POST["clone"]){$r[idf_escape($f)]=($b!==false?$b:idf_escape($f));}elseif($b!==false){$r[]=idf_escape($f)." = $b";}}}$j.=($_POST["clone"]?" (".implode(", ",array_keys($r)).")\nSELECT ".implode(", ",$r)."\nFROM ".table($m):" SET\n".implode(",\n",$r));}if($_POST["delete"]||$r){$id="UPDATE";if($_POST["delete"]){$id="DELETE";$j="FROM $j";}if($_POST["clone"]){$id="INSERT";$j="INTO $j";}if($_POST["all"]||($ad===array()&&$_POST["check"])||count($pa)affected_rows;}else{foreach((array)$_POST["check"]as$b){$i=queries($id.limit1($j,"\nWHERE ".where_check($b)));if(!$i){break;}$wb+=$g->affected_rows;}}}queries_redirect(remove_from_uri("page"),lang(225,$wb),$i);}elseif(!$_POST["import"]){if(!$_POST["val"]){$n=lang(226);}else{$i=true;$wb=0;foreach($_POST["val"]as$gb=>$a){$r=array();foreach($a +as$d=>$b){$d=bracket_escape($d,1);$r[]=idf_escape($d)." = ".(ereg('char|text',$p[$d]["type"])||$b!=""?$o->processInput($p[$d],$b):"NULL");}$j=table($m)." SET ".implode(", ",$r);$bc=" WHERE ".where_check($gb).($s?" AND ".implode(" AND ",$s):"");$i=queries("UPDATE".(count($pa)affected_rows;}queries_redirect(remove_from_uri(),lang(225,$wb),$i);}}elseif(is_string($Ia=get_file("csv_file",true))){$i=true;$mb=array_keys($p);preg_match_all('~(?>"[^"]*"|[^"\\r\\n]+)+~',$Ia,$oa);$wb=count($oa[0]);begin();$Wa=($_POST["separator"]=="csv"?",":($_POST["separator"]=="tsv"?"\t":";"));foreach($oa[0]as$d=>$b){preg_match_all("~((\"[^\"]*\")+|[^$Wa]*)$Wa~",$b.$Wa,$Gd);if(!$d&&!array_diff($Gd[1],$mb)){$mb=$Gd[1];$wb--;}else{$r=array();foreach($Gd[1]as$l=>$Pc){$r[idf_escape($mb[$l])]=($Pc==""&&$p[$mb[$l]]["null"]?"NULL":q(str_replace('""','"',preg_replace('~^"|"$~','',$Pc))));}$i=insert_update($m,$r,$Qa);if(!$i){break;}}}if($i){queries("COMMIT");}queries_redirect(remove_from_uri("page"),lang(227,$wb),$i);queries("ROLLBACK");}else{$n=upload_error($Ia);}}}$Ea=$o->tableName($D);page_header(lang(33).": $Ea",$n);session_write_close();$r=null;if(isset($Td["insert"])){$r="";foreach((array)$_GET["where"]as$b){if(count($ha[$b["col"]])==1&&($b["op"]=="="||(!$b["op"]&&!ereg('[_%]',$b["val"])))){$r.="&set".urlencode("[".bracket_escape($b["col"])."]")."=".urlencode($b["val"]);}}}$o->selectLinks($D,$r);if(!$B){echo"

".lang(228).($p?".":": ".error())."\n";}else{echo"

\n","
";hidden_fields_get();echo(DB!=""?''.(isset($_GET["ns"])?'':""):"");echo'',"
\n";$o->selectColumnsPrint($Q,$B);$o->selectSearchPrint($s,$B,$J);$o->selectOrderPrint($Xa,$B,$J);$o->selectLimitPrint($O);$o->selectLengthPrint($Db);$o->selectActionPrint($Db);echo"
\n";$ca=$_GET["page"];if($ca=="last"){$Ya=$g->result("SELECT COUNT(*) FROM ".table($m).($s?" WHERE ".implode(" AND ",$s):""));$ca=floor(max(0,$Ya-1)/$O);}$j="SELECT".limit((+$O&&$pa&&count($pa)selectQuery($j);$i=$g->query($j);if(!$i){echo"

".error()."\n";}else{if($v=="mssql"){$i->seek($O*$ca);}$Hc=array();echo"

\n";$H=array();while($a=$i->fetch_assoc()){$H[]=$a;}if($_GET["page"]!="last"){$Ya=(+$O&&$pa&&count($pa)result(" SELECT FOUND_ROWS()"):$g->result("SELECT COUNT(*) FROM ($j) x")):count($H));}if(!$H){echo"

".lang(82)."\n";}else{$Bd=$o->backwardKeys($m,$Ea);echo"\n","".(!$pa&&$Q?"":"\n";foreach($o->rowDescriptions($H,$ha)as$fa=>$a){$pd=unique_array($H[$fa],$J);$gb="";foreach($pd +as$d=>$b){$gb.="&".(isset($b)?urlencode("where[".bracket_escape($d)."]")."=".urlencode($b):"null%5B%5D=".urlencode($d));}echo"".(!$pa&&$Q?"":"\n";}echo"
".lang(119)."");$Cd=array();$da=array();reset($Q);$ke=1;foreach($H[0]as$d=>$b){if($D["Oid"]!="t"||$d!="oid"){$b=$_GET["columns"][key($Q)];$e=$p[$Q?$b["col"]:$d];$f=($e?$o->fieldName($e,$ke):"*");if($f!=""){$ke++;$Cd[$d]=$f;$C=idf_escape($d);echo''.apply_sql_function($b["fun"],$f)."";}$da[$d]=$b["fun"];next($Q);}}$ec=array();if($_GET["modify"]){foreach($H +as$a){foreach($a +as$d=>$b){$ec[$d]=max($ec[$d],min(40,strlen(utf8_decode($b))));}}}echo($Bd?"".lang(229):"")."
".checkbox("check[]",substr($gb,1),in_array(substr($gb,1),(array)$_POST["check"]),"","this.form['all'].checked = false; formUncheck('all-page');").(count($pa)".lang(119).""));foreach($a +as$d=>$b){if(isset($Cd[$d])){$e=$p[$d];if($b!=""&&(!isset($Hc[$d])||$Hc[$d]!="")){$Hc[$d]=(is_mail($b)?$Cd[$d]:"");}$w="";$b=$o->editVal($b,$e);if(!isset($b)){$b="NULL";}else{if(ereg('blob|bytea|raw|file',$e["type"])&&$b!=""){$w=h(ME.'download='.urlencode($m).'&field='.urlencode($d).$gb);}if($b===""){$b=" ";}elseif($Db!=""&&ereg('text|blob',$e["type"])&&is_utf8($b)){$b=shorten_utf8($b,max(0,+$Db));}else{$b=h($b);}if(!$w){foreach((array)$ha[$d]as$A){if(count($ha[$d])==1||end($A["source"])==$d){$w="";foreach($A["source"]as$l=>$Ga){$w.=where_link($l,$A["target"][$l],$H[$fa][$Ga]);}$w=h(($A["db"]!=""?preg_replace('~([?&]db=)[^&]+~','\\1'.urlencode($A["db"]),ME):ME).'select='.urlencode($A["table"]).$w);if(count($A["source"])==1){break;}}}}if($d=="COUNT(*)"){$w=h(ME."select=".urlencode($m));$l=0;foreach((array)$_GET["where"]as$y){if(!array_key_exists($y["col"],$pd)){$w.=h(where_link($l++,$y["col"],$y["val"],$y["op"]));}}foreach($pd +as$Ma=>$y){$w.=h(where_link($l++,$Ma,$y));}}}if(!$w){if(is_mail($b)){$w="mailto:$b";}if($le=is_url($a[$d])){$w=($le=="http"&&$Ac?$a[$d]:"$le://www.adminer.org/redirect/?url=".urlencode($a[$d]));}}$S=h("val[$gb][".bracket_escape($d)."]");$q=$_POST["val"][$gb][bracket_escape($d)];$Pd=h(isset($q)?$q:$a[$d]);$uf=strpos($b,"...");$Yd=is_utf8($b)&&$H[$fa][$d]==$a[$d]&&!$da[$d];$Wd=ereg('text|lob',$e["type"]);echo(($_GET["modify"]&&$Yd)||isset($q)?"".($Wd?"":""):"".$o->selectVal($b,$w,$e));}}if($Bd){echo"";}$o->backwardKeysPrint($Bd,$H[$fa]);echo"
\n";}parse_str($_COOKIE["adminer_export"],$Xb);if($H||$ca){$md=true;if($_GET["page"]!="last"&&+$O&&count($pa)>=count($Q)&&($Ya>=$O||$ca)){$Ya=$D["Rows"];if(!isset($Ya)||$s||($D["Engine"]=="InnoDB"&&$Yaresult("SELECT COUNT(*) FROM ".table($m).($s?" WHERE ".implode(" AND ",$s):""));}else{$md=false;}}echo"

";if(+$O&&$Ya>$O){$Nd=floor(($Ya-1)/$O);echo'".lang(231).":",pagination(0,$ca).($ca>5?" ...":"");for($l=max(1,$ca-4);$l'.lang(232)."");}echo" (".($md?"":"~ ").lang(122,$Ya).") ".checkbox("all",1,0,lang(233))."\n";if(!information_schema(DB)){echo'

',lang(31),'
+ + + + +
+';}print_fieldset("export",lang(113));$Na=$o->dumpOutput();echo($Na?adminer_html_select("output",$Na,$Xb["output"])." ":""),adminer_html_select("format",$o->dumpFormat(),$Xb["format"])," \n","\n";}print_fieldset("import",lang(235),!$H);echo" ",adminer_html_select("separator",array("csv"=>"CSV,","csv;"=>"CSV;","tsv"=>"TSV"),$Xb["format"],1);echo" ","\n","\n";$o->selectEmailPrint(array_filter($Hc,'strlen'),$B);echo"\n";}}}elseif(isset($_GET["variables"])){$fc=isset($_GET["status"]);page_header($fc?lang(73):lang(72));$Pe=($fc?show_status():show_variables());if(!$Pe){echo"

".lang(82)."\n";}else{echo"\n";foreach($Pe +as$d=>$b){echo"","
".h($d)."","".nbsp($b);}echo"
\n";}}elseif(isset($_GET["script"])){header("Content-Type: text/javascript; charset=utf-8");if($_GET["script"]=="db"){$Yc=array("Data_length"=>0,"Index_length"=>0,"Data_free"=>0);foreach(table_status()as$a){$S=js_escape($a["Name"]);json_row("Comment-$S",nbsp($a["Comment"]));if(!is_view($a)){foreach(array("Engine","Collation")as$d){json_row("$d-$S",nbsp($a[$d]));}foreach($Yc+array("Auto_increment"=>0,"Rows"=>0)as$d=>$b){if($a[$d]!=""){$b=number_format($a[$d],0,'.',lang(236));json_row("$d-$S",($d=="Rows"&&$a["Engine"]=="InnoDB"&&$b?"~ $b":$b));if(isset($Yc[$d])){$Yc[$d]+=($a["Engine"]!="InnoDB"||$d!="Data_free"?$a[$d]:0);}}elseif(array_key_exists($d,$a)){json_row("$d-$S");}}}}foreach($Yc +as$d=>$b){json_row("sum-$d",number_format($b,0,'.',lang(236)));}json_row("");}else{foreach(count_tables(get_databases())as$t=>$b){json_row("tables-".js_escape($t),$b);}json_row("");}exit;}else{$Fe=array_merge((array)$_POST["tables"],(array)$_POST["views"]);if($Fe&&!$n&&!$_POST["search"]){$i=true;$va="";if($v=="sql"&&count($_POST["tables"])>1&&($_POST["drop"]||$_POST["truncate"]||$_POST["copy"])){queries("SET foreign_key_checks = 0");}if($_POST["truncate"]){if($_POST["tables"]){$i=truncate_tables($_POST["tables"]);}$va=lang(237);}elseif($_POST["move"]){$i=move_tables((array)$_POST["tables"],(array)$_POST["views"],$_POST["target"]);$va=lang(238);}elseif($_POST["copy"]){$i=copy_tables((array)$_POST["tables"],(array)$_POST["views"],$_POST["target"]);$va=lang(239);}elseif($_POST["drop"]){if($_POST["views"]){$i=drop_views($_POST["views"]);}if($i&&$_POST["tables"]){$i=drop_tables($_POST["tables"]);}$va=lang(240);}elseif($_POST["tables"]&&($i=queries(($_POST["optimize"]?"OPTIMIZE":($_POST["check"]?"CHECK":($_POST["repair"]?"REPAIR":"ANALYZE")))." TABLE ".implode(", ",array_map('idf_escape',$_POST["tables"]))))){while($a=$i->fetch_assoc()){$va.="".h($a["Table"]).": ".h($a["Msg_text"])."
";}}queries_redirect(substr(ME,0,-1),$va,$i);}page_header(($_GET["ns"]==""?lang(65).": ".h(DB):lang(80).": ".h($_GET["ns"])),$n,true);if($o->homepage()){if($_GET["ns"]!==""){echo''.lang(111)."\n","

".lang(241)."

\n";$jd=tables_list();if(!$jd){echo"

".lang(6)."\n";}else{echo"

\n","

".lang(242).": \n";if($_POST["search"]&&$_POST["query"]!=""){search_tables();}echo"\n",'\n";foreach($jd +as$f=>$z){$cc=(isset($z)&&!eregi("table",$z));echo'
'.lang(100).''.lang(243).''.lang(76).''.lang(244).''.lang(245).''.lang(246).''.lang(92).''.lang(247).(support("comment")?''.lang(94):'')."
'.checkbox(($cc?"views[]":"tables[]"),$f,in_array($f,$Fe,true),"","formUncheck('check-all');"),''.h($f).'';if($cc){echo''.lang(99).'','?';}else{foreach(array("Engine"=>"","Collation"=>"","Data_length"=>"create","Index_length"=>"indexes","Data_free"=>"edit","Auto_increment"=>"auto_increment=1&create","Rows"=>"select")as$d=>$w){echo($w?"?":" ");}}echo(support("comment")?" ":"");}echo"
 ".lang(223,count($jd)),"".nbsp($v=="sql"?$g->result("SELECT @@storage_engine"):""),"".nbsp(db_collation(DB,collations()));foreach(array("Data_length","Index_length","Data_free")as$d){echo" ";}echo"
\n";if(!information_schema(DB)){echo"

".($v=="sql"?" ":"")." \n";$_=(support("scheme")?schemas():get_databases());if(count($_)!=1&&$v!="sqlite"){$t=(isset($_POST["target"])?$_POST["target"]:(support("scheme")?$_GET["ns"]:DB));echo"

".lang(253).": ",($_?adminer_html_select("target",$_,$t):'')," ",(support("copy")?" ":""),"\n";}echo"\n";}echo"

\n";}echo'

'.lang(148)."\n";if(support("view")){echo''.lang(180)."\n";}if(support("routine")){echo"

".lang(116)."

\n";$Ue=routines();if($Ue){echo"\n",'\n";odd('');foreach($Ue +as$a){echo'','
'.lang(181).''.lang(89).''.lang(198)." 
'.h($a["ROUTINE_NAME"]).'',''.h($a["ROUTINE_TYPE"]),''.h($a["DTD_IDENTIFIER"]),''.lang(107)."";}echo"
\n";}echo'

'.lang(197).' '.lang(196)."\n";}if(support("sequence")){echo"

".lang(256)."

\n";$ff=get_vals("SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = current_schema()");if($ff){echo"\n","\n";odd('');foreach($ff +as$b){echo"
".lang(181)."
".h($b)."\n";}echo"
\n";}echo"

".lang(203)."\n";}if(support("type")){echo"

".lang(11)."

\n";$R=types();if($R){echo"\n","\n";odd('');foreach($R +as$b){echo"
".lang(181)."
".h($b)."\n";}echo"
\n";}echo"

".lang(207)."\n";}if(support("event")){echo"

".lang(117)."

\n";$H=get_rows("SHOW EVENTS");if($H){echo"\n","\n";foreach($H +as$a){echo"",'
".lang(181)."".lang(257)."".lang(187)."".lang(188)."
'.h($a["Name"])."","".($a["Execute at"]?lang(258)."".$a["Execute at"]:lang(189)." ".$a["Interval value"]." ".$a["Interval field"]."$a[Starts]"),"$a[Ends]";}echo"
\n";}echo'

'.lang(186)."\n";}if($jd){echo"\n";}}}}page_footer(); \ No newline at end of file diff --git a/app/adminer/app_config.php b/app/adminer/app_config.php new file mode 100644 index 0000000000..316440f3fa --- /dev/null +++ b/app/adminer/app_config.php @@ -0,0 +1,24 @@ +/app/adminer/index.php'; + $apps[$x]['menu'][0]['groups'][] = 'superadmin'; + + //permission details + $apps[$x]['permissions'][0]['name'] = 'adminer'; + $apps[$x]['permissions'][0]['groups'][] = 'superadmin'; + +?> \ No newline at end of file diff --git a/app/adminer/index.php b/app/adminer/index.php new file mode 100644 index 0000000000..9f6ea0688c --- /dev/null +++ b/app/adminer/index.php @@ -0,0 +1,66 @@ + \ No newline at end of file diff --git a/app/adminer/root.php b/app/adminer/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/adminer/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/call_broadcast/app_config.php b/app/call_broadcast/app_config.php new file mode 100644 index 0000000000..750b60a72e --- /dev/null +++ b/app/call_broadcast/app_config.php @@ -0,0 +1,120 @@ + \ No newline at end of file diff --git a/app/call_broadcast/root.php b/app/call_broadcast/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/call_broadcast/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/call_broadcast/v_call_broadcast.php b/app/call_broadcast/v_call_broadcast.php new file mode 100644 index 0000000000..49f636d246 --- /dev/null +++ b/app/call_broadcast/v_call_broadcast.php @@ -0,0 +1,151 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('call_broadcast_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + + +//get the http get variables and set them to php variables + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + echo "

"; + echo "\n"; + + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Call Broadcast List 
\n"; + + $sql = "select * from v_call_broadcasts "; + $sql .= "where domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $num_rows = count($result); + unset ($prep_statement, $result, $sql); + + $rows_per_page = 10; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + $sql = "select * from v_call_broadcasts "; + $sql .= "where domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo th_order_by('broadcast_name', 'Name', $order_by, $order); + echo th_order_by('broadcast_concurrent_limit', 'Concurrent Limit', $order_by, $order); + echo th_order_by('broadcast_description', 'Description', $order_by, $order); + //echo th_order_by('recordingid', 'Recording', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + if (permission_exists('call_broadcast_add')) { + echo " $v_link_label_add\n"; + } + echo "
".$row['broadcast_name']." ".$row['broadcast_concurrent_limit']." ".$row['recordingid']."".$row['broadcast_description']." \n"; + if (permission_exists('call_broadcast_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('call_broadcast_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('call_broadcast_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/call_broadcast/v_call_broadcast_delete.php b/app/call_broadcast/v_call_broadcast_delete.php new file mode 100644 index 0000000000..0cf0d98463 --- /dev/null +++ b/app/call_broadcast/v_call_broadcast_delete.php @@ -0,0 +1,61 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('call_broadcast_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the id + if (count($_GET)>0) { + $id = $_GET["id"]; + } + +//delete the call broadcast entry + if (strlen($id)>0) { + $sql = "delete from v_call_broadcasts "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and call_broadcast_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + } + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/call_broadcast/v_call_broadcast_edit.php b/app/call_broadcast/v_call_broadcast_edit.php new file mode 100644 index 0000000000..2e888b273d --- /dev/null +++ b/app/call_broadcast/v_call_broadcast_edit.php @@ -0,0 +1,560 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('call_broadcast_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//set the action with add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $call_broadcast_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get the http post variables and set them to php variables + if (count($_POST)>0) { + $broadcast_name = check_str($_POST["broadcast_name"]); + $broadcast_description = check_str($_POST["broadcast_description"]); + $broadcast_timeout = check_str($_POST["broadcast_timeout"]); + $broadcast_concurrent_limit = check_str($_POST["broadcast_concurrent_limit"]); + //$recording_uuid = check_str($_POST["recording_uuid"]); + $broadcast_caller_id_name = check_str($_POST["broadcast_caller_id_name"]); + $broadcast_caller_id_number = check_str($_POST["broadcast_caller_id_number"]); + $broadcast_destination_type = check_str($_POST["broadcast_destination_type"]); + $broadcast_phone_numbers = check_str($_POST["broadcast_phone_numbers"]); + $broadcast_destination_data = check_str($_POST["broadcast_destination_data"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $call_broadcast_uuid = check_str($_POST["call_broadcast_uuid"]); + } + + //check for all required data + if (strlen($broadcast_name) == 0) { $msg .= "Please provide: Name
\n"; } + //if (strlen($broadcast_description) == 0) { $msg .= "Please provide: Description
\n"; } + //if (strlen($broadcast_timeout) == 0) { $msg .= "Please provide: Timeout
\n"; } + //if (strlen($broadcast_concurrent_limit) == 0) { $msg .= "Please provide: Concurrent Limit
\n"; } + //if (strlen($recording_uuid) == 0) { $msg .= "Please provide: Recording
\n"; } + //if (strlen($broadcast_caller_id_name) == 0) { $msg .= "Please provide: Caller ID Name
\n"; } + //if (strlen($broadcast_caller_id_number) == 0) { $msg .= "Please provide: Caller ID Number
\n"; } + //if (strlen($broadcast_destination_type) == 0) { $msg .= "Please provide: Type
\n"; } + //if (strlen($broadcast_phone_numbers) == 0) { $msg .= "Please provide: Phone Number List
\n"; } + //if (strlen($broadcast_destination_data) == 0) { $msg .= "Please provide: Destination
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('call_broadcast_add')) { + $call_broadcast_uuid = uuid(); + $sql = "insert into v_call_broadcasts "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "call_broadcast_uuid, "; + $sql .= "broadcast_name, "; + $sql .= "broadcast_description, "; + $sql .= "broadcast_timeout, "; + $sql .= "broadcast_concurrent_limit, "; + //$sql .= "recording_uuid, "; + $sql .= "broadcast_caller_id_name, "; + $sql .= "broadcast_caller_id_number, "; + $sql .= "broadcast_destination_type, "; + $sql .= "broadcast_phone_numbers, "; + $sql .= "broadcast_destination_data "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$call_broadcast_uuid', "; + $sql .= "'$broadcast_name', "; + $sql .= "'$broadcast_description', "; + if (strlen($broadcast_timeout) == 0) { + $sql .= "null, "; + } + else { + $sql .= "'$broadcast_timeout', "; + } + if (strlen($broadcast_concurrent_limit) == 0) { + $sql .= "null, "; + } + else { + $sql .= "'$broadcast_concurrent_limit', "; + } + //$sql .= "'$recording_uuid', "; + $sql .= "'$broadcast_caller_id_name', "; + $sql .= "'$broadcast_caller_id_number', "; + $sql .= "'$broadcast_destination_type', "; + $sql .= "'$broadcast_phone_numbers', "; + $sql .= "'$broadcast_destination_data' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update" && permission_exists('call_broadcast_edit')) { + $sql = "update v_call_broadcasts set "; + $sql .= "broadcast_name = '$broadcast_name', "; + $sql .= "broadcast_description = '$broadcast_description', "; + if (strlen($broadcast_timeout) == 0) { + $sql .= "broadcast_timeout = null, "; + } + else { + $sql .= "broadcast_timeout = '$broadcast_timeout', "; + } + if (strlen($broadcast_concurrent_limit) == 0) { + $sql .= "broadcast_concurrent_limit = null, "; + } + else { + $sql .= "broadcast_concurrent_limit = '$broadcast_concurrent_limit', "; + } + //$sql .= "recording_uuid = '$recording_uuid', "; + $sql .= "broadcast_caller_id_name = '$broadcast_caller_id_name', "; + $sql .= "broadcast_caller_id_number = '$broadcast_caller_id_number', "; + $sql .= "broadcast_destination_type = '$broadcast_destination_type', "; + $sql .= "broadcast_phone_numbers = '$broadcast_phone_numbers', "; + $sql .= "broadcast_destination_data = '$broadcast_destination_data' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and call_broadcast_uuid = '$call_broadcast_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $call_broadcast_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_call_broadcasts "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and call_broadcast_uuid = '$call_broadcast_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + while($row = $prep_statement->fetch()) { + $broadcast_name = $row["broadcast_name"]; + $broadcast_description = $row["broadcast_description"]; + $broadcast_timeout = $row["broadcast_timeout"]; + $broadcast_concurrent_limit = $row["broadcast_concurrent_limit"]; + //$recording_uuid = $row["recording_uuid"]; + $broadcast_caller_id_name = $row["broadcast_caller_id_name"]; + $broadcast_caller_id_number = $row["broadcast_caller_id_number"]; + $broadcast_destination_type = $row["broadcast_destination_type"]; + $broadcast_phone_numbers = $row["broadcast_phone_numbers"]; + $broadcast_destination_data = $row["broadcast_destination_data"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//begin header + require_once "includes/header.php"; + +//begin content + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + //echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +/* + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +*/ + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " "; + echo "
Call BroadcastCall Broadcast Edit\n"; + echo " \n"; + echo "
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter a name here.\n"; + echo "
\n"; + echo " Timeout:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Limit the length of the call. Leave this empty for no limit.\n"; + echo "
\n"; + echo " Concurrent Limit:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Limit the approximate number of concurrent calls. Leave this empty for no limit.\n"; + echo "
\n"; + //echo " Recording:\n"; + //echo "\n"; + //echo " \n"; + //echo "
\n"; + //echo "Recording to play when the call is answered.
\n"; + //echo "\n"; + //echo "
\n"; + echo " Caller ID Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Applicable if the provider allow the Caller ID Name to be set. default: anonymous\n"; + echo "
\n"; + echo " Caller ID Number:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Applicable if the provider that allow the Caller ID number to be sent. default: 0000000000\n"; + echo "
\n"; + echo " Type:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Optional, Destination Type: bridge, transfer, voicemail, conference, fifo, etc.\n"; + echo "
\n"; + echo " Destination:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Optional, send the call to an auto attendant, conference room, or any other destination.

\n"; + echo "conference (8khz): 01-\${domain}@default
\n"; + echo "bridge (external number): sofia/gateway/gatewayname/12081231234
\n"; + echo "bridge (auto attendant): sofia/internal/5002@\${domain}
\n"; + echo "transfer (external number): 12081231234 XML default
\n"; + echo "
\n"; + echo " Destination Number:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Send the call to the extension an IVR Menu, Conference Room, or any other number.

\n"; + echo "
\n"; + echo " Phone Number List:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Optional, set a list of phone numbers one per row in the following format: 123-123-1234|Last Name, First Name

\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter a description here.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + echo " \n"; + } + + echo " \n"; + echo "
"; + echo ""; + + echo "
\n"; + echo "
\n"; + echo "
\n"; + + /* + if ($action == "update") { + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Call Broadcast 
\n"; + + echo "
\n"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo " \n"; + echo " \n"; + echo " "; + + echo "
\n"; + echo " Category:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + //echo "zzz.
\n"; + echo "\n"; + echo "
\n"; + echo " Group:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + //echo "zzz.
\n"; + echo "\n"; + echo "
\n"; + echo " Gateway:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + //echo "zzz.
\n"; + echo "\n"; + echo "
\n"; + echo " Phone Type:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + //echo "zzz.
\n"; + echo "\n"; + echo "
\n"; + echo " Phone Type:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + //echo "zzz.
\n"; + echo "\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo "
"; + echo ""; + } + */ + + + echo "
"; + echo "
"; + + +require_once "includes/footer.php"; +?> diff --git a/app/call_broadcast/v_call_broadcast_send.php b/app/call_broadcast/v_call_broadcast_send.php new file mode 100644 index 0000000000..0cbe12c715 --- /dev/null +++ b/app/call_broadcast/v_call_broadcast_send.php @@ -0,0 +1,374 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('call_broadcast_send')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//set the max execution time to 1 hour + ini_set(max_execution_time,3600); + +function cmd_async($cmd) { + //windows + if (stristr(PHP_OS, 'WIN')) { + $descriptorspec = array( + 0 => array("pipe", "r"), // stdin + 1 => array("pipe", "w"), // stdout + 2 => array("pipe", "w") // stderr + ); + $process = proc_open("start ".$cmd, $descriptorspec, $pipes); + //sleep(1); + proc_close($process); + } + else { //posix + exec ($cmd ." /dev/null 2>&1 &"); + } +} + +//get the http get values and set as php variables + $group_name = $_GET["group_name"]; + $call_broadcast_uuid = $_GET["call_broadcast_uuid"]; + $user_category = $_GET["user_category"]; + $gateway = $_GET["gateway"]; + $phonetype1 = $_GET["phonetype1"]; + $phonetype2 = $_GET["phonetype2"]; + +//get the call broadcast details from the database + $sql = ""; + $sql .= "select * from v_call_broadcasts "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and call_broadcast_uuid = '$call_broadcast_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + while($row = $prep_statement->fetch()) { + $broadcast_name = $row["broadcast_name"]; + $broadcast_description = $row["broadcast_description"]; + $broadcast_timeout = $row["broadcast_timeout"]; + $broadcast_concurrent_limit = $row["broadcast_concurrent_limit"]; + $recordingid = $row["recordingid"]; + $broadcast_caller_id_name = $row["broadcast_caller_id_name"]; + $broadcast_caller_id_number = $row["broadcast_caller_id_number"]; + $broadcast_destination_type = $row["broadcast_destination_type"]; + $broadcast_phone_numbers = $row["broadcast_phone_numbers"]; + $broadcast_destination_data = $row["broadcast_destination_data"]; + //if (strlen($row["broadcast_destination_data"]) == 0) { + // $broadcast_destination_application = ''; + // $broadcast_destination_data = ''; + //} + //else { + // $broadcast_destination_array = explode(":", $row["broadcast_destination_data"]); + // $broadcast_destination_application = $broadcast_destination_array[0]; + // $broadcast_destination_data = $broadcast_destination_array[1]; + //} + break; //limit to 1 row + } + unset ($prep_statement); + + if (strlen($broadcast_caller_id_name) == 0) { + $broadcast_caller_id_name = "anonymous"; + } + if (strlen($broadcast_caller_id_number) == 0) { + $broadcast_caller_id_number = "0000000000"; + } + + //get the recording name + //$recording_filename = get_recording_filename($recordingid); + +//remove unsafe characters from the name + $broadcast_name = str_replace(" ", "", $broadcast_name); + $broadcast_name = str_replace("'", "", $broadcast_name); + +//create the event socket connection + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + +//get information over event socket + if (!$fp) { + require_once "includes/header.php"; + $msg = "
Connection to Event Socket failed.
"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Message
$msg
\n"; + echo "
\n"; + require_once "includes/footer.php"; + } + else { + //show the header + require_once "includes/header.php"; + + //send the call broadcast + if (strlen($broadcast_phone_numbers) > 0) { + $broadcast_phone_number_array = explode ("\n", $broadcast_phone_numbers); + $count = 1; + $sched_seconds = '3'; + foreach ($broadcast_phone_number_array as $tmp_value) { + $tmp_value = str_replace(";", "|", $tmp_value); + $tmp_value_array = explode ("|", $tmp_value); + + //make sure the phone numbers are correct + $phone1 = trim($tmp_value_array[0]); + $phone1 = str_replace("-", "", $phone1); + $phone1 = str_replace("(", "", $phone1); + $phone1 = str_replace(")", "", $phone1); + $phone1 = str_replace(" ", "", $phone1); + $phone1 = str_replace(".", "", $phone1); + + //get the correct gateway + $bridge_array = outbound_route_to_bridge ($phone1); + + //prepare the string + $channel_variables = "ignore_early_media=true,origination_number=$phone1,origination_caller_id_name='$broadcast_caller_id_name',origination_caller_id_number=$broadcast_caller_id_number"; + $origination_url = "{".$channel_variables."}".$bridge_array[0].""; + + //get the context + if (count($_SESSION["domains"]) > 1) { + $context = $_SESSION['domain_name']; + } + else { + $context = "default"; + } + + //set the command + $cmd = "bgapi sched_api +".$sched_seconds." none bgapi originate ".$origination_url." ".$broadcast_destination_data." XML $context"; + + //if the event socket connection is lost then re-connect + if (!$fp) { + $fp = eventsocket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + } + + //method 1 + $response = trim(event_socket_request($fp, 'api '.$cmd)); + + //method 2 + //cmd_async($_SESSION['switch']['bin']['dir']."/fs_cli -x \"".$cmd."\";"); + + //spread the calls out so that they are scheduled with different times + if (strlen($broadcast_concurrent_limit) > 0 && strlen($broadcast_timeout) > 0) { + if ($broadcast_concurrent_limit == $count) { + $sched_seconds = $sched_seconds + $broadcast_timeout; + $count=0; + } + } + + $count++; + } + fclose($fp); + + //echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Message
\n"; + echo " Call Broadcast $broadcast_name has been started.\n"; + echo "

\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " View Calls\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + + } + + //show the footer + require_once "includes/footer.php"; + } + +/* +//reserved for future use + +require_once "includes/header.php"; + + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Contact List 
\n"; + + $broadcast_phone_number_array = explode ("\n", $broadcast_phone_numbers); + foreach ($broadcast_phone_number_array as $tmp_value) { + $tmp_value = str_replace(";", "|", $tmp_value); + $tmp_value_array = explode ("|", $tmp_value); + + //make sure the phone numbers are correct + $phone1 = trim($tmp_value_array[0]); + $phone1 = str_replace("-", "", $phone1); + $phone1 = str_replace("(", "", $phone1); + $phone1 = str_replace(")", "", $phone1); + $phone1 = str_replace(" ", "", $phone1); + $phone1 = str_replace(".", "", $phone1); + + if ($gateway == "loopback") { + $cmd = $_SESSION['switch']['bin']['dir']."/fs_cli -x \"luarun call_broadcast_originate.lua {call_timeout=".$broadcast_timeout."}loopback/".$phone1."/default/XML ".$_SESSION['switch']['recordings']['dir']."/".$recording_filename." '".$broadcast_caller_id_name."' ".$broadcast_caller_id_number." ".$broadcast_timeout." '".$broadcast_destination_application."' '".$broadcast_destination_data."'\";"; + } + else { + $cmd = $_SESSION['switch']['bin']['dir']."/fs_cli -x \"luarun call_broadcast_originate.lua {call_timeout=".$broadcast_timeout."}sofia/gateway/".$gateway."/".$phone1." ".$_SESSION['switch']['recordings']['dir']."/".$recording_filename." '".$broadcast_caller_id_name."' ".$broadcast_caller_id_number." ".$broadcast_timeout." '".$broadcast_destination_application."' '".$broadcast_destination_data."'\";"; + } + echo $cmd."
\n"; + cmd_async($cmd); + //sleep(60); + } + + if (strlen($group_name) > 0) { + $sql = " select * from v_users as u, v_group_users as m "; + $sql .= " where u.user_uuid = m.user_uuid "; + $sql .= " and m.group_name = '".$group_name."' "; + $sql .= " and u.user_category = '".$user_category."' "; + //echo $sql."
"; + } + else { + $sql = " select * from v_users as u "; + $sql .= " where u.user_category = '".$user_category."' "; + //echo $sql."
"; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + //echo th_order_by('username', 'Username', $order_by, $order); + echo th_order_by('user_type', 'Type', $order_by, $order); + //echo th_order_by('user_category', 'Category', $order_by, $order); + echo th_order_by('user_first_name', 'First Name', $order_by, $order); + echo th_order_by('user_last_name', 'Last Name', $order_by, $order); + echo th_order_by('user_company_name', 'Organization', $order_by, $order); + echo th_order_by('user_phone_1', 'Phone1', $order_by, $order); + echo th_order_by('user_phone_2', 'Phone2', $order_by, $order); + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + //echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + + //if (strlen($gateway) > 0) { + if ($phonetype1 == "phone1" && strlen($row[user_phone_1]) > 0) { $phone1 = $row[user_phone_1]; } + if ($phonetype1 == "phone2" && strlen($row[user_phone_2]) > 0) { $phone1 = $row[user_phone_2]; } + if ($phonetype1 == "cell" && strlen($row[user_phone_mobile]) > 0) { $phone1 = $row[user_phone_mobile]; } + if ($phonetype2 == "phone1" && strlen($row[user_phone_2]) > 0) { $phone2 = $row[user_phone_2]; } + if ($phonetype2 == "phone2" && strlen($row[user_phone_2]) > 0) { $phone2 = $row[user_phone_2]; } + if ($phonetype2 == "cell" && strlen($row[user_phone_mobile]) > 0) { $phone2 = $row[user_phone_mobile]; } + + //make sure the phone numbers are correct + $phone1 = str_replace("-", "", $phone1); + $phone1 = str_replace("(", "", $phone1); + $phone1 = str_replace(")", "", $phone1); + $phone1 = str_replace(" ", "", $phone1); + $phone1 = str_replace(".", "", $phone1); + $phone2 = str_replace("-", "", $phone2); + $phone2 = str_replace("(", "", $phone2); + $phone2 = str_replace(")", "", $phone2); + $phone2 = str_replace(" ", "", $phone2); + $phone2 = str_replace(".", "", $phone2); + + //make the call + if (strlen($phone1)> 0) { + if ($gateway == "loopback") { + $cmd = $_SESSION['switch']['bin']['dir']."/fs_cli -x \"luarun call_broadcast_originate.lua {call_timeout=".$broadcast_timeout."}loopback/".$phone1."/default/XML ".$_SESSION['switch']['recordings']['dir']."/".$recording_filename." '".$broadcast_caller_id_name."' ".$broadcast_caller_id_number." ".$broadcast_timeout." '".$broadcast_destination_application."' '".$broadcast_destination_data."'\";"; + } + else { + $cmd = $_SESSION['switch']['bin']['dir']."/fs_cli -x \"luarun call_broadcast_originate.lua {call_timeout=".$broadcast_timeout."}sofia/gateway/".$gateway."/".$phone1." ".$_SESSION['switch']['recordings']['dir']."/".$recording_filename." '".$broadcast_caller_id_name."' ".$broadcast_caller_id_number." ".$broadcast_timeout." '".$broadcast_destination_application."' '".$broadcast_destination_data."'\";"; + } + //echo $cmd."
\n"; + cmd_async($cmd); + } + if (strlen($phone2)> 0) { + if ($gateway == "loopback") { + $cmd = $_SESSION['switch']['bin']['dir']."/fs_cli -x \"luarun call_broadcast_originate.lua {call_timeout=".$broadcast_timeout."}loopback/".$phone2."/default/XML ".$_SESSION['switch']['recordings']['dir']."/".$recording_filename." '".$broadcast_caller_id_name."' ".$broadcast_caller_id_number." ".$broadcast_timeout." '".$broadcast_destination_application."' '".$broadcast_destination_data."'\";"; + } + else { + $cmd = $_SESSION['switch']['bin']['dir']."/fs_cli -x \"luarun call_broadcast_originate.lua {call_timeout=".$broadcast_timeout."}sofia/gateway/".$gateway."/".$phone2." ".$_SESSION['switch']['recordings']['dir']."/".$recording_filename." '".$broadcast_caller_id_name."' ".$broadcast_caller_id_number." ".$broadcast_timeout." '".$broadcast_destination_application."' '".$broadcast_destination_data."'\";"; + } + //echo $cmd."
\n"; + cmd_async($cmd); + } + + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "
".$row[username]." ".$row[user_type]." ".$row[user_category]." ".$row[user_first_name]." ".$row[user_last_name]." ".$row[user_company_name]." ".$row[user_phone_1]." ".$row[user_phone_2]." 
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + + +require_once "includes/footer.php"; +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); +*/ +?> diff --git a/app/call_center/app_config.php b/app/call_center/app_config.php new file mode 100644 index 0000000000..7d84b72b40 --- /dev/null +++ b/app/call_center/app_config.php @@ -0,0 +1,457 @@ + \ No newline at end of file diff --git a/app/call_center/root.php b/app/call_center/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/call_center/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/call_center/v_call_center_agent.php b/app/call_center/v_call_center_agent.php new file mode 100644 index 0000000000..8387e886f7 --- /dev/null +++ b/app/call_center/v_call_center_agent.php @@ -0,0 +1,190 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('call_center_agents_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get http values and set them to php variables + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Call Center Agent List\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "List of call center agents.

\n"; + echo "
\n"; + + $sql = ""; + $sql .= "select * from v_call_center_agents "; + $sql .= "where domain_uuid = '$domain_uuid' "; + if (strlen($order_by) == 0) { + $order_by = 'agent_name'; + $order = 'asc'; + } + else { + $sql .= "order by $order_by $order "; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $num_rows = count($result); + unset ($prep_statement, $result, $sql); + $rows_per_page = 100; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + $sql = ""; + $sql .= " select * from v_call_center_agents "; + $sql .= "where domain_uuid = '$domain_uuid' "; + if (strlen($order_by) == 0) { + $order_by = 'agent_name'; + $order = 'asc'; + } + else { + $sql .= "order by $order_by $order "; + } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + //echo th_order_by('domain_uuid', 'domain_uuid', $order_by, $order); + echo th_order_by('agent_name', 'Agent Name', $order_by, $order); + echo th_order_by('agent_type', 'Type', $order_by, $order); + echo th_order_by('agent_call_timeout', 'Call Timeout', $order_by, $order); + echo th_order_by('agent_contact', 'Contact', $order_by, $order); + echo th_order_by('agent_max_no_answer', 'Max No Answer', $order_by, $order); + echo th_order_by('agent_status', 'Status', $order_by, $order); + //echo th_order_by('agent_wrap_up_time', 'Wrap Up Time', $order_by, $order); + //echo th_order_by('agent_reject_delay_time', 'Reject Delay Time', $order_by, $order); + //echo th_order_by('agent_busy_delay_time', 'Busy Delay Time', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count == 0) { //no results + } + else { //received results + foreach($result as $row) { + echo "\n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + if (permission_exists('call_center_agents_add')) { + echo " $v_link_label_add\n"; + } + echo "
".$row[domain_uuid]."".$row[agent_name]." ".$row[agent_type]." ".$row[agent_call_timeout]." ".$row[agent_contact]." ".$row[agent_max_no_answer]." ".$row[agent_status]." ".$row[agent_wrap_up_time]." ".$row[agent_reject_delay_time]." ".$row[agent_busy_delay_time]." \n"; + if (permission_exists('call_center_agents_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('call_center_agents_delete')) { + echo " $v_link_label_delete\n"; + } + //echo " \n"; + //echo " \n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('call_center_agents_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//show the footer + require_once "includes/footer.php"; +?> diff --git a/app/call_center/v_call_center_agent_delete.php b/app/call_center/v_call_center_agent_delete.php new file mode 100644 index 0000000000..0c49348af5 --- /dev/null +++ b/app/call_center/v_call_center_agent_delete.php @@ -0,0 +1,85 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('call_center_agents_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); +} + +//get the agent details + $sql = ""; + $sql .= "select * from v_call_center_agents "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and call_center_agent_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $agent_name = $row["agent_name"]; + break; //limit to 1 row + } + unset ($prep_statement); + +//delete the agent from the freeswitch + //setup the event socket connection + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + //delete the agent over event socket + if ($fp) { + $cmd = "api callcenter_config agent del ".$agent_name."@".$_SESSION['domains'][$domain_uuid]['domain_name']; + $response = event_socket_request($fp, $cmd); + } + +//delete the agent from the db + if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_call_center_agents "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and call_center_agent_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + } + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> + diff --git a/app/call_center/v_call_center_agent_edit.php b/app/call_center/v_call_center_agent_edit.php new file mode 100644 index 0000000000..92d3e5eb56 --- /dev/null +++ b/app/call_center/v_call_center_agent_edit.php @@ -0,0 +1,513 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('call_center_agents_add') || permission_exists('call_center_agents_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $call_center_agent_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $agent_name = check_str($_POST["agent_name"]); + $agent_type = check_str($_POST["agent_type"]); + $agent_call_timeout = check_str($_POST["agent_call_timeout"]); + $agent_contact = check_str($_POST["agent_contact"]); + $agent_status = check_str($_POST["agent_status"]); + $agent_logout = check_str($_POST["agent_logout"]); + $agent_no_answer_delay_time = check_str($_POST["agent_no_answer_delay_time"]); + $agent_max_no_answer = check_str($_POST["agent_max_no_answer"]); + $agent_wrap_up_time = check_str($_POST["agent_wrap_up_time"]); + $agent_reject_delay_time = check_str($_POST["agent_reject_delay_time"]); + $agent_busy_delay_time = check_str($_POST["agent_busy_delay_time"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + + if ($action == "update") { + $call_center_agent_uuid = check_str($_POST["call_center_agent_uuid"]); + } + + //check for all required data + //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + //if (strlen($agent_name) == 0) { $msg .= "Please provide: Agent Name
\n"; } + //if (strlen($agent_type) == 0) { $msg .= "Please provide: Type
\n"; } + //if (strlen($agent_call_timeout) == 0) { $msg .= "Please provide: Call Timeout
\n"; } + //if (strlen($agent_contact) == 0) { $msg .= "Please provide: Contact
\n"; } + //if (strlen($agent_status) == 0) { $msg .= "Please provide: Status
\n"; } + //if (strlen($agent_logout) == 0) { $msg .= "Please provide: Logout
\n"; } + //if (strlen($agent_no_answer_delay_time) == 0) { $msg .= "Please provide: No Answer Delay Time
\n"; } + //if (strlen($agent_max_no_answer) == 0) { $msg .= "Please provide: Max No Answer
\n"; } + //if (strlen($agent_wrap_up_time) == 0) { $msg .= "Please provide: Wrap Up Time
\n"; } + //if (strlen($agent_reject_delay_time) == 0) { $msg .= "Please provide: Reject Delay Time
\n"; } + //if (strlen($agent_busy_delay_time) == 0) { $msg .= "Please provide: Busy Delay Time
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //get and then set the complete agent_contact with the call_timeout and when necessary confirm + $tmp_confirm = "group_confirm_file=custom/press_1_to_accept_this_call.wav,group_confirm_key=1"; + if(strstr($agent_contact, '}') === FALSE) { + //not found + if(stristr($agent_contact, 'sofia/gateway') === FALSE) { + //add the call_timeout + $tmp_agent_contact = "{call_timeout=".$agent_call_timeout."}".$agent_contact; + } + else { + //add the call_timeout and confirm + $tmp_agent_contact = $tmp_first.',call_timeout='.$agent_call_timeout.$tmp_last; + $tmp_agent_contact = "{".$tmp_confirm.",call_timeout=".$agent_call_timeout."}".$agent_contact; + } + } + else { + //found + if(stristr($agent_contact, 'sofia/gateway') === FALSE) { + //not found + if(stristr($agent_contact, 'call_timeout') === FALSE) { + //add the call_timeout + $tmp_pos = strrpos($agent_contact, "}"); + $tmp_first = substr($agent_contact, 0, $tmp_pos); + $tmp_last = substr($agent_contact, $tmp_pos); + $tmp_agent_contact = $tmp_first.',call_timeout='.$agent_call_timeout.$tmp_last; + } + else { + //the string has the call timeout + $tmp_agent_contact = $agent_contact; + } + } + else { + //found + $tmp_pos = strrpos($agent_contact, "}"); + $tmp_first = substr($agent_contact, 0, $tmp_pos); + $tmp_last = substr($agent_contact, $tmp_pos); + if(stristr($agent_contact, 'call_timeout') === FALSE) { + //add the call_timeout and confirm + $tmp_agent_contact = $tmp_first.','.$tmp_confirm.',call_timeout='.$agent_call_timeout.$tmp_last; + } + else { + //add confirm + $tmp_agent_contact = $tmp_first.','.$tmp_confirm.$tmp_last; + } + } + } + + //set the user_status + $sql = "update v_users set "; + $sql .= "user_status = '".$agent_status."' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and username = '".$agent_name."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + + //add the agent + //setup the event socket connection + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + //add the agent using event socket + if ($fp) { + //add the agent + $cmd = "api callcenter_config agent add ".$agent_name."@".$_SESSION['domains'][$domain_uuid]['domain_name']." ".$agent_type; + $response = event_socket_request($fp, $cmd); + usleep(200); + //agent set contact + $cmd = "api callcenter_config agent set contact ".$agent_name."@".$_SESSION['domains'][$domain_uuid]['domain_name']." ".$tmp_agent_contact; + $response = event_socket_request($fp, $cmd); + usleep(200); + //agent set status + $cmd = "api callcenter_config agent set status ".$agent_name."@".$_SESSION['domains'][$domain_uuid]['domain_name']." '".$agent_status."'"; + $response = event_socket_request($fp, $cmd); + usleep(200); + //agent set reject_delay_time + $cmd = "api callcenter_config agent set reject_delay_time ".$agent_name."@".$_SESSION['domains'][$domain_uuid]['domain_name']." ".$agent_reject_delay_time; + $response = event_socket_request($fp, $cmd); + usleep(200); + //agent set busy_delay_time + $cmd = "api callcenter_config agent set busy_delay_time ".$agent_name."@".$_SESSION['domains'][$domain_uuid]['domain_name']." ".$agent_busy_delay_time; + $response = event_socket_request($fp, $cmd); + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + //add the agent to the database + $call_center_agent_uuid = uuid(); + $sql = "insert into v_call_center_agents "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "call_center_agent_uuid, "; + $sql .= "agent_name, "; + $sql .= "agent_type, "; + $sql .= "agent_call_timeout, "; + $sql .= "agent_contact, "; + $sql .= "agent_status, "; + $sql .= "agent_logout, "; + $sql .= "agent_no_answer_delay_time, "; + $sql .= "agent_max_no_answer, "; + $sql .= "agent_wrap_up_time, "; + $sql .= "agent_reject_delay_time, "; + $sql .= "agent_busy_delay_time "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$call_center_agent_uuid', "; + $sql .= "'$agent_name', "; + $sql .= "'$agent_type', "; + $sql .= "'$agent_call_timeout', "; + $sql .= "'$agent_contact', "; + $sql .= "'$agent_status', "; + $sql .= "'$agent_logout', "; + $sql .= "'$agent_no_answer_delay_time', "; + $sql .= "'$agent_max_no_answer', "; + $sql .= "'$agent_wrap_up_time', "; + $sql .= "'$agent_reject_delay_time', "; + $sql .= "'$agent_busy_delay_time' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //syncrhonize configuration + save_call_center_xml(); + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_call_center_agents set "; + $sql .= "agent_name = '$agent_name', "; + $sql .= "agent_type = '$agent_type', "; + $sql .= "agent_call_timeout = '$agent_call_timeout', "; + $sql .= "agent_contact = '$agent_contact', "; + $sql .= "agent_status = '$agent_status', "; + $sql .= "agent_logout = '$agent_logout', "; + $sql .= "agent_no_answer_delay_time = '$agent_no_answer_delay_time', "; + $sql .= "agent_max_no_answer = '$agent_max_no_answer', "; + $sql .= "agent_wrap_up_time = '$agent_wrap_up_time', "; + $sql .= "agent_reject_delay_time = '$agent_reject_delay_time', "; + $sql .= "agent_busy_delay_time = '$agent_busy_delay_time' "; + $sql .= "where domain_uuid = '$domain_uuid'"; + $sql .= "and call_center_agent_uuid = '$call_center_agent_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + //syncrhonize configuration + save_call_center_xml(); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $call_center_agent_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_call_center_agents "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and call_center_agent_uuid = '$call_center_agent_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $agent_name = $row["agent_name"]; + $agent_type = $row["agent_type"]; + $agent_call_timeout = $row["agent_call_timeout"]; + $agent_contact = $row["agent_contact"]; + $agent_status = $row["agent_status"]; + $agent_logout = $row["agent_logout"]; + $agent_no_answer_delay_time = $row["agent_no_answer_delay_time"]; + $agent_max_no_answer = $row["agent_max_no_answer"]; + $agent_wrap_up_time = $row["agent_wrap_up_time"]; + $agent_reject_delay_time = $row["agent_reject_delay_time"]; + $agent_busy_delay_time = $row["agent_busy_delay_time"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//set default values + if (strlen($agent_type) == 0) { $agent_type = "callback"; } + if (strlen($agent_call_timeout) == 0) { $agent_call_timeout = 10; } + if (strlen($agent_max_no_answer) == 0) { $agent_max_no_answer = "3"; } + if (strlen($agent_wrap_up_time) == 0) { $agent_wrap_up_time = "10"; } + if (strlen($agent_no_answer_delay_time) == 0) { $agent_no_answer_delay_time = "10"; } + if (strlen($agent_reject_delay_time) == 0) { $agent_reject_delay_time = "10"; } + if (strlen($agent_busy_delay_time) == 0) { $agent_busy_delay_time = "60"; } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " "; + echo "
Call Center Agent AddCall Center Agent Edit
\n"; + //echo "Call Center agents settings.

\n"; + echo "
\n"; + echo " Agent Name:\n"; + echo "\n"; + //---- Begin Select List -------------------- + $sql = "SELECT * FROM v_users "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "order by username asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + + echo ""; + unset($sql, $result); + //---- End Select List -------------------- + echo "
\n"; + echo "Select the agents name.\n"; + echo "
\n"; + echo " Type:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the agent type.\n"; + echo "
\n"; + echo " Call Timeout:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the call timeout.\n"; + echo "
\n"; + echo " Contact:\n"; + echo "\n"; + + //switch_select_destination(select_type, select_label, select_name, select_value, select_style, action); + switch_select_destination("call_center_contact", "", "agent_contact", $agent_contact, "", ""); + + echo "
\n"; + echo "Select the contact number.\n"; + echo "
\n"; + echo " Status:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Select the agent status.\n"; + echo "
\n"; + echo " No Answer Delay Time:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the agent no answer delay time in seconds.\n"; + echo "
\n"; + echo " Max No Answer:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter max no answer.\n"; + echo "
\n"; + echo " Wrap Up Time:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the wrap up time.\n"; + echo "
\n"; + echo " Reject Delay Time:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the reject delay time.\n"; + echo "
\n"; + echo " Busy Delay Time:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the agent busy delay time.\n"; + echo "
\n"; + echo " Agent Logout:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the auto agent logout time in 00:00 format. Requires a service to enforce the logout time.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//footer + require_once "includes/footer.php"; +?> diff --git a/app/call_center/v_call_center_agent_status.php b/app/call_center/v_call_center_agent_status.php new file mode 100644 index 0000000000..46a768d8f1 --- /dev/null +++ b/app/call_center/v_call_center_agent_status.php @@ -0,0 +1,235 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('call_center_agents_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//setup the event socket connection + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + +//get the http post values and set them as php variables + if (count($_POST)>0) { + //include the dnd php class + include "includes/classes/do_not_disturb.php"; + + foreach($_POST['agents'] as $row) { + if (strlen($row['status']) > 0) { + //agent set status + if ($fp) { + //set the user_status + $sql = "update v_users set "; + $sql .= "user_status = '".$row['status']."' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and username = '".$row['name']."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + //set the call center status + if ($row['status'] == "Do Not Disturb") { + //set the default dnd action + $dnd_action = "add"; + //set the call center status to Logged Out + $cmd = "api callcenter_config agent set status ".$row['name']."@".$_SESSION['domains'][$domain_uuid]['domain_name']." 'Logged Out'"; + } + else { + $cmd = "api callcenter_config agent set status ".$row['name']."@".$_SESSION['domains'][$domain_uuid]['domain_name']." '".$row['status']."'"; + } + //echo $cmd."
\n"; + $response = event_socket_request($fp, $cmd); + usleep(200); + } + + //loop through the list of assigned extensions + foreach ($_SESSION['user']['extension'] as &$sub_row) { + $extension = $sub_row["user"]; + //hunt_group information used to determine if this is an add or an update + $sql = "select * from v_hunt_groups "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and hunt_group_extension = '$extension' "; + $prep_statement_2 = $db->prepare(check_sql($sql)); + $prep_statement_2->execute(); + $result2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED); + foreach ($result2 as &$row2) { + if ($row2["hunt_group_type"] == 'dnd') { + $dnd_action = "update"; + $dnd_uuid = $row2["hunt_group_uuid"]; + } + } + unset ($prep_statement_2, $result2, $row2); + //add or update dnd + $dnd = new do_not_disturb; + //$dnd->debug = false; + $dnd->domain_uuid = $domain_uuid; + $dnd->dnd_uuid = $dnd_uuid; + $dnd->domain_name = $_SESSION['domain_name']; + $dnd->extension = $extension; + if ($row['status'] == "Do Not Disturb") { + $dnd->dnd_enabled = "true"; + if ($dnd_action == "add") { + $dnd->dnd_add(); + } + if ($dnd_action == "update") { + $dnd->dnd_update(); + } + } + else { + //for other status disable dnd + if ($dnd_action == "update") { + $dnd->dnd_enabled = "false"; + $dnd->dnd_update(); + } + } + unset($dnd); + } + unset ($prep_statement); + } + } + } + +//get the agent list from event socket + $switch_cmd = 'callcenter_config agent list'; + $event_socket_str = trim(event_socket_request($fp, 'api '.$switch_cmd)); + $agent_array = csv_to_named_array($event_socket_str, '|'); +//set the status on the user_array by using the extension as the key + foreach ($agent_array as $row) { + if (count($_SESSION['domains']) == 1) { + //get the extension status from the call center agent list + preg_match('/user\/(\d{2,7})/', $row['contact'], $matches); + $extension = $matches[1]; + $user_array[$extension]['username'] = $tmp[0]; + if ($user_array[$extension]['user_status'] != "Do Not Disturb") { + $user_array[$extension]['user_status'] = $row['status']; + } + } else { + $tmp = explode('@',$row["name"]); + if ($tmp[1] == $_SESSION['domain_name']) { + //get the extension status from the call center agent list + preg_match('/user\/(\d{2,7})/', $row['contact'], $matches); + $extension = $matches[1]; + $user_array[$extension]['username'] = $tmp[0]; + if ($user_array[$extension]['user_status'] != "Do Not Disturb") { + $user_array[$extension]['user_status'] = $row['status']; + } + } + } + } + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Call Center Agent Status\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "List all the call center agents with the option to change the status of one or more agents.

\n"; + echo "
\n"; + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $x = 0; + foreach($agent_array as $row) { + $tmp = explode('@',$row["name"]); + $agent_name = $tmp[0]; + if ($tmp[1] == $_SESSION['domain_name']) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + } + if ($c==0) { $c=1; } else { $c=0; } + $x++; + } //end foreach + unset($sql, $result, $row_count); + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
AgentStatusOptions
".$row['name']." ".$row['status']." "; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo "
\n"; + echo " \n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "\n"; + echo "

"; + +//show the footer + require_once "includes/footer.php"; +?> diff --git a/app/call_center/v_call_center_queue.php b/app/call_center/v_call_center_queue.php new file mode 100644 index 0000000000..902b08d276 --- /dev/null +++ b/app/call_center/v_call_center_queue.php @@ -0,0 +1,194 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('call_center_queues_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get http variables and set as php variables + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Call Center Queue\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "List of queues for the call center.

\n"; + echo "
\n"; + + $sql = ""; + $sql .= "select * from v_call_center_queues "; + $sql .= "where domain_uuid = '$domain_uuid' "; + if (strlen($order_by) == 0) { + $order_by = 'queue_name'; + $order = 'asc'; + } + else { + $sql .= "order by $order_by $order "; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $num_rows = count($result); + unset ($prep_statement, $result, $sql); + $rows_per_page = 100; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + $sql = ""; + $sql .= "select * from v_call_center_queues "; + $sql .= "where domain_uuid = '$domain_uuid' "; + if (strlen($order_by) == 0) { + $order_by = 'queue_name'; + $order = 'asc'; + } + else { + $sql .= "order by $order_by $order "; + } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo th_order_by('queue_name', 'Queue Name', $order_by, $order); + echo th_order_by('queue_extension', 'Extension', $order_by, $order); + echo th_order_by('queue_strategy', 'Strategy', $order_by, $order); + //echo th_order_by('queue_moh_sound', 'Music On Hold', $order_by, $order); + //echo th_order_by('queue_record_template', 'Record Template', $order_by, $order); + //echo th_order_by('queue_time_base_score', 'Time Base Score', $order_by, $order); + //echo th_order_by('queue_max_wait_time', 'Max Wait Time', $order_by, $order); + //echo th_order_by('queue_max_wait_time_with_no_agent', 'Max Wait Time With No Agent', $order_by, $order); + echo th_order_by('queue_tier_rules_apply', 'Tier Rules Apply', $order_by, $order); + //echo th_order_by('queue_tier_rule_wait_second', 'Tier Rule Wait Second', $order_by, $order); + //echo th_order_by('queue_tier_rule_no_agent_no_wait', 'Tier Rule No Agent No Wait', $order_by, $order); + //echo th_order_by('queue_discard_abandoned_after', 'Discard Abandoned After', $order_by, $order); + //echo th_order_by('queue_abandoned_resume_allowed', 'Abandoned Resume Allowed', $order_by, $order); + //echo th_order_by('queue_tier_rule_wait_multiply_level', 'Tier Rule Wait Multiply Level', $order_by, $order); + echo th_order_by('queue_description', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + if (permission_exists('call_center_queues_add')) { + echo " $v_link_label_add\n"; + } + echo "
".$row[queue_name]." ".$row[queue_extension]." ".$row[queue_strategy]." ".$row[queue_moh_sound]." ".$row[queue_record_template]." ".$row[queue_time_base_score]." ".$row[queue_max_wait_time]." ".$row[queue_max_wait_time_with_no_agent]." ".$row[queue_tier_rules_apply]." ".$row[queue_tier_rule_wait_second]." ".$row[queue_tier_rule_no_agent_no_wait]." ".$row[queue_discard_abandoned_after]." ".$row[queue_abandoned_resume_allowed]." ".$row[queue_tier_rule_wait_multiply_level]." ".$row[queue_description]." \n"; + if (permission_exists('call_center_queues_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('call_center_queues_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('call_center_queues_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//show the footer + require_once "includes/footer.php"; +?> diff --git a/app/call_center/v_call_center_queue_delete.php b/app/call_center/v_call_center_queue_delete.php new file mode 100644 index 0000000000..8e9b4a704f --- /dev/null +++ b/app/call_center/v_call_center_queue_delete.php @@ -0,0 +1,93 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('call_center_queues_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET) > 0) { + $id = check_str($_GET["id"]); +} + +if (strlen($id) > 0) { + + //get the dialplan uuid + $sql = "select * from v_call_center_queues "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and call_center_queue_uuid = '$id' "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + while($row = $prep_statement->fetch(PDO::FETCH_ASSOC)) { + $dialplan_uuid = $row['dialplan_uuid']; + } + + //delete the call center queue + $sql = "delete from v_call_center_queues "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + + //delete the dialplan entry + $sql = "delete from v_dialplans "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + //echo $sql."
\n"; + $db->query($sql); + unset($sql); + + //delete the dialplan details + $sql = "delete from v_dialplan_details "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + //echo $sql."
\n"; + $db->query($sql); + unset($sql); + + //syncrhonize configuration + save_dialplan_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; +} + +//redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/call_center/v_call_center_queue_edit.php b/app/call_center/v_call_center_queue_edit.php new file mode 100644 index 0000000000..45ac396108 --- /dev/null +++ b/app/call_center/v_call_center_queue_edit.php @@ -0,0 +1,633 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('call_center_queues_add') || permission_exists('call_center_queues_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $call_center_queue_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http post variables and set them to php variables + if (count($_POST)>0) { + //$domain_uuid = check_str($_POST["domain_uuid"]); + $queue_name = check_str($_POST["queue_name"]); + $queue_extension = check_str($_POST["queue_extension"]); + $queue_strategy = check_str($_POST["queue_strategy"]); + $queue_moh_sound = check_str($_POST["queue_moh_sound"]); + $queue_record_template = check_str($_POST["queue_record_template"]); + $queue_time_base_score = check_str($_POST["queue_time_base_score"]); + $queue_max_wait_time = check_str($_POST["queue_max_wait_time"]); + $queue_max_wait_time_with_no_agent = check_str($_POST["queue_max_wait_time_with_no_agent"]); + $queue_tier_rules_apply = check_str($_POST["queue_tier_rules_apply"]); + $queue_tier_rule_wait_second = check_str($_POST["queue_tier_rule_wait_second"]); + $queue_tier_rule_wait_multiply_level = check_str($_POST["queue_tier_rule_wait_multiply_level"]); + $queue_tier_rule_no_agent_no_wait = check_str($_POST["queue_tier_rule_no_agent_no_wait"]); + $queue_timeout_action = check_str($_POST["queue_timeout_action"]); + $queue_discard_abandoned_after = check_str($_POST["queue_discard_abandoned_after"]); + $queue_abandoned_resume_allowed = check_str($_POST["queue_abandoned_resume_allowed"]); + $queue_cid_prefix = check_str($_POST["queue_cid_prefix"]); + $queue_description = check_str($_POST["queue_description"]); + + //remove invalid characters + $queue_cid_prefix = str_replace(":", "-", $queue_cid_prefix); + $queue_cid_prefix = str_replace("\"", "", $queue_cid_prefix); + $queue_cid_prefix = str_replace("@", "", $queue_cid_prefix); + $queue_cid_prefix = str_replace("\\", "", $queue_cid_prefix); + $queue_cid_prefix = str_replace("/", "", $queue_cid_prefix); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $call_center_queue_uuid = check_str($_POST["call_center_queue_uuid"]); + } + + //check for all required data + if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + if (strlen($queue_name) == 0) { $msg .= "Please provide: Queue Name
\n"; } + if (strlen($queue_extension) == 0) { $msg .= "Please provide: Extension
\n"; } + if (strlen($queue_strategy) == 0) { $msg .= "Please provide: Strategy
\n"; } + if (strlen($queue_moh_sound) == 0) { $msg .= "Please provide: Music on Hold
\n"; } + //if (strlen($queue_record_template) == 0) { $msg .= "Please provide: Record Template
\n"; } + //if (strlen($queue_time_base_score) == 0) { $msg .= "Please provide: Time Base Score
\n"; } + //if (strlen($queue_max_wait_time) == 0) { $msg .= "Please provide: Max Wait Time
\n"; } + //if (strlen($queue_max_wait_time_with_no_agent) == 0) { $msg .= "Please provide: Max Wait Time with no Agent
\n"; } + //if (strlen($queue_tier_rules_apply) == 0) { $msg .= "Please provide: Tier Rules Apply
\n"; } + //if (strlen($queue_tier_rule_wait_second) == 0) { $msg .= "Please provide: Tier Rule Wait Second
\n"; } + //if (strlen($queue_tier_rule_wait_multiply_level) == 0) { $msg .= "Please provide: Tier Rule Wait Multiply Level
\n"; } + //if (strlen($queue_tier_rule_no_agent_no_wait) == 0) { $msg .= "Please provide: Tier Rule No Agent No Wait
\n"; } + //if (strlen($queue_timeout_action) == 0) { $msg .= "Please provide: Timeout Action
\n"; } + //if (strlen($queue_discard_abandoned_after) == 0) { $msg .= "Please provide: Discard Abandoned After
\n"; } + //if (strlen($queue_abandoned_resume_allowed) == 0) { $msg .= "Please provide: Abandoned Resume Allowed
\n"; } + //if (strlen($queue_cid_prefix) == 0) { $msg .= "Please provide: Caller ID Prefix
\n"; } + //if (strlen($queue_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + //add the call center queue + $call_center_queue_uuid = uuid(); + $sql = "insert into v_call_center_queues "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "call_center_queue_uuid, "; + $sql .= "queue_name, "; + $sql .= "queue_extension, "; + $sql .= "queue_strategy, "; + $sql .= "queue_moh_sound, "; + $sql .= "queue_record_template, "; + $sql .= "queue_time_base_score, "; + $sql .= "queue_max_wait_time, "; + $sql .= "queue_max_wait_time_with_no_agent, "; + $sql .= "queue_tier_rules_apply, "; + $sql .= "queue_tier_rule_wait_second, "; + $sql .= "queue_tier_rule_wait_multiply_level, "; + $sql .= "queue_tier_rule_no_agent_no_wait, "; + $sql .= "queue_timeout_action, "; + $sql .= "queue_discard_abandoned_after, "; + $sql .= "queue_abandoned_resume_allowed, "; + $sql .= "queue_cid_prefix, "; + $sql .= "queue_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$call_center_queue_uuid', "; + $sql .= "'$queue_name', "; + $sql .= "'$queue_extension', "; + $sql .= "'$queue_strategy', "; + $sql .= "'$queue_moh_sound', "; + $sql .= "'$queue_record_template', "; + $sql .= "'$queue_time_base_score', "; + $sql .= "'$queue_max_wait_time', "; + $sql .= "'$queue_max_wait_time_with_no_agent', "; + $sql .= "'$queue_tier_rules_apply', "; + $sql .= "'$queue_tier_rule_wait_second', "; + $sql .= "'$queue_tier_rule_wait_multiply_level', "; + $sql .= "'$queue_tier_rule_no_agent_no_wait', "; + $sql .= "'$queue_timeout_action', "; + $sql .= "'$queue_discard_abandoned_after', "; + $sql .= "'$queue_abandoned_resume_allowed', "; + $sql .= "'$queue_cid_prefix', "; + $sql .= "'$queue_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //syncrhonize the configuration + save_call_center_xml(); + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + //update the call center queue + $sql = "update v_call_center_queues set "; + $sql .= "queue_name = '$queue_name', "; + $sql .= "queue_extension = '$queue_extension', "; + $sql .= "queue_strategy = '$queue_strategy', "; + $sql .= "queue_moh_sound = '$queue_moh_sound', "; + $sql .= "queue_record_template = '$queue_record_template', "; + $sql .= "queue_time_base_score = '$queue_time_base_score', "; + $sql .= "queue_max_wait_time = '$queue_max_wait_time', "; + $sql .= "queue_max_wait_time_with_no_agent = '$queue_max_wait_time_with_no_agent', "; + $sql .= "queue_tier_rules_apply = '$queue_tier_rules_apply', "; + $sql .= "queue_tier_rule_wait_second = '$queue_tier_rule_wait_second', "; + $sql .= "queue_tier_rule_wait_multiply_level = '$queue_tier_rule_wait_multiply_level', "; + $sql .= "queue_tier_rule_no_agent_no_wait = '$queue_tier_rule_no_agent_no_wait', "; + $sql .= "queue_timeout_action = '$queue_timeout_action', "; + $sql .= "queue_discard_abandoned_after = '$queue_discard_abandoned_after', "; + $sql .= "queue_abandoned_resume_allowed = '$queue_abandoned_resume_allowed', "; + $sql .= "queue_cid_prefix = '$queue_cid_prefix', "; + $sql .= "queue_description = '$queue_description' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and call_center_queue_uuid = '$call_center_queue_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + //syncrhonize the configuration + save_call_center_xml(); + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $call_center_queue_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_call_center_queues "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and call_center_queue_uuid = '$call_center_queue_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $queue_name = $row["queue_name"]; + $queue_extension = $row["queue_extension"]; + $queue_strategy = $row["queue_strategy"]; + $queue_moh_sound = $row["queue_moh_sound"]; + $queue_record_template = $row["queue_record_template"]; + $queue_time_base_score = $row["queue_time_base_score"]; + $queue_max_wait_time = $row["queue_max_wait_time"]; + $queue_max_wait_time_with_no_agent = $row["queue_max_wait_time_with_no_agent"]; + $queue_timeout_action = $row["queue_timeout_action"]; + $queue_tier_rules_apply = $row["queue_tier_rules_apply"]; + $queue_tier_rule_wait_second = $row["queue_tier_rule_wait_second"]; + $queue_tier_rule_wait_multiply_level = $row["queue_tier_rule_wait_multiply_level"]; + $queue_tier_rule_no_agent_no_wait = $row["queue_tier_rule_no_agent_no_wait"]; + $queue_discard_abandoned_after = $row["queue_discard_abandoned_after"]; + $queue_abandoned_resume_allowed = $row["queue_abandoned_resume_allowed"]; + $queue_cid_prefix = $row["queue_cid_prefix"]; + $queue_description = $row["queue_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//set default values + if (strlen($queue_strategy) == 0) { $queue_strategy = "longest-idle-agent"; } + if (strlen($queue_moh_sound) == 0) { $queue_moh_sound = "\$\${hold_music}"; } + if (strlen($queue_time_base_score) == 0) { $queue_time_base_score = "system"; } + if (strlen($queue_max_wait_time) == 0) { $queue_max_wait_time = "0"; } + if (strlen($queue_max_wait_time_with_no_agent) == 0) { $queue_max_wait_time_with_no_agent = "0"; } + if (strlen($queue_tier_rules_apply) == 0) { $queue_tier_rules_apply = "false"; } + if (strlen($queue_tier_rule_wait_second) == 0) { $queue_tier_rule_wait_second = "300"; } + if (strlen($queue_tier_rule_wait_multiply_level) == 0) { $queue_tier_rule_wait_multiply_level = "true"; } + if (strlen($queue_tier_rule_no_agent_no_wait) == 0) { $queue_tier_rule_no_agent_no_wait = "false"; } + if (strlen($queue_discard_abandoned_after) == 0) { $queue_discard_abandoned_after = "60"; } + if (strlen($queue_abandoned_resume_allowed) == 0) { $queue_abandoned_resume_allowed = "false"; } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Call Center Queue AddCall Center Queue Edit\n"; + if ($action == "update") { + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + } + echo " \n"; + echo "
\n"; + //echo "Call Center queue settings.

\n"; + echo "
\n"; + echo " Queue Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the queue name.\n"; + echo "
\n"; + echo " Extension:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the extension number.\n"; + echo "
\n"; + echo " Strategy:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the queue strategy.\n"; + echo "
\n"; + echo " Music on Hold:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the music on hold information.\n"; + echo "
\n"; + echo " Record Template:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter a record template. \$\${base_dir}/recordings/archive/\${strftime(%Y)}/\${strftime(%b)}/\${strftime(%d)}/\${uuid}.wav\n"; + echo "
\n"; + echo " Time Base Score:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the time base score.\n"; + echo "
\n"; + echo " Max Wait Time:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the max wait time.\n"; + echo "
\n"; + echo " Max Wait Time with no Agent:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the max wait time with no agent.\n"; + echo "
\n"; + echo " Timeout Action:\n"; + echo "\n"; + //switch_select_destination(select_type, select_label, select_name, select_value, select_style, action); + switch_select_destination("dialplan", "", "queue_timeout_action", $queue_timeout_action, "", ""); + echo "
\n"; + echo "Set the action to perform when the max wait time is reached.\n"; + echo "
\n"; + echo " Tier Rules Apply:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Set the tier rule rules apply to true or false.\n"; + echo "
\n"; + echo " Tier Rule Wait Second:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the tier rule wait seconds.\n"; + echo "
\n"; + echo " Tier Rule Wait Multiply Level:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Set the tier rule wait multiply level to true or false.\n"; + echo "
\n"; + echo " Tier Rule No Agent No Wait:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the tier rule no agent no wait.\n"; + echo "
\n"; + echo " Discard Abandoned After:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Set the discard abandoned after seconds.\n"; + echo "
\n"; + echo " Abandoned Resume Allowed:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Set the abandoned resume allowed to true or false.\n"; + echo "
\n"; + echo " CID Prefix:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Set a prefix on the caller ID name.\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the description.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + + +require_once "includes/footer.php"; +?> diff --git a/app/call_center/v_call_center_tier.php b/app/call_center/v_call_center_tier.php new file mode 100644 index 0000000000..a9bc27c086 --- /dev/null +++ b/app/call_center/v_call_center_tier.php @@ -0,0 +1,177 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('call_center_tiers_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get http variables and set as php variables + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Call Center Tier List\n"; + echo " \n"; + echo "
\n"; + echo "List all tiers. Tiers assign agents to queues.

\n"; + echo "
\n"; + + $sql = ""; + $sql .= "select * from v_call_center_tiers "; + $sql .= "where domain_uuid = '$domain_uuid' "; + if (strlen($order_by) == 0) { + $order_by = 'queue_name'; + $order = 'asc'; + } + else { + $sql .= "order by $order_by $order "; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $num_rows = count($result); + unset ($prep_statement, $result, $sql); + $rows_per_page = 100; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + $sql = ""; + $sql .= "select * from v_call_center_tiers "; + $sql .= "where domain_uuid = '$domain_uuid' "; + if (strlen($order_by) == 0) { + $order_by = 'queue_name'; + $order = 'asc'; + } + else { + $sql .= "order by $order_by $order "; + } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo th_order_by('agent_name', 'Agent Name', $order_by, $order); + echo th_order_by('queue_name', 'Queue Name', $order_by, $order); + echo th_order_by('tier_level', 'Tier Level', $order_by, $order); + echo th_order_by('tier_position', 'Tier Position', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count == 0) { //no results + } + else { //received results + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "
\n"; + if (permission_exists('call_center_tiers_add')) { + echo " $v_link_label_add\n"; + } + echo "
".$row[agent_name]." ".$row[queue_name]." ".$row[tier_level]." ".$row[tier_position]." \n"; + if (permission_exists('call_center_tiers_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('call_center_tiers_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('call_center_tiers_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + + echo "
"; + echo "
"; + echo "

"; + +//show the footer + require_once "includes/footer.php"; +?> diff --git a/app/call_center/v_call_center_tier_delete.php b/app/call_center/v_call_center_tier_delete.php new file mode 100644 index 0000000000..246fee9af2 --- /dev/null +++ b/app/call_center/v_call_center_tier_delete.php @@ -0,0 +1,89 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('call_center_tiers_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the id + if (count($_GET)>0) { + $id = check_str($_GET["id"]); + } + +//get the agent details + $sql = ""; + $sql .= "select * from v_call_center_tiers "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and call_center_tier_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $agent_name = $row["agent_name"]; + $queue_name = $row["queue_name"]; + break; //limit to 1 row + } + unset ($prep_statement); + +//delete the agent from the freeswitch + //get the domain using the $domain_uuid + $tmp_domain = $_SESSION['domains'][$domain_uuid]['domain_name']; + //setup the event socket connection + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + //delete the agent over event socket + if ($fp) { + //callcenter_config tier del [queue_name] [agent_name] + $cmd = "api callcenter_config tier del ".$queue_name."@".$tmp_domain." ".$agent_name."@".$_SESSION['domains'][$domain_uuid]['domain_name']; + $response = event_socket_request($fp, $cmd); + } + +//delete the tier from the database + if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_call_center_tiers "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and call_center_tier_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + } + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> diff --git a/app/call_center/v_call_center_tier_edit.php b/app/call_center/v_call_center_tier_edit.php new file mode 100644 index 0000000000..731a88eaef --- /dev/null +++ b/app/call_center/v_call_center_tier_edit.php @@ -0,0 +1,437 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('call_center_tiers_add') || permission_exists('call_center_tiers_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $call_center_tier_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $agent_name = check_str($_POST["agent_name"]); + $queue_name = check_str($_POST["queue_name"]); + $tier_level = check_str($_POST["tier_level"]); + $tier_position = check_str($_POST["tier_position"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $call_center_tier_uuid = check_str($_POST["call_center_tier_uuid"]); + } + + //check for all required data + //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + //if (strlen($agent_name) == 0) { $msg .= "Please provide: Agent Name
\n"; } + //if (strlen($queue_name) == 0) { $msg .= "Please provide: Queue Name
\n"; } + //if (strlen($tier_level) == 0) { $msg .= "Please provide: Tier Level
\n"; } + //if (strlen($tier_position) == 0) { $msg .= "Please provide: Tier Position
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add the agent + //setup the event socket connection + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + //add the agent using event socket + if ($fp) { + //get the domain using the $domain_uuid + $tmp_domain = $_SESSION['domains'][$domain_uuid]['domain_name']; + //syntax + //callcenter_config tier add [queue_name] [agent_name] [level] [position] + //callcenter_config tier set state [queue_name] [agent_name] [state] + //callcenter_config tier set level [queue_name] [agent_name] [level] + //callcenter_config tier set position [queue_name] [agent_name] [position] + //add the agent + $cmd = "api callcenter_config tier add ".$queue_name."@".$tmp_domain." ".$agent_name."@".$tmp_domain." ".$tier_level." ".$tier_position; + $response = event_socket_request($fp, $cmd); + usleep(200); + //agent set level + $cmd = "api callcenter_config tier set level ".$queue_name."@".$tmp_domain." ".$agent_name."@".$tmp_domain." ".$tier_level; + $response = event_socket_request($fp, $cmd); + usleep(200); + //agent set position + $cmd = "api callcenter_config tier set position ".$queue_name."@".$tmp_domain." ".$agent_name."@".$tmp_domain." ".$tier_position; + $response = event_socket_request($fp, $cmd); + usleep(200); + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $call_center_tier_uuid = uuid(); + $sql = "insert into v_call_center_tiers "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "call_center_tier_uuid, "; + $sql .= "agent_name, "; + $sql .= "queue_name, "; + $sql .= "tier_level, "; + $sql .= "tier_position "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$call_center_tier_uuid', "; + $sql .= "'$agent_name', "; + $sql .= "'$queue_name', "; + $sql .= "'$tier_level', "; + $sql .= "'$tier_position' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //syncrhonize configuration + save_call_center_xml(); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_call_center_tiers set "; + $sql .= "domain_uuid = '$domain_uuid', "; + $sql .= "agent_name = '$agent_name', "; + $sql .= "queue_name = '$queue_name', "; + $sql .= "tier_level = '$tier_level', "; + $sql .= "tier_position = '$tier_position' "; + $sql .= "where call_center_tier_uuid = '$call_center_tier_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + //syncrhonize configuration + save_call_center_xml(); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $call_center_tier_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_call_center_tiers "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and call_center_tier_uuid = '$call_center_tier_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $agent_name = $row["agent_name"]; + $queue_name = $row["queue_name"]; + $tier_level = $row["tier_level"]; + $tier_position = $row["tier_position"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Call Center Tier AddCall Center Tier Edit
\n"; + echo "List all tiers. Tiers assign agents to queues.

\n"; + echo "
\n"; + echo " Agent Name:\n"; + echo "\n"; + + //---- Begin Select List -------------------- + $sql = "SELECT * FROM v_users "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "order by username asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + + echo ""; + unset($sql, $result); + //---- End Select List -------------------- + + echo "
\n"; + echo "Select the agent name.\n"; + echo "
\n"; + echo " Queue Name:\n"; + echo "\n"; + + //---- Begin Select List -------------------- + $sql = "SELECT * FROM v_call_center_queues "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "order by queue_name asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + + echo ""; + unset($sql, $result); + //---- End Select List -------------------- + + echo "
\n"; + echo "Select the queue name.\n"; + echo "
\n"; + echo " Tier Level:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Select the tier level.\n"; + echo "
\n"; + echo " Tier Position:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Select the tier position.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + + +require_once "includes/footer.php"; +?> diff --git a/app/call_center/v_cmd.php b/app/call_center/v_cmd.php new file mode 100644 index 0000000000..08cf654fb8 --- /dev/null +++ b/app/call_center/v_cmd.php @@ -0,0 +1,57 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('call_center_queues_add') || permission_exists('call_center_queues_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$cmd = $_GET['cmd']; +$rdr = $_GET['rdr']; + +//connect to event socket +$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); +if ($fp) { + $response = event_socket_request($fp, 'api reloadxml'); + $response = event_socket_request($fp, $cmd); + fclose($fp); +} +else { + $response = ''; +} +if ($rdr == "false") { + //redirect false + echo $response; +} +else { + header("Location: v_call_center_queue.php?savemsg=".urlencode($response)); +} +?> \ No newline at end of file diff --git a/app/call_center_active/app_config.php b/app/call_center_active/app_config.php new file mode 100644 index 0000000000..6689d095c2 --- /dev/null +++ b/app/call_center_active/app_config.php @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/app/call_center_active/root.php b/app/call_center_active/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/call_center_active/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/call_center_active/v_call_center_active.php b/app/call_center_active/v_call_center_active.php new file mode 100644 index 0000000000..63946f2bfc --- /dev/null +++ b/app/call_center_active/v_call_center_active.php @@ -0,0 +1,122 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('call_center_active_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the queue_name and set it as a variable + $queue_name = $_GET[queue_name]; + +//get the header + require_once "includes/header.php"; +?> + +"; +echo "\n"; +echo "\n"; +echo " "; +echo " "; +echo "
\n"; + +echo "
\n"; +echo "
\n"; + +echo "
"; +echo ""; + +require_once "includes/footer.php"; +?> diff --git a/app/call_center_active/v_call_center_active_inc.php b/app/call_center_active/v_call_center_active_inc.php new file mode 100644 index 0000000000..4d19b3e2d6 --- /dev/null +++ b/app/call_center_active/v_call_center_active_inc.php @@ -0,0 +1,302 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('call_center_active_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the queue_name and set it as a variable + $queue_name = $_GET[queue_name].'@'. $_SESSION['domains'][$domain_uuid]['domain_name']; + +//convert the string to a named array + function str_to_named_array($tmp_str, $tmp_delimiter) { + $tmp_array = explode ("\n", $tmp_str); + $result = ''; + if (trim(strtoupper($tmp_array[0])) != "+OK") { + $tmp_field_name_array = explode ($tmp_delimiter, $tmp_array[0]); + $x = 0; + foreach ($tmp_array as $row) { + if ($x > 0) { + $tmp_field_value_array = explode ($tmp_delimiter, $tmp_array[$x]); + $y = 0; + foreach ($tmp_field_value_array as $tmp_value) { + $tmp_name = $tmp_field_name_array[$y]; + if (trim(strtoupper($tmp_value)) != "+OK") { + $result[$x][$tmp_name] = $tmp_value; + } + $y++; + } + } + $x++; + } + unset($row); + } + return $result; + } + +//alternate the color of the row + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + +//create an event socket connection + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + +//get the call center queue, agent and tiers list + if (!$fp) { + $msg = "
Connection to Event Socket failed.
"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Message
$msg
\n"; + echo "
\n"; + } + else { + //get the queue list + //send the event socket command and get the response + //callcenter_config queue list members [queue_name] + $switch_cmd = 'callcenter_config queue list members '.$queue_name; + $event_socket_str = trim(event_socket_request($fp, 'api '.$switch_cmd)); + $result = str_to_named_array($event_socket_str, '|'); + + //show the title + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
".ucfirst($_GET[queue_name])." Queue
\n"; + echo " Shows a list of callers in the queue.
\n"; + echo "
\n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + if (if_group("admin") || if_group("superadmin")) { + echo "\n"; + } + echo "\n"; + + foreach ($result as $row) { + $switch_cmd = 'uuid_exists '.$row['session_uuid']; + if (trim(event_socket_request($fp, 'api '.$switch_cmd)) == "true") { + $queue = $row['queue']; + $system = $row['system']; + $uuid = $row['uuid']; + $session_uuid = $row['session_uuid']; + $caller_number = $row['caller_number']; + $caller_name = $row['caller_name']; + $system_epoch = $row['system_epoch']; + $joined_epoch = $row['joined_epoch']; + $rejoined_epoch = $row['rejoined_epoch']; + $bridge_epoch = $row['bridge_epoch']; + $abandoned_epoch = $row['abandoned_epoch']; + $base_score = $row['base_score']; + $skill_score = $row['skill_score']; + $serving_agent = $row['serving_agent']; + $serving_system = $row['serving_system']; + $state = $row['state']; + + $joined_seconds = time() - $joined_epoch; + $joined_length_hour = floor($joined_seconds/3600); + $joined_length_min = floor($joined_seconds/60 - ($joined_length_hour * 60)); + $joined_length_sec = $joined_seconds - (($joined_length_hour * 3600) + ($joined_length_min * 60)); + $joined_length_min = sprintf("%02d", $joined_length_min); + $joined_length_sec = sprintf("%02d", $joined_length_sec); + $joined_length = $joined_length_hour.':'.$joined_length_min.':'.$joined_length_sec; + + //$system_seconds = time() - $system_epoch; + //$system_length_hour = floor($system_seconds/3600); + //$system_length_min = floor($system_seconds/60 - ($system_length_hour * 60)); + //$system_length_sec = $system_seconds - (($system_length_hour * 3600) + ($system_length_min * 60)); + //$system_length_min = sprintf("%02d", $system_length_min); + //$system_length_sec = sprintf("%02d", $system_length_sec); + //$system_length = $system_length_hour.':'.$system_length_min.':'.$system_length_sec; + + echo "\n"; + echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + if (if_group("admin") || if_group("superadmin")) { + echo ""; + } + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end if uuid_exists + } + echo "
TimeSystemNameNumberStatusOptions
".$joined_length."".$system_length."".$caller_name." ".$caller_number." ".$state.""; + echo " eavesdrop \n"; + echo "
\n"; + + //add vertical spacing + echo "
\n"; + echo "
\n"; + echo "
\n"; + + //get the agent list + + //show the title + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Agents
\n"; + echo " List all the agents.
\n"; + echo "
\n"; + echo "
\n"; + + //send the event socket command and get the response + //callcenter_config queue list tiers [queue_name] | + $switch_cmd = 'callcenter_config queue list tiers '.$queue_name; + $event_socket_str = trim(event_socket_request($fp, 'api '.$switch_cmd)); + $result = str_to_named_array($event_socket_str, '|'); + + //prepare the result for array_multisort + $x = 0; + foreach ($result as $row) { + $tier_result[$x]['level'] = $row['level']; + $tier_result[$x]['position'] = $row['position']; + $tier_result[$x]['agent'] = $row['agent']; + $tier_result[$x]['state'] = trim($row['state']); + $tier_result[$x]['queue'] = $row['queue']; + $x++; + } + + //sort the array //SORT_ASC, SORT_DESC, SORT_REGULAR, SORT_NUMERIC, SORT_STRING + array_multisort($tier_result, SORT_ASC); + + //send the event socket command and get the response + //callcenter_config queue list agents [queue_name] [status] | + $switch_cmd = 'callcenter_config queue list agents '.$queue_name; + $event_socket_str = trim(event_socket_request($fp, 'api '.$switch_cmd)); + $agent_result = str_to_named_array($event_socket_str, '|'); + + //list the agents + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + foreach ($tier_result as $tier_row) { + //$queue = $tier_row['queue']; + //$queue = str_replace('@'.$_SESSION['domain_name'], '', $queue); + $agent = $tier_row['agent']; + //$agent = str_replace('@'.$_SESSION['domain_name'], '', $agent); + $tier_state = $tier_row['state']; + $tier_level = $tier_row['level']; + $tier_position = $tier_row['position']; + + foreach ($agent_result as $agent_row) { + if ($tier_row['agent'] == $agent_row['name']) { + $name = $agent_row['name']; + $name = str_replace('@'.$_SESSION['domain_name'], '', $name); + //$system = $agent_row['system']; + //$uuid = $agent_row['uuid']; + //$type = $agent_row['type']; + $contact = $agent_row['contact']; + $status = $agent_row['status']; + $state = $agent_row['state']; + $max_no_answer = $agent_row['max_no_answer']; + $wrap_up_time = $agent_row['wrap_up_time']; + $reject_delay_time = $agent_row['reject_delay_time']; + $busy_delay_time = $agent_row['busy_delay_time']; + $last_bridge_start = $agent_row['last_bridge_start']; + $last_bridge_end = $agent_row['last_bridge_end']; + //$last_offered_call = $agent_row['last_offered_call']; + $last_status_change = $agent_row['last_status_change']; + $no_answer_count = $agent_row['no_answer_count']; + $calls_answered = $agent_row['calls_answered']; + $talk_time = $agent_row['talk_time']; + $ready_time = $agent_row['ready_time']; + + $last_offered_call_seconds = time() - $last_offered_call; + $last_offered_call_length_hour = floor($last_offered_call_seconds/3600); + $last_offered_call_length_min = floor($last_offered_call_seconds/60 - ($last_offered_call_length_hour * 60)); + $last_offered_call_length_sec = $last_offered_call_seconds - (($last_offered_call_length_hour * 3600) + ($last_offered_call_length_min * 60)); + $last_offered_call_length_min = sprintf("%02d", $last_offered_call_length_min); + $last_offered_call_length_sec = sprintf("%02d", $last_offered_call_length_sec); + $last_offered_call_length = $last_offered_call_length_hour.':'.$last_offered_call_length_min.':'.$last_offered_call_length_sec; + + $last_status_change_seconds = time() - $last_status_change; + $last_status_change_length_hour = floor($last_status_change_seconds/3600); + $last_status_change_length_min = floor($last_status_change_seconds/60 - ($last_status_change_length_hour * 60)); + $last_status_change_length_sec = $last_status_change_seconds - (($last_status_change_length_hour * 3600) + ($last_status_change_length_min * 60)); + $last_status_change_length_min = sprintf("%02d", $last_status_change_length_min); + $last_status_change_length_sec = sprintf("%02d", $last_status_change_length_sec); + $last_status_change_length = $last_status_change_length_hour.':'.$last_status_change_length_min.':'.$last_status_change_length_sec; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + } + echo "\n"; + + if ($c==0) { $c=1; } else { $c=0; } + } + echo "
NameContactStatusStateOffered CallStatus ChangeMissedAnsweredTier StateTier LevelTier Position
".$name."".$contact."".$status."".$state."".$last_offered_call_length."".$last_status_change_length."".$no_answer_count."".$calls_answered."".$tier_state."".$tier_level."".$tier_position."
\n"; + + //add vertical spacing + echo "
\n"; + echo "
\n"; + echo "
\n"; + } +?> \ No newline at end of file diff --git a/app/call_center_active/v_call_center_exec.php b/app/call_center_active/v_call_center_exec.php new file mode 100644 index 0000000000..8ee480ce68 --- /dev/null +++ b/app/call_center_active/v_call_center_exec.php @@ -0,0 +1,96 @@ +0) { + $switch_cmd = trim($_GET["cmd"]); + $action = trim(check_str($_GET["action"])); + $data = trim(check_str($_GET["data"])); + $username = trim(check_str($_GET["username"])); + } + +//authorized commands + if (stristr($switch_cmd, 'user_status') == true) { + //authorized; + } elseif (stristr($switch_cmd, 'callcenter_config') == true) { + //authorized; + } elseif (stristr($switch_cmd, 'eavesdrop') == true) { + //authorized; + } else { + //not found. this command is not authorized + echo "access denied"; + exit; + } + +//set the username + if (if_group("admin") || if_group("superadmin")) { + //use the username that was provided + } + else { + $username = $_SESSION['username']; + } + +//get to php variables + if (count($_GET)>0) { + if ($action == "user_status") { + $user_status = $data; + $sql = "update v_users set "; + $sql .= "user_status = '".trim($user_status, "'")."' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and username = '".$username."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + } + + //fs cmd + if (strlen($switch_cmd) > 0) { + //setup the event socket connection + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + //ensure the connection exists + if ($fp) { + //send the command + $switch_result = event_socket_request($fp, 'api '.$switch_cmd); + //set the user state + $cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting"; + $response = event_socket_request($fp, $cmd); + } + } + } + +?> diff --git a/app/call_center_active/v_call_center_queue.php b/app/call_center_active/v_call_center_queue.php new file mode 100644 index 0000000000..16374189b9 --- /dev/null +++ b/app/call_center_active/v_call_center_queue.php @@ -0,0 +1,177 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('call_center_active_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Call Center Queue List\n"; + echo "
\n"; + echo "List of queues for the call center.

\n"; + echo "
\n"; + + $sql = ""; + $sql .= " select * from v_call_center_queues "; + $sql .= " where domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $num_rows = count($result); + unset ($prep_statement, $result, $sql); + $rows_per_page = 100; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + $sql = ""; + $sql .= " select * from v_call_center_queues "; + $sql .= " where domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo th_order_by('queue_name', 'Queue Name', $order_by, $order); + echo th_order_by('queue_extension', 'Extension', $order_by, $order); + echo th_order_by('queue_strategy', 'Strategy', $order_by, $order); + //echo th_order_by('queue_moh_sound', 'Music On Hold', $order_by, $order); + //echo th_order_by('queue_record_template', 'Record Template', $order_by, $order); + //echo th_order_by('queue_time_base_score', 'Time Base Score', $order_by, $order); + //echo th_order_by('queue_max_wait_time', 'Max Wait Time', $order_by, $order); + //echo th_order_by('queue_max_wait_time_with_no_agent', 'Max Wait Time With No Agent', $order_by, $order); + //echo th_order_by('queue_tier_rules_apply', 'Tier Rules Apply', $order_by, $order); + //echo th_order_by('queue_tier_rule_wait_second', 'Tier Rule Wait Second', $order_by, $order); + //echo th_order_by('queue_tier_rule_no_agent_no_wait', 'Tier Rule No Agent No Wait', $order_by, $order); + //echo th_order_by('queue_discard_abandoned_after', 'Discard Abandoned After', $order_by, $order); + //echo th_order_by('queue_abandoned_resume_allowed', 'Abandoned Resume Allowed', $order_by, $order); + //echo th_order_by('queue_tier_rule_wait_multiply_level', 'Tier Rule Wait Multiply Level', $order_by, $order); + echo th_order_by('queue_description', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count == 0) { //no results + } + else { //received results + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + //echo " $v_link_label_add\n"; + echo "
".$row[queue_name]."".$row[queue_extension]."".$row[queue_strategy]."".$row[queue_moh_sound]."".$row[queue_record_template]."".$row[queue_time_base_score]."".$row[queue_max_wait_time]."".$row[queue_max_wait_time_with_no_agent]."".$row[queue_tier_rules_apply]."".$row[queue_tier_rule_wait_second]."".$row[queue_tier_rule_no_agent_no_wait]."".$row[queue_discard_abandoned_after]."".$row[queue_abandoned_resume_allowed]."".$row[queue_tier_rule_wait_multiply_level]."".$row[queue_description]." \n"; + echo " $v_link_label_edit\n"; + //echo " $v_link_label_delete\n"; + //echo " \n"; + //echo " \n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + //echo " $v_link_label_add\n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//show the footer + require_once "includes/footer.php"; + +?> diff --git a/app/calls/app_config.php b/app/calls/app_config.php new file mode 100644 index 0000000000..734b4451d0 --- /dev/null +++ b/app/calls/app_config.php @@ -0,0 +1,37 @@ + \ No newline at end of file diff --git a/app/calls/root.php b/app/calls/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/calls/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/calls/v_call_edit.php b/app/calls/v_call_edit.php new file mode 100644 index 0000000000..9bb526b7b4 --- /dev/null +++ b/app/calls/v_call_edit.php @@ -0,0 +1,751 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('follow_me') || permission_exists('call_forward') || permission_exists('do_not_disturb')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +function destination_select($select_name, $select_value, $select_default) { + if (strlen($select_value) == 0) { $select_value = $select_default; } + echo " \n"; +} + +//get the extension_uuid + $extension_uuid = $_REQUEST["id"]; + +//get the extension number + $sql = ""; + $sql .= "select * from v_extensions "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and extension_uuid = '$extension_uuid' "; + if (!(if_group("admin") || if_group("superadmin"))) { + if (count($_SESSION['user']['extension']) > 0) { + $sql .= "and ("; + $x = 0; + foreach($_SESSION['user']['extension'] as $row) { + if ($x > 0) { $sql .= "or "; } + $sql .= "extension = '".$row['user']."' "; + $x++; + } + $sql .= ")"; + } + else { + //hide any results when a user has not been assigned an extension + $sql .= "and extension = 'disabled' "; + } + } + $sql .= "and enabled = 'true' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + if (count($result)== 0) { + echo "access denied"; + exit; + } + else { + foreach ($result as &$row) { + $extension = $row["extension"]; + $effective_caller_id_name = $row["effective_caller_id_name"]; + $effective_caller_id_number = $row["effective_caller_id_number"]; + $outbound_caller_id_name = $row["outbound_caller_id_name"]; + $outbound_caller_id_number = $row["outbound_caller_id_number"]; + $description = $row["description"]; + break; //limit to 1 row + } + } + unset ($prep_statement); + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + //get http post variables and set them to php variables + if (count($_POST)>0) { + $call_forward_enabled = check_str($_POST["call_forward_enabled"]); + $call_forward_number = check_str($_POST["call_forward_number"]); + $follow_me_enabled = check_str($_POST["follow_me_enabled"]); + $follow_me_type = check_str($_POST["follow_me_type"]); + $destination_data_1 = check_str($_POST["destination_data_1"]); + $destination_timeout_1 = check_str($_POST["destination_timeout_1"]); + $destination_data_2 = check_str($_POST["destination_data_2"]); + $destination_timeout_2 = check_str($_POST["destination_timeout_2"]); + $destination_data_3 = check_str($_POST["destination_data_3"]); + $destination_timeout_3 = check_str($_POST["destination_timeout_3"]); + $destination_data_4 = check_str($_POST["destination_data_4"]); + $destination_timeout_4 = check_str($_POST["destination_timeout_4"]); + $destination_data_5 = check_str($_POST["destination_data_5"]); + $destination_timeout_5 = check_str($_POST["destination_timeout_5"]); + $dnd_enabled = check_str($_POST["dnd_enabled"]); + $hunt_group_call_prompt = check_str($_POST["hunt_group_call_prompt"]); + + if (strlen($follow_me_type) == 0) { $follow_me_type = "follow_me_sequence"; } + + if (strlen($call_forward_number) > 0) { + $call_forward_number = preg_replace("~[^0-9]~", "",$call_forward_number); + } + if (strlen($destination_data_1) > 0) { + $destination_data_1 = preg_replace("~[^0-9]~", "",$destination_data_1); + } + if (strlen($destination_data_2) > 0) { + $destination_data_2 = preg_replace("~[^0-9]~", "",$destination_data_2); + } + if (strlen($destination_data_3) > 0) { + $destination_data_3 = preg_replace("~[^0-9]~", "",$destination_data_3); + } + if (strlen($destination_data_4) > 0) { + $destination_data_4 = preg_replace("~[^0-9]~", "",$destination_data_4); + } + if (strlen($destination_data_5) > 0) { + $destination_data_5 = preg_replace("~[^0-9]~", "",$destination_data_5); + } + + //set the default + if (strlen($hunt_group_call_prompt) == 0) { + $hunt_group_call_prompt = 'false'; + } + + //destination_1 + if (strlen($destination_data_1) > 0) { + if (extension_exists($destination_data_1)) { + $destination_type_1 = 'extension'; + } + else { + $destination_type_1 = 'sip uri'; + } + } + //destination_2 + if (extension_exists($destination_data_2)) { + $destination_type_2 = 'extension'; + } + else { + $destination_type_2 = 'sip uri'; + } + //destination_3 + if (extension_exists($destination_data_3)) { + $destination_type_3 = 'extension'; + } + else { + $destination_type_3 = 'sip uri'; + } + //destination_4 + if (extension_exists($destination_data_4)) { + $destination_type_4 = 'extension'; + } + else { + $destination_type_4 = 'sip uri'; + } + //destination_5 + if (extension_exists($destination_data_5)) { + $destination_type_5 = 'extension'; + } + else { + $destination_type_5 = 'sip uri'; + } + } + + //check for all required data + //if (strlen($call_forward_enabled) == 0) { $msg .= "Please provide: Call Forward
\n"; } + //if (strlen($call_forward_number) == 0) { $msg .= "Please provide: Number
\n"; } + //if (strlen($follow_me_enabled) == 0) { $msg .= "Please provide: Follow Me
\n"; } + //if (strlen($destination_data_1) == 0) { $msg .= "Please provide: 1st Number
\n"; } + //if (strlen($destination_timeout_1) == 0) { $msg .= "Please provide: sec
\n"; } + //if (strlen($destination_data_2) == 0) { $msg .= "Please provide: 2nd Number
\n"; } + //if (strlen($destination_timeout_2) == 0) { $msg .= "Please provide: sec
\n"; } + //if (strlen($destination_data_3) == 0) { $msg .= "Please provide: 3rd Number
\n"; } + //if (strlen($destination_timeout_3) == 0) { $msg .= "Please provide: sec
\n"; } + //if (strlen($destination_data_4) == 0) { $msg .= "Please provide: 4th Number
\n"; } + //if (strlen($destination_timeout_4) == 0) { $msg .= "Please provide: sec
\n"; } + //if (strlen($destination_data_5) == 0) { $msg .= "Please provide: 5th Number
\n"; } + //if (strlen($destination_timeout_5) == 0) { $msg .= "Please provide: sec
\n"; } + //if (strlen($destination_data_6) == 0) { $msg .= "Please provide: 6th Number
\n"; } + //if (strlen($destination_timeout_6) == 0) { $msg .= "Please provide: sec
\n"; } + //if (strlen($destination_data_7) == 0) { $msg .= "Please provide: 7th Number
\n"; } + //if (strlen($destination_timeout_7) == 0) { $msg .= "Please provide: sec
\n"; } + //if (strlen($hunt_group_call_prompt) == 0) { $msg .= "Please provide: call prompt
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //set the default action to add + $call_forward_action = "add"; + $dnd_action = "add"; + $follow_me_action = "add"; + + //get the hunt group timeout + //add the destination timeouts together to create the hunt group timeout + if ($follow_me_type == "follow_me_sequence") { + if (strlen($destination_data_1) > 0) { + $hunt_group_timeout = $destination_timeout_1; + } + if (strlen($destination_data_2) > 0) { + $hunt_group_timeout = $hunt_group_timeout + $destination_timeout_2; + } + if (strlen($destination_data_3) > 0) { + $hunt_group_timeout = $hunt_group_timeout + $destination_timeout_3; + } + if (strlen($destination_data_4) > 0) { + $hunt_group_timeout = $hunt_group_timeout + $destination_timeout_4; + } + if (strlen($destination_data_5) > 0) { + $hunt_group_timeout = $hunt_group_timeout + $destination_timeout_5; + } + } + //find the highest timeout and set that as the hunt_group_timeout + if ($follow_me_type == "follow_me_simultaneous") { + if (strlen($destination_data_1) > 0) { + $hunt_group_timeout = $destination_timeout_1; + } + if (strlen($destination_data_2) > 0 && $hunt_group_timeout < $destination_timeout_2) { + $hunt_group_timeout = $destination_timeout_2; + } + if (strlen($destination_data_3) > 0 && $hunt_group_timeout < $destination_timeout_3) { + $hunt_group_timeout = $destination_timeout_3; + } + if (strlen($destination_data_4) > 0 && $hunt_group_timeout < $destination_timeout_4) { + $hunt_group_timeout = $destination_timeout_4; + } + if (strlen($destination_data_5) > 0 && $hunt_group_timeout < $destination_timeout_5) { + $hunt_group_timeout = $destination_timeout_5; + } + } + + //hunt_group information used to determine if this is an add or an update + $sql = "select * from v_hunt_groups "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and hunt_group_extension = '$extension' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + if ($row["hunt_group_type"] == 'call_forward') { + $call_forward_action = "update"; + $call_forward_uuid = $row["hunt_group_uuid"]; + } + if ($row["hunt_group_type"] == 'follow_me_sequence') { + $follow_me_action = "update"; + $follow_me_uuid = $row["hunt_group_uuid"]; + } + if ($row["hunt_group_type"] == 'follow_me_simultaneous') { + $follow_me_action = "update"; + $follow_me_uuid = $row["hunt_group_uuid"]; + } + if ($row["hunt_group_type"] == 'dnd') { + $dnd_action = "update"; + $dnd_uuid = $row["hunt_group_uuid"]; + } + } + unset ($prep_statement); + + //include the classes + include "includes/classes/call_forward.php"; + include "includes/classes/follow_me.php"; + include "includes/classes/do_not_disturb.php"; + + //call forward config + if (permission_exists('call_forward')) { + $call_forward = new call_forward; + $call_forward->domain_uuid = $_SESSION['domain_uuid']; + $call_forward->db_type = $db_type; + $call_forward->extension = $extension; + $call_forward->call_forward_number = $call_forward_number; + $call_forward->call_forward_enabled = $call_forward_enabled; + if ($call_forward_enabled == "true") { + if ($call_forward_action == "add") { + $call_forward->call_forward_uuid = uuid(); + $call_forward->call_forward_add(); + } + } + if ($call_forward_action == "update") { + $call_forward->call_forward_uuid = $call_forward_uuid; + $call_forward->call_forward_update(); + } + unset($call_forward); + } + + //follow me config + if (permission_exists('follow_me')) { + $follow_me = new follow_me; + $follow_me->domain_uuid = $_SESSION['domain_uuid']; + $follow_me->db_type = $db_type; + $follow_me->extension = $extension; + $follow_me->follow_me_enabled = $follow_me_enabled; + $follow_me->follow_me_type = $follow_me_type; + $follow_me->hunt_group_call_prompt = $hunt_group_call_prompt; + $follow_me->hunt_group_timeout = $hunt_group_timeout; + + $follow_me->destination_data_1 = $destination_data_1; + $follow_me->destination_type_1 = $destination_type_1; + $follow_me->destination_timeout_1 = $destination_timeout_1; + + $follow_me->destination_data_2 = $destination_data_2; + $follow_me->destination_type_2 = $destination_type_2; + $follow_me->destination_timeout_2 = $destination_timeout_2; + + $follow_me->destination_data_3 = $destination_data_3; + $follow_me->destination_type_3 = $destination_type_3; + $follow_me->destination_timeout_3 = $destination_timeout_3; + + $follow_me->destination_data_4 = $destination_data_4; + $follow_me->destination_type_4 = $destination_type_4; + $follow_me->destination_timeout_4 = $destination_timeout_4; + + $follow_me->destination_data_5 = $destination_data_5; + $follow_me->destination_type_5 = $destination_type_5; + $follow_me->destination_timeout_5 = $destination_timeout_5; + + if ($follow_me_enabled == "true") { + if ($follow_me_action == "add") { + $follow_me->follow_me_uuid = uuid(); + $follow_me->follow_me_add(); + } + } + if ($follow_me_action == "update") { + $follow_me->follow_me_uuid = $follow_me_uuid; + $follow_me->follow_me_update(); + } + unset($follow_me); + } + + //do not disturb (dnd) config + if (permission_exists('do_not_disturb')) { + $dnd = new do_not_disturb; + $dnd->domain_uuid = $_SESSION['domain_uuid']; + $dnd->domain_name = $_SESSION['domain_name']; + $dnd->extension = $extension; + $dnd->dnd_enabled = $dnd_enabled; + if ($dnd_enabled == "true") { + if ($dnd_action == "add") { + $dnd->dnd_uuid = uuid(); + $dnd->dnd_add(); + } + } + if ($dnd_action == "update") { + $dnd->dnd_uuid = $dnd_uuid; + $dnd->dnd_update(); + } + $dnd->dnd_status(); + unset($dnd); + } + + //synchronize the xml config + save_hunt_group_xml(); + + //synchronize the xml config + save_dialplan_xml(); + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete
\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//show the header + require_once "includes/header.php"; + +//pre-populate the form + $sql = "select * from v_hunt_groups "; + $sql .= "where hunt_group_extension = '$extension' "; + $sql .= "and domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $hunt_group_uuid = $row["hunt_group_uuid"]; + $hunt_group_extension = $row["hunt_group_extension"]; + $huntgroup_name = $row["hunt_group_name"]; + $hunt_group_type = $row["hunt_group_type"]; + $hunt_group_context = $row["hunt_group_context"]; + $hunt_group_timeout = $row["hunt_group_timeout"]; + $hunt_group_timeout_destination = $row["hunt_group_timeout_destination"]; + $hunt_group_timeout_type = $row["hunt_group_timeout_type"]; + $hunt_group_ring_back = $row["hunt_group_ringback"]; + $hunt_group_cid_name_prefix = $row["hunt_group_cid_name_prefix"]; + $hunt_group_pin = $row["hunt_group_pin"]; + $hunt_group_call_prompt = $row["hunt_group_call_prompt"]; + $huntgroup_caller_announce = $row["hunt_group_caller_announce"]; + $hunt_group_user_list = $row["hunt_group_user_list"]; + $hunt_group_enabled = $row["hunt_group_enabled"]; + $hunt_group_description = $row["hunt_group_description"]; + + if ($row["hunt_group_type"] == 'call_forward') { + $call_forward_enabled = $hunt_group_enabled; + } + if ($row["hunt_group_type"] == 'follow_me_simultaneous') { + $follow_me_enabled = $hunt_group_enabled; + $follow_me_type = 'follow_me_simultaneous'; + } + if ($row["hunt_group_type"] == 'follow_me_sequence') { + $follow_me_enabled = $hunt_group_enabled; + $follow_me_type = 'follow_me_sequence'; + } + if ($row["hunt_group_type"] == 'dnd') { + $dnd_enabled = $hunt_group_enabled; + } + + if ($row["hunt_group_type"] == 'call_forward' || $row["hunt_group_type"] == 'follow_me_sequence' || $row["hunt_group_type"] == 'follow_me_simultaneous') { + $sql = "select * from v_hunt_group_destinations "; + $sql .= "where hunt_group_uuid = '$hunt_group_uuid' "; + $prep_statement_2 = $db->prepare(check_sql($sql)); + $prep_statement_2->execute(); + $result2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED); + $x=1; + foreach ($result2 as &$row2) { + if ($row["hunt_group_type"] == 'call_forward') { + if (strlen($row2["destination_data"]) > 0) { + $call_forward_number = $row2["destination_data"]; + } + } + if ($row["hunt_group_type"] == 'follow_me_sequence' || $row["hunt_group_type"] == 'follow_me_simultaneous') { + if ($x == 1) { + $destination_data_1 = $row2["destination_data"]; + $destination_timeout_1 = $row2["destination_timeout"]; + } + if ($x == 2) { + $destination_data_2 = $row2["destination_data"]; + $destination_timeout_2 = $row2["destination_timeout"]; + } + if ($x == 3) { + $destination_data_3 = $row2["destination_data"]; + $destination_timeout_3 = $row2["destination_timeout"]; + } + if ($x == 4) { + $destination_data_4 = $row2["destination_data"]; + $destination_timeout_4 = $row2["destination_timeout"]; + } + if ($x == 5) { + $destination_data_5 = $row2["destination_data"]; + $destination_timeout_5 = $row2["destination_timeout"]; + } + $x++; + } + } + unset ($prep_statement_2); + } + } + unset ($prep_statement); + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " "; + echo "
\n"; + echo " Calls\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo " Directs incoming calls for extension $extension.

\n"; + echo "
\n"; + echo " Call Forward:\n"; + echo "\n"; + $on_click = "document.getElementById('follow_me_enabled').checked=true;"; + $on_click .= "document.getElementById('follow_me_disabled').checked=true;"; + $on_click .= "document.getElementById('dnd_enabled').checked=false;"; + $on_click .= "document.getElementById('dnd_disabled').checked=true;"; + if ($call_forward_enabled == "true") { + echo " Enabled \n"; + } + else { + echo " Enable \n"; + } + if ($call_forward_enabled == "false" || $call_forward_enabled == "") { + echo " Disabled \n"; + } + else { + echo " Disable \n"; + } + unset($on_click); + echo "
\n"; + echo "
\n"; + //echo "Enable or disable call forward.\n"; + echo "
\n"; + echo " Number:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + //echo "Enter the call forward number.\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo " Follow Me:\n"; + echo "\n"; + $on_click = "document.getElementById('call_forward_enabled').checked=true;"; + $on_click .= "document.getElementById('call_forward_disabled').checked=true;"; + $on_click .= "document.getElementById('dnd_enabled').checked=false;"; + $on_click .= "document.getElementById('dnd_disabled').checked=true;"; + if ($follow_me_enabled == "true") { + echo " Enabled \n"; + } + else { + echo " Enable \n"; + } + if ($follow_me_enabled == "false" || $follow_me_enabled == "") { + echo " Disabled \n"; + } + else { + echo " Disable \n"; + } + unset($on_click); + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo " Ring 1st Number:\n"; + echo "\n"; + echo " \n"; + echo " Sec \n"; + destination_select('destination_timeout_1', $destination_timeout_1, '10'); + //echo "
\n"; + //echo "This number rings first.\n"; + echo "
\n"; + echo " Ring 2nd Number:\n"; + echo "\n"; + echo " \n"; + echo " Sec \n"; + destination_select('destination_timeout_2', $destination_timeout_2, '30'); + //echo "
\n"; + //echo "Enter the destination number.\n"; + echo "
\n"; + echo " Ring 3rd Number:\n"; + echo "\n"; + echo " \n"; + echo " Sec \n"; + destination_select('destination_timeout_3', $destination_timeout_3, '30'); + //echo "
\n"; + //echo "Enter the destination number.\n"; + echo "
\n"; + echo " Ring 4th Number:\n"; + echo "\n"; + echo " \n"; + echo " Sec \n"; + destination_select('destination_timeout_4', $destination_timeout_4, '30'); + //echo "
\n"; + //echo "Enter the destination number.\n"; + echo "
\n"; + echo " Ring 5th Number:\n"; + echo "\n"; + echo " \n"; + echo " Sec \n"; + destination_select('destination_timeout_5', $destination_timeout_5, '30'); + //echo "
\n"; + //echo "Enter the destination number.\n"; + echo "
\n"; + echo " Ring Order:\n"; + echo "\n"; + echo "\n"; + //echo "
\n"; + //echo "Enter the destination number.\n"; + echo "
\n"; + echo " Prompt to accept the call:\n"; + echo "\n"; + echo "\n"; + //echo "
\n"; + //echo "Enter the destination number.\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo " Do Not Disturb:\n"; + echo "\n"; + $on_click = "document.getElementById('call_forward_enabled').checked=true;"; + $on_click .= "document.getElementById('call_forward_disabled').checked=true;"; + $on_click .= "document.getElementById('follow_me_enabled').checked=true;"; + $on_click .= "document.getElementById('follow_me_disabled').checked=true;"; + if ($dnd_enabled == "true") { + echo " Enabled \n"; + } + else { + echo " Enable \n"; + } + if ($dnd_enabled == "false" || $dnd_enabled == "") { + echo " Disabled \n"; + } + else { + echo " Disable \n"; + } + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo "
"; + + echo "
"; + echo "
"; + +require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/calls/v_calls.php b/app/calls/v_calls.php new file mode 100644 index 0000000000..c4a329b6bf --- /dev/null +++ b/app/calls/v_calls.php @@ -0,0 +1,196 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('follow_me') || permission_exists('call_forward') || permission_exists('do_not_disturb')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + + echo "
"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "
"; + + if ($is_included != "true") { + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Calls
\n"; + echo " Use the links to configure call forward follow me, or do no disturb.\n"; + echo " The following list the extensions that have been assigned to this user account. \n"; + echo "
\n"; + echo "
"; + } + + $sql = ""; + $sql .= " select * from v_extensions "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and enabled = 'true' "; + if (!(if_group("admin") || if_group("superadmin"))) { + if (count($_SESSION['user']['extension']) > 0) { + $sql .= "and ("; + $x = 0; + foreach($_SESSION['user']['extension'] as $row) { + if ($x > 0) { $sql .= "or "; } + $sql .= "extension = '".$row['user']."' "; + $x++; + } + $sql .= ")"; + } + else { + //used to hide any results when a user has not been assigned an extension + $sql .= "and extension = 'disabled' "; + } + } + if (strlen($order_by)> 0) { + $sql .= "order by $order_by $order "; + } + else { + $sql .= "order by extension asc "; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $num_rows = count($result); + unset ($prep_statement, $result, $sql); + + $rows_per_page = 150; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + $sql = ""; + $sql .= " select * from v_extensions "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and enabled = 'true' "; + if (!(if_group("admin") || if_group("superadmin"))) { + if (count($_SESSION['user']['extension']) > 0) { + $sql .= "and ("; + $x = 0; + foreach($_SESSION['user']['extension'] as $row) { + if ($x > 0) { $sql .= "or "; } + $sql .= "extension = '".$row['user']."' "; + $x++; + } + $sql .= ")"; + } + else { + //hide any results when a user has not been assigned an extension + $sql .= "and extension = 'disabled' "; + } + } + if (strlen($order_by)> 0) { + $sql .= "order by $order_by $order "; + } + else { + $sql .= "order by extension asc "; + } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if ($result_count == 0) { + //no results + } + else { //received results + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + if (strlen($paging_controls) > 0) { + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "
ExtensionToolsDescription
".$row[extension]."\n"; + if (permission_exists('call_forward')) { + echo " Call Forward \n"; + echo "   \n"; + } + if (permission_exists('follow_me')) { + echo " Follow Me \n"; + echo "   \n"; + } + if (permission_exists('do_not_disturb')) { + echo " Do Not Disturb \n"; + } + echo " ".$row[description]." 
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls
\n"; + echo "
"; + + echo "
"; + echo "
"; + echo "
"; + echo "
"; + echo "
"; + + if ($is_included != "true") { + require_once "includes/footer.php"; + } + + +?> diff --git a/app/calls_active/app_config.php b/app/calls_active/app_config.php new file mode 100644 index 0000000000..03a9e63696 --- /dev/null +++ b/app/calls_active/app_config.php @@ -0,0 +1,75 @@ + \ No newline at end of file diff --git a/app/calls_active/root.php b/app/calls_active/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/calls_active/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/calls_active/v_calls_active.php b/app/calls_active/v_calls_active.php new file mode 100644 index 0000000000..0c6f988269 --- /dev/null +++ b/app/calls_active/v_calls_active.php @@ -0,0 +1,165 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('calls_active_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$conference_name = trim($_REQUEST["c"]); +$tmp_conference_name = str_replace("_", " ", $conference_name); + +require_once "includes/header.php"; +?> + +"; + +echo "\n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
Active Calls
\n"; +echo " Use this to monitor and interact with the active calls.\n"; +echo "
\n"; + +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
\n"; +echo "
\n"; +echo "
\n"; +echo "
\n"; +echo "
\n"; +echo "
\n"; + +echo "
\n"; + +echo "\n"; +echo " \n"; +echo " "; +echo " "; +echo "
\n"; +echo "
\n"; +echo "
".date('Y-m-d-s')."
\n"; +echo "
"; + +echo "\n"; + +echo "\n"; + +require_once "includes/footer.php"; +?> diff --git a/app/calls_active/v_calls_active_assigned_extensions_inc.php b/app/calls_active/v_calls_active_assigned_extensions_inc.php new file mode 100644 index 0000000000..05ed7522ad --- /dev/null +++ b/app/calls_active/v_calls_active_assigned_extensions_inc.php @@ -0,0 +1,231 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('extensions_active_assigned_view')) { + + //http get and set variables + if (strlen($_GET['url']) > 0) { + $url = $_GET['url']; + } + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + if ($_SESSION['user_status_display'] == "false") { + //hide the user_status when it is set to false + } + else { + echo "\n"; + } + echo "\n"; + //echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + foreach ($_SESSION['extension_array'] as $row) { + $domain_uuid = $row['domain_uuid']; + $extension = $row['extension']; + $enabled = $row['enabled']; + $effective_caller_id_name = $row['effective_caller_id_name']; + + foreach ($_SESSION['user']['extension'] as &$user_row) { + if ($extension == $user_row['user']) { + $found_extension = false; + $x = 1; + + foreach ($channels_array as $row) { + //set the php variables + foreach ($row as $key => $value) { + $$key = $value; + } + //find the matching extensions + if ($number == $extension) { + //set the found extension to true + $found_extension = true; + break; + } + } //end foreach + + if ($number == $extension) { + if ($application == "conference") { + $alt_color = "background-image: url('".PROJECT_PATH."/images/background_cell_active.gif"; + } + switch ($application) { + case "conference": + $style_alternate = "style=\"color: #444444; background-image: url('".PROJECT_PATH."/images/background_cell_conference.gif');\""; + break; + case "fifo": + $style_alternate = "style=\"color: #444444; background-image: url('".PROJECT_PATH."/images/background_cell_fifo.gif');\""; + break; + case "valet_park": + $style_alternate = "style=\"color: #444444; background-image: url('".PROJECT_PATH."/images/background_cell_fifo.gif');\""; + break; + default: + $style_alternate = "style=\"color: #444444; background-image: url('".PROJECT_PATH."/images/background_cell_active.gif');\""; + } + echo "\n"; + echo "\n"; + if ($_SESSION['user_status_display'] == "false") { + //hide the user_status when it is set to false + } + else { + echo "\n"; + } + echo "\n"; + + if (strlen($url) == 0) { + $url = PROJECT_PATH."/app/contacts/contacts.php?search_all={cid_num}"; + } + $url = str_replace ("{cid_num}", $cid_num, $url); + $url = str_replace ("{cid_name}", $cid_name, $url); + echo "\n"; + echo "\n"; + + //get the active uuid list + if (strlen($uuid) > 1) { + if (strlen($uuid_1) == 0) { + $uuid_1 = $uuid; + //$direction_1 = $direction; + $cid_name_1 = $cid_name; + $cid_num_1 = $cid_num; + } + if (strlen($uuid_1) > 0 && $uuid != $uuid_1) { + $uuid_2 = $uuid; + //$direction_2 = $direction; + $cid_name_2 = $cid_name; + $cid_num_2 = $cid_num; + } + } + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + else { + $style_alternate = "style=\"color: #444444; background-image: url('".PROJECT_PATH."/images/background_cell_light.gif');\""; + echo "\n"; + echo "\n"; + if ($_SESSION['user_status_display'] == "false") { + //hide the user_status when it is set to false + } + else { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + if ($c==0) { $c=1; } else { $c=0; } + } //end if + } //end foreach + } + echo "
ExtStatusTimeDirectionProfileCID NameCID NumberDestApplicationSecureNameOptions
$extension".$user_array[$extension]['user_status']." ".$call_length."".$cid_name."".$cid_num."\n"; + if ($application == "valet_park") { + echo $valet_array[trim($uuid)]['extension']."\n"; + } + else { + echo $dest." \n"; + } + echo "\n"; + if ($application == "fifo") { + echo "queue  \n"; + } + else { + echo $application." \n"; + } + echo "\n"; + echo "".$secure." \n"; + echo "\n"; + echo "".$effective_caller_id_name." \n"; + echo "\n"; + //transfer + echo " Transfer To';\" onclick=\"send_cmd('v_calls_exec.php?cmd='+get_transfer_cmd(escape('$uuid')));\">transfer \n"; + //park + echo " park \n"; + //hangup + echo " hangup \n"; + //record start/stop + $tmp_file = $_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d")."/".$uuid.".wav"; + if (file_exists($tmp_file)) { + //stop + echo " stop record \n"; + } + else { + //start + echo " start record \n"; + } + echo "  "; + echo "
$extension".$user_array[$extension]['user_status']."    \n"; + echo "  "; + echo "\n"; + echo "  "; + echo "\n"; + echo "  "; + echo "\n"; + echo "  "; + echo "\n"; + echo "  "; + echo "
\n"; + + echo "
\n"; + + echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; +} + +?> \ No newline at end of file diff --git a/app/calls_active/v_calls_active_extensions.php b/app/calls_active/v_calls_active_extensions.php new file mode 100644 index 0000000000..a2fa501fda --- /dev/null +++ b/app/calls_active/v_calls_active_extensions.php @@ -0,0 +1,337 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('extensions_active_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//http get and set variables + $event_type = $_GET['event_type']; //open_window //iframe + if ($event_type=="iframe") { + $iframe_width = $_GET['iframe_width']; + $iframe_height = $_GET['iframe_height']; + $iframe_postition = $_GET['iframe_postition']; + if (strlen($iframe_postition) > 0) { $iframe_postition = 'right'; } + if (strlen($iframe_width) > 0) { $iframe_width = '25%'; } + if (strlen($iframe_height) > 0) { $iframe_height = '100%'; } + } + if (strlen($_GET['url']) > 0) { + $url = $_GET['url']; + } + if (strlen($_GET['rows']) > 0) { + $rows = $_GET['rows']; + } + else { + $rows = 0; + } + +$conference_name = trim($_REQUEST["c"]); +$tmp_conference_name = str_replace("_", " ", $conference_name); + +require_once "includes/header.php"; +?> + +"; + +echo "\n"; +echo " \n"; +echo " \n"; + +//get the user status when the page loads + $sql = ""; + $sql .= "select * from v_users "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and username = '".$_SESSION['username']."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $user_status = $row["user_status"]; + break; //limit to 1 row + } + +if ($_SESSION['user_status_display'] == "false") { + //hide the user_status when it is set to false +} +else { + echo " \n"; + echo " \n"; +} + +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
\n"; +echo " Active Extensions
\n"; +echo "
\n"; + echo "  "; + echo " \n"; + //status list + echo "  "; + echo " Status \n"; + $cmd = "'v_calls_exec.php?action=user_status&data='+this.value+'"; + $cmd .= "&cmd=callcenter_config+agent+set+status+".$_SESSION['username']."@".$_SESSION['domain_name']."+'+this.value"; + echo " \n"; + echo " \n"; +echo "  "; +echo " Transfer To\n"; +echo " \n"; +echo "
\n"; +echo " Use this to view all extensions and monitor and interact with active calls.\n"; +echo "
\n"; + +echo "
\n"; +echo "
\n"; + +echo "\n"; +echo " \n"; +if ($event_type=="iframe") { + echo " \n"; + +if ($event_type=="iframe") { + echo "\n"; + echo "\n"; +} + +echo " "; +echo "
\n"; +} +else { + echo " \n"; +} +echo "
\n"; +echo "
".date('Y-m-d-s')."
\n"; +echo "
\n"; + echo " \n"; + echo "
"; +echo "\n"; + +echo "\n"; + +require_once "includes/footer.php"; +?> diff --git a/app/calls_active/v_calls_active_extensions_inc.php b/app/calls_active/v_calls_active_extensions_inc.php new file mode 100644 index 0000000000..40ed9a7b5a --- /dev/null +++ b/app/calls_active/v_calls_active_extensions_inc.php @@ -0,0 +1,561 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('extensions_active_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//set debug to true or false + $debug = false; + +//http get and set variables + if (strlen($_GET['url']) > 0) { + $url = $_GET['url']; + } + if (strlen($_GET['rows']) == 0) { + $_GET['rows'] = 0; + } + +//define variables + $c = 0; + $row_style["0"] = "row_style1"; + $row_style["1"] = "row_style1"; + +//get the user status + $sql = ""; + $sql .= "select e.extension, u.username, u.user_status "; + $sql .= "from v_users as u, v_extensions as e "; + $sql .= "where e.domain_uuid = '$domain_uuid' "; + $sql .= "and u.domain_uuid = '$domain_uuid' "; + if (!(if_group("admin") || if_group("superadmin"))) { + if (count($_SESSION['user']['extension']) > 0) { + $sql .= "and ("; + $x = 0; + foreach($_SESSION['user']['extension'] as $row) { + if ($x > 0) { $sql .= "or "; } + $sql .= "e.extension = '".$row['user']."' "; + $x++; + } + $sql .= ")"; + } + else { + //hide any results when a user has not been assigned an extension + $sql .= "and extension = 'disabled' "; + } + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $x = 0; + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + if (strlen($row["user_status"]) > 0) { + $user_array[$row["extension"]]['username'] = $row["username"]; + $user_array[$row["extension"]]['user_status'] = $row["user_status"]; + $username_array[$row["username"]]['user_status'] = $row["user_status"]; + if ($row["username"] == $_SESSION["username"]) { + $user_status = $row["user_status"]; + } + } + $x++; + } + unset ($prep_statement, $x); + +//create the event socket connection + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + +//get information over event socket + if (!$fp) { + $msg = "
Connection to Event Socket failed.
"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Message
$msg
\n"; + echo "
\n"; + } + else { + //get the agent list from event socket + $switch_cmd = 'callcenter_config agent list'; + $event_socket_str = trim(event_socket_request($fp, 'api '.$switch_cmd)); + $agent_array = csv_to_named_array($event_socket_str, '|'); + //set the status on the user_array by using the extension as the key + foreach ($agent_array as $row) { + if (count($_SESSION['domains']) == 1) { + //get the extension status from the call center agent list + preg_match('/user\/(\d{2,7})/', $row['contact'], $matches); + $extension = $matches[1]; + $user_array[$extension]['username'] = $tmp[0]; + if ($user_array[$extension]['user_status'] != "Do Not Disturb") { + $user_array[$extension]['user_status'] = $row['status']; + } + } else { + $tmp = explode('@',$row["name"]); + if ($tmp[1] == $_SESSION['domain_name']) { + //get the extension status from the call center agent list + preg_match('/user\/(\d{2,7})/', $row['contact'], $matches); + $extension = $matches[1]; + $user_array[$extension]['username'] = $tmp[0]; + if ($user_array[$extension]['user_status'] != "Do Not Disturb") { + $user_array[$extension]['user_status'] = $row['status']; + } + } + } + } + + //send the api command over event socket + $switch_cmd = 'valet_info'; + $valet_xml_str = trim(event_socket_request($fp, 'api '.$switch_cmd)); + + //parse the xml + try { + $valet_xml = new SimpleXMLElement($valet_xml_str); + } + catch(Exception $e) { + //echo $e->getMessage(); + } + $valet_xml = new SimpleXMLElement($valet_xml_str); + foreach ($valet_xml as $row) { + $valet_name = (string) $row->attributes()->name; + foreach ($row->extension as $row2) { + $extension = (string) $row2; + $uuid = (string) $row2->attributes()->uuid; + $uuid = trim($uuid); + $valet_array[$uuid]['name'] = $valet_name; + $valet_array[$uuid]['extension'] = $extension; + } + } + + //send the event socket command + $switch_cmd = 'show channels as xml'; + $xml_str = trim(event_socket_request($fp, 'api '.$switch_cmd)); + + //parse the xml + try { + $xml = new SimpleXMLElement($xml_str); + } + catch(Exception $e) { + //echo $e->getMessage(); + } + + //active channels array + $channels_array = ''; + $x = 1; + foreach ($xml as $row) { + //set the original array id + $channels_array[$x]['x'] = $x; + + //get the values from xml and set them to the channel array + $channels_array[$x]['uuid'] = $row->uuid; + $channels_array[$x]['direction'] = $row->direction; + $channels_array[$x]['created'] = $row->created; + $channels_array[$x]['created_epoch'] = $row->created_epoch; + $channels_array[$x]['name'] = $row->name; + $channels_array[$x]['state'] = $row->state; + $channels_array[$x]['cid_name'] = $row->cid_name; + $channels_array[$x]['cid_num'] = $row->cid_num; + $channels_array[$x]['ip_addr'] = $row->ip_addr; + $channels_array[$x]['dest'] = $row->dest; + $channels_array[$x]['application'] = $row->application; + $channels_array[$x]['application_data'] = $row->application_data; + $channels_array[$x]['dialplan'] = $row->dialplan; + $channels_array[$x]['context'] = $row->context; + $channels_array[$x]['read_codec'] = $row->read_codec; + $channels_array[$x]['read_rate'] = $row->read_rate; + $channels_array[$x]['read_bit_rate'] = $row->read_bit_rate; + $channels_array[$x]['write_codec'] = $row->write_codec; + $channels_array[$x]['write_rate'] = $row->write_rate; + $channels_array[$x]['write_bit_rate'] = $row->write_bit_rate; + $channels_array[$x]['secure'] = $row->secure; + $channels_array[$x]['hostname'] = $row->hostname; + $channels_array[$x]['presence_id'] = $row->presence_id; + $channels_array[$x]['presence_data'] = $row->presence_data; + $channels_array[$x]['callstate'] = $row->callstate; + $channels_array[$x]['callee_name'] = $row->callee_name; + $channels_array[$x]['callee_num'] = $row->callee_num; + $channels_array[$x]['callee_direction'] = $row->callee_direction; + $channels_array[$x]['call_uuid'] = $row->call_uuid; + + //remove other domains + if (count($_SESSION["domains"]) > 1) { + //unset domains that are not related to this tenant + $temp_array = explode("@", $channels_array[$x]['presence_id']); + if ($temp_array[1] != $_SESSION['domain_name']) { + unset($channels_array[$x]); + } + } + + //parse some of the php variables\ + $temp_array = explode("@", $channels_array[$x]['presence_id']); + $channels_array[$x]['number'] = $temp_array[0]; + + //remove the '+' because it breaks the call recording + $channels_array[$x]['cid_num'] = $temp_array[0] = str_replace("+", "", $channels_array[$x]['cid_num']); + + //calculate and set the call length + $call_length_seconds = time() - $channels_array[$x]['created_epoch']; + $call_length_hour = floor($call_length_seconds/3600); + $call_length_min = floor($call_length_seconds/60 - ($call_length_hour * 60)); + $call_length_sec = $call_length_seconds - (($call_length_hour * 3600) + ($call_length_min * 60)); + $call_length_min = sprintf("%02d", $call_length_min); + $call_length_sec = sprintf("%02d", $call_length_sec); + $call_length = $call_length_hour.':'.$call_length_min.':'.$call_length_sec; + $channels_array[$x]['call_length'] = $call_length; + + //valet park + if (is_array($valet_array[$uuid])) { + $valet_array[$uuid]['context'] = $channels_array[$x]['context']; + $valet_array[$uuid]['cid_name'] = $channels_array[$x]['cid_name']; + $valet_array[$uuid]['cid_num'] = $channels_array[$x]['cid_num']; + $valet_array[$uuid]['call_length'] = $call_length; + } + //increment the array index + $x++; + } + + //active extensions + //get the extension information + if ($debug) { + unset($_SESSION['extension_array']); + } + if (count($_SESSION['extension_array']) == 0) { + $sql = ""; + $sql .= "select * from v_extensions "; + $x = 0; + $range_array = $_GET['range']; + foreach($range_array as $tmp_range) { + $tmp_range = str_replace(":", "-", $tmp_range); + $tmp_array = explode("-", $tmp_range); + $tmp_min = $tmp_array[0]; + $tmp_max = $tmp_array[1]; + if ($x == 0) { + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and extension >= $tmp_min "; + $sql .= "and extension <= $tmp_max "; + $sql .= "and enabled = 'true' "; + } + else { + $sql .= "or domain_uuid = '$domain_uuid' "; + $sql .= "and extension >= $tmp_min "; + $sql .= "and extension <= $tmp_max "; + $sql .= "and enabled = 'true' "; + } + $x++; + } + if (count($range_array) == 0) { + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and enabled = 'true' "; + } + $sql .= "order by extension asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + if ($row["enabled"] == "true") { + $extension = $row["extension"]; + $extension_array[$extension]['domain_uuid'] = $row["domain_uuid"]; + $extension_array[$extension]['extension'] = $row["extension"]; + + //$extension_array[$extension]['password'] = $row["password"]; + $extension_array[$extension]['mailbox'] = $row["mailbox"]; + //$vm_password = $row["vm_password"]; + //$vm_password = str_replace("#", "", $vm_password); //preserves leading zeros + //$_SESSION['extension_array'][$extension]['vm_password'] = $vm_password; + $extension_array[$extension]['accountcode'] = $row["accountcode"]; + $extension_array[$extension]['effective_caller_id_name'] = $row["effective_caller_id_name"]; + $extension_array[$extension]['effective_caller_id_number'] = $row["effective_caller_id_number"]; + $extension_array[$extension]['outbound_caller_id_name'] = $row["outbound_caller_id_name"]; + $extension_array[$extension]['outbound_caller_id_number'] = $row["outbound_caller_id_number"]; + $extension_array[$extension]['vm_enabled'] = $row["vm_enabled"]; + $extension_array[$extension]['vm_mailto'] = $row["vm_mailto"]; + $extension_array[$extension]['vm_attach_file'] = $row["vm_attach_file"]; + $extension_array[$extension]['vm_keep_local_after_email'] = $row["vm_keep_local_after_email"]; + $extension_array[$extension]['user_context'] = $row["user_context"]; + $extension_array[$extension]['call_group'] = $row["call_group"]; + $extension_array[$extension]['auth_acl'] = $row["auth_acl"]; + $extension_array[$extension]['cidr'] = $row["cidr"]; + $extension_array[$extension]['sip_force_contact'] = $row["sip_force_contact"]; + //$extension_array[$extension]['enabled'] = $row["enabled"]; + $extension_array[$extension]['effective_caller_id_name'] = $row["effective_caller_id_name"]; + } + } + $_SESSION['extension_array'] = $extension_array; + } + + //get a list of assigned extensions for this user + include "v_calls_active_assigned_extensions_inc.php"; + + //list all extensions + if (permission_exists('extensions_active_list_view')) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + } //end if results + + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + if ($_SESSION['user_status_display'] == "false") { + //hide the user_status when it is set to false + } + else { + echo "\n"; + } + echo "\n"; + if (if_group("admin") || if_group("superadmin")) { + if (strlen(($_GET['rows'])) == 0) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + } + echo "\n"; + if (if_group("admin") || if_group("superadmin")) { + if (strlen(($_GET['rows'])) == 0) { + echo "\n"; + } + } + echo "\n"; + $x = 1; + + foreach ($_SESSION['extension_array'] as $row) { + $domain_uuid = $row['domain_uuid']; + $extension = $row['extension']; + $enabled = $row['enabled']; + $effective_caller_id_name = $row['effective_caller_id_name']; + + $found_extension = false; + foreach ($channels_array as $row) { + //set the php variables + foreach ($row as $key => $value) { + $$key = $value; + } + //check to see if the extension is found in the channel array + if ($number == $extension) { + $found_extension = true; + break; + } + } + + if ($found_extension) { + if ($application == "conference") { + $alt_color = "background-image: url('".PROJECT_PATH."/images/background_cell_active.gif"; + } + switch ($application) { + case "conference": + $style_alternate = "style=\"color: #444444; background-image: url('".PROJECT_PATH."/images/background_cell_conference.gif');\""; + break; + case "fifo": + $style_alternate = "style=\"color: #444444; background-image: url('".PROJECT_PATH."/images/background_cell_fifo.gif');\""; + break; + case "valet_park": + $style_alternate = "style=\"color: #444444; background-image: url('".PROJECT_PATH."/images/background_cell_fifo.gif');\""; + break; + default: + $style_alternate = "style=\"color: #444444; background-image: url('".PROJECT_PATH."/images/background_cell_active.gif');\""; + } + echo "\n"; + echo "\n"; + if ($_SESSION['user_status_display'] == "false") { + //hide the user_status when it is set to false + } + else { + echo "\n"; + } + echo "\n"; + if (if_group("admin") || if_group("superadmin")) { + if (strlen(($_GET['rows'])) == 0) { + if (strlen($url) == 0) { + $url = PROJECT_PATH."/app/contacts/contacts.php?search_all={cid_num}"; + } + $url = str_replace ("{cid_num}", $cid_num, $url); + $url = str_replace ("{cid_name}", $cid_name, $url); + echo "\n"; + echo "\n"; + } + } + if (if_group("admin") || if_group("superadmin")) { + if (strlen(($_GET['rows'])) == 0) { + echo "\n"; + echo "\n"; + echo "\n"; + } + } + } + else { + $style_alternate = "style=\"color: #444444; background-image: url('".PROJECT_PATH."/images/background_cell_light.gif');\""; + echo "\n"; + echo "\n"; + if ($_SESSION['user_status_display'] == "false") { + //hide the user_status when it is set to false + } + else { + echo "\n"; + } + echo "\n"; + if (if_group("admin") || if_group("superadmin")) { + if (strlen(($_GET['rows'])) == 0) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + } + } + + echo "\n"; + + if (if_group("admin") || if_group("superadmin")) { + if (strlen(($_GET['rows'])) == 0) { + if ($found_extension) { + echo "\n"; + } + else { + echo "\n"; + } + } + } + echo "\n"; + + if ($y == $_GET['rows'] && $_GET['rows'] > 0) { + $y = 0; + echo "
ExtStatusTimeCID NameCID NumberDestAppSecureNameOptions
$extension".$user_array[$extension]['user_status']." ".$call_length."".$cid_name."".$cid_num."\n"; + echo "".$dest."
\n"; + echo "
\n"; + if ($application == "fifo") { + echo "queue  \n"; + } + else { + echo $application."  \n"; + } + echo "\n"; + echo "".$secure."
\n"; + echo "
$extension".$user_array[$extension]['user_status']."       \n"; + echo " ".$effective_caller_id_name." \n"; + echo "\n"; + //transfer + echo " transfer \n"; + //park + echo " park \n"; + //hangup + echo " hangup \n"; + //record start/stop + $tmp_file = $_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d")."/".$uuid.".wav"; + if (file_exists($tmp_file)) { + //stop + echo " stop record \n"; + } + else { + //start + echo " start record \n"; + } + echo "  "; + echo "\n"; + echo "  "; + echo "
\n"; + + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + if ($_SESSION['user_status_display'] == "false") { + //hide the user_status when it is set to false + } + else { + echo "\n"; + } + echo "\n"; + if (if_group("admin") || if_group("superadmin")) { + if ($_GET['rows'] == 0) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + } + echo "\n"; + if (if_group("admin") || if_group("superadmin")) { + if ($_GET['rows'] == 0) { + echo "\n"; + } + } + echo "\n"; + } + $y++; + if ($c==0) { $c=1; } else { $c=0; } + } + + echo "
ExtStatusTimeCID NameCID NumberDestAppSecureNameOptions
\n"; + echo "

\n"; + + //valet park + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + foreach ($valet_array as $row) { + if (strlen($row['extension']) > 0) { + if ($row['context'] == $_SESSION['domain_name'] || $row['context'] == "default") { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + } + } + echo "
Park ExtensionTimeCID NameCID Number
*".$row['extension']."".$row['call_length']."".$row['cid_name']."".$row['cid_num']."
\n"; + } + + echo "

\n"; + + if ($user_status == "Available (On Demand)") { + $user_status = "Available_On_Demand"; + } + $user_status = str_replace(" ", "_", $user_status); + echo "\n"; + echo "
\n"; + echo "
\n"; + } +?> diff --git a/app/calls_active/v_calls_active_inc.php b/app/calls_active/v_calls_active_inc.php new file mode 100644 index 0000000000..65864277c0 --- /dev/null +++ b/app/calls_active/v_calls_active_inc.php @@ -0,0 +1,172 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('calls_active_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//set the command + $switch_cmd = 'show channels'; +//create the event socket connection + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); +//if the connnection is available then run it and return the results + if (!$fp) { + $msg = "
Connection to Event Socket failed.
"; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Message
$msg
\n"; + echo "\n"; + } + else { + //send the event socket command + $csv = trim(event_socket_request($fp, 'api '.$switch_cmd)); + //prepare the string + $result_array = explode("\n\n",$csv); + //get the named array + $result_array = csv_to_named_array($result_array[0], ","); + + //set the alternating color for each row + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + //show the results + echo "
\n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + //echo "\n"; + echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + //echo "\n"; + echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + foreach ($result_array as $row) { + //set the php variables + foreach ($row as $key => $value) { + $$key = $value; + } + + //get the sip profile + $name_array = explode("/", $name); + $sip_profile = $name_array[1]; + $sip_uri = $name_array[2]; + + //get the number + $temp_array = explode("@", $sip_uri); + $tmp_number = $temp_array[0]; + $tmp_number = str_replace("sip:", "", $tmp_number); + + //remove the '+' because it breaks the call recording + $cid_num = str_replace("+", "", $cid_num); + + echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + //echo "\n"; + echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + echo "\n"; + if (strlen($application) > 0) { + echo "\n"; + } + else { + echo "\n"; + } + //echo "\n"; + //echo "\n"; + echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } + echo "\n"; + echo "\n"; + echo "
IDUUIDDirProfileCreatedCreated EpochNameNumberStateCID NameCID NumberIP AddrDestApplicationDialplanContextRead / Write CodecRead RateWrite CodecWrite RateSecureOptions
$id  $uuid  $direction  $sip_profile  $created  $created_epoch  $name  ".$tmp_number." $state  $cid_name  $cid_num  $ip_addr  $dest  ".$application.":".$application_data."   $dialplan  $context  $read_codec:$read_rate / $write_codec:$write_rate  $read_rate  $write_codec  $write_rate  $secure  \n"; + //transfer + echo " Transfer To';\" onclick=\"send_cmd('v_calls_exec.php?cmd='+get_transfer_cmd(escape('$uuid')));\">xfer \n"; + //park + echo " park \n"; + //hangup + echo " hangup \n"; + //record start/stop + $tmp_dir = $_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d"); + mkdir($tmp_dir, 0777, true); + $tmp_file = $tmp_dir."/".$uuid.".wav"; + if (file_exists($tmp_file)) { + //stop + echo " stop rec \n"; + } + else { + //start + echo " rec \n"; + } + echo "  "; + echo "
\n"; + } +?> diff --git a/app/calls_active/v_calls_exec.php b/app/calls_active/v_calls_exec.php new file mode 100644 index 0000000000..0bdf087ab2 --- /dev/null +++ b/app/calls_active/v_calls_exec.php @@ -0,0 +1,259 @@ +0) { + $switch_cmd = trim($_GET["cmd"]); + $action = trim($_GET["action"]); + $data = trim($_GET["data"]); + $direction = trim($_GET["direction"]); + $username = $_SESSION['username']; + } + +//authorized commands + if (stristr($switch_cmd, '&uuid=') == true) { + //authorized; + } elseif (stristr($switch_cmd, 'uuid_kill') == true) { + //authorized; + } elseif (stristr($switch_cmd, 'uuid_transfer') == true) { + //authorized; + } elseif (stristr($switch_cmd, 'uuid_record') == true) { + //authorized; + } elseif (stristr($action, 'user_status') == true) { + //authorized; + } elseif (stristr($action, 'callcenter_config') == true) { + //authorized; + } else { + //not found. this command is not authorized + echo "access denied"; + exit; + } + + +if (count($_GET)>0) { + + //setup the event socket connection + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + + if (stristr($action, 'user_status') == true) { + $user_status = $data; + switch ($user_status) { + case "Available": + $user_status = "Available"; + //update the user state + $cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting"; + $response = event_socket_request($fp, $cmd); + break; + case "Available_On_Demand": + $user_status = "Available (On Demand)"; + //update the user state + $cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting"; + $response = event_socket_request($fp, $cmd); + break; + case "Logged_Out": + $user_status = "Logged Out"; + //update the user state + $cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting"; + $response = event_socket_request($fp, $cmd); + break; + case "On_Break": + $user_status = "On Break"; + //update the user state + $cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting"; + $response = event_socket_request($fp, $cmd); + break; + case "Do_Not_Disturb": + $user_status = "Do Not Disturb"; + //update the user state + $cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting"; + $response = event_socket_request($fp, $cmd); + break; + default: + $user_status = ""; + } + + //update the v_users table with the status + $sql = "update v_users set "; + $sql .= "user_status = '$user_status' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and username = '".$username."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + + if (strlen($user_status) > 0) { + //include the dnd class + include "includes/classes/do_not_disturb.php"; + //loop through the list of assigned extensions + foreach ($_SESSION['user']['extension'] as &$row) { + $extension = $row["user"]; + + //set the default action + if ($user_status == "Do Not Disturb") { + $dnd_action = "add"; + } + + //hunt_group information used to determine if this is an add or an update + $sql = "select * from v_hunt_groups "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and hunt_group_extension = '$extension' "; + $prep_statement_2 = $db->prepare(check_sql($sql)); + $prep_statement_2->execute(); + $result2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED); + foreach ($result2 as &$row2) { + if ($row2["hunt_group_type"] == 'dnd') { + $dnd_action = "update"; + $dnd_uuid = $row2["hunt_group_uuid"]; + } + } + unset ($prep_statement_2, $result, $row2); + + //add or update dnd + $dnd = new do_not_disturb; + $dnd->domain_uuid = $domain_uuid; + $dnd->dnd_uuid = $dnd_uuid; + $dnd->domain_name = $_SESSION['domain_name']; + $dnd->extension = $extension; + if ($user_status == "Do Not Disturb") { + $dnd->dnd_enabled = "true"; + if ($dnd_action == "add") { + $dnd->dnd_add(); + } + if ($dnd_action == "update") { + $dnd->dnd_update(); + } + } + else { + //for other status disable dnd + if ($dnd_action == "update") { + $dnd->dnd_enabled = "false"; + $dnd->dnd_update(); + } + } + $dnd->debug = false; + $dnd->dnd_status(); + unset($dnd); + } + unset ($prep_statement); + } + + //synchronize the xml config + save_hunt_group_xml(); + + //synchronize the xml config + save_dialplan_xml(); + + //reloadxml + $cmd = 'api reloadxml'; + $response = event_socket_request($fp, $cmd); + + //apply settings reminder + $_SESSION["reload_xml"] = false; + } + + //fs cmd + if (strlen($switch_cmd) > 0) { + + //set the status so they are compatible with mod_callcenter + $switch_cmd = str_replace("Available_On_Demand", "'Available (On Demand)'", $switch_cmd); + $switch_cmd = str_replace("Logged_Out", "'Logged Out'", $switch_cmd); + $switch_cmd = str_replace("On_Break", "'On Break'", $switch_cmd); + $switch_cmd = str_replace("Do_Not_Disturb", "'Logged Out'", $switch_cmd); + + /* + //if ($action == "energy") { + //conference 3001-example.org energy 103 + $switch_result = event_socket_request($fp, 'api '.$switch_cmd); + $result_array = explode("=",$switch_result); + $tmp_value = $result_array[1]; + //if ($direction == "up") { $tmp_value = $tmp_value + 100; } + //if ($direction == "down") { $tmp_value = $tmp_value - 100; } + //echo "energy $tmp_value
\n"; + $switch_result = event_socket_request($fp, 'api '.$switch_cmd.' '.$tmp_value); + //} + if ($action == "volume_in") { + $switch_result = event_socket_request($fp, 'api '.$switch_cmd); + $result_array = explode("=",$switch_result); + $tmp_value = $result_array[1]; + if ($direction == "up") { $tmp_value = $tmp_value + 1; } + if ($direction == "down") { $tmp_value = $tmp_value - 1; } + //echo "volume $tmp_value
\n"; + $switch_result = event_socket_request($fp, 'api '.$switch_cmd.' '.$tmp_value); + } + if ($action == "volume_out") { + $switch_result = event_socket_request($fp, 'api '.$switch_cmd); + $result_array = explode("=",$switch_result); + $tmp_value = $result_array[1]; + if ($direction == "up") { $tmp_value = $tmp_value + 1; } + if ($direction == "down") { $tmp_value = $tmp_value - 1; } + //echo "volume $tmp_value
\n"; + $switch_result = event_socket_request($fp, 'api '.$switch_cmd.' '.$tmp_value); + } + */ + + $switch_result = event_socket_request($fp, 'api '.$switch_cmd); + if ($action == "record") { + if (trim($_GET["action2"]) == "stop") { + $x=0; + while (true) { + if ($x > 0) { + $dest_file = $_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"]."_".$x.".wav"; + } + else { + $dest_file = $_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"].".wav"; + } + if (!file_exists($dest_file)) { + rename($_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d")."/".$_GET["uuid"].".wav", $dest_file); + break; + } + $x++; + } + } + } + } +} + +?> diff --git a/app/click_to_call/app_config.php b/app/click_to_call/app_config.php new file mode 100644 index 0000000000..4df738cbfb --- /dev/null +++ b/app/click_to_call/app_config.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/app/click_to_call/click_to_call.php b/app/click_to_call/click_to_call.php new file mode 100644 index 0000000000..a89608e38a --- /dev/null +++ b/app/click_to_call/click_to_call.php @@ -0,0 +1,331 @@ + 0) { + $context = $_SESSION['context']; + } + else { + $context = 'default'; + } + + //translate ringback + switch ($ringback) { + case "us-ring": + $ringback_value = "\'%(2000,4000,440.0,480.0)\'"; + break; + case "uk-ring": + $ringback_value = "\'%(400,200,400,450);%(400,2200,400,450)\'"; + break; + case "fr-ring": + $ringback_value = "\'%(1500,3500,440.0,0.0)\'"; + break; + case "rs-ring": + $ringback_value = "\'%(1000,4000,425.0,0.0)\'"; + break; + case "music": + $ringback_value = "\'local_stream://moh\'"; + break; + default: + $ringback = 'us-ring'; + $ringback_value = "\'%(2000,4000,440.0,480.0)\'"; + } + + //source should see the destination caller id + if (strlen($src) < 7) { + $source = "{origination_caller_id_name='$src_cid_name',origination_caller_id_number=$src_cid_number,instant_ringback=true,ringback=$ringback_value,presence_id=$src@".$_SESSION['domains'][$domain_uuid]['domain_name'].",call_direction=outbound}sofia/internal/$src%".$_SESSION['domains'][$domain_uuid]['domain_name']; + } + else { + $bridge_array = outbound_route_to_bridge ($src); + $source = "{origination_caller_id_name='$src_cid_name',origination_caller_id_number=$src_cid_number,instant_ringback=true,ringback=$ringback_value,presence_id=$src@".$_SESSION['domains'][$domain_uuid]['domain_name'].",call_direction=outbound}".$bridge_array[0]; + } + + //destination needs to see the source caller id + if (strlen($dest) < 7) { + $switch_cmd = "api originate $source &transfer('".$dest." XML ".$context."')"; + } + else { + if (strlen($src) < 7) { + if (strlen($dest_cid_number) == 0) { + //get the caller id from the extension caller id comes from the extension (the source number) + $sql = ""; + $sql .= "select * from v_extensions "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and extension = '$src' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $dest_cid_name = $row["outbound_caller_id_name"]; + $dest_cid_number = $row["outbound_caller_id_number"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + } + $bridge_array = outbound_route_to_bridge ($dest); + $destination = "{origination_caller_id_name='$dest_cid_name',origination_caller_id_number=$dest_cid_number}".$bridge_array[0]; + if (permission_exists('click_to_call_call')) { + $switch_cmd = "api originate $source &bridge($destination)"; + } + } + + //display the last command + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Message
$switch_cmd $src has called $dest
\n"; + echo "
\n"; + + //create the even socket connection and send the event socket command + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + if (!$fp) { + //show the error message + $msg = "
Connection to Event Socket failed.
"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "
Message
$msg
\n"; + echo "
\n"; + } + else { + //show the command result + $result = trim(event_socket_request($fp, $switch_cmd)); + if (substr($result, 0,3) == "+OK") { + $uuid = substr($result, 4); + if ($rec == "true") { + //use the server's time zone to ensure it matches the time zone used by freeswitch + date_default_timezone_set($_SESSION['time_zone']['system']); + //create the api record command and send it over event socket + $switch_cmd = "api uuid_record ".$uuid." start ".$_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d")."/".$uuid.".wav"; + $result2 = trim(event_socket_request($fp, $switch_cmd)); + } + } + echo "
\n"; + echo "
\n"; + echo $result; + echo "
\n"; + echo "
\n"; + echo "
\n"; + } +} + +//show html form + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo " \n"; + echo " Click to Call\n"; + echo " \n"; + echo " \n"; + echo "  \n"; + echo "
\n"; + echo " \n"; + echo " Provide the following information to make a call from the source number to the destination number.\n"; + echo " \n"; + echo "
"; + + echo "
"; + + echo "
\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + echo "
Source Caller ID Name:\n"; + echo " \n"; + echo "
\n"; + echo " Enter the name to show to the source caller.\n"; + echo "
Source Caller ID Number:\n"; + echo " \n"; + echo "
\n"; + echo " Enter the number to show to the source caller.\n"; + echo "
Destination Caller ID Name:\n"; + echo " \n"; + echo "
\n"; + echo " Enter the name to send to the destination callee.\n"; + echo "
Destination Caller ID Number:\n"; + echo " \n"; + echo "
\n"; + echo " Enter the number to show to the destination callee.\n"; + echo "
Source Number:\n"; + echo " \n"; + echo "
\n"; + echo " Enter the number to call from.\n"; + echo "
Destination Number:\n"; + echo " \n"; + echo "
\n"; + echo " Enter the number to call.\n"; + echo "
\n"; + echo " Record:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Select whether to record the call.\n"; + echo "
\n"; + echo " Ring Back:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Defines what the caller will hear while destination is being called. The choices are music (music on hold) ring (ring tone.)\n"; + echo "
\n"; + echo " \n"; + echo "
\n"; + echo "
"; + +//show the footer + require_once "includes/footer.php"; +?> diff --git a/app/click_to_call/root.php b/app/click_to_call/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/click_to_call/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/conferences/app_config.php b/app/conferences/app_config.php new file mode 100644 index 0000000000..0adabb693b --- /dev/null +++ b/app/conferences/app_config.php @@ -0,0 +1,140 @@ + \ No newline at end of file diff --git a/app/conferences/conferences.php b/app/conferences/conferences.php new file mode 100644 index 0000000000..a53688a6cc --- /dev/null +++ b/app/conferences/conferences.php @@ -0,0 +1,202 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('conference_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get variables used to control the order + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Conferences 
\n"; + echo " Conferences is used to setup conference rooms with a name, description, and optional pin number. \n"; + if (permission_exists('conferences_active_advanced_view')) { + echo " Show Active Conferences and then select a conference to monitor and interact with it.

\n"; + } + echo "
\n"; + + //prepare to page the results + if (if_group("superadmin") || if_group("admin")) { + //show all extensions + $sql = "select count(*) as num_rows from v_conferences "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + } + else { + //show only assigned extensions + $sql = "select count(*) as num_rows from v_conferences as c, v_conference_users as u "; + $sql .= "where c.conference_uuid = u.conference_uuid "; + $sql .= "and c.domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and u.user_uuid = '".$_SESSION['user_uuid']."' "; + } + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + + //prepare to page the results + $rows_per_page = 10; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + //get the list + if (if_group("superadmin") || if_group("admin")) { + //show all extensions + $sql = "select * from v_conferences "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + } + else { + //show only assigned extensions + $sql = "select * from v_conferences as c, v_conference_users as u "; + $sql .= "where c.conference_uuid = u.conference_uuid "; + $sql .= "and c.domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and u.user_uuid = '".$_SESSION['user_uuid']."' "; + } + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo th_order_by('conference_name', 'Name', $order_by, $order); + echo th_order_by('conference_extension', 'Extension', $order_by, $order); + echo th_order_by('conference_profile', 'Profile', $order_by, $order); + //echo th_order_by('conference_flags', 'Flags', $order_by, $order); + echo th_order_by('conference_order', 'Order', $order_by, $order); + echo th_order_by('conference_enabled', 'Enabled', $order_by, $order); + echo th_order_by('conference_description', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + $conference_name = $row['conference_name']; + $conference_name = str_replace("-", " ", $conference_name); + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + if (permission_exists('conference_add')) { + echo " $v_link_label_add\n"; + } + else { + echo "  \n"; + } + echo "
".$conference_name." ".$row['conference_extension']." ".$row['conference_profile']." ".$row['conference_flags']." ".$row['conference_order']." ".$row['conference_enabled']." ".$row['conference_description']." \n"; + if (permission_exists('conference_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('conference_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('conference_add')) { + echo " $v_link_label_add\n"; + } + else { + echo "  \n"; + } + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/conferences/conferences_delete.php b/app/conferences/conferences_delete.php new file mode 100644 index 0000000000..f80941b3a3 --- /dev/null +++ b/app/conferences/conferences_delete.php @@ -0,0 +1,91 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('conference_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); +} + +if (strlen($id)>0) { + + //get the dialplan uuid + $sql = "select * from v_conferences "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and conference_uuid = '$id' "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + while($row = $prep_statement->fetch(PDO::FETCH_ASSOC)) { + $dialplan_uuid = $row['dialplan_uuid']; + } + + //delete conference + $sql = "delete from v_conferences "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and conference_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + + //delete the dialplan entry + $sql = "delete from v_dialplans "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $db->query($sql); + unset($sql); + + //delete the dialplan details + $sql = "delete from v_dialplan_details "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $db->query($sql); + unset($sql); + + //syncrhonize configuration + save_dialplan_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; +} + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/conferences/conferences_edit.php b/app/conferences/conferences_edit.php new file mode 100644 index 0000000000..79013ff6a0 --- /dev/null +++ b/app/conferences/conferences_edit.php @@ -0,0 +1,541 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('conference_add') || permission_exists('conference_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $conference_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $dialplan_uuid = check_str($_POST["dialplan_uuid"]); + $conference_name = check_str($_POST["conference_name"]); + $conference_extension = check_str($_POST["conference_extension"]); + $conference_pin_number = check_str($_POST["conference_pin_number"]); + $conference_profile = check_str($_POST["conference_profile"]); + $conference_flags = check_str($_POST["conference_flags"]); + $conference_order = check_str($_POST["conference_order"]); + $conference_description = check_str($_POST["conference_description"]); + $conference_enabled = check_str($_POST["conference_enabled"]); + + //sanitize the conference name + $conference_name = preg_replace("/[^A-Za-z0-9\- ]/", "", $conference_name); + $conference_name = str_replace(" ", "-", $conference_name); + } + +//delete the user from the v_conference_users + if ($_GET["a"] == "delete" && permission_exists("conference_delete")) { + //set the variables + $user_uuid = check_str($_REQUEST["user_uuid"]); + $conference_uuid = check_str($_REQUEST["id"]); + //delete the group from the users + $sql = "delete from v_conference_users "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and conference_uuid = '".$conference_uuid."' "; + $sql .= "and user_uuid = '".$user_uuid."' "; + $db->exec(check_sql($sql)); + //redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
Delete Complete
"; + require_once "includes/footer.php"; + return; + } + +//add the user to the v_conference_users + if (strlen($_REQUEST["user_uuid"]) > 0 && strlen($_REQUEST["id"]) > 0 && $_GET["a"] != "delete") { + //set the variables + $user_uuid = check_str($_REQUEST["user_uuid"]); + $conference_uuid = check_str($_REQUEST["id"]); + //assign the user to the extension + $sql_insert = "insert into v_conference_users "; + $sql_insert .= "("; + $sql_insert .= "conference_user_uuid, "; + $sql_insert .= "domain_uuid, "; + $sql_insert .= "conference_uuid, "; + $sql_insert .= "user_uuid "; + $sql_insert .= ")"; + $sql_insert .= "values "; + $sql_insert .= "("; + $sql_insert .= "'".uuid()."', "; + $sql_insert .= "'".$_SESSION['domain_uuid']."', "; + $sql_insert .= "'".$conference_uuid."', "; + $sql_insert .= "'".$user_uuid."' "; + $sql_insert .= ")"; + $db->exec($sql_insert); + //redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
Add Complete
"; + require_once "includes/footer.php"; + return; + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $conference_uuid = check_str($_POST["conference_uuid"]); + } + + //check for all required data + //if (strlen($dialplan_uuid) == 0) { $msg .= "Please provide: Dialplan UUID
\n"; } + if (strlen($conference_name) == 0) { $msg .= "Please provide: Name
\n"; } + if (strlen($conference_extension) == 0) { $msg .= "Please provide: Extension
\n"; } + //if (strlen($conference_pin_number) == 0) { $msg .= "Please provide: Pin Number
\n"; } + if (strlen($conference_profile) == 0) { $msg .= "Please provide: Profile
\n"; } + //if (strlen($conference_flags) == 0) { $msg .= "Please provide: Flags
\n"; } + //if (strlen($conference_order) == 0) { $msg .= "Please provide: Order
\n"; } + //if (strlen($conference_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($conference_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + //prepare the uuids + $conference_uuid = uuid(); + $dialplan_uuid = uuid(); + //add the conference + $sql = "insert into v_conferences "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "conference_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "conference_name, "; + $sql .= "conference_extension, "; + $sql .= "conference_pin_number, "; + $sql .= "conference_profile, "; + $sql .= "conference_flags, "; + $sql .= "conference_order, "; + $sql .= "conference_description, "; + $sql .= "conference_enabled "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$conference_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$conference_name', "; + $sql .= "'$conference_extension', "; + $sql .= "'$conference_pin_number', "; + $sql .= "'$conference_profile', "; + $sql .= "'$conference_flags', "; + $sql .= "'$conference_order', "; + $sql .= "'$conference_description', "; + $sql .= "'$conference_enabled' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //create the dialplan entry + $dialplan_name = $conference_name; + $dialplan_order ='333'; + $dialplan_context = $_SESSION['context']; + $dialplan_enabled = 'true'; + $dialplan_description = $conference_description; + $app_uuid = 'b81412e8-7253-91f4-e48e-42fc2c9a38d9'; + dialplan_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_name, $dialplan_order, $dialplan_context, $dialplan_enabled, $dialplan_description, $app_uuid); + + // + $dialplan_detail_tag = 'condition'; //condition, action, antiaction + $dialplan_detail_type = 'destination_number'; + $dialplan_detail_data = '^'.$conference_extension.'$'; + $dialplan_detail_order = '000'; + $dialplan_detail_group = '2'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + // + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'answer'; + $dialplan_detail_data = ''; + $dialplan_detail_order = '010'; + $dialplan_detail_group = '2'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + // + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'conference'; + $pin_number = ''; if (strlen($conference_pin_number) > 0) { $pin_number = "+".$conference_pin_number; } + $flags = ''; if (strlen($conference_flags) > 0) { $flags = "+flags{".$conference_flags."}"; } + $dialplan_detail_data = $conference_name.'-'.$_SESSION['domain_name']."@".$conference_profile.$pin_number.$flags; + $dialplan_detail_order = '020'; + $dialplan_detail_group = '2'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + //save the xml + save_dialplan_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + + //redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + //update the conference extension + $sql = "update v_conferences set "; + $sql .= "conference_name = '$conference_name', "; + $sql .= "conference_extension = '$conference_extension', "; + $sql .= "conference_pin_number = '$conference_pin_number', "; + $sql .= "conference_profile = '$conference_profile', "; + $sql .= "conference_flags = '$conference_flags', "; + $sql .= "conference_order = '$conference_order', "; + $sql .= "conference_description = '$conference_description', "; + $sql .= "conference_enabled = '$conference_enabled' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and conference_uuid = '$conference_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + //udpate the conference dialplan + $sql = "update v_dialplans set "; + $sql .= "dialplan_name = '$conference_name', "; + if (strlen($dialplan_order) > 0) { + $sql .= "dialplan_order = '333', "; + } + $sql .= "dialplan_context = '".$_SESSION['context']."', "; + $sql .= "dialplan_enabled = 'true', "; + $sql .= "dialplan_description = '$conference_description' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $db->query($sql); + unset($sql); + + //update dialplan detail condition + $sql = ""; + $sql = "update v_dialplan_details set "; + $sql .= "dialplan_detail_data = '^".$conference_extension."$' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_detail_tag = 'condition' "; + $sql .= "and dialplan_detail_type = 'destination_number' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $db->query($sql); + unset($sql); + + //update dialplan detail action + $pin_number = ''; if (strlen($conference_pin_number) > 0) { $pin_number = "+".$conference_pin_number; } + $flags = ''; if (strlen($conference_flags) > 0) { $flags = "+flags{".$conference_flags."}"; } + $dialplan_detail_data = $conference_name.'-'.$_SESSION['domain_name']."@".$conference_profile.$pin_number.$flags; + $sql = "update v_dialplan_details set "; + $sql .= "dialplan_detail_data = '".$dialplan_detail_data."' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_detail_tag = 'action' "; + $sql .= "and dialplan_detail_type = 'conference' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $db->query($sql); + + //save the xml + save_dialplan_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + + //redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $conference_uuid = $_GET["id"]; + $sql = "select * from v_conferences "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and conference_uuid = '$conference_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(); + foreach ($result as &$row) { + $dialplan_uuid = $row["dialplan_uuid"]; + $conference_name = $row["conference_name"]; + $conference_extension = $row["conference_extension"]; + $conference_pin_number = $row["conference_pin_number"]; + $conference_profile = $row["conference_profile"]; + $conference_flags = $row["conference_flags"]; + $conference_order = $row["conference_order"]; + $conference_description = $row["conference_description"]; + $conference_enabled = $row["conference_enabled"]; + $conference_name = str_replace("-", " ", $conference_name); + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if (if_group("admin") || if_group("superadmin")) { + if ($action == "update") { + echo " "; + echo " "; + echo " "; + echo " "; + } + } + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " "; + echo "
Conference AddConference Edit
\n"; + echo "Conferences is used to setup conference rooms with a name, description, and optional pin number. \n"; + echo "Click on Active Conference \n"; + echo "to monitor and interact with the conference room.

\n"; + echo "
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the conference name.\n"; + echo "
\n"; + echo " Extension:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the conference extension number.\n"; + echo "
\n"; + echo " Pin Number:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Optional pin number to secure access to the conference.\n"; + echo "
User List:"; + + echo " \n"; + $sql = "SELECT * FROM v_conference_users as e, v_users as u "; + $sql .= "where e.user_uuid = u.user_uuid "; + $sql .= "and e.domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and e.conference_uuid = '".$conference_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + $result_count = count($result); + foreach($result as $field) { + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + } + echo "
".$field['username']."\n"; + echo " $v_link_label_delete\n"; + echo "
\n"; + + echo "
\n"; + $sql = "SELECT * FROM v_users "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + echo " "; + echo " \n"; + unset($sql, $result); + echo "
\n"; + echo " Assign the users that are can manage this conference extension.\n"; + echo "
\n"; + echo "
\n"; + echo " Profile:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Conference Profile is a collection of settings for the conference.\n"; + echo "
\n"; + echo " Flags:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Optional conference flags. examples: mute|deaf|waste|moderator\n"; + echo "
\n"; + echo " Order:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the order number.\n"; + echo "
\n"; + echo " Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Select whether to enable or disable the conference.\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the description.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/conferences/root.php b/app/conferences/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/conferences/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/conferences_active/app_config.php b/app/conferences_active/app_config.php new file mode 100644 index 0000000000..20d9cb95b5 --- /dev/null +++ b/app/conferences_active/app_config.php @@ -0,0 +1,70 @@ + \ No newline at end of file diff --git a/app/conferences_active/root.php b/app/conferences_active/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/conferences_active/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/conferences_active/v_conference_exec.php b/app/conferences_active/v_conference_exec.php new file mode 100644 index 0000000000..896f78bda6 --- /dev/null +++ b/app/conferences_active/v_conference_exec.php @@ -0,0 +1,126 @@ +0) { + $cmd = trim($_GET["cmd"]); + $name = trim($_GET["name"]); + $data = trim($_GET["data"]); + $id = trim($_GET["id"]); + $direction = trim($_GET["direction"]); + } + +//authorized commands + if ($cmd == "conference") { + //authorized; + } else { + //not found. this command is not authorized + echo "access denied"; + exit; + } + +//check if the domain is in the switch_cmd + if(stristr($name, $_SESSION['domain_name']) === FALSE) { + echo "access denied"; + exit; + } + +if (count($_GET)>0) { + if (strlen($cmd) > 0) { + //prepare the switch cmd + $switch_cmd = $cmd . " "; + $switch_cmd .= $name . " "; + $switch_cmd .= $data . " "; + if (strlen($id) > 0) { + $switch_cmd .= " ".$id; + } + + //connect to event socket + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + if ($fp) { + if ($data == "energy") { + //conference 3001-example-domain.org energy 103 + $switch_result = event_socket_request($fp, 'api '.$switch_cmd); + $result_array = explode("=",$switch_result); + $tmp_value = $result_array[1]; + if ($direction == "up") { $tmp_value = $tmp_value + 100; } + if ($direction == "down") { $tmp_value = $tmp_value - 100; } + //echo "energy $tmp_value
\n"; + $switch_result = event_socket_request($fp, 'api '.$switch_cmd.' '.$tmp_value); + } + elseif ($data == "volume_in") { + $switch_result = event_socket_request($fp, 'api '.$switch_cmd); + $result_array = explode("=",$switch_result); + $tmp_value = $result_array[1]; + if ($direction == "up") { $tmp_value = $tmp_value + 1; } + if ($direction == "down") { $tmp_value = $tmp_value - 1; } + //echo "volume $tmp_value
\n"; + $switch_result = event_socket_request($fp, 'api '.$switch_cmd.' '.$tmp_value); + } + elseif ($data == "volume_out") { + $switch_result = event_socket_request($fp, 'api '.$switch_cmd); + $result_array = explode("=",$switch_result); + $tmp_value = $result_array[1]; + if ($direction == "up") { $tmp_value = $tmp_value + 1; } + if ($direction == "down") { $tmp_value = $tmp_value - 1; } + //echo "volume $tmp_value
\n"; + $switch_result = event_socket_request($fp, 'api '.$switch_cmd.' '.$tmp_value); + } + elseif ($data == "record") { + $switch_cmd .= $_SESSION['switch']['recordings']['dir']."/".$name."-tmp.wav"; + if (!file_exists($_SESSION['switch']['recordings']['dir']."/".$name."-tmp.wav")) { + $switch_result = event_socket_request($fp, "api ".$switch_cmd); + } + } + elseif ($data == "norecord") { + //stop recording and rename the file + if (file_exists($_SESSION['switch']['recordings']['dir']."/".$name."-tmp.wav")) { + rename($_SESSION['switch']['recordings']['dir']."/".$name."-tmp.wav", $_SESSION['switch']['recordings']['dir']."/".$name."-".date("Y").".".date("M").".".date("d")."-".uuid().".wav"); + } + $switch_cmd .= $_SESSION['switch']['recordings']['dir']."/".$name."-tmp.wav"; + $switch_result = event_socket_request($fp, 'api '.$switch_cmd); + } + else { + $switch_result = event_socket_request($fp, 'api '.$switch_cmd); + } + } + } +} + +?> \ No newline at end of file diff --git a/app/conferences_active/v_conference_interactive.php b/app/conferences_active/v_conference_interactive.php new file mode 100644 index 0000000000..273e548d79 --- /dev/null +++ b/app/conferences_active/v_conference_interactive.php @@ -0,0 +1,129 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('conferences_active_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get and prepare the conference name + $conference_name = check_str(trim($_REQUEST["c"])); + $conference_display_name = str_replace("-", " ", $conference_name); + $conference_display_name = str_replace("_", " ", $conference_display_name); + +//show the header + require_once "includes/header.php"; + +?> + +"; +echo "\n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
Interactive Conference
\n"; +echo " Use this to monitor and interact with the members of the $conference_display_name conference.\n"; +echo "
\n"; +echo "\n"; +echo " \n"; +echo " "; +echo " "; +echo "
\n"; +echo "
\n"; +echo "
".date('Y-m-d-s')."
\n"; +echo "
"; +echo ""; + +//show the header + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/conferences_active/v_conference_interactive_inc.php b/app/conferences_active/v_conference_interactive_inc.php new file mode 100644 index 0000000000..b9de5b2a46 --- /dev/null +++ b/app/conferences_active/v_conference_interactive_inc.php @@ -0,0 +1,263 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('conferences_active_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the http get or post and set it as php variables + $conference_name = check_str($_REQUEST["c"]); + +//determine if the user should have access to the conference room + if (if_group("superadmin") || if_group("admin")) { + //access granted + } + else { + //get the conference_uuid from the coference_name + $sql = "select conference_uuid from v_conferences "; + $sql .= "where conference_name = '".$conference_name."' "; + $sql .= "and domain_uuid = '".$_SESSION['domain_uuid']."' "; + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + $conference_uuid = $row['conference_uuid']; + } + + //show only assigned extensions + $sql = "select count(*) as num_rows from v_conferences as c, v_conference_users as u "; + $sql .= "where c.conference_uuid = u.conference_uuid "; + $sql .= "and c.conference_uuid = '".$conference_uuid."' "; + $sql .= "and c.domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and u.user_uuid = '".$_SESSION['user_uuid']."' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] == 0) { + echo "access denied"; + exit; + } + } + } + +//replace the space with underscore + $conference_name = $conference_name.'-'.$_SESSION['domain_name']; + +//create the conference list command + $switch_cmd = "conference '".$conference_name."' xml_list"; + +//connect to event socket, send the command and process the results + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + if (!$fp) { + $msg = "
Connection to Event Socket failed.
"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Message
$msg
\n"; + echo "
\n"; + } + else { + //show the content + $xml_str = trim(event_socket_request($fp, 'api '.$switch_cmd)); + try { + $xml = new SimpleXMLElement($xml_str); + } + catch(Exception $e) { + //echo $e->getMessage(); + } + //$name = $xml->conference['name']; + $member_count = $xml->conference['member-count']; + $locked = $xml->conference['locked']; + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + foreach ($xml->conference->members->member as $row) { + $id = $row->id; + $record_path = $row->record_path; + $flag_can_hear = $row->flags->can_hear; + $flag_can_speak = $row->flags->can_speak; + $flag_talking = $row->flags->talking; + $last_talking = $row->last_talking; + $join_time = $row->join_time; + $flag_has_video = $row->flags->has_video; + $flag_has_floor = $row->flags->has_floor; + $uuid = $row->uuid; + $caller_id_name = $row->caller_id_name; + $caller_id_name = str_replace("%20", " ", $caller_id_name); + $caller_id_number = $row->caller_id_number; + + //format the seconds + $join_time_formatted = floor($join_time/60)."' ".($join_time - (floor($join_time/60))*60)."\""; + $last_talking_formatted = floor($last_talking/60)."' ".($last_talking - (floor($last_talking/60))*60)."\""; + + if (strlen($record_path) == 0) { + echo "\n"; + echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + if ($flag_can_hear == "true") { + echo "\n"; + } + else { + echo "\n"; + } + if ($flag_can_speak == "true") { + echo "\n"; + } + else { + echo "\n"; + } + if ($flag_talking == "true") { + echo "\n"; + } + else { + echo "\n"; + } + echo "\n"; + if ($flag_has_video == "true") { + echo "\n"; + } + else { + echo "\n"; + } + if ($flag_has_floor == "true") { + echo "\n"; + } + else { + echo "\n"; + } + echo "\n"; + echo "\n"; + } + if ($c==0) { $c=1; } else { $c=0; } + } + echo "
\n"; + echo " Count: $member_count\n"; + echo "\n"; + echo "  \n"; + echo "\n"; + if (permission_exists('conferences_active_record') || permission_exists('conferences_active_lock')) { + echo " Conference Tools: \n"; + } + if (permission_exists('conferences_active_record')) { + if (file_exists($_SESSION['switch']['recordings']['dir']."/".$conference_name."-tmp.wav")) { + echo " Stop Record \n"; + } + else { + echo " Start Record \n"; + } + } + if (permission_exists('conferences_active_lock')) { + if ($locked == "true") { + echo " Unlock \n"; + } + else { + echo " Lock \n"; + } + } + echo "
IDUUIDCaller ID NameCaller ID NumberJoinedHearSpeakTalkingLast TalkedVideoHas FloorTools
$id$uuid$caller_id_name$caller_id_number".$join_time_formatted."yesnoyesnoyesno$last_talking_formattedyesnoyesno\n"; + //energy + if (permission_exists('conferences_active_energy')) { + echo " +energy \n"; + echo " -energy \n"; + } + //volume + if (permission_exists('conferences_active_volume')) { + echo " +vol \n"; + echo " -vol \n"; + } + if (permission_exists('conferences_active_gain')) { + echo " +gain \n"; + echo " -gain \n"; + } + //mute and unmute + if (permission_exists('conferences_active_mute')) { + if ($flag_can_speak == "true"){ + echo " mute \n"; + } + else { + echo " unmute \n"; + } + } + //deaf and undeaf + if (permission_exists('conferences_active_deaf')) { + if ($flag_can_hear == "true"){ + echo " deaf \n"; + } + else { + echo " undeaf \n"; + } + } + //kick someone from the conference + if (permission_exists('conferences_active_kick')) { + echo " kick \n"; + } + echo "  "; + echo "
\n"; + } +?> \ No newline at end of file diff --git a/app/conferences_active/v_conferences_active.php b/app/conferences_active/v_conferences_active.php new file mode 100644 index 0000000000..93361b185c --- /dev/null +++ b/app/conferences_active/v_conferences_active.php @@ -0,0 +1,112 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('conferences_active_advanced_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +require_once "includes/header.php"; +?> + +"; + +echo "\n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
Active Conferences
\n"; +echo " List all the conferences that are currently active with one or more members.\n"; +echo "
\n"; + +echo "\n"; +echo "\n"; +echo " "; +echo " "; +echo "
\n"; + +echo "
\n"; +echo "
\n"; + +echo "
"; +echo ""; + +require_once "includes/footer.php"; +?> diff --git a/app/conferences_active/v_conferences_active_inc.php b/app/conferences_active/v_conferences_active_inc.php new file mode 100644 index 0000000000..911e62274a --- /dev/null +++ b/app/conferences_active/v_conferences_active_inc.php @@ -0,0 +1,107 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('conferences_active_advanced_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$tmp_conference_name = str_replace("_", " ", $conference_name); + +$switch_cmd = 'conference xml_list'; +$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); +if (!$fp) { + $msg = "
Connection to Event Socket failed.
"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Message
$msg
\n"; + echo "
\n"; +} +else { + $xml_str = trim(event_socket_request($fp, 'api '.$switch_cmd)); + try { + $xml = new SimpleXMLElement($xml_str); + } + catch(Exception $e) { + //echo $e->getMessage(); + } + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + foreach ($xml->conference as $row) { + //set the variables + $name = $row['name']; + $member_count = $row['member-count']; + //show the conferences that have a matching domain + $tmp_domain = substr($name, -strlen($_SESSION['domain_name'])); + if ($tmp_domain == $_SESSION['domain_name']) { + $conference_name = substr($name, 0, strlen($name) - strlen('-'.$_SESSION['domain_name'])); + $conference_display_name = str_replace("-", " ", $conference_name); + $conference_display_name = str_replace("_", " ", $conference_display_name); + + //$id = $row->members->member->id; + //$flag_can_hear = $row->members->member->flags->can_hear; + //$flag_can_speak = $row->members->member->flags->can_speak; + //$flag_talking = $row->members->member->flags->talking; + //$flag_has_video = $row->members->member->flags->has_video; + //$flag_has_floor = $row->members->member->flags->has_floor; + //$uuid = $row->members->member->uuid; + //$caller_id_name = $row->members->member->caller_id_name; + //$caller_id_name = str_replace("%20", " ", $caller_id_name); + //$caller_id_number = $row->members->member->caller_id_number; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if ($c==0) { $c=1; } else { $c=0; } + } + } + echo "
NameMember Count 
".$conference_display_name."".$member_count."view
\n"; +} +?> \ No newline at end of file diff --git a/app/contacts/app_config.php b/app/contacts/app_config.php new file mode 100644 index 0000000000..6fd3bd0a44 --- /dev/null +++ b/app/contacts/app_config.php @@ -0,0 +1,275 @@ + \ No newline at end of file diff --git a/app/contacts/contact_addresses.php b/app/contacts/contact_addresses.php new file mode 100644 index 0000000000..bd9d5cc610 --- /dev/null +++ b/app/contacts/contact_addresses.php @@ -0,0 +1,173 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('contacts_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get variables used to control the order + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + //echo "
"; + //echo "\n"; + //echo "\n"; + //echo " "; + //echo ""; + //echo "
\n"; + //echo "
"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + echo "
Addresses 
\n"; + //echo "List of addresses for the contact.

\n"; + //echo "
\n"; + + //prepare to page the results + $sql = " select count(*) as num_rows from v_contact_addresses "; + $sql .= " where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= " and contact_uuid = '$contact_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + + //prepare to page the results + $rows_per_page = 10; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + //get the contact list + $sql = " select * from v_contact_addresses "; + $sql .= " where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= " and contact_uuid = '$contact_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo th_order_by('address_type', 'Type', $order_by, $order); + //echo th_order_by('address_street', 'Street Address', $order_by, $order); + //echo th_order_by('address_extended', 'Extended Address', $order_by, $order); + echo th_order_by('address_locality', 'City', $order_by, $order); + echo th_order_by('address_region', 'Region', $order_by, $order); + //echo th_order_by('address_postal_code', 'Postal Code', $order_by, $order); + echo th_order_by('address_country', 'Country', $order_by, $order); + //echo th_order_by('address_latitude', 'Latitude', $order_by, $order); + //echo th_order_by('address_longitude', 'Longitude', $order_by, $order); + echo "\n"; + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + $map_query = $row['address_street']." ".$row['address_extended'].", ".$row['address_locality'].", ".$row['address_region'].", ".$row['address_region'].", ".$row['address_postal_code']; + echo "\n"; + echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
Tools\n"; + echo " $v_link_label_add\n"; + echo "
".$row['address_type']." ".$row['address_street']." ".$row['address_extended']." ".$row['address_locality']." ".$row['address_region']." ".$row['address_postal_code']." ".$row['address_country']." ".$row['address_latitude']." ".$row['address_longitude']." \n"; + echo " Map \n"; + echo " \n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + echo "
\n"; + echo "
"; + echo "
"; + + //echo "
"; + //echo "
"; + //echo "

"; + +//include the footer + //require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/contacts/contact_addresses_delete.php b/app/contacts/contact_addresses_delete.php new file mode 100644 index 0000000000..5131a788f3 --- /dev/null +++ b/app/contacts/contact_addresses_delete.php @@ -0,0 +1,61 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('contacts_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); + $contact_uuid = check_str($_GET["contact_uuid"]); +} + +if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_contact_addresses "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and contact_address_uuid = '$id' "; + + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); +} + +require_once "includes/header.php"; +echo "\n"; +echo "
\n"; +echo "Delete Complete\n"; +echo "
\n"; +require_once "includes/footer.php"; +return; + +?> \ No newline at end of file diff --git a/app/contacts/contact_addresses_edit.php b/app/contacts/contact_addresses_edit.php new file mode 100644 index 0000000000..c03bbc93ac --- /dev/null +++ b/app/contacts/contact_addresses_edit.php @@ -0,0 +1,352 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('contacts_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $contact_address_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +if (strlen($_GET["contact_uuid"]) > 0) { + $contact_uuid = check_str($_GET["contact_uuid"]); +} + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $address_type = check_str($_POST["address_type"]); + $address_street = check_str($_POST["address_street"]); + $address_extended = check_str($_POST["address_extended"]); + $address_locality = check_str($_POST["address_locality"]); + $address_region = check_str($_POST["address_region"]); + $address_postal_code = check_str($_POST["address_postal_code"]); + $address_country = check_str($_POST["address_country"]); + $address_latitude = check_str($_POST["address_latitude"]); + $address_longitude = check_str($_POST["address_longitude"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $contact_address_uuid = check_str($_POST["contact_address_uuid"]); + } + + //check for all required data + //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + //if (strlen($address_type) == 0) { $msg .= "Please provide: Address Type
\n"; } + //if (strlen($address_street) == 0) { $msg .= "Please provide: Street Address
\n"; } + //if (strlen($address_extended) == 0) { $msg .= "Please provide: Extended Address
\n"; } + //if (strlen($address_locality) == 0) { $msg .= "Please provide: City
\n"; } + //if (strlen($address_region) == 0) { $msg .= "Please provide: State / Province
\n"; } + //if (strlen($address_postal_code) == 0) { $msg .= "Please provide: Postal Code
\n"; } + //if (strlen($address_country) == 0) { $msg .= "Please provide: Country
\n"; } + //if (strlen($address_latitude) == 0) { $msg .= "Please provide: Latitude
\n"; } + //if (strlen($address_longitude) == 0) { $msg .= "Please provide: Longitude
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $contact_address_uuid = uuid(); + $sql = "insert into v_contact_addresses "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "contact_uuid, "; + $sql .= "contact_address_uuid, "; + $sql .= "address_type, "; + $sql .= "address_street, "; + $sql .= "address_extended, "; + $sql .= "address_locality, "; + $sql .= "address_region, "; + $sql .= "address_postal_code, "; + $sql .= "address_country, "; + $sql .= "address_latitude, "; + $sql .= "address_longitude "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$_SESSION['domain_uuid']."', "; + $sql .= "'$contact_uuid', "; + $sql .= "'$contact_address_uuid', "; + $sql .= "'$address_type', "; + $sql .= "'$address_street', "; + $sql .= "'$address_extended', "; + $sql .= "'$address_locality', "; + $sql .= "'$address_region', "; + $sql .= "'$address_postal_code', "; + $sql .= "'$address_country', "; + $sql .= "'$address_latitude', "; + $sql .= "'$address_longitude' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_contact_addresses set "; + $sql .= "contact_uuid = '$contact_uuid', "; + $sql .= "address_type = '$address_type', "; + $sql .= "address_street = '$address_street', "; + $sql .= "address_extended = '$address_extended', "; + $sql .= "address_locality = '$address_locality', "; + $sql .= "address_region = '$address_region', "; + $sql .= "address_postal_code = '$address_postal_code', "; + $sql .= "address_country = '$address_country', "; + $sql .= "address_latitude = '$address_latitude', "; + $sql .= "address_longitude = '$address_longitude' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."'"; + $sql .= "and contact_address_uuid = '$contact_address_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $contact_address_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_contact_addresses "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and contact_address_uuid = '$contact_address_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $address_type = $row["address_type"]; + $address_street = $row["address_street"]; + $address_extended = $row["address_extended"]; + $address_locality = $row["address_locality"]; + $address_region = $row["address_region"]; + $address_postal_code = $row["address_postal_code"]; + $address_country = $row["address_country"]; + $address_latitude = $row["address_latitude"]; + $address_longitude = $row["address_longitude"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Contacts Address AddContacts Address Edit
\n"; + echo "Contact address information.

\n"; + echo "
\n"; + echo " Address Type:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the address type.\n"; + echo "
\n"; + echo " Street Address:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the street address.\n"; + echo "
\n"; + echo " Extended Address:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the extended address.\n"; + echo "
\n"; + echo " City:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the city.\n"; + echo "
\n"; + echo " Region:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the state or province.\n"; + echo "
\n"; + echo " Postal Code:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the postal code.\n"; + echo "
\n"; + echo " Country:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the country.\n"; + echo "
\n"; + echo " Latitude:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the latitude\n"; + echo "
\n"; + echo " Longitude:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the longitude\n"; + echo "
\n"; + echo " \n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/contacts/contact_notes.php b/app/contacts/contact_notes.php new file mode 100644 index 0000000000..d4a185f1ca --- /dev/null +++ b/app/contacts/contact_notes.php @@ -0,0 +1,179 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('contacts_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get variables used to control the order + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + //echo "
"; + //echo "\n"; + //echo "\n"; + //echo " "; + //echo ""; + //echo "
\n"; + //echo "
"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + echo "
Notes 
\n"; + //echo " List of notes for the contact.

\n"; + //echo "
\n"; + + //prepare to page the results + $sql = " select count(*) as num_rows from v_contact_notes "; + $sql .= " where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= " and contact_uuid = '$contact_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + + //prepare to page the results + $rows_per_page = 10; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + //get the contact list + $sql = "select * from v_contact_notes "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and contact_uuid = '$contact_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + } + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + if ($result_count == 0) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + else { + foreach($result as $row) { + $contact_note = $row['contact_note']; + //$contact_note = str_replace("\n","
",$contact_note); + + echo "\n"; + echo "\n"; + //echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo "   \n"; + echo "\n"; + echo " $v_link_label_add\n"; + echo "
\n"; + echo " ".$row['last_mod_date']."    \n"; + echo " ".$row['last_mod_user']."     \n"; + echo "Modified Date ".$row['last_mod_date']."Modified By ".$row['last_mod_user']."\n"; + echo " $v_link_label_add\n"; + echo "

".$contact_note." 

".$row['last_mod_date']." ".$row['last_mod_user']." \n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + echo "
 
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + echo "
\n"; + echo "
"; + echo "
"; + + //echo "
"; + //echo "
"; + //echo "

"; + +//include the footer + //require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/contacts/contact_notes_delete.php b/app/contacts/contact_notes_delete.php new file mode 100644 index 0000000000..308731e642 --- /dev/null +++ b/app/contacts/contact_notes_delete.php @@ -0,0 +1,60 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('contacts_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); + $contact_uuid = check_str($_GET["contact_uuid"]); +} + +if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_contact_notes "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and contact_note_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); +} + +require_once "includes/header.php"; +echo "\n"; +echo "
\n"; +echo "Delete Complete\n"; +echo "
\n"; +require_once "includes/footer.php"; +return; + +?> \ No newline at end of file diff --git a/app/contacts/contact_notes_edit.php b/app/contacts/contact_notes_edit.php new file mode 100644 index 0000000000..f155db0ac0 --- /dev/null +++ b/app/contacts/contact_notes_edit.php @@ -0,0 +1,210 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('contacts_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $contact_note_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +if (strlen($_GET["contact_uuid"]) > 0) { + $contact_uuid = check_str($_GET["contact_uuid"]); +} + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $contact_note = check_str($_POST["contact_note"]); + $last_mod_date = check_str($_POST["last_mod_date"]); + $last_mod_user = check_str($_POST["last_mod_user"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $contact_note_uuid = check_str($_POST["contact_note_uuid"]); + } + + //check for all required data + //if (strlen($contact_note) == 0) { $msg .= "Please provide: Notes
\n"; } + //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + //if (strlen($last_mod_date) == 0) { $msg .= "Please provide: Last Modified Date
\n"; } + //if (strlen($last_mod_user) == 0) { $msg .= "Please provide: Last Modified By
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $contact_note_uuid = uuid(); + $sql = "insert into v_contact_notes "; + $sql .= "("; + $sql .= "contact_note_uuid, "; + $sql .= "contact_uuid, "; + $sql .= "contact_note, "; + $sql .= "domain_uuid, "; + $sql .= "last_mod_date, "; + $sql .= "last_mod_user "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$contact_note_uuid', "; + $sql .= "'$contact_uuid', "; + $sql .= "'$contact_note', "; + $sql .= "'$domain_uuid', "; + $sql .= "now(), "; + $sql .= "'".$_SESSION['username']."' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_contact_notes set "; + $sql .= "contact_uuid = '$contact_uuid', "; + $sql .= "contact_note = '$contact_note', "; + $sql .= "last_mod_date = now(), "; + $sql .= "last_mod_user = '".$_SESSION['username']."' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and contact_note_uuid = '$contact_note_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $contact_note_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_contact_notes "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and contact_note_uuid = '$contact_note_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $contact_note = $row["contact_note"]; + $last_mod_date = $row["last_mod_date"]; + $last_mod_user = $row["last_mod_user"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Add NotesEdit Notes
\n"; + echo " Notes:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " \n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/contacts/contact_phones.php b/app/contacts/contact_phones.php new file mode 100644 index 0000000000..d754c53fcf --- /dev/null +++ b/app/contacts/contact_phones.php @@ -0,0 +1,154 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('contacts_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get variables used to control the order + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + //echo "
"; + //echo "\n"; + //echo "\n"; + //echo " "; + //echo ""; + //echo "
\n"; + //echo "
"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + echo "
Phone Numbers 
\n"; + //echo " List of phone numbers for the contact.

\n"; + //echo "
\n"; + + //prepare to page the results + $sql = " select count(*) as num_rows from v_contact_phones "; + $sql .= " where domain_uuid = '$domain_uuid' "; + $sql .= " and contact_uuid = '$contact_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + + //prepare to page the results + $rows_per_page = 10; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + //get the contact list + $sql = " select * from v_contact_phones "; + $sql .= " where domain_uuid = '$domain_uuid' "; + $sql .= " and contact_uuid = '$contact_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo th_order_by('phone_type', 'Type', $order_by, $order); + echo th_order_by('phone_number', 'Numbers', $order_by, $order); + echo "\n"; + echo "\n"; + echo "\n"; + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
Tools\n"; + echo " $v_link_label_add\n"; + echo "
".$row['phone_type']." ".format_phone($row['phone_number'])." CDR \n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + echo "
\n"; + echo "
"; + echo "
"; + + //echo "
"; + //echo "
"; + //echo "

"; + +//include the footer + //require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/contacts/contact_phones_delete.php b/app/contacts/contact_phones_delete.php new file mode 100644 index 0000000000..fe8dadf675 --- /dev/null +++ b/app/contacts/contact_phones_delete.php @@ -0,0 +1,61 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('contacts_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); + $contact_uuid = check_str($_GET["contact_uuid"]); +} + +if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_contact_phones "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and contact_phone_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); +} + +require_once "includes/header.php"; +echo "\n"; +echo "
\n"; +echo "Delete Complete\n"; +echo "
\n"; + +require_once "includes/footer.php"; +return; + +?> \ No newline at end of file diff --git a/app/contacts/contact_phones_edit.php b/app/contacts/contact_phones_edit.php new file mode 100644 index 0000000000..8ea657b46b --- /dev/null +++ b/app/contacts/contact_phones_edit.php @@ -0,0 +1,320 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('contacts_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $contact_phone_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +if (strlen($_GET["contact_uuid"]) > 0) { + $contact_uuid = check_str($_GET["contact_uuid"]); +} + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $phone_type = check_str($_POST["phone_type"]); + $phone_number = check_str($_POST["phone_number"]); + + //remove any phone number formatting + $phone_number = preg_replace('{\D}', '', $phone_number); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $contact_phone_uuid = check_str($_POST["contact_phone_uuid"]); + } + + //check for all required data + //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + //if (strlen($phone_type) == 0) { $msg .= "Please provide: Telephone Type.
\n"; } + //if (strlen($phone_number) == 0) { $msg .= "Please provide: Telephone Number
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $contact_phone_uuid = uuid(); + $sql = "insert into v_contact_phones "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "contact_uuid, "; + $sql .= "contact_phone_uuid, "; + $sql .= "phone_type, "; + $sql .= "phone_number "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$contact_uuid', "; + $sql .= "'$contact_phone_uuid', "; + $sql .= "'$phone_type', "; + $sql .= "'$phone_number' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_contact_phones set "; + $sql .= "contact_uuid = '$contact_uuid', "; + $sql .= "phone_type = '$phone_type', "; + $sql .= "phone_number = '$phone_number' "; + $sql .= "where domain_uuid = '$domain_uuid'"; + $sql .= "and contact_phone_uuid = '$contact_phone_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $contact_phone_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_contact_phones "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and contact_phone_uuid = '$contact_phone_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $phone_type = $row["phone_type"]; + $phone_number = $row["phone_number"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Contacts Phone AddContacts Phone Edit
\n"; + echo "Telephone Numbers

\n"; + echo "
\n"; + echo " Telephone Type.:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the telephone type.\n"; + echo "
\n"; + echo " Telephone Number:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the telephone number.\n"; + echo "
\n"; + echo " \n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/contacts/contacts.php b/app/contacts/contacts.php new file mode 100644 index 0000000000..f7de7da1d5 --- /dev/null +++ b/app/contacts/contacts.php @@ -0,0 +1,224 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('contacts_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get the search criteria + $search_all = $_GET["search_all"]; + +//get variables used to control the order + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Contacts
\n"; + echo " The contact is a list of individuals and organizations.\n"; + echo "
\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "
\n"; + + //prepare to page the results + $sql = ""; + $sql .= " select count(*) as num_rows from v_contacts "; + $sql .= " where domain_uuid = '".$_SESSION['domain_uuid']."' "; + if (strlen($search_all) > 0) { + if (is_numeric($search_all)) { + $sql .= "and contact_uuid in (select contact_uuid from v_contact_phones where phone_number like '%".$search_all."%') \n"; + } + else { + $sql .= "and contact_uuid in (\n"; + $sql .= " select contact_uuid from v_contacts "; + $sql .= " where domain_uuid = '".$_SESSION['domain_uuid']."' \n"; + $sql .= " and (\n"; + $sql .= " contact_organization like '%".$search_all."%' or \n"; + $sql .= " contact_name_given like '%".$search_all."%' or \n"; + $sql .= " contact_name_family like '%".$search_all."%' or \n"; + $sql .= " contact_nickname like '%".$search_all."%' or \n"; + $sql .= " contact_title like '%".$search_all."%' or \n"; + $sql .= " contact_role like '%".$search_all."%' or \n"; + $sql .= " contact_email like '%".$search_all."%' or \n"; + $sql .= " contact_url like '%".$search_all."%' or \n"; + $sql .= " contact_time_zone like '%".$search_all."%' or \n"; + $sql .= " contact_note like '%".$search_all."%' or \n"; + $sql .= " contact_type like '%".$search_all."%'\n"; + $sql .= " )\n"; + $sql .= ")\n"; + } + } + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + + //prepare to page the results + $rows_per_page = 30; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + //get the list + $sql = " select * from v_contacts "; + $sql .= " where domain_uuid = '".$_SESSION['domain_uuid']."' "; + if (strlen($search_all) > 0) { + if (is_numeric($search_all)) { + $sql .= "and contact_uuid in (select contact_uuid from v_contact_phones where phone_number like '%".$search_all."%') \n"; + } + else { + $sql .= "and contact_uuid in (\n"; + $sql .= " select contact_uuid from v_contacts where domain_uuid = '".$_SESSION['domain_uuid']."' \n"; + $sql .= " and (\n"; + $sql .= " contact_organization like '%".$search_all."%' or \n"; + $sql .= " contact_name_given like '%".$search_all."%' or \n"; + $sql .= " contact_name_family like '%".$search_all."%' or \n"; + $sql .= " contact_nickname like '%".$search_all."%' or \n"; + $sql .= " contact_title like '%".$search_all."%' or \n"; + $sql .= " contact_role like '%".$search_all."%' or \n"; + $sql .= " contact_email like '%".$search_all."%' or \n"; + $sql .= " contact_url like '%".$search_all."%' or \n"; + $sql .= " contact_time_zone like '%".$search_all."%' or \n"; + $sql .= " contact_note like '%".$search_all."%' or \n"; + $sql .= " contact_type like '%".$search_all."%'\n"; + $sql .= " )\n"; + $sql .= ")\n"; + } + } + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo th_order_by('contact_type', 'Type', $order_by, $order); + echo th_order_by('contact_organization', 'Organization', $order_by, $order); + echo th_order_by('contact_name_given', 'First Name', $order_by, $order); + echo th_order_by('contact_name_family', 'Last Name', $order_by, $order); + echo th_order_by('contact_nickname', 'Nickname', $order_by, $order); + echo th_order_by('contact_title', 'Title', $order_by, $order); + echo th_order_by('contact_role', 'Role', $order_by, $order); + //echo th_order_by('contact_email', 'Email', $order_by, $order); + //echo th_order_by('contact_url', 'URL', $order_by, $order); + //echo th_order_by('contact_time_zone', 'Time Zone', $order_by, $order); + //echo th_order_by('contact_note', 'Notes', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo " $v_link_label_add\n"; + echo "
".ucwords($row['contact_type'])." ".$row['contact_organization']." ".$row['contact_name_given']." ".$row['contact_name_family']." ".$row['contact_nickname']." ".$row['contact_title']." ".$row['contact_role']." ".$row['contact_email']." ".$row['contact_url']." ".$row['contact_time_zone']." ".$row['contact_note']." \n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/contacts/contacts_delete.php b/app/contacts/contacts_delete.php new file mode 100644 index 0000000000..560abdd98a --- /dev/null +++ b/app/contacts/contacts_delete.php @@ -0,0 +1,86 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('contacts_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); +} + +if (strlen($id)>0) { + //delete a contact + $sql = "delete from v_contacts "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and contact_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($prep_statement, $sql); + + //delete addresses + $sql = "delete from v_contact_addresses "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and contact_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($prep_statement, $sql); + + //delete phones + $sql = ""; + $sql .= "delete from v_contact_phones "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and contact_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($prep_statement, $sql); + + //delete notes + $sql = ""; + $sql .= "delete from v_contact_notes "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and contact_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($prep_statement, $sql); +} + +//redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/contacts/contacts_edit.php b/app/contacts/contacts_edit.php new file mode 100644 index 0000000000..d32789a58b --- /dev/null +++ b/app/contacts/contacts_edit.php @@ -0,0 +1,481 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('contacts_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $contact_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $contact_type = check_str($_POST["contact_type"]); + $contact_organization = check_str($_POST["contact_organization"]); + $contact_name_given = check_str($_POST["contact_name_given"]); + $contact_name_family = check_str($_POST["contact_name_family"]); + $contact_nickname = check_str($_POST["contact_nickname"]); + $contact_title = check_str($_POST["contact_title"]); + $contact_role = check_str($_POST["contact_role"]); + $contact_email = check_str($_POST["contact_email"]); + $contact_url = check_str($_POST["contact_url"]); + $contact_time_zone = check_str($_POST["contact_time_zone"]); + $contact_note = check_str($_POST["contact_note"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $contact_uuid = check_str($_POST["contact_uuid"]); + } + + //check for all required data + //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + //if (strlen($contact_type) == 0) { $msg .= "Please provide: Type
\n"; } + //if (strlen($contact_organization) == 0) { $msg .= "Please provide: Organization
\n"; } + //if (strlen($contact_name_given) == 0) { $msg .= "Please provide: First Name
\n"; } + //if (strlen($contact_name_family) == 0) { $msg .= "Please provide: Last Name
\n"; } + //if (strlen($contact_nickname) == 0) { $msg .= "Please provide: Nickname
\n"; } + //if (strlen($contact_title) == 0) { $msg .= "Please provide: Title
\n"; } + //if (strlen($contact_role) == 0) { $msg .= "Please provide: Role
\n"; } + //if (strlen($) == 0) { $msg .= "Please provide: Contact Information
\n"; } + //if (strlen($contact_email) == 0) { $msg .= "Please provide: Email
\n"; } + //if (strlen($contact_url) == 0) { $msg .= "Please provide: URL
\n"; } + //if (strlen($) == 0) { $msg .= "Please provide: Additional Information
\n"; } + //if (strlen($contact_time_zone) == 0) { $msg .= "Please provide: Time Zone
\n"; } + //if (strlen($contact_note) == 0) { $msg .= "Please provide: Notes
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $contact_uuid = uuid(); + $sql = "insert into v_contacts "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "contact_uuid, "; + $sql .= "contact_type, "; + $sql .= "contact_organization, "; + $sql .= "contact_name_given, "; + $sql .= "contact_name_family, "; + $sql .= "contact_nickname, "; + $sql .= "contact_title, "; + $sql .= "contact_role, "; + $sql .= "contact_email, "; + $sql .= "contact_url, "; + $sql .= "contact_time_zone, "; + $sql .= "contact_note "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$_SESSION['domain_uuid']."', "; + $sql .= "'$contact_uuid', "; + $sql .= "'$contact_type', "; + $sql .= "'$contact_organization', "; + $sql .= "'$contact_name_given', "; + $sql .= "'$contact_name_family', "; + $sql .= "'$contact_nickname', "; + $sql .= "'$contact_title', "; + $sql .= "'$contact_role', "; + $sql .= "'$contact_email', "; + $sql .= "'$contact_url', "; + $sql .= "'$contact_time_zone', "; + $sql .= "'$contact_note' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_contacts set "; + $sql .= "contact_type = '$contact_type', "; + $sql .= "contact_organization = '$contact_organization', "; + $sql .= "contact_name_given = '$contact_name_given', "; + $sql .= "contact_name_family = '$contact_name_family', "; + $sql .= "contact_nickname = '$contact_nickname', "; + $sql .= "contact_title = '$contact_title', "; + $sql .= "contact_role = '$contact_role', "; + $sql .= "contact_email = '$contact_email', "; + $sql .= "contact_url = '$contact_url', "; + $sql .= "contact_time_zone = '$contact_time_zone', "; + $sql .= "contact_note = '$contact_note' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and contact_uuid = '$contact_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $contact_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_contacts "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and contact_uuid = '$contact_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $contact_type = $row["contact_type"]; + $contact_organization = $row["contact_organization"]; + $contact_name_given = $row["contact_name_given"]; + $contact_name_family = $row["contact_name_family"]; + $contact_nickname = $row["contact_nickname"]; + $contact_title = $row["contact_title"]; + $contact_role = $row["contact_role"]; + $contact_email = $row["contact_email"]; + $contact_url = $row["contact_url"]; + $contact_time_zone = $row["contact_time_zone"]; + $contact_note = $row["contact_note"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Contact AddContact Edit\n"; + echo " \n"; + echo " \n"; + if ($action == "update" && is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/invoices')) { + echo " \n"; + } + echo " \n"; + echo "
\n"; + echo "The contact is a list of individuals and organizations.

\n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + //echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + //echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
User Information 
\n"; + echo " Type:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Select the contact type.\n"; + echo "
\n"; + echo " Organization:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the organization.\n"; + echo "
\n"; + echo " First Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the given name.\n"; + echo "
\n"; + echo " Last Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the family name.\n"; + echo "
\n"; + echo " Nickname:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the nickname.\n"; + echo "
\n"; + echo " Title:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the title.\n"; + echo "
\n"; + echo " Role:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the role.\n"; + echo "
Contact Information 
\n"; + echo " Email:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the email address.\n"; + echo "
\n"; + echo " URL:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the website address.\n"; + echo "
Additional Information 
\n"; + echo " Time Zone:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the time zone.\n"; + echo "
\n"; + echo " Notes:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the notes.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo "
"; + + echo "
\n"; + //echo "

\n"; + if ($action == "update") { + require "contact_phones.php"; + require "contact_addresses.php"; + require "contact_notes.php"; + //echo "

\n"; + } + + echo "
\n"; + + if ($action == "update") { + echo "
\n"; + + } + + echo "
"; + echo "
"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/contacts/contacts_vcard.php b/app/contacts/contacts_vcard.php new file mode 100644 index 0000000000..a1838389b0 --- /dev/null +++ b/app/contacts/contacts_vcard.php @@ -0,0 +1,202 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('contacts_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + //create the vcard object + require_once "includes/class_vcard.php"; + $vcard = new vcard(); + + //get the contact id + $contact_uuid = $_GET["id"]; + + //get the contact's information + $sql = ""; + $sql .= "select * from v_contacts "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and contact_uuid = '$contact_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $contact_type = $row["contact_type"]; + $contact_organization = $row["contact_organization"]; + $contact_name_given = $row["contact_name_given"]; + $contact_name_family = $row["contact_name_family"]; + $contact_nickname = $row["contact_nickname"]; + $contact_title = $row["contact_title"]; + $contact_role = $row["contact_role"]; + $contact_email = $row["contact_email"]; + $contact_url = $row["contact_url"]; + $contact_time_zone = $row["contact_time_zone"]; + $contact_note = $row["contact_note"]; + break; //limit to 1 row + } + unset ($prep_statement); + + $vcard->data['company'] = $contact_organization; + $vcard->data['first_name'] = $contact_name_given; + $vcard->data['last_name'] = $contact_name_family; + $vcard->data['contact_email1'] = $contact_email; + $vcard->data['contact_url'] = $contact_url; + + if ($_GET['type'] == "image" || $_GET['type'] == "html") { + //don't add this to the QR code at this time + } + else { + $vcard->data['display_name'] = $contact_name_given." ".$contact_name_family; + $vcard->data['contact_nickname'] = $contact_nickname; + $vcard->data['contact_title'] = $contact_title; + $vcard->data['contact_role'] = $contact_role; + $vcard->data['timezone'] = $contact_time_zone; + $vcard->data['contact_note'] = $contact_note; + } + + //get the contact's telephone numbers + $sql = ""; + $sql .= "select * from v_contact_phones "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and contact_uuid = '$contact_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $phone_type = $row["phone_type"]; + $phone_number = $row["phone_number"]; + $vcard->data[$phone_type.'_tel'] = $phone_number; + } + unset ($prep_statement); + + //get the contact's addresses + if ($_GET['type'] == "image" || $_GET['type'] == "html") { + //don't add this to the QR code at this time + } + else { + $sql = ""; + $sql .= "select * from v_contact_addresses "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and contact_uuid = '$contact_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $address_type = $row["address_type"]; + $address_street = $row["address_street"]; + $address_extended = $row["address_extended"]; + $address_locality = $row["address_locality"]; + $address_region = $row["address_region"]; + $address_postal_code = $row["address_postal_code"]; + $address_country = $row["address_country"]; + $address_latitude = $row["address_latitude"]; + $address_longitude = $row["address_longitude"]; + $address_type = strtolower(trim($address_type)); + + $vcard->data[$address_type.'_address'] = $address_street; + $vcard->data[$address_type.'_extended_address'] = $address_extended; + $vcard->data[$address_type.'_city'] = $address_locality; + $vcard->data[$address_type.'_state'] = $address_region; + $vcard->data[$address_type.'_postal_code'] = $address_postal_code; + $vcard->data[$address_type.'_country'] = $address_country; + } + unset ($prep_statement); + } + + //download the vcard + if ($_GET['type'] == "download") { + $vcard->download(); + } + + //show the vcard in an text qr code + if ($_GET['type'] == "text") { + $vcard->build(); + $content = $vcard->card; + echo $content; + } + + //show the vcard in an image qr code + if ($_GET['type'] == "image" || $_GET['type'] == "html") { + $vcard->build(); + $content = $vcard->card; + + //include + require_once "includes/qr/qrcode.php"; + + //error correction level + //QR_ERROR_CORRECT_LEVEL_L : $e = 0; + //QR_ERROR_CORRECT_LEVEL_M : $e = 1; + //QR_ERROR_CORRECT_LEVEL_Q : $e = 2; + //QR_ERROR_CORRECT_LEVEL_H : $e = 3; + + //get the qr object + $qr = QRCode::getMinimumQRCode($content, QR_ERROR_CORRECT_LEVEL_L); + } + + //show the vcard as an png image + if ($_GET['type'] == "image") { + header("Content-type: image/png"); + $im = $qr->createImage(5, 10); + imagepng($im); + imagedestroy($im); + } + + //show the vcard in an html qr code + if ($_GET['type'] == "html") { + $qr->make(); + $qr->printHTML(); + } +} + +/* +//additional un accounted fields +additional_name +name_prefix +name_suffix +department +work_po_box +home_po_box +home_extended_address +home_address +home_city +home_state +home_postal_code +home_country +pager_tel +contact_email2 +photo +birthday +sort_string +*/ + +?> \ No newline at end of file diff --git a/app/contacts/root.php b/app/contacts/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/contacts/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/content/app_config.php b/app/content/app_config.php new file mode 100644 index 0000000000..3cbe6cfd13 --- /dev/null +++ b/app/content/app_config.php @@ -0,0 +1,351 @@ + \ No newline at end of file diff --git a/app/content/config.php b/app/content/config.php new file mode 100644 index 0000000000..9a8794e676 --- /dev/null +++ b/app/content/config.php @@ -0,0 +1,32 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +$module_title = 'Content'; +$rss_category = 'content'; + +$rss_sub_show = 0; //1 = yes, 0 = no +$rss_sub_title = 'Content'; +?> \ No newline at end of file diff --git a/app/content/index.php b/app/content/index.php new file mode 100644 index 0000000000..5c6fdd0a2f --- /dev/null +++ b/app/content/index.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +return; //disable + +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('content_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +require_once "config.php"; +session_start(); + +require_once "includes/header.php"; +echo "\n"; + +$_GET["c"] = "html"; +require_once "rss.php"; +require_once "includes/footer.php"; + +return; +?> diff --git a/app/content/root.php b/app/content/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/content/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/content/rss.css b/app/content/rss.css new file mode 100644 index 0000000000..cfe4385064 --- /dev/null +++ b/app/content/rss.css @@ -0,0 +1,44 @@ +rss { + display: block; + font-family: verdana, arial; +} + +title { + display: block; + margin: 5px; + padding: 2px; + color: #77A3EF; + border-bottom: 1px solid #77A3EF; +} + +link { + display: block; + font-size: small; + padding-left: 10px; +} + +description { + display: block; + font-size: small; + padding-left: 10px; +} + +item { + display: block; + padding: 2px 30px 2px 30px; +} + +description { + display: block; + background-color: #FCFCFC; + margin: 20px; + text-align: left; + padding: 5px; + color: #7f7f7f; + border: 1px solid #EEEEEE; +} + +/* all hidden elements */ +language, lastBuildDate, ttl, guid, category, pubDate, copyright, webmaster, comments { + display: none; +} diff --git a/app/content/rss.php b/app/content/rss.php new file mode 100644 index 0000000000..fff631d105 --- /dev/null +++ b/app/content/rss.php @@ -0,0 +1,244 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +return; //disable +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "config.php"; +if (permission_exists('content_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//include module specific information +if (strlen($mod_config_path)==0) { + include "config.php"; +} +else { + //$mod_config_path = "/news"; //examples + //$mod_config_path = "/app/news"; //examples + include $mod_config_path.'/config.php'; +} + +$rss_css_url = 'http://'.$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"]; +$rss_css_url = str_replace ("rss.php", "rss.css", $rss_css_url); +$content_type = $_GET["c"]; +//echo "contenttype $content_type"; +if (strlen($_GET["rss_category"]) > 0) { + $rss_category = $_GET["rss_category"]; +} +if (strlen($content_type) == 0) { + $content_type = "rss"; //define default contenttype +} +if ($content_type == "html") { + session_start(); +} +//echo $rss_css_url; +//exit; + +if ($content_type == "rss") { + header('Content-Type: text/xml'); + echo ''; + echo ''; + //echo ''; + //echo "\n"; + echo "\n"; + echo "\n"; + + echo "$module_title RSS Feed\n"; + //echo "http://www.xul.fr/\n"; + echo "Task List for RSS...\n"; + echo "en-US\n"; + //echo "\n"; + //echo "\n"; + //echo " http://www.xul.fr/xul-icon.gif\n"; + //echo " http://www.xul.fr/index.html\n"; + //echo ""; +} + +$sql = ""; +$sql .= "select * from v_rss "; +$sql .= "where rss_category = '$rss_category' "; +$sql .= "and length(rss_del_date) = 0 "; +$sql .= "or rss_category = '$rss_category' "; +$sql .= "and rss_del_date is null "; +$sql .= "order by rss_uuid asc "; +$prep_statement = $db->prepare(check_sql($sql)); +$prep_statement->execute(); + +$last_cat = ""; +$count = 0; +$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); +foreach ($result as &$row) { + + $rss_uuid = $row["rss_uuid"]; + $rss_title = $row["rss_title"]; + $rss_description = $row["rss_description"]; + $rss_link = $row["rss_link"]; + + //$rss_description = $row[rss_sub_description]; + //$rss_description = str_replace ("\r\n", "
", $rss_description); + //$rss_description = str_replace ("\n", "
", $rss_description); + + if ($content_type == "rss") { + $rss_title = htmlentities($rss_title); + $rss_description = htmlentities($rss_description); + + echo "\n"; + echo "".$rss_title."\n"; + echo "".$rss_description."\n"; + echo "".$rss_link."\n"; + //echo "12 Mar 2007 19:38:06 GMT\n"; + //echo "http://www.google.com/log/123\n"; + //echo "http://www.google.com/log/121#comments\n"; + //echo "Web Design"; + echo "\n"; + echo "\n"; + + } + else { + if (strlen($rss_link) > 0) { + echo "".$rss_title."
\n"; + } + else { + echo "".$rss_title."
\n"; + } + echo "".$rss_description."\n"; + echo "

"; + + if ($rss_sub_show == 1) { + //--- Begin Sub List ------------------------------------------------------- + + echo "


"; + echo "$rss_sub_title
"; + + $sql = ""; + $sql .= "select * from v_rss_sub "; + $sql .= "where rss_uuid = '$rss_uuid' "; + $sql .= "and length(rss_sub_del_date) = 0 "; + $sql .= "or rss_uuid = '$rss_uuid' "; + $sql .= "and rss_sub_del_date is null "; + + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + + $prep_statement_2 = $db->prepare($sql); + $prep_statement_2->execute(); + $result2 = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count2 = count($result2); + + $c2 = 0; + $row_style["0"] = "background-color: #F5F5DC;"; + $row_style["1"] = "background-color: #FFFFFF;"; + + echo "
\n"; + //echo " Notes"; + echo "\n"; + //echo ""; + if ($result_count == 0) { //no results + echo ""; + } + else { + echo "\n"; + + foreach($result2 as $row2) { + echo "\n"; + //echo ""; + //echo ""; + //echo ""; + echo ""; + + echo ""; + + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + + $rss_sub_description = $row2[rss_sub_description]; + //$rss_sub_description = str_replace ("\r\n", "
", $rss_sub_description); + //$rss_sub_description = str_replace ("\n", "
", $rss_sub_description); + + + echo ""; + echo "\n"; + echo ""; + + echo ""; + + echo "\n"; + if ($c2==0) { $c2=1; } else { $c2=0; } + } //end foreach + unset($sql, $result, $row_count); + + echo "
 
".$rss_uuid." ".$row2[rss_sub_title]."  ".$row2[rss_sub_link]." "; + echo " ".$row2[rss_sub_title].""; + echo "".$row2[rss_sub_add_date]."".$row2[rss_sub_optional_1]."".$row2[rss_sub_optional_2]."".$row2[rss_sub_optional_3]."".$row2[rss_sub_optional_4]."".$row2[rss_sub_optional_5]."".$row2[rss_sub_add_user].""; + echo "  "; + //echo " "; + echo "   \n"; + //echo " Update "; + echo "
"; + echo "".$rss_sub_description." "; + echo "
\n"; + echo "
\n"; + + + echo "

"; + echo "
\n"; + //--- End Sub List ------------------------------------------------------- + } + } + + + //echo "\n"; + //echo " ".$row["favname"]."\n"; + //echo "".$row["favdesc"]."\n"; + //echo "".$row["favurl"]."\n"; + //echo "\n"; + + //$last_cat = $row["favcat"]; + $count++; + +} + +if ($content_type == "rss") { + echo "\n"; + echo "\n"; + echo "\n"; +} + +?> \ No newline at end of file diff --git a/app/content/rssadd.php b/app/content/rssadd.php new file mode 100644 index 0000000000..0a831029ea --- /dev/null +++ b/app/content/rssadd.php @@ -0,0 +1,347 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "config.php"; +if (permission_exists('content_add')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_POST)>0) { + + //get the http values and set them as variables + $rss_sub_category = check_str($_POST["rss_sub_category"]); + $rss_title = check_str($_POST["rss_title"]); + $rss_link = check_str($_POST["rss_link"]); + $rss_description = check_str($_POST["rss_description"]); + $rss_img = check_str($_POST["rss_img"]); + $rss_optional_1 = check_str($_POST["rss_optional_1"]); + $rss_optional_2 = check_str($_POST["rss_optional_2"]); + $rss_optional_3 = check_str($_POST["rss_optional_3"]); + $rss_optional_4 = check_str($_POST["rss_optional_4"]); + $rss_optional_5 = check_str($_POST["rss_optional_5"]); + $rss_group = check_str($_POST["rss_group"]); + $rss_order = check_str($_POST["rss_order"]); + + //insert the data into the database + $rss_uuid = uuid(); + $sql = "insert into v_rss "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "rss_uuid, "; + $sql .= "rss_category, "; + $sql .= "rss_sub_category, "; + $sql .= "rss_title, "; + $sql .= "rss_link, "; + $sql .= "rss_description, "; + $sql .= "rss_img, "; + $sql .= "rss_optional_1, "; + $sql .= "rss_optional_2, "; + $sql .= "rss_optional_3, "; + $sql .= "rss_optional_4, "; + $sql .= "rss_optional_5, "; + $sql .= "rss_group, "; + $sql .= "rss_order, "; + $sql .= "rss_add_date, "; + $sql .= "rss_add_user "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$rss_uuid', "; + $sql .= "'$rss_category', "; + $sql .= "'$rss_sub_category', "; + $sql .= "'$rss_title', "; + $sql .= "'$rss_link', "; + $sql .= "'$rss_description', "; + $sql .= "'$rss_img', "; + $sql .= "'$rss_optional_1', "; + $sql .= "'$rss_optional_2', "; + $sql .= "'$rss_optional_3', "; + $sql .= "'$rss_optional_4', "; + $sql .= "'$rss_optional_5', "; + $sql .= "'$rss_group', "; + $sql .= "'$rss_order', "; + $sql .= "now(), "; + $sql .= "'".$_SESSION["username"]."' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
"; + echo "Add Complete"; + echo "
"; + require_once "includes/footer.php"; + return; +} + + require_once "includes/header.php"; + if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/tiny_mce')) { + if ($rss_optional_1 == "text/html") { + require_once "includes/wysiwyg.php"; + } + } + else { + //--- Begin: Edit Area ----------------------------------------------------- + echo " \n"; + echo " \n"; + + echo " "; + //--- End: Edit Area ------------------------------------------------------- + } + + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + + echo "
"; + echo ""; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo " "; + + /* + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + */ + + echo " "; + echo " "; + echo " "; + echo " "; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " "; + //echo " "; + echo " "; + echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + + echo " "; + echo " "; + echo " "; + echo "
Content Add

Category:
Sub Category:
Title:
Link:
Group:"; + //echo " "; + + //---- Begin Select List -------------------- + $sql = "SELECT * FROM v_groups "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + + echo ""; + unset($sql, $result); + //---- End Select List -------------------- + + echo "
\n"; + echo " Template: \n"; + echo " \n"; + echo "\n"; + echo "
\n"; + echo " Select a template to set as the default and then press save.
\n"; + echo "
Type:"; + echo " "; + echo "
\n"; + echo " Order:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "
"; + echo " Content: "; + if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/tiny_mce')) { + echo "       editor   on/off
"; + } + else { + echo " "; + } + echo "
Image:
Priority:"; + //echo " "; + //echo " "; + //echo "
Status:"; + //echo " "; + //echo " "; + //echo "
Optional 3:
Optional 4:
rss_optional_5:
rss_add_date:
"; + echo " \n"; + echo "
"; + echo "
"; + + + echo "
"; + echo "
"; + + +require_once "includes/footer.php"; +?> diff --git a/app/content/rsscontent.php b/app/content/rsscontent.php new file mode 100644 index 0000000000..07cd5f98ac --- /dev/null +++ b/app/content/rsscontent.php @@ -0,0 +1,74 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "config.php"; +if (permission_exists('content_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + + +//get data from the db +$rss_uuid = $_REQUEST["rss_uuid"]; + +$sql = ""; +$sql .= "select * from v_rss "; +$sql .= "where domain_uuid = '$domain_uuid' "; +$sql .= "and rss_uuid = '$rss_uuid' "; +//echo $sql; +$prep_statement = $db->prepare(check_sql($sql)); +$prep_statement->execute(); +$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); +foreach ($result as &$row) { + $rss_category = $row["rss_category"]; + $rss_sub_category = $row["rss_sub_category"]; + $rss_title = $row["rss_title"]; + $rss_link = $row["rss_link"]; + $rss_description = $row["rss_description"]; + $rss_img = $row["rss_img"]; + $rss_optional_1 = $row["rss_optional_1"]; + $rss_optional_2 = $row["rss_optional_2"]; + $rss_optional_3 = $row["rss_optional_3"]; + $rss_optional_4 = $row["rss_optional_4"]; + $rss_optional_5 = $row["rss_optional_5"]; + $rss_add_date = $row["rss_add_date"]; + $rss_add_user = $row["rss_add_user"]; + $rss_group = $row["rss_group"]; + $rss_order = $row["rss_order"]; + //$rss_description = str_replace ("\r\n", "
", $rss_description); + + echo $rss_description; + //return; + + break; //limit to 1 row +} + +?> diff --git a/app/content/rssdelete.php b/app/content/rssdelete.php new file mode 100644 index 0000000000..496e3cd954 --- /dev/null +++ b/app/content/rssdelete.php @@ -0,0 +1,62 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "config.php"; +if (permission_exists('content_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + + +if (count($_GET)>0) { + $rss_uuid = check_str($_GET["rss_uuid"]); + + //mark the the item as deleted and who deleted it + $sql = "update v_rss set "; + $sql .= "rss_del_date = now(), "; + $sql .= "rss_del_user = '".$_SESSION["username"]."' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and rss_uuid = '$rss_uuid' "; + $sql .= "and rss_category = '$rss_category' "; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
"; + echo "Delete Completed"; + echo "
"; + require_once "includes/footer.php"; + return; +} + + +?> diff --git a/app/content/rsslist.php b/app/content/rsslist.php new file mode 100644 index 0000000000..b28fd6131d --- /dev/null +++ b/app/content/rsslist.php @@ -0,0 +1,217 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "config.php"; +if (permission_exists('content_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (!function_exists('th_order_by')) { + //html table header order by + function th_order_by($field_name, $columntitle, $order_by, $order) { + + $html .= "    "; + if (strlen($order_by)==0) { + $html .= "$columntitle"; + } + else { + if ($order=="asc") { + $html .= "$columntitle"; + } + else { + $html .= "$columntitle"; + } + } + $html .= "    "; + + return $html; + } +} + +require_once "includes/header.php"; +echo "\n"; + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + + + echo "
"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "
\n"; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "
"; + echo " $module_title List"; + echo ""; + //echo "    \n"; + echo "
"; + + $sql = ""; + $sql .= "select * from v_rss "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and rss_category = '$rss_category' "; + $sql .= "and length(rss_del_date) = 0 "; + $sql .= "or domain_uuid = '$domain_uuid' "; + $sql .= "and rss_category = '$rss_category' "; + $sql .= "and rss_del_date is null "; + if (strlen($order_by)> 0) { + $sql .= "order by $order_by $order "; + } + else { + $sql .= "order by rss_order asc "; + } + //echo $sql; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo ""; + echo th_order_by('rss_title', 'Title', $order_by, $order); + echo th_order_by('rss_link', 'Link', $order_by, $order); + //echo th_order_by('rss_sub_category', 'Template', $order_by, $order); + echo th_order_by('rss_group', 'Group', $order_by, $order); + echo th_order_by('rss_order', 'Order', $order_by, $order); + if ($result_count == 0) { //no results + echo "\n"; + echo ""; + + if ($result_count > 0) { + foreach($result as $row) { + //print_r( $row ); + echo "\n"; + //echo ""; + //echo ""; + + echo ""; + echo ""; + //echo ""; + if (strlen($row[rss_group]) > 0) { + echo ""; + } + else { + echo ""; + } + + //echo ""; + //echo ""; + //echo ""; //priority + + //echo ""; //completion status + + //echo ""; + //echo ""; + //echo ""; + echo ""; + + //echo ""; + + echo " \n"; + + //echo ""; + + echo ""; + + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + } + else { + echo "\n"; + } + echo " $v_link_label_add\n"; + echo "
".$row[rss_uuid]."".$row[rss_category]." ".$row[rss_title]."  ".$row[rss_link]." ".$row[rss_sub_category]." ".$row[rss_group]."public".$row[rss_description]."".$row[rss_img]." ".$row[rss_optional_1]."  "; + //sif ($row[rss_optional_2]=="100") { + // echo "Complete"; + //} + //else { + // echo $row[rss_optional_2]."%"; + //} + //echo " ".$row[rss_optional_3]."".$row[rss_optional_4]."".$row[rss_optional_5]."".$row[rss_order]." "; + //echo " "; + //echo " "; + //echo "\n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + echo " "; + //echo " "; + //echo "
\n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + echo "
\n"; + + echo "
\n"; + echo "
\n"; + + echo "
"; + echo "
\n"; + //echo "   \n"; + //echo "   \n"; + echo "
"; + + echo "

"; + require_once "includes/footer.php"; + + unset ($result_count); + unset ($result); + unset ($key); + unset ($val); + unset ($c); + +?> diff --git a/app/content/rssmovedown.php b/app/content/rssmovedown.php new file mode 100644 index 0000000000..05e91f8862 --- /dev/null +++ b/app/content/rssmovedown.php @@ -0,0 +1,92 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "config.php"; +if (permission_exists('content_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//move down more than one level at a time +//update v_rss set rss_order = (rss_order+1) where rss_order > 2 or rss_order = 2 + +if (count($_GET)>0) { + $rss_uuid = check_str($_GET["rss_uuid"]); + $rss_order = check_str($_GET["rss_order"]); + + $sql = "SELECT rss_order FROM v_rss "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and rss_category = '$rss_category' "; + $sql .= "order by rss_order desc "; + $sql .= "limit 1 "; + //echo $sql."

"; + //return; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + //print_r( $row ); + $highestrss_order = $row[rss_order]; + } + unset($prep_statement); + + if ($rss_order != $highestrss_order) { + //move the current item's order number up + $sql = "update v_rss set "; + $sql .= "rss_order = (rss_order-1) "; //move down + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and rss_order = ".($rss_order+1)." "; + $sql .= "and rss_category = '$rss_category' "; + //echo $sql."

"; + $db->exec(check_sql($sql)); + unset($sql); + + //move the selected item's order number down + $sql = "update v_rss set "; + $sql .= "rss_order = (rss_order+1) "; //move up + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and rss_uuid = '$rss_uuid' "; + $sql .= "and rss_category = '$rss_category' "; + //echo $sql."

"; + $db->exec(check_sql($sql)); + unset($sql); + } + require_once "includes/header.php"; + echo "\n"; + echo "
"; + echo "Item Moved Down"; + echo "
"; + require_once "includes/footer.php"; + return; +} + + +?> diff --git a/app/content/rssmoveup.php b/app/content/rssmoveup.php new file mode 100644 index 0000000000..e2a4032673 --- /dev/null +++ b/app/content/rssmoveup.php @@ -0,0 +1,76 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "config.php"; +if (permission_exists('content_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//move down more than one level at a time +//update v_rss set rss_order = (rss_order+1) where rss_order > 2 or rss_order = 2 + +if (count($_GET)>0) { + $rss_uuid = check_str($_GET["rss_uuid"]); + $rss_order = check_str($_GET["rss_order"]); + if ($rss_order != 1) { + //move the current item's order number down + $sql = "update v_rss set "; + $sql .= "rss_order = (rss_order+1) "; //move down + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and rss_order = ".($rss_order-1)." "; + $sql .= "and rss_category = '$rss_category' "; + //echo $sql."

"; + $db->exec(check_sql($sql)); + unset($sql); + + + //move the selected item's order number up + $sql = "update v_rss set "; + $sql .= "rss_order = (rss_order-1) "; //move up + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and rss_uuid = '$rss_uuid' "; + $sql .= "and rss_category = '$rss_category' "; + //echo $sql."

"; + $db->exec(check_sql($sql)); + unset($sql); + } + require_once "includes/header.php"; + echo "\n"; + echo "
"; + echo "Item Moved Up"; + echo "
"; + require_once "includes/footer.php"; + return; +} + + +?> diff --git a/app/content/rsssearch.php b/app/content/rsssearch.php new file mode 100644 index 0000000000..b1c1dcdd40 --- /dev/null +++ b/app/content/rsssearch.php @@ -0,0 +1,277 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +return; //disabled + +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "config.php"; +if (permission_exists('content_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_POST)>0) { + $rss_uuid = check_str($_POST["rss_uuid"]); + //$rss_category = check_str($_POST["rss_category"]); //defined in local config.php + $rss_sub_category = check_str($_POST["rss_sub_category"]); + $rss_title = check_str($_POST["rss_title"]); + $rss_link = check_str($_POST["rss_link"]); + $rss_description = check_str($_POST["rss_description"]); + $rss_img = check_str($_POST["rss_img"]); + $rss_optional_1 = check_str($_POST["rss_optional_1"]); + $rss_optional_2 = check_str($_POST["rss_optional_2"]); + $rss_optional_3 = check_str($_POST["rss_optional_3"]); + $rss_optional_4 = check_str($_POST["rss_optional_4"]); + $rss_optional_5 = check_str($_POST["rss_optional_5"]); + $rss_add_date = check_str($_POST["rss_add_date"]); + $rss_add_user = check_str($_POST["rss_add_user"]); + + require_once "includes/header.php"; + + + + echo "
"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + + } //end if results + + echo "
\n"; + echo "
"; + + + $sql = ""; + $sql .= "select * from v_rss "; + $sql .= "where "; + if (strlen($rss_uuid) > 0) { $sql .= "and rss_uuid like '%$rss_uuid%' "; } + if (strlen($rss_category) > 0) { $sql .= "and rss_category like '%$rss_category%' "; } + if (strlen($rss_sub_category) > 0) { $sql .= "and rss_sub_category like '%$rss_sub_category%' "; } + if (strlen($rss_title) > 0) { $sql .= "and rss_title like '%$rss_title%' "; } + if (strlen($rss_link) > 0) { $sql .= "and rss_link like '%$rss_link%' "; } + if (strlen($rss_description) > 0) { $sql .= "and rss_description like '%$rss_description%' "; } + if (strlen($rss_img) > 0) { $sql .= "and rss_img like '%$rss_img%' "; } + if (strlen($rss_optional_1) > 0) { $sql .= "and rss_optional_1 like '%$rss_optional_1%' "; } + if (strlen($rss_optional_2) > 0) { $sql .= "and rss_optional_2 like '%$rss_optional_2%' "; } + if (strlen($rss_optional_3) > 0) { $sql .= "and rss_optional_3 like '%$rss_optional_3%' "; } + if (strlen($rss_optional_4) > 0) { $sql .= "and rss_optional_4 like '%$rss_optional_4%' "; } + if (strlen($rss_optional_5) > 0) { $sql .= "and rss_optional_5 like '%$rss_optional_5%' "; } + if (strlen($rss_add_date) > 0) { $sql .= "and rss_add_date like '%$rss_add_date%' "; } + if (strlen($rss_add_user) > 0) { $sql .= "and rss_add_user like '%$rss_add_user%' "; } + $sql .= "and length(rss_del_date) = 0 "; + $sql .= "or "; + if (strlen($rss_uuid) > 0) { $sql .= "and rss_uuid like '%$rss_uuid%' "; } + if (strlen($rss_category) > 0) { $sql .= "and rss_category like '%$rss_category%' "; } + if (strlen($rss_sub_category) > 0) { $sql .= "and rss_sub_category like '%$rss_sub_category%' "; } + if (strlen($rss_title) > 0) { $sql .= "and rss_title like '%$rss_title%' "; } + if (strlen($rss_link) > 0) { $sql .= "and rss_link like '%$rss_link%' "; } + if (strlen($rss_description) > 0) { $sql .= "and rss_description like '%$rss_description%' "; } + if (strlen($rss_img) > 0) { $sql .= "and rss_img like '%$rss_img%' "; } + if (strlen($rss_optional_1) > 0) { $sql .= "and rss_optional_1 like '%$rss_optional_1%' "; } + if (strlen($rss_optional_2) > 0) { $sql .= "and rss_optional_2 like '%$rss_optional_2%' "; } + if (strlen($rss_optional_3) > 0) { $sql .= "and rss_optional_3 like '%$rss_optional_3%' "; } + if (strlen($rss_optional_4) > 0) { $sql .= "and rss_optional_4 like '%$rss_optional_4%' "; } + if (strlen($rss_optional_5) > 0) { $sql .= "and rss_optional_5 like '%$rss_optional_5%' "; } + if (strlen($rss_add_date) > 0) { $sql .= "and rss_add_date like '%$rss_add_date%' "; } + if (strlen($rss_add_user) > 0) { $sql .= "and rss_add_user like '%$rss_add_user%' "; } + $sql .= "and rss_del_date is null "; + + $sql = trim($sql); + if (substr($sql, -5) == "where"){ $sql = substr($sql, 0, (strlen($sql)-5)); } + if (substr($sql, -3) == " or"){ $sql = substr($sql, 0, (strlen($sql)-5)); } + $sql = str_replace ("where and", "where", $sql); + $sql = str_replace ("or and", "or", $sql); + //echo $sql; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + $c = 0; + $row_style["0"] = "background-color: #F5F5DC;"; + $row_style["1"] = "background-color: #FFFFFF;"; + + echo "Search Results
"; + echo "
\n"; + echo "\n"; + echo ""; + + if ($result_count == 0) { //no results + echo ""; + } + else { //received results + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + echo "\n"; + + foreach($result as $row) { + //print_r( $row ); + echo "\n"; + echo ""; + echo ""; + echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach unset($sql, $result, $row_count); + + echo "
 
    ID        Category        Sub Category        Title        rss_link        rss_description        rss_img        rss_optional_1        rss_optional_2        rss_optional_3        rss_optional_4        rss_optional_5        rss_add_date        rss_add_user   
".$row[rss_uuid]."".$row[rss_category]."".$row[rss_sub_category]."".$row[rss_title]."".$row[rss_link]."".$row[rss_description]."".$row[rss_img]."".$row[rss_optional_1]."".$row[rss_optional_2]."".$row[rss_optional_3]."".$row[rss_optional_4]."".$row[rss_optional_5]."".$row[rss_add_date]."".$row[rss_add_user]."
\n"; + echo "
\n"; + + + echo "

"; + echo "
\n"; + echo "
"; + + echo "

"; + require_once "includes/footer.php"; + + unset ($result_count); + unset ($result); + unset ($key); + unset ($val); + unset ($c); + + } + else { + + echo "\n"; require_once "includes/header.php"; + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + echo " "; + echo " "; + echo " "; + echo "
Id:
Category:
rss_sub_category:
Title:
Link:
Desc:
Image:
rss_optional_1:
rss_optional_2:
rss_optional_3:
rss_optional_4:
rss_optional_5:
rss_add_date:
rss_add_user:
"; + echo "
"; + + + echo "
"; + echo "
"; + + +require_once "includes/footer.php"; + +} //end if not post +?> diff --git a/app/content/rsssubadd.php b/app/content/rsssubadd.php new file mode 100644 index 0000000000..af92000410 --- /dev/null +++ b/app/content/rsssubadd.php @@ -0,0 +1,174 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "config.php"; +if (permission_exists('content_add')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$rss_uuid = $_GET["rss_uuid"]; + +if (count($_POST)>0) { + $rss_uuid = check_str($_POST["rss_uuid"]); + $rss_sub_title = check_str($_POST["rss_sub_title"]); + $rss_sub_link = check_str($_POST["rss_sub_link"]); + $rss_sub_description = check_str($_POST["rss_sub_description"]); + $rss_sub_optional_1 = check_str($_POST["rss_sub_optional_1"]); + $rss_sub_optional_2 = check_str($_POST["rss_sub_optional_2"]); + $rss_sub_optional_3 = check_str($_POST["rss_sub_optional_3"]); + $rss_sub_optional_4 = check_str($_POST["rss_sub_optional_4"]); + $rss_sub_optional_5 = check_str($_POST["rss_sub_optional_5"]); + $rss_sub_add_date = check_str($_POST["rss_sub_add_date"]); + $rss_sub_add_user = check_str($_POST["rss_sub_add_user"]); + + $rss_sub_uuid = uuid(); + $sql = "insert into v_rss_sub "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "rss_uuid, "; + $sql .= "rss_sub_uuid, "; + $sql .= "rss_sub_title, "; + $sql .= "rss_sub_link, "; + $sql .= "rss_sub_description, "; + $sql .= "rss_sub_optional_1, "; + $sql .= "rss_sub_optional_2, "; + $sql .= "rss_sub_optional_3, "; + $sql .= "rss_sub_optional_4, "; + $sql .= "rss_sub_optional_5, "; + $sql .= "rss_sub_add_date, "; + $sql .= "rss_sub_add_user "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$rss_uuid', "; + $sql .= "'$rss_sub_uuid', "; + $sql .= "'$rss_sub_title', "; + $sql .= "'$rss_sub_link', "; + $sql .= "'$rss_sub_description', "; + $sql .= "'$rss_sub_optional_1', "; + $sql .= "'$rss_sub_optional_2', "; + $sql .= "'$rss_sub_optional_3', "; + $sql .= "'$rss_sub_optional_4', "; + $sql .= "'$rss_sub_optional_5', "; + $sql .= "now(), "; + $sql .= "'".$_SESSION["username"]."' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
"; + echo "Add Complete"; + echo "
"; + require_once "includes/footer.php"; + return; +} + +//show the header + require_once "includes/header.php"; + require_once "includes/wysiwyg.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + /* + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + */ + //echo " "; + //echo " "; + //echo " "; + //echo " "; echo " "; + echo " "; + echo " "; + echo "
Title:
Link:
Description:"; + echo " "; + echo "
rss_sub_optional_1:
rss_sub_optional_2:
rss_sub_optional_3:
rss_sub_optional_4:
rss_sub_optional_5:
rss_sub_add_date:
rss_sub_add_user:
example:
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + + echo "
"; + echo "
"; + +//show the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/content/rsssubcategoryadd.php b/app/content/rsssubcategoryadd.php new file mode 100644 index 0000000000..49e1af97d1 --- /dev/null +++ b/app/content/rsssubcategoryadd.php @@ -0,0 +1,117 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "config.php"; +if (permission_exists('content_add')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_POST)>0) { + $rss_sub_category_uuid = uuid(); + $rss_category = check_str($_POST["rss_category"]); + $rss_sub_category = check_str($_POST["rss_sub_category"]); + $rss_sub_category_description = check_str($_POST["rss_sub_category_description"]); + $rss_add_user = check_str($_POST["rss_add_user"]); + $rss_add_date = check_str($_POST["rss_add_date"]); + + $sql = "insert into v_rss_sub_category "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "rss_sub_category_uuid, "; + $sql .= "rss_category, "; + $sql .= "rss_sub_category, "; + $sql .= "rss_sub_category_description, "; + $sql .= "rss_add_user, "; + $sql .= "rss_add_date "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$rss_sub_category_uuid', "; + $sql .= "'$rss_category', "; + $sql .= "'$rss_sub_category', "; + $sql .= "'$rss_sub_category_description', "; + $sql .= "'$rss_add_user', "; + $sql .= "'$rss_add_date' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "Add Complete"; + require_once "includes/footer.php"; + return; +} + +require_once "includes/header.php"; +echo "
"; +echo "\n"; +echo "\n"; +echo " "; +echo " "; +echo "
\n"; +echo "
"; + +echo "
"; +echo ""; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " \n"; +echo " "; +echo " "; +echo " "; +echo "
RSS Category:
rss_sub_category:
rss_sub_category_description:
rss_add_user:
rss_add_date:
"; +echo "
"; + +echo "
"; +echo "
"; + +require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/content/rsssubcategorylist.php b/app/content/rsssubcategorylist.php new file mode 100644 index 0000000000..b27b42622e --- /dev/null +++ b/app/content/rsssubcategorylist.php @@ -0,0 +1,204 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "config.php"; +if (permission_exists('content_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + + +require_once "includes/header.php"; + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + + + +echo "
"; +echo "\n"; + +echo "\n"; +echo " \n"; + echo "\n"; + +} //end if results + +echo "
\n"; +echo "
"; + + +$sql = ""; +$sql .= "select * from v_rss_sub_category "; +$sql .= "where domain_uuid = '$domain_uuid' "; +if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + +$prep_statement = $db->prepare(check_sql($sql)); +$prep_statement->execute(); +$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); +$result_count = count($result); + +$c = 0; +$row_style["0"] = "background-color: #F5F5DC;"; +$row_style["1"] = "background-color: #FFFFFF;"; + +echo "
\n"; +echo "\n"; +echo ""; + +if ($result_count == 0) { //no results + echo ""; +} +else { //received results + + echo ""; + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + echo "\n"; + + foreach($result as $row) { + //print_r( $row ); + echo "\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach unset($sql, $result, $row_count); + + echo "
 
    "; + if (strlen($order_by)==0) { + echo "rss_sub_category_uuid"; + } + else { + if ($order=="asc") { + echo "rss_sub_category_uuid"; + } + else { + echo "rss_sub_category_uuid"; + } + } + echo "        "; + if (strlen($order_by)==0) { + echo "rss_category"; + } + else { + if ($order=="asc") { + echo "rss_category"; + } + else { + echo "rss_category"; + } + } + echo "        "; + if (strlen($order_by)==0) { + echo "rss_sub_category"; + } + else { + if ($order=="asc") { + echo "rss_sub_category"; + } + else { + echo "rss_sub_category"; + } + } + echo "        "; + if (strlen($order_by)==0) { + echo "rss_sub_category_description"; + } + else { + if ($order=="asc") { + echo "rss_sub_category_description"; + } + else { + echo "rss_sub_category_description"; + } + } + echo "        "; + if (strlen($order_by)==0) { + echo "rss_add_user"; + } + else { + if ($order=="asc") { + echo "rss_add_user"; + } + else { + echo "rss_add_user"; + } + } + echo "        "; + if (strlen($order_by)==0) { + echo "rss_add_date"; + } + else { + if ($order=="asc") { + echo "rss_add_date"; + } + else { + echo "rss_add_date"; + } + } + echo "   
".$row[rss_sub_category_uuid]."".$row[rss_category]."".$row[rss_sub_category]."".$row[rss_sub_category_description]."".$row[rss_add_user]."".$row[rss_add_date]."
\n"; + echo "
\n"; + + + echo "

"; + echo "
\n"; +echo "   \n"; +echo "   \n"; +echo "
"; + +echo "

"; +require_once "includes/footer.php"; + +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); + +?> diff --git a/app/content/rsssubcategoryupdate.php b/app/content/rsssubcategoryupdate.php new file mode 100644 index 0000000000..6dba2af02b --- /dev/null +++ b/app/content/rsssubcategoryupdate.php @@ -0,0 +1,134 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "config.php"; +if (permission_exists('content_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_POST)>0) { + $rss_sub_category_uuid = check_str($_POST["rss_sub_category_uuid"]); + $rss_category = check_str($_POST["rss_category"]); + $rss_sub_category = check_str($_POST["rss_sub_category"]); + $rss_sub_category_description = check_str($_POST["rss_sub_category_description"]); + $rss_add_user = check_str($_POST["rss_add_user"]); + $rss_add_date = check_str($_POST["rss_add_date"]); + + //sql update + $sql = "update v_rss_sub_category set "; + $sql .= "rss_category = '$rss_category', "; + $sql .= "rss_sub_category = '$rss_sub_category', "; + $sql .= "rss_sub_category_description = '$rss_sub_category_description', "; + $sql .= "rss_add_user = '$rss_add_user', "; + $sql .= "rss_add_date = '$rss_add_date' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and rss_sub_category_uuid = '$rss_sub_category_uuid' "; + $count = $db->exec(check_sql($sql)); + //echo "Affected Rows: ".$count; + + //edit: make sure the meta redirect url is correct + require_once "includes/header.php"; + echo "\n"; + echo "Update Complete"; + require_once "includes/footer.php"; + return; +} +else { + //get data from the db + $rss_sub_category_uuid = $_GET["rss_sub_category_uuid"]; + + $sql = ""; + $sql .= "select * from v_rss_sub_category "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and rss_sub_category_uuid = '$rss_sub_category_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $rss_category = $row["rss_category"]; + $rss_sub_category = $row["rss_sub_category"]; + $rss_sub_category_description = $row["rss_sub_category_description"]; + $rss_add_user = $row["rss_add_user"]; + $rss_add_date = $row["rss_add_date"]; + break; //limit to 1 row + } +} + +require_once "includes/header.php"; +echo "
"; +echo "\n"; + +echo "\n"; +echo " "; +echo " "; +echo "
\n"; +echo "
"; + + +echo "
"; +echo ""; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo " "; +echo "
rss_category:
rss_sub_category:
rss_sub_category_description:
rss_add_user:
rss_add_date:
"; +echo " "; +echo " "; +echo "
"; +echo "
"; + + +echo "
"; +echo "
"; + + + require_once "includes/footer.php"; +?> diff --git a/app/content/rsssubdelete.php b/app/content/rsssubdelete.php new file mode 100644 index 0000000000..0dad197228 --- /dev/null +++ b/app/content/rsssubdelete.php @@ -0,0 +1,60 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "config.php"; +if (permission_exists('content_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $rss_uuid = check_str($_GET["rss_uuid"]); + $rss_sub_uuid = check_str($_GET["rss_sub_uuid"]); + + //mark the the item as deleted and who deleted it + $sql = "update v_rss_sub set "; + $sql .= "rss_sub_del_date = now(), "; + $sql .= "rss_sub_del_user = '".$_SESSION["username"]."' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and rss_sub_uuid = '$rss_sub_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
"; + echo "Delete Completed"; + echo "
"; + require_once "includes/footer.php"; + return; +} + +?> \ No newline at end of file diff --git a/app/content/rsssublist.php b/app/content/rsssublist.php new file mode 100644 index 0000000000..4828e81242 --- /dev/null +++ b/app/content/rsssublist.php @@ -0,0 +1,444 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "config.php"; +if (permission_exists('content_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$rss_uuid = $_GET["rss_uuid"]; +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + +require_once "includes/header.php"; + + + echo "
"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "
\n"; + + echo "
"; + echo " $module_title Details"; + $sql = ""; + $sql .= "select * from v_rss "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and rss_uuid = '$rss_uuid' "; + $sql .= "and rss_category = '$rss_category' "; + $sql .= "and length(rss_del_date) = 0 "; + $sql .= "or domain_uuid = '$domain_uuid' "; + $sql .= "and rss_uuid = '$rss_uuid' "; + $sql .= "and rss_category = '$rss_category' "; + $sql .= "and rss_del_date is null "; + $sql .= "order by rss_uuid asc "; + + //echo $sql; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + echo ""; + if ($result_count == 0) { //no results + echo ""; + } + else { //received results + foreach($result as $row) { + //print_r( $row ); + //echo "\n"; + //echo ""; + //echo " "; + //echo " "; + //echo ""; + //echo ""; + + echo ""; + echo " "; + echo " "; + echo " "; + $rss_description = $row[rss_description]; + //$rss_description = str_replace ("\r\n", "
", $rss_description); + //$rss_description = str_replace ("\n", "
", $rss_description); + echo ""; + + + echo ""; + echo " "; + echo " "; + echo ""; + + echo ""; + echo " "; + echo " "; + echo ""; + + if (strlen($row[rss_order]) > 0) { + echo ""; + echo " "; + echo " "; + echo ""; + } + + //echo ""; + echo " "; + echo " "; + //echo ""; + + //echo ""; + //echo " "; + //echo " "; //priority + //echo ""; + + //echo ""; + //echo " "; //completion status + //echo " "; //completion status + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo " "; + //echo ""; + + echo ""; + + //echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + } + echo "
 
Title".$row[rss_uuid]."
".$row[rss_category]."
Title:  ".$row[rss_title].""; + echo " "; + echo "
Template:  ".$row[rss_sub_category]."
Group:  ".$row[rss_group]."
Order:  ".$row[rss_order]."
".$row[rss_link]."Description:  ".$rss_description."".$row[rss_img]."
Priority:  ".$row[rss_optional_1]."
Status:  "; + //echo $row[rss_optional_2]; + //if ($row[rss_optional_2]=="100") { + // echo "Complete"; + //} + //else { + // echo $row[rss_optional_2]."%"; + //} + //echo "".$row[rss_optional_3]."".$row[rss_optional_4]."".$row[rss_optional_5]."".$row[rss_add_date]."".$row[rss_add_user]."
"; + //echo " Details"; + //echo " "; + //echo "
"; + unset($sql, $prep_statement, $result); + + + if ($rss_sub_show == 1) { + + echo "


"; + echo "$rss_sub_title
"; + + $sql = ""; + $sql .= "select * from v_rss_sub "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and rss_uuid = '$rss_uuid' "; + $sql .= "and length(rss_sub_del_date) = 0 "; + $sql .= "or domain_uuid = '$domain_uuid' "; + $sql .= "and rss_uuid = '$rss_uuid' "; + $sql .= "and rss_sub_del_date is null "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + //echo $sql; + + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + $c = 0; + $row_style["0"] = "background-color: #F5F5DC;"; + $row_style["1"] = "background-color: #FFFFFF;"; + + echo "
\n"; + echo "\n"; + //echo ""; + + if ($result_count == 0) { //no results + echo ""; + } + else { //received results + + echo ""; + /* + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + */ + + echo ""; + echo "\n"; + + foreach($result as $row) { + //print_r( $row ); + echo "\n"; + //echo ""; + //echo ""; + //echo ""; + echo ""; + + echo ""; + + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + + echo ""; + + echo ""; + + + $rss_sub_description = $row[rss_sub_description]; + $rss_sub_description = str_replace ("\r\n", "
", $rss_sub_description); + $rss_sub_description = str_replace ("\n", "
", $rss_sub_description); + + echo ""; + echo "\n"; + echo ""; + + echo ""; + + + + echo ""; + + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach unset($sql, $result, $row_count); + + + + } //end if results + + echo "
 
    "; + if (strlen($order_by)==0) { + echo "rss_sub_uuid"; + } + else { + if ($order=="asc") { + echo "rss_sub_uuid"; + } + else { + echo "rss_sub_uuid"; + } + } + echo "        "; + if (strlen($order_by)==0) { + echo "rss_uuid"; + } + else { + if ($order=="asc") { + echo "rss_uuid"; + } + else { + echo "rss_uuid"; + } + } + echo "        "; + if (strlen($order_by)==0) { + echo "rss_sub_title"; + } + else { + if ($order=="asc") { + echo "rss_sub_title"; + } + else { + echo "rss_sub_title"; + } + } + echo "        "; + if (strlen($order_by)==0) { + echo "rss_sub_link"; + } + else { + if ($order=="asc") { + echo "rss_sub_link"; + } + else { + echo "rss_sub_link"; + } + } + echo "        "; + if (strlen($order_by)==0) { + echo "rss_sub_description"; + } + else { + if ($order=="asc") { + echo "rss_sub_description"; + } + else { + echo "rss_sub_description"; + } + } + echo "        "; + if (strlen($order_by)==0) { + echo "rss_sub_optional_1"; + } + else { + if ($order=="asc") { + echo "rss_sub_optional_1"; + } + else { + echo "rss_sub_optional_1"; + } + } + echo "        "; + if (strlen($order_by)==0) { + echo "rss_sub_optional_2"; + } + else { + if ($order=="asc") { + echo "rss_sub_optional_2"; + } + else { + echo "rss_sub_optional_2"; + } + } + echo "        "; + if (strlen($order_by)==0) { + echo "rss_sub_optional_3"; + } + else { + if ($order=="asc") { + echo "rss_sub_optional_3"; + } + else { + echo "rss_sub_optional_3"; + } + } + echo "        "; + if (strlen($order_by)==0) { + echo "rss_sub_optional_4"; + } + else { + if ($order=="asc") { + echo "rss_sub_optional_4"; + } + else { + echo "rss_sub_optional_4"; + } + } + echo "        "; + if (strlen($order_by)==0) { + echo "rss_sub_optional_5"; + } + else { + if ($order=="asc") { + echo "rss_sub_optional_5"; + } + else { + echo "rss_sub_optional_5"; + } + } + echo "        "; + if (strlen($order_by)==0) { + echo "rss_sub_add_date"; + } + else { + if ($order=="asc") { + echo "rss_sub_add_date"; + } + else { + echo "rss_sub_add_date"; + } + } + echo "        "; + if (strlen($order_by)==0) { + echo "rss_sub_add_user"; + } + else { + if ($order=="asc") { + echo "rss_sub_add_user"; + } + else { + echo "rss_sub_add_user"; + } + } + echo "   
".$rss_uuid." ".$row[rss_sub_title]."  ".$row[rss_sub_link]." "; + echo " ".$row[rss_sub_title].""; + echo "".$row[rss_sub_add_date]."".$row[rss_sub_optional_1]."".$row[rss_sub_optional_2]."".$row[rss_sub_optional_3]."".$row[rss_sub_optional_4]."".$row[rss_sub_optional_5]."".$row[rss_sub_add_user].""; + echo " "; + echo ""; + echo "  "; + echo " "; + echo "   \n"; + //echo " Update "; + echo "
"; + echo "".$rss_sub_description." "; + echo "
\n"; + echo "
\n"; + + + } //if ($showrsssub == 1) { + + echo "

"; + echo "
\n"; + + //echo "   \n"; + if ($rss_sub_show == 1) { + echo "   \n"; + } + echo "
"; + + echo "

"; + require_once "includes/footer.php"; + + unset ($result_count); + unset ($result); + unset ($key); + unset ($val); + unset ($c); + +?> diff --git a/app/content/rsssubsearch.php b/app/content/rsssubsearch.php new file mode 100644 index 0000000000..c233dd2fe6 --- /dev/null +++ b/app/content/rsssubsearch.php @@ -0,0 +1,260 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "config.php"; +if (permission_exists('content_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + + +if (count($_POST)>0) { + $rss_sub_uuid = check_str($_POST["rss_sub_uuid"]); + $rss_uuid = check_str($_POST["rss_uuid"]); + $rss_sub_title = check_str($_POST["rss_sub_title"]); + $rss_sub_link = check_str($_POST["rss_sub_link"]); + $rss_sub_description = check_str($_POST["rss_sub_description"]); + $rss_sub_optional_1 = check_str($_POST["rss_sub_optional_1"]); + $rss_sub_optional_2 = check_str($_POST["rss_sub_optional_2"]); + $rss_sub_optional_3 = check_str($_POST["rss_sub_optional_3"]); + $rss_sub_optional_4 = check_str($_POST["rss_sub_optional_4"]); + $rss_sub_optional_5 = check_str($_POST["rss_sub_optional_5"]); + $rss_sub_add_date = check_str($_POST["rss_sub_add_date"]); + $rss_sub_add_user = check_str($_POST["rss_sub_add_user"]); + + + require_once "includes/header.php"; + + echo "
"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + + } //end if results + + echo "
\n"; + echo "
"; + + + $sql = ""; + $sql .= "select * from v_rss_sub "; + $sql .= "where "; + if (strlen($domain_uuid) > 0) { $sql .= "and rss_sub_uuid = '$domain_uuid' "; } + if (strlen($rss_sub_uuid) > 0) { $sql .= "and rss_sub_uuid like '%$rss_sub_uuid%' "; } + if (strlen($rss_uuid) > 0) { $sql .= "and rss_uuid like '%$rss_uuid%' "; } + if (strlen($rss_sub_title) > 0) { $sql .= "and rss_sub_title like '%$rss_sub_title%' "; } + if (strlen($rss_sub_link) > 0) { $sql .= "and rss_sub_link like '%$rss_sub_link%' "; } + if (strlen($rss_sub_description) > 0) { $sql .= "and rss_sub_description like '%$rss_sub_description%' "; } + if (strlen($rss_sub_optional_1) > 0) { $sql .= "and rss_sub_optional_1 like '%$rss_sub_optional_1%' "; } + if (strlen($rss_sub_optional_2) > 0) { $sql .= "and rss_sub_optional_2 like '%$rss_sub_optional_2%' "; } + if (strlen($rss_sub_optional_3) > 0) { $sql .= "and rss_sub_optional_3 like '%$rss_sub_optional_3%' "; } + if (strlen($rss_sub_optional_4) > 0) { $sql .= "and rss_sub_optional_4 like '%$rss_sub_optional_4%' "; } + if (strlen($rss_sub_optional_5) > 0) { $sql .= "and rss_sub_optional_5 like '%$rss_sub_optional_5%' "; } + if (strlen($rss_sub_add_date) > 0) { $sql .= "and rss_sub_add_date like '%$rss_sub_add_date%' "; } + if (strlen($rss_sub_add_user) > 0) { $sql .= "and rss_sub_add_user like '%$rss_sub_add_user%' "; } + $sql .= "and length(rss_sub_del_date) = 0 "; + $sql .= "or "; + if (strlen($domain_uuid) > 0) { $sql .= "and rss_sub_uuid = '$domain_uuid' "; } + if (strlen($rss_sub_uuid) > 0) { $sql .= "and rss_sub_uuid like '%$rss_sub_uuid%' "; } + if (strlen($rss_uuid) > 0) { $sql .= "and rss_uuid like '%$rss_uuid%' "; } + if (strlen($rss_sub_title) > 0) { $sql .= "and rss_sub_title like '%$rss_sub_title%' "; } + if (strlen($rss_sub_link) > 0) { $sql .= "and rss_sub_link like '%$rss_sub_link%' "; } + if (strlen($rss_sub_description) > 0) { $sql .= "and rss_sub_description like '%$rss_sub_description%' "; } + if (strlen($rss_sub_optional_1) > 0) { $sql .= "and rss_sub_optional_1 like '%$rss_sub_optional_1%' "; } + if (strlen($rss_sub_optional_2) > 0) { $sql .= "and rss_sub_optional_2 like '%$rss_sub_optional_2%' "; } + if (strlen($rss_sub_optional_3) > 0) { $sql .= "and rss_sub_optional_3 like '%$rss_sub_optional_3%' "; } + if (strlen($rss_sub_optional_4) > 0) { $sql .= "and rss_sub_optional_4 like '%$rss_sub_optional_4%' "; } + if (strlen($rss_sub_optional_5) > 0) { $sql .= "and rss_sub_optional_5 like '%$rss_sub_optional_5%' "; } + if (strlen($rss_sub_add_date) > 0) { $sql .= "and rss_sub_add_date like '%$rss_sub_add_date%' "; } + if (strlen($rss_sub_add_user) > 0) { $sql .= "and rss_sub_add_user like '%$rss_sub_add_user%' "; } + $sql .= "and rss_sub_del_date is null "; + + $sql = trim($sql); + if (substr($sql, -5) == "where"){ $sql = substr($sql, 0, (strlen($sql)-5)); } + if (substr($sql, -3) == " or"){ $sql = substr($sql, 0, (strlen($sql)-5)); } + $sql = str_replace ("where and", "where", $sql); + $sql = str_replace ("or and", "or", $sql); + + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + $c = 0; + $row_style["0"] = "background-color: #F5F5DC;"; + $row_style["1"] = "background-color: #FFFFFF;"; + + echo "Search Results
"; + echo "
\n"; + echo "\n"; + echo ""; + + if ($result_count == 0) { //no results + echo ""; + } + else { //received results + + echo ""; + echo ""; + echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + echo "\n"; + + foreach($result as $row) { + //print_r( $row ); + echo "\n"; + echo ""; + echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + + echo "
 
    Sub ID        Id        Title        Link        rss_sub_description        rss_sub_optional_1        rss_sub_optional_2        rss_sub_optional_3        rss_sub_optional_4        rss_sub_optional_5        rss_sub_add_date        rss_sub_add_user   
".$row[rss_sub_uuid]."".$row[rss_uuid]."".$row[rss_sub_title]."".$row[rss_sub_link]."".$row[rss_sub_description]."".$row[rss_sub_optional_1]."".$row[rss_sub_optional_2]."".$row[rss_sub_optional_3]."".$row[rss_sub_optional_4]."".$row[rss_sub_optional_5]."".$row[rss_sub_add_date]."".$row[rss_sub_add_user]."
\n"; + echo "
\n"; + + + echo "

"; + echo "
\n"; + echo "
"; + + echo "

"; + require_once "includes/footer.php"; + + unset ($result_count); + unset ($result); + unset ($key); + unset ($val); + unset ($c); + + } + else { + + echo "\n"; require_once "includes/header.php"; + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + echo " "; + echo " "; + echo " "; + echo "
Sub ID:
ID:
Sub Title:
Sub Link:
Sub Desc:
rss_sub_optional_1:
rss_sub_optional_2:
rss_sub_optional_3:
rss_sub_optional_4:
rss_sub_optional_5:
rss_sub_add_date:
rss_sub_add_user:
"; + echo "
"; + + + echo "
"; + echo "
"; + + +require_once "includes/footer.php"; + +} //end if not post +?> diff --git a/app/content/rsssubupdate.php b/app/content/rsssubupdate.php new file mode 100644 index 0000000000..80d472efa2 --- /dev/null +++ b/app/content/rsssubupdate.php @@ -0,0 +1,206 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "config.php"; +if (permission_exists('content_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$rss_uuid = $_GET["rss_uuid"]; + +if (count($_POST)>0 && $_POST["persistform"] == "0") { + $rss_sub_uuid = check_str($_POST["rss_sub_uuid"]); + $rss_uuid = check_str($_POST["rss_uuid"]); + $rss_sub_title = check_str($_POST["rss_sub_title"]); + $rss_sub_link = check_str($_POST["rss_sub_link"]); + $rss_sub_description = check_str($_POST["rss_sub_description"]); + $rss_sub_optional_1 = check_str($_POST["rss_sub_optional_1"]); + $rss_sub_optional_2 = check_str($_POST["rss_sub_optional_2"]); + $rss_sub_optional_3 = check_str($_POST["rss_sub_optional_3"]); + $rss_sub_optional_4 = check_str($_POST["rss_sub_optional_4"]); + $rss_sub_optional_5 = check_str($_POST["rss_sub_optional_5"]); + $rss_sub_add_date = check_str($_POST["rss_sub_add_date"]); + $rss_sub_add_user = check_str($_POST["rss_sub_add_user"]); + + $msg = ''; + if (strlen($rss_uuid) == 0) { $msg .= "Error missing rss_uuid.
\n"; } + if (strlen($rss_sub_uuid) == 0) { $msg .= "Error missing rss_sub_uuid.
\n"; } + //if (strlen($rss_sub_title) == 0) { $msg .= "Please provide a title.
\n"; } + if (strlen($rss_sub_description) == 0) { $msg .= "Please provide a description.
\n"; } + + if (strlen($msg) > 0) { + require_once "includes/persistform.php"; + require_once "includes/header.php"; + echo "
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo "
"; + echo "
"; + echo " $msg"; + echo "
"; + echo "
".persistform($_POST)."
"; + echo "
"; + echo "
"; + echo "
"; + + require_once "includes/footer.php"; + return; + } + + //sql update + $sql = "update v_rss_sub set "; + //$sql .= "rss_uuid = '$rss_uuid', "; + $sql .= "rss_sub_title = '$rss_sub_title', "; + $sql .= "rss_sub_link = '$rss_sub_link', "; + $sql .= "rss_sub_description = '$rss_sub_description', "; + $sql .= "rss_sub_optional_1 = '$rss_sub_optional_1', "; + $sql .= "rss_sub_optional_2 = '$rss_sub_optional_2', "; + $sql .= "rss_sub_optional_3 = '$rss_sub_optional_3', "; + $sql .= "rss_sub_optional_4 = '$rss_sub_optional_4', "; + $sql .= "rss_sub_optional_5 = '$rss_sub_optional_5' "; + //$sql .= "rss_sub_add_date = now(), "; + //$sql .= "rss_sub_add_user = '".$_SESSION["username"]."' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and rss_sub_uuid = '$rss_sub_uuid' "; + //$sql .= "and rss_uuid = '$rss_uuid' "; + $count = $db->exec(check_sql($sql)); + //echo "Affected Rows: ".$count; + + //edit: make sure the meta redirect url is correct + require_once "includes/header.php"; + echo "\n"; + echo "
"; + echo "Update Complete"; + echo "
"; + require_once "includes/footer.php"; + return; +} +else { + //get data from the db + $rss_sub_uuid = $_GET["rss_sub_uuid"]; + + $sql = ""; + $sql .= "select * from v_rss_sub "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and rss_sub_uuid = '$rss_sub_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + //$rss_uuid = $row["rss_uuid"]; + $rss_sub_title = $row["rss_sub_title"]; + $rss_sub_link = $row["rss_sub_link"]; + $rss_sub_description = $row["rss_sub_description"]; + $rss_sub_optional_1 = $row["rss_sub_optional_1"]; + $rss_sub_optional_2 = $row["rss_sub_optional_2"]; + $rss_sub_optional_3 = $row["rss_sub_optional_3"]; + $rss_sub_optional_4 = $row["rss_sub_optional_4"]; + $rss_sub_optional_5 = $row["rss_sub_optional_5"]; + $rss_sub_add_date = $row["rss_sub_add_date"]; + $rss_sub_add_user = $row["rss_sub_add_user"]; + break; //limit to 1 row + } +} + +//show the header + require_once "includes/header.php"; + require_once "includes/wysiwyg.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
"; + echo ""; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + + echo " "; + echo " "; + echo " "; + echo "
rss_uuid:
Sub Title:
Sub Link:
Description:"; + echo " "; + echo "
rss_sub_optional_1:
rss_sub_optional_2:
rss_sub_optional_3:
rss_sub_optional_4:
rss_sub_optional_5:
"; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
"; + echo "
"; + + echo "
"; + echo "
"; + +//show the footer + require_once "includes/footer.php"; +?> diff --git a/app/content/rssupdate.php b/app/content/rssupdate.php new file mode 100644 index 0000000000..0f53de85d0 --- /dev/null +++ b/app/content/rssupdate.php @@ -0,0 +1,392 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "config.php"; +if (permission_exists('content_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + + +if (count($_POST)>0) { + $rss_uuid = check_str($_POST["rss_uuid"]); + //$rss_category = check_str($_POST["rss_category"]); //defined in local config.php + $rss_sub_category = check_str($_POST["rss_sub_category"]); + $rss_title = check_str($_POST["rss_title"]); + $rss_link = check_str($_POST["rss_link"]); + $rss_description = check_str($_POST["rss_description"]); + $rss_group = check_str($_POST["rss_group"]); + $rss_order = check_str($_POST["rss_order"]); + + //$rss_description = str_replace ("
\r\n
", "
", $rss_description); + //$rss_description = str_replace ("
\n
", "
", $rss_description); + //$rss_description = str_replace ("

", "", $rss_description); + //$rss_description = str_replace ("

", "
", $rss_description); + + $rss_img = check_str($_POST["rss_img"]); + $rss_optional_1 = check_str($_POST["rss_optional_1"]); + $rss_optional_2 = check_str($_POST["rss_optional_2"]); + //$rss_optional_3 = check_str($_POST["rss_optional_3"]); + //$rss_optional_4 = check_str($_POST["rss_optional_4"]); + //$rss_optional_5 = check_str($_POST["rss_optional_5"]); + + //sql update + $sql = "update v_rss set "; + $sql .= "rss_sub_category = '$rss_sub_category', "; + $sql .= "rss_title = '$rss_title', "; + $sql .= "rss_link = '$rss_link', "; + $sql .= "rss_description = '$rss_description', "; + $sql .= "rss_img = '$rss_img', "; + $sql .= "rss_optional_1 = '$rss_optional_1', "; + $sql .= "rss_optional_2 = '$rss_optional_2', "; + //$sql .= "rss_optional_3 = '$rss_optional_3', "; + //$sql .= "rss_optional_4 = '$rss_optional_4', "; + //$sql .= "rss_optional_5 = '$rss_optional_5', "; + //$sql .= "rss_add_date = '$rss_add_date', "; + $sql .= "rss_group = '$rss_group', "; + $sql .= "rss_order = '$rss_order' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and rss_uuid = '$rss_uuid' "; + $sql .= "and rss_category = '$rss_category' "; + //echo $sql; + //return; + $count = $db->exec(check_sql($sql)); + //echo $sql."
"; + //echo "Affected Rows: ".$count; + //exit; + + //edit: make sure the meta redirect url is correct + require_once "includes/header.php"; + echo "\n"; + echo "
"; + echo "Update Complete"; + echo "
"; + require_once "includes/footer.php"; + return; +} +else { + //get data from the db + $rss_uuid = $_GET["rss_uuid"]; + + $sql = ""; + $sql .= "select * from v_rss "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and rss_uuid = '$rss_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $rss_category = $row["rss_category"]; + $rss_sub_category = $row["rss_sub_category"]; + $rss_optional_1 = $row["rss_optional_1"]; + $rss_title = $row["rss_title"]; + $rss_link = $row["rss_link"]; + $rss_description = $row["rss_description"]; + + if ($rss_optional_1 == "text/html") { //type + $rss_description = htmlentities($rss_description); + } + + $rss_img = $row["rss_img"]; + $rss_optional_2 = $row["rss_optional_2"]; + $rss_optional_3 = $row["rss_optional_3"]; + $rss_optional_4 = $row["rss_optional_4"]; + $rss_optional_5 = $row["rss_optional_5"]; + $rss_add_date = $row["rss_add_date"]; + $rss_add_user = $row["rss_add_user"]; + $rss_group = $row["rss_group"]; + $rss_order = $row["rss_order"]; + //$rss_description = str_replace ("\r\n", "
", $rss_description); + + //echo $rss_description; + //return; + + break; //limit to 1 row + } +} + + require_once "includes/header.php"; + if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/tiny_mce')) { + if ($rss_optional_1 == "text/html") { + require_once "includes/wysiwyg.php"; + } + } + else { + //--- Begin: Edit Area ----------------------------------------------------- + echo " \n"; + echo " \n"; + + echo " "; + //--- End: Edit Area ------------------------------------------------------- + } + + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + //echo "
"; + + + echo "
"; + echo ""; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo " "; + + /* + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + */ + + echo " "; + echo " "; + echo " "; + echo " "; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " "; + echo " "; + echo " "; + + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + + echo " "; + echo " "; + echo " "; + echo "
Content Edit

Category:
Sub Category:
Title:
Link:
Group:"; + //echo " "; + + //---- Begin Select List -------------------- + $sql = "SELECT * FROM v_groups "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + + echo ""; + unset($sql, $result); + //---- End Select List -------------------- + + echo "
\n"; + echo " Template: \n"; + echo " \n"; + echo "\n"; + echo "
\n"; + echo " Select a template to set as the default and then press save.
\n"; + echo "
Type:"; + echo " "; + echo "
\n"; + echo " Order:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
"; + echo " Content: "; + if ($rss_optional_1 == "text/html") { + if (is_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/tiny_mce')) { + echo "       editor   on/off
"; + } + echo " "; + } + if ($rss_optional_1 == "text/javascript") { + echo " "; + } + echo "
Image:
Priority:"; + //echo " "; + //echo " "; + //echo "
Status:"; + //echo " "; + //echo " "; + //echo "
Optional 3:
Optional 4:
rss_optional_5:
rss_add_date:
"; + //echo ""; + //echo ""; + + echo " "; + echo " "; + echo "
"; + echo "
"; + + if ($rss_optional_1 == "text/javascript") { + echo "\n"; + } + + echo "
"; + echo "
"; + + + require_once "includes/footer.php"; +?> diff --git a/app/destinations/app_config.php b/app/destinations/app_config.php new file mode 100644 index 0000000000..7b7a3992ac --- /dev/null +++ b/app/destinations/app_config.php @@ -0,0 +1,75 @@ + \ No newline at end of file diff --git a/app/destinations/destinations.php b/app/destinations/destinations.php new file mode 100644 index 0000000000..77e611ad49 --- /dev/null +++ b/app/destinations/destinations.php @@ -0,0 +1,134 @@ +"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Destinations 
\n"; + echo " Used to provide a simple way of directing a call through the dialplan to find its destination.

\n"; + echo "
\n"; + + //prepare to page the results + $sql = " select count(*) as num_rows from v_destinations "; + $sql .= " where domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + + //prepare to page the results + $rows_per_page = 10; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + //get the list + $sql = " select * from v_destinations "; + $sql .= " where domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo th_order_by('destination_name', 'Name', $order_by, $order); + echo th_order_by('destination_context', 'Context', $order_by, $order); + echo th_order_by('destination_extension', 'Extension', $order_by, $order); + echo th_order_by('destination_enabled', 'Enabled', $order_by, $order); + echo th_order_by('destination_description', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo " $v_link_label_add\n"; + echo "
".$row['destination_name']." ".$row['destination_context']." ".$row['destination_extension']." ".$row['destination_enabled']." ".$row['destination_description']." \n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo ""; + echo "

"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/destinations/destinations_delete.php b/app/destinations/destinations_delete.php new file mode 100644 index 0000000000..b754506f70 --- /dev/null +++ b/app/destinations/destinations_delete.php @@ -0,0 +1,35 @@ +0) { + $id = check_str($_GET["id"]); +} + +if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_destinations "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and destination_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); +} + +require_once "includes/header.php"; +echo "\n"; +echo "
\n"; +echo "Delete Complete\n"; +echo "
\n"; +require_once "includes/footer.php"; +return; + +?> \ No newline at end of file diff --git a/app/destinations/destinations_edit.php b/app/destinations/destinations_edit.php new file mode 100644 index 0000000000..c13a91aa93 --- /dev/null +++ b/app/destinations/destinations_edit.php @@ -0,0 +1,249 @@ +0) { + $destination_name = check_str($_POST["destination_name"]); + $destination_context = check_str($_POST["destination_context"]); + $destination_extension = check_str($_POST["destination_extension"]); + $destination_enabled = check_str($_POST["destination_enabled"]); + $destination_description = check_str($_POST["destination_description"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $destination_uuid = check_str($_POST["destination_uuid"]); + } + + //check for all required data + //if (strlen($destination_name) == 0) { $msg .= "Please provide: Name
\n"; } + //if (strlen($destination_context) == 0) { $msg .= "Please provide: Context
\n"; } + //if (strlen($destination_extension) == 0) { $msg .= "Please provide: Extension
\n"; } + //if (strlen($destination_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } + //if (strlen($destination_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $sql = "insert into v_destinations "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "destination_uuid, "; + $sql .= "destination_name, "; + $sql .= "destination_context, "; + $sql .= "destination_extension, "; + $sql .= "destination_enabled, "; + $sql .= "destination_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'".uuid()."', "; + $sql .= "'$destination_name', "; + $sql .= "'$destination_context', "; + $sql .= "'$destination_extension', "; + $sql .= "'$destination_enabled', "; + $sql .= "'$destination_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_destinations set "; + $sql .= "destination_name = '$destination_name', "; + $sql .= "destination_context = '$destination_context', "; + $sql .= "destination_extension = '$destination_extension', "; + $sql .= "destination_enabled = '$destination_enabled', "; + $sql .= "destination_description = '$destination_description' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and destination_uuid = '$destination_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $destination_uuid = $_GET["id"]; + $sql = "select * from v_destinations "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and destination_uuid = '$destination_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(); + foreach ($result as &$row) { + $destination_name = $row["destination_name"]; + $destination_context = $row["destination_context"]; + $destination_extension = $row["destination_extension"]; + $destination_enabled = $row["destination_enabled"]; + $destination_description = $row["destination_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Destination AddDestination Edit
\n"; + echo "An alias for a call destination. The destination will use the dialplan to find it its target.

\n"; + echo "
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the name.\n"; + echo "
\n"; + echo " Context:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the context.\n"; + echo "
\n"; + echo " Extension:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the extension.\n"; + echo "
\n"; + echo " Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the description.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/destinations/root.php b/app/destinations/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/destinations/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/dialplan/app_config.php b/app/dialplan/app_config.php new file mode 100644 index 0000000000..85b7ead19b --- /dev/null +++ b/app/dialplan/app_config.php @@ -0,0 +1,160 @@ + \ No newline at end of file diff --git a/app/dialplan/app_defaults.php b/app/dialplan/app_defaults.php new file mode 100644 index 0000000000..a96cab81ad --- /dev/null +++ b/app/dialplan/app_defaults.php @@ -0,0 +1,74 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//only run the following code if the directory exists + if (is_dir($_SESSION['switch']['dialplan']['dir'])) { + //write the dialplan/default.xml if it does not exist + //get the contents of the dialplan/default.xml + $file_default_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/templates/conf/dialplan/default.xml'; + $file_default_contents = file_get_contents($file_default_path); + + //prepare the file contents and the path + //replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number + $file_default_contents = str_replace("{v_domain}", $context, $file_default_contents); + //set the file path + $file_path = $_SESSION['switch']['conf']['dir'].'/dialplan/'.$context.'.xml'; + + //write the default dialplan + if (!file_exists($file_path)) { + $fh = fopen($file_path,'w') or die('Unable to write to '.$file_path.'. Make sure the path exists and permissons are set correctly.'); + fwrite($fh, $file_default_contents); + fclose($fh); + } + + //get the $apps array from the installed apps from the core and mod directories + $xml_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/app/dialplan/resources/xml/dialplan/*.xml"); + foreach ($xml_list as &$xml_file) { + //get and parse the xml + $xml_string = file_get_contents($xml_file); + //get the order number prefix from the file name + $name_array = explode('_', basename($xml_file)); + if (is_numeric($name_array[0])) { + $dialplan_order = $name_array[0]; + } + else { + $dialplan_order = 0; + } + //dialplan class + require_once "includes/classes/dialplan.php"; + $dialplan = new dialplan; + $dialplan->domain_uuid = $domain_uuid; + $dialplan->dialplan_order = $dialplan_order; + $dialplan->dialplan_context = $context; + if ($display_type == "text") { + $dialplan->display_type = 'text'; + } + $dialplan->xml = $xml_string; + $dialplan->import(); + } + } + +?> \ No newline at end of file diff --git a/app/dialplan/dialplan_add.php b/app/dialplan/dialplan_add.php new file mode 100644 index 0000000000..a42c02aa57 --- /dev/null +++ b/app/dialplan/dialplan_add.php @@ -0,0 +1,734 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('dialplan_add')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + + +//POST to PHP variables + if (count($_POST)>0) { + $dialplan_name = check_str($_POST["dialplan_name"]); + $dialplan_order = check_str($_POST["dialplan_order"]); + $condition_field_1 = check_str($_POST["condition_field_1"]); + $condition_expression_1 = check_str($_POST["condition_expression_1"]); + $condition_field_2 = check_str($_POST["condition_field_2"]); + $condition_expression_2 = check_str($_POST["condition_expression_2"]); + + $action_1 = check_str($_POST["action_1"]); + //$action_1 = "transfer:1001 XML default"; + $action_1_array = explode(":", $action_1); + $action_application_1 = array_shift($action_1_array); + $action_data_1 = join(':', $action_1_array); + + $action_2 = check_str($_POST["action_2"]); + //$action_2 = "transfer:1001 XML default"; + $action_2_array = explode(":", $action_2); + $action_application_2 = array_shift($action_2_array); + $action_data_2 = join(':', $action_2_array); + + //$action_application_1 = check_str($_POST["action_application_1"]); + //$action_data_1 = check_str($_POST["action_data_1"]); + //$action_application_2 = check_str($_POST["action_application_2"]); + //$action_data_2 = check_str($_POST["action_data_2"]); + + $dialplan_enabled = check_str($_POST["dialplan_enabled"]); + $dialplan_description = check_str($_POST["dialplan_description"]); + if (strlen($dialplan_enabled) == 0) { $dialplan_enabled = "true"; } //set default to enabled + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + //check for all required data + if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + if (strlen($dialplan_name) == 0) { $msg .= "Please provide: Extension Name
\n"; } + if (strlen($condition_field_1) == 0) { $msg .= "Please provide: Condition Field
\n"; } + if (strlen($condition_expression_1) == 0) { $msg .= "Please provide: Condition Expression
\n"; } + if (strlen($action_application_1) == 0) { $msg .= "Please provide: Action Application
\n"; } + //if (strlen($dialplan_enabled) == 0) { $msg .= "Please provide: Enabled True or False
\n"; } + //if (strlen($dialplan_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //remove the invalid characters from the extension name + $dialplan_name = str_replace(" ", "_", $dialplan_name); + $dialplan_name = str_replace("/", "", $dialplan_name); + + //start the atomic transaction + $db->exec("BEGIN;"); //returns affected rows + + //add the main dialplan include entry + $dialplan_context = $_SESSION['context']; + $dialplan_uuid = uuid(); + $sql = "insert into v_dialplans "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "app_uuid, "; + $sql .= "dialplan_name, "; + $sql .= "dialplan_order, "; + $sql .= "dialplan_continue, "; + $sql .= "dialplan_context, "; + $sql .= "dialplan_enabled, "; + $sql .= "dialplan_description "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'742714e5-8cdf-32fd-462c-cbe7e3d655db', "; + $sql .= "'$dialplan_name', "; + $sql .= "'$dialplan_order', "; + $sql .= "'false', "; + $sql .= "'".$_SESSION['context']."', "; + $sql .= "'$dialplan_enabled', "; + $sql .= "'$dialplan_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //add condition 1 + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data, "; + $sql .= "dialplan_detail_order "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$dialplan_detail_uuid', "; + $sql .= "'condition', "; + $sql .= "'$condition_field_1', "; + $sql .= "'$condition_expression_1', "; + $sql .= "'1' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //add condition 2 + if (strlen($condition_field_2) > 0) { + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data, "; + $sql .= "dialplan_detail_order "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$dialplan_detail_uuid', "; + $sql .= "'condition', "; + $sql .= "'$condition_field_2', "; + $sql .= "'$condition_expression_2', "; + $sql .= "'2' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + + //add action 1 + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data, "; + $sql .= "dialplan_detail_order "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$dialplan_detail_uuid', "; + $sql .= "'action', "; + $sql .= "'$action_application_1', "; + $sql .= "'$action_data_1', "; + $sql .= "'3' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //add action 2 + if (strlen($action_application_2) > 0) { + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data, "; + $sql .= "dialplan_detail_order "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$dialplan_detail_uuid', "; + $sql .= "'action', "; + $sql .= "'$action_application_2', "; + $sql .= "'$action_data_2', "; + $sql .= "'4' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + + //commit the atomic transaction + $count = $db->exec("COMMIT;"); //returns affected rows + + //synchronize the xml config + save_dialplan_xml(); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; +} //end if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +?> + +"; +echo "\n"; + +echo "\n"; +echo " \n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo " \n"; +echo ""; + +echo "
\n"; +echo "
"; + +echo "
\n"; +echo "
\n"; + +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
Dialplan\n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
\n"; +echo " \n"; +echo " The dialplan is used to setup call destinations based on conditions and context.\n"; +echo " You can use the dialplan to send calls to gateways, auto attendants, external numbers,\n"; +echo " to scripts, or any destination.\n"; +echo " \n"; +echo "
"; + +echo "
\n"; +echo "
\n"; + +echo "\n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; + +//echo "\n"; +//echo "\n"; +//echo "\n"; +//echo "\n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
\n"; +echo " Name:\n"; +echo "\n"; +echo " \n"; +echo "
\n"; +echo "\n"; +echo "
\n"; +//echo " Continue:\n"; +//echo "\n"; +//echo " \n"; +//echo "
\n"; +//echo "Extension Continue in most cases this is false. default: false\n"; +//echo "
\n"; +echo " Condition 1:\n"; +echo "\n"; +?> + +\n"; +echo "
Field:\n"; +echo " \n"; +echo " \n"; +echo "
\n"; +echo "
  Expression:\n"; +echo " \n"; +echo "
\n"; +echo "
\n"; +echo "
\n"; +echo " Condition 2:\n"; +echo "\n"; + +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
\n"; +echo " Field:\n"; +echo " \n"; +?> + +\n"; +echo " \n"; +if (strlen($condition_field_2) > 0) { + echo " \n"; +} +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
\n"; +echo "
\n"; +echo "   Expression:\n"; +echo " \n"; +echo " \n"; +echo "
\n"; +echo "
\n"; +echo "
\n"; +echo " Action 1:\n"; +echo "\n"; + +//switch_select_destination(select_type, select_label, select_name, select_value, select_style, action); +switch_select_destination("dialplan", "", "action_1", $action_1, "width: 60%;", ""); + +/* +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
Application: \n"; +echo "
\n"; +echo "
\n"; +echo "   Data: \n"; +echo " \n"; +echo " \n"; +echo "
\n"; +echo "
\n"; +*/ +echo "
\n"; +echo " Action 2:\n"; +echo "\n"; + +//switch_select_destination(select_type, select_label, select_name, select_value, select_style, action); +switch_select_destination("dialplan", "", "action_2", $action_2, "width: 60%;", ""); + +/* +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
Application: \n"; +echo "
\n"; +echo "
\n"; +echo "   Data: \n"; +echo " \n"; +echo " \n"; +echo "
\n"; +echo "
\n"; +*/ +echo "
\n"; +echo " Order:\n"; +echo "\n"; +echo " \n"; +echo "
\n"; +echo "\n"; +echo "
\n"; +echo " Enabled:\n"; +echo "\n"; +echo " \n"; +echo "
\n"; +echo "\n"; +echo "
\n"; +echo " Description:\n"; +echo "\n"; +//echo " \n"; +echo " \n"; +echo "
\n"; +echo "\n"; +echo "
\n"; +if ($action == "update") { + echo " \n"; +} +echo " \n"; +echo "
"; +echo ""; +echo ""; + +echo "\n"; +echo ""; +echo ""; +echo ""; +echo "

"; + +require_once "includes/footer.php"; + +?> \ No newline at end of file diff --git a/app/dialplan/dialplan_advanced.php b/app/dialplan/dialplan_advanced.php new file mode 100644 index 0000000000..e039145e51 --- /dev/null +++ b/app/dialplan/dialplan_advanced.php @@ -0,0 +1,155 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('dialplan_advanced_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; + +if ($_GET['a'] == "default" && permission_exists('dialplan_advanced_edit')) { + //create the dialplan/default.xml for single tenant or dialplan/domain.xml + require_once "includes/classes/dialplan.php"; + $dialplan = new dialplan; + $dialplan->domain_uuid = $_SESSION['domain_uuid']; + $dialplan->switch_dialplan_dir = $_SESSION['switch']['dialplan']['dir']; + $dialplan->restore_advanced_xml(); + //print_r($dialplan->result); +} + +if ($_POST['a'] == "save" && permission_exists('dialplan_advanced_edit')) { + $v_content = str_replace("\r","",$_POST['code']); + if (file_exists($_SESSION['switch']['dialplan']['dir']."/".$_SESSION['domain_name'].".xml")) { + $fd = fopen($_SESSION['switch']['dialplan']['dir']."/".$_SESSION['domain_name'].".xml", "w"); + } + else { + $fd = fopen($_SESSION['switch']['dialplan']['dir']."/default.xml", "w"); + } + fwrite($fd, $v_content); + fclose($fd); + $savemsg = "Saved"; +} + +if (file_exists($_SESSION['switch']['dialplan']['dir']."/".$_SESSION['domain_name'].".xml")) { + $fd = fopen($_SESSION['switch']['dialplan']['dir']."/".$_SESSION['domain_name'].".xml", "r"); + $v_content = fread($fd, filesize($_SESSION['switch']['dialplan']['dir']."/".$_SESSION['domain_name'].".xml")); +} +else { + $fd = fopen($_SESSION['switch']['dialplan']['dir']."/default.xml", "r"); + $v_content = fread($fd, filesize($_SESSION['switch']['dialplan']['dir']."/default.xml")); +} +fclose($fd); + +?> + + + + + +
+ + + + +
+
+ + + + + + + + + + + + + + + +
Default Dialplan
+
+ The default dialplan is used to setup call destinations based on conditions and context. + You can use the dialplan to send calls to gateways, auto attendants, external numbers, to scripts, or any destination. +
+
+
+ +
+
+
+ location: ".$_SESSION['switch']['conf']['dir']."/dialplan/default.xml\n"; + } + ?> + + ' /> + + "; + } + ?> +
+


+


+


+


+


+


+


+


+


+


+
+
+
+
+ + \ No newline at end of file diff --git a/app/dialplan/dialplan_copy.php b/app/dialplan/dialplan_copy.php new file mode 100644 index 0000000000..7714dd9ffb --- /dev/null +++ b/app/dialplan/dialplan_copy.php @@ -0,0 +1,164 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "includes/paging.php"; +if (permission_exists('dialplan_add') + || permission_exists('inbound_route_add') + || permission_exists('outbound_route_add') + || permission_exists('time_conditions_add')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//set the http get/post variable(s) to a php variable + if (isset($_REQUEST["id"])) { + $dialplan_uuid = check_str($_REQUEST["id"]); + } + +//get the dialplan data + $dialplan_uuid = $_GET["id"]; + $sql = "select * from v_dialplans "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $database_dialplan_uuid = $row["dialplan_uuid"]; + $app_uuid = $row["app_uuid"]; + $dialplan_name = $row["dialplan_name"]; + $dialplan_order = $row["dialplan_order"]; + $dialplan_continue = $row["dialplan_continue"]; + $dialplan_context = $row["dialplan_context"]; + $dialplan_enabled = $row["dialplan_enabled"]; + $dialplan_description = "copy: ".$row["dialplan_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + + //copy the dialplan + $dialplan_uuid = uuid(); + $sql = "insert into v_dialplans "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "app_uuid, "; + $sql .= "dialplan_name, "; + $sql .= "dialplan_order, "; + $sql .= "dialplan_continue, "; + $sql .= "dialplan_context, "; + $sql .= "dialplan_enabled, "; + $sql .= "dialplan_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$_SESSION['domain_uuid']."', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$app_uuid', "; + $sql .= "'".$dialplan_name."-copy', "; + $sql .= "'$dialplan_order', "; + $sql .= "'$dialplan_continue', "; + $sql .= "'$dialplan_context', "; + $sql .= "'$dialplan_enabled', "; + $sql .= "'$dialplan_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //get the the dialplan details + $sql = "select * from v_dialplan_details "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '$database_dialplan_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $dialplan_detail_tag = $row["dialplan_detail_tag"]; + $dialplan_detail_order = $row["dialplan_detail_order"]; + $dialplan_detail_type = $row["dialplan_detail_type"]; + $dialplan_detail_data = $row["dialplan_detail_data"]; + + //copy the dialplan details + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_order, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$_SESSION['domain_uuid']."', "; + $sql .= "'".check_str($dialplan_uuid)."', "; + $sql .= "'".check_str($dialplan_detail_uuid)."', "; + $sql .= "'".check_str($dialplan_detail_tag)."', "; + $sql .= "'".check_str($dialplan_detail_order)."', "; + $sql .= "'".check_str($dialplan_detail_type)."', "; + $sql .= "'".check_str($dialplan_detail_data)."' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + unset ($prep_statement); + + //synchronize the xml config + save_dialplan_xml(); + + //redirect the user + require_once "includes/header.php"; + switch ($app_uuid) { + case "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4": + //inbound routes + echo "\n"; + break; + case "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3": + //outbound routes + echo "\n"; + break; + case "4b821450-926b-175a-af93-a03c441818b1": + //time conditions + echo "\n"; + break; + default: + echo "\n"; + break; + } + echo "
\n"; + echo "Copy Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/dialplan/dialplan_delete.php b/app/dialplan/dialplan_delete.php new file mode 100644 index 0000000000..31b204342f --- /dev/null +++ b/app/dialplan/dialplan_delete.php @@ -0,0 +1,107 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('dialplan_delete') + || permission_exists('inbound_route_delete') + || permission_exists('outbound_route_delete') + || permission_exists('time_conditions_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $dialplan_uuid = check_str($_GET["id"]); +} + +if (strlen($dialplan_uuid)>0) { + //get the dialplan data + $sql = "select * from v_dialplans "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $database_dialplan_uuid = $row["dialplan_uuid"]; + $dialplan_context = $row["dialplan_context"]; + $app_uuid = $row["app_uuid"]; + } + unset ($prep_statement); + + //start the atomic transaction + $count = $db->exec("BEGIN;"); + + //delete child data + $sql = "delete from v_dialplan_details "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $db->query($sql); + unset($sql); + + //delete parent data + $sql = "delete from v_dialplans "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $db->query($sql); + unset($sql); + + //commit the atomic transaction + $count = $db->exec("COMMIT;"); + + //synchronize the xml config + save_dialplan_xml(); +} + +//redirect the user + require_once "includes/header.php"; + switch ($app_uuid) { + case "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4": + //inbound routes + echo "\n"; + break; + case "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3": + //outbound routes + echo "\n"; + break; + case "4b821450-926b-175a-af93-a03c441818b1": + //time conditions + echo "\n"; + break; + default: + echo "\n"; + break; + } + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; +?> \ No newline at end of file diff --git a/app/dialplan/dialplan_details_delete.php b/app/dialplan/dialplan_details_delete.php new file mode 100644 index 0000000000..cb87b16409 --- /dev/null +++ b/app/dialplan/dialplan_details_delete.php @@ -0,0 +1,69 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('dialplan_delete') + || permission_exists('inbound_route_delete') + || permission_exists('outbound_route_delete') + || permission_exists('time_conditions_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = $_GET["id"]; + $dialplan_uuid = check_str($_REQUEST["id2"]); +} + +if (strlen($id)>0) { + + //delete child data + $sql = ""; + $sql .= "delete from v_dialplan_details "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_detail_uuid = '$id' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $db->query($sql); + unset($sql); + + //synchronize the xml config + save_dialplan_xml(); + +} + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + +?> \ No newline at end of file diff --git a/app/dialplan/dialplan_details_edit.php b/app/dialplan/dialplan_details_edit.php new file mode 100644 index 0000000000..8127f6dfdc --- /dev/null +++ b/app/dialplan/dialplan_details_edit.php @@ -0,0 +1,561 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('dialplan_add') + || permission_exists('dialplan_edit') + || permission_exists('inbound_route_add') + || permission_exists('inbound_route_edit') + || permission_exists('outbound_route_add') + || permission_exists('outbound_route_edit') + || permission_exists('time_conditions_add') + || permission_exists('time_conditions_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//set the action as an add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $dialplan_detail_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + $dialplan_uuid = check_str($_REQUEST["id2"]); + } + if (isset($_REQUEST["id2"])) { + $dialplan_uuid = check_str($_REQUEST["id2"]); + } + +//get the http values and set them as php variables + if (count($_POST)>0) { + if (isset($_REQUEST["dialplan_uuid"])) { + $dialplan_uuid = check_str($_POST["dialplan_uuid"]); + } + $dialplan_detail_tag = check_str($_POST["dialplan_detail_tag"]); + $dialplan_detail_order = check_str($_POST["dialplan_detail_order"]); + $dialplan_detail_type = check_str($_POST["dialplan_detail_type"]); + $dialplan_detail_data = check_str($_POST["dialplan_detail_data"]); + $dialplan_detail_break = check_str($_POST["dialplan_detail_break"]); + $dialplan_detail_inline = check_str($_POST["dialplan_detail_inline"]); + $dialplan_detail_group = check_str($_POST["dialplan_detail_group"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $dialplan_detail_uuid = check_str($_POST["dialplan_detail_uuid"]); + } + + //check for all required data + if (strlen($dialplan_detail_tag) == 0) { $msg .= "Please provide: Tag
\n"; } + if (strlen($dialplan_detail_order) == 0) { $msg .= "Please provide: Order
\n"; } + //if (strlen($dialplan_detail_type) == 0) { $msg .= "Please provide: Type
\n"; } + //if (strlen($dialplan_detail_data) == 0) { $msg .= "Please provide: Data
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('dialplan_add')) { + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_order, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data, "; + $sql .= "dialplan_detail_break, "; + $sql .= "dialplan_detail_inline, "; + $sql .= "dialplan_detail_group, "; + $sql .= "domain_uuid "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$dialplan_detail_uuid', "; + $sql .= "'$dialplan_detail_tag', "; + $sql .= "'$dialplan_detail_order', "; + $sql .= "'$dialplan_detail_type', "; + $sql .= "'$dialplan_detail_data', "; + $sql .= "'$dialplan_detail_break', "; + $sql .= "'$dialplan_detail_inline', "; + if (strlen($dialplan_detail_group) == 0) { + $sql .= "null, "; + } + else { + $sql .= "'$dialplan_detail_group', "; + } + $sql .= "'".$_SESSION['domain_uuid']."' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //synchronize the xml config + save_dialplan_xml(); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update" && permission_exists('dialplan_edit')) { + $sql = "update v_dialplan_details set "; + $sql .= "dialplan_uuid = '$dialplan_uuid', "; + $sql .= "dialplan_detail_tag = '$dialplan_detail_tag', "; + $sql .= "dialplan_detail_order = '$dialplan_detail_order', "; + $sql .= "dialplan_detail_type = '$dialplan_detail_type', "; + $sql .= "dialplan_detail_data = '$dialplan_detail_data', "; + $sql .= "dialplan_detail_break = '$dialplan_detail_break', "; + $sql .= "dialplan_detail_inline = '$dialplan_detail_inline', "; + if (strlen($dialplan_detail_group) == 0) { + $sql .= "dialplan_detail_group = null "; + } + else { + $sql .= "dialplan_detail_group = '$dialplan_detail_group' "; + } + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_detail_uuid = '$dialplan_detail_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + //synchronize the xml config + save_dialplan_xml(); + + require_once "includes/header.php"; + + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") { +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $dialplan_detail_uuid = $_GET["id"]; + $sql = "select * from v_dialplan_details "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_detail_uuid = '$dialplan_detail_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $dialplan_uuid = $row["dialplan_uuid"]; + $dialplan_detail_tag = $row["dialplan_detail_tag"]; + $dialplan_detail_order = $row["dialplan_detail_order"]; + $dialplan_detail_type = $row["dialplan_detail_type"]; + $dialplan_detail_data = $row["dialplan_detail_data"]; + $dialplan_detail_break = $row["dialplan_detail_break"]; + $dialplan_detail_inline = $row["dialplan_detail_inline"]; + $dialplan_detail_group = $row["dialplan_detail_group"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " \n"; + echo ""; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + ?> + + \n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +?> + +\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if ($action == "update") { + if ($dialplan_detail_tag == "condition") { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + if ($dialplan_detail_tag == "action") { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + } + + echo " \n"; + echo " \n"; + echo " "; + echo "
Dialplan Detail
\n"; + echo " Tag:\n"; + echo "\n"; + echo " \n"; + + //condition + //field expression + //action + //application + //data + //antiaction + //application + //data + //param + //name + //value + //echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Order:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Type:\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo " Data:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Group:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Break:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Inline:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " \n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo "
\n"; + echo "
"; + echo ""; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/dialplan/dialplan_edit.php b/app/dialplan/dialplan_edit.php new file mode 100644 index 0000000000..e6344481b8 --- /dev/null +++ b/app/dialplan/dialplan_edit.php @@ -0,0 +1,592 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "includes/paging.php"; +if (permission_exists('dialplan_add') + || permission_exists('dialplan_edit') + || permission_exists('inbound_route_add') + || permission_exists('inbound_route_edit') + || permission_exists('outbound_route_add') + || permission_exists('outbound_route_edit') + || permission_exists('time_conditions_add') + || permission_exists('time_conditions_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//set the action as an add or an update + if (isset($_REQUEST["id"])) { + $action = "update"; + $dialplan_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get the app uuid + $app_uuid = check_str($_REQUEST["app_uuid"]); + +//get the http post values and set them as php variables + if (count($_POST)>0) { + $dialplan_name = check_str($_POST["dialplan_name"]); + $dialplan_number = check_str($_POST["dialplan_number"]); + $dialplan_order = check_str($_POST["dialplan_order"]); + $dialplan_continue = check_str($_POST["dialplan_continue"]); + if (strlen($dialplan_continue) == 0) { $dialplan_continue = "false"; } + $dialplan_context = check_str($_POST["dialplan_context"]); + $dialplan_enabled = check_str($_POST["dialplan_enabled"]); + $dialplan_description = check_str($_POST["dialplan_description"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $dialplan_uuid = check_str($_POST["dialplan_uuid"]); + } + + //check for all required data + if (strlen($dialplan_name) == 0) { $msg .= "Please provide: Extension Name
\n"; } + if (strlen($dialplan_order) == 0) { $msg .= "Please provide: Order
\n"; } + if (strlen($dialplan_continue) == 0) { $msg .= "Please provide: Continue
\n"; } + if (strlen($dialplan_context) == 0) { $msg .= "Please provide: Context
\n"; } + if (strlen($dialplan_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } + //if (strlen($dialplan_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //remove the invalid characters from the extension name + $dialplan_name = str_replace(" ", "_", $dialplan_name); + $dialplan_name = str_replace("/", "", $dialplan_name); + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('dialplan_add')) { + //add the data into the database + $dialplan_context = $_SESSION['context']; + $dialplan_uuid = uuid(); + $sql = "insert into v_dialplans "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "app_uuid, "; + $sql .= "dialplan_name, "; + $sql .= "dialplan_number, "; + $sql .= "dialplan_order, "; + $sql .= "dialplan_continue, "; + $sql .= "dialplan_context, "; + $sql .= "dialplan_enabled, "; + $sql .= "dialplan_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$_SESSION['domain_uuid']."', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'742714e5-8cdf-32fd-462c-cbe7e3d655db', "; + $sql .= "'$dialplan_name', "; + $sql .= "'$dialplan_number', "; + $sql .= "'$dialplan_order', "; + $sql .= "'$dialplan_continue', "; + $sql .= "'$dialplan_context', "; + $sql .= "'$dialplan_enabled', "; + $sql .= "'$dialplan_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //synchronize the xml config + save_dialplan_xml(); + + //redirect the user + require_once "includes/header.php"; + switch ($app_uuid) { + case "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4": + //inbound routes + echo "\n"; + break; + case "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3": + //outbound routes + echo "\n"; + break; + case "4b821450-926b-175a-af93-a03c441818b1": + //time conditions + echo "\n"; + break; + default: + echo "\n"; + break; + } + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update" && permission_exists('dialplan_edit')) { + //update the database + $sql = "update v_dialplans set "; + $sql .= "dialplan_name = '$dialplan_name', "; + $sql .= "dialplan_number = '$dialplan_number', "; + $sql .= "dialplan_order = '$dialplan_order', "; + $sql .= "dialplan_continue = '$dialplan_continue', "; + $sql .= "dialplan_context = '$dialplan_context', "; + $sql .= "dialplan_enabled = '$dialplan_enabled', "; + $sql .= "dialplan_description = '$dialplan_description' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + //synchronize the xml config + save_dialplan_xml(); + + //redirect the user + require_once "includes/header.php"; + switch ($app_uuid) { + case "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4": + //inbound routes + echo "\n"; + break; + case "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3": + //outbound routes + echo "\n"; + break; + case "4b821450-926b-175a-af93-a03c441818b1": + //time conditions + echo "\n"; + break; + default: + echo "\n"; + break; + } + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $dialplan_uuid = $_GET["id"]; + $sql = "select * from v_dialplans "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $app_uuid = $row["app_uuid"]; + $dialplan_name = $row["dialplan_name"]; + $dialplan_number = $row["dialplan_number"]; + $dialplan_order = $row["dialplan_order"]; + $dialplan_continue = $row["dialplan_continue"]; + $dialplan_context = $row["dialplan_context"]; + $dialplan_enabled = $row["dialplan_enabled"]; + $dialplan_description = $row["dialplan_description"]; + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo" Dialplan
\n"; + echo "
\n"; + echo " \n"; + switch ($app_uuid) { + case "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4": + //inbound routes + echo " \n"; + break; + case "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3": + //outbound routes + echo " \n"; + break; + case "4b821450-926b-175a-af93-a03c441818b1": + //time conditions + echo " \n"; + break; + default: + echo " \n"; + break; + } + echo "
\n"; + echo " Dialplan Include general settings. \n"; + echo " \n"; + echo "
"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Number:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Context:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Continue:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "
\n"; + echo " Order:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "
\n"; + echo " Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + + //dialplan details + if ($action == "update") { + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "

Conditions and Actions
\n"; + echo "
\n"; + echo " The following conditions, actions and anti-actions are used in the dialplan to direct \n"; + echo " call flow. Each is processed in order that it is given. \n"; + echo " Use as many conditions, actions or anti-actions as needed. \n"; + echo "

"; + echo "
\n"; + + $sql = " select * from v_dialplan_details "; + $sql .= " where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= " and dialplan_uuid = '$dialplan_uuid' "; + $sql .= " order by dialplan_detail_group asc, dialplan_detail_order asc"; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + //create a new array that is sorted into groups and put the tags in order conditions, actions, anti-actions + $x = 0; + $details = ''; + //conditions + foreach($result as $row) { + if ($row['dialplan_detail_tag'] == "condition") { + $group = $row['dialplan_detail_group']; + foreach ($row as $key => $val) { + $details[$group][$x][$key] = $val; + } + } + $x++; + } + //regex + foreach($result as $row) { + if ($row['dialplan_detail_tag'] == "regex") { + $group = $row['dialplan_detail_group']; + foreach ($row as $key => $val) { + $details[$group][$x][$key] = $val; + } + } + $x++; + } + //actions + foreach($result as $row) { + if ($row['dialplan_detail_tag'] == "action") { + $group = $row['dialplan_detail_group']; + foreach ($row as $key => $val) { + $details[$group][$x][$key] = $val; + } + } + $x++; + } + //anti-actions + foreach($result as $row) { + if ($row['dialplan_detail_tag'] == "anti-action") { + $group = $row['dialplan_detail_group']; + foreach ($row as $key => $val) { + $details[$group][$x][$key] = $val; + } + } + $x++; + } + unset($result); + + //define the alternating row styles + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + //display the results + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + $x = 0; + foreach($details as $group) { + if ($x > 0) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "
TagTypeDataOrderGroup\n"; + echo " $v_link_label_add\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + } + + foreach($group as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo "\n"; + } + if ($c==0) { $c=1; } else { $c=0; } + $x++; + } //end foreach + unset($sql, $result, $row_count); + + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
TagTypeDataOrderGroup\n"; + echo " $v_link_label_add\n"; + echo "
  ".$row['dialplan_detail_tag']."  ".$row['dialplan_detail_type']."  ".wordwrap($row['dialplan_detail_data'],180,"
",1)."
  ".$row['dialplan_detail_order']."  ".$row['dialplan_detail_group']."\n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + } //end if update + +//show the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/dialplan/dialplans.php b/app/dialplan/dialplans.php new file mode 100644 index 0000000000..0d62678662 --- /dev/null +++ b/app/dialplan/dialplans.php @@ -0,0 +1,348 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('dialplan_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//includes + require_once "includes/header.php"; + require_once "includes/paging.php"; + +//set the http values as php variables + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + $dialplan_context = $_GET["dialplan_context"]; + $app_uuid = $_GET["app_uuid"]; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo ""; + echo ""; + echo "
\n"; + echo "
"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " \n"; + if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4") { + echo " Inbound Routes\n"; + } + elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3") { + echo " Outbound Routes\n"; + } + elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1") { + echo " Time Conditions\n"; + } + else { + echo " Dialplan\n"; + } + + echo " \n"; + echo " \n"; + if (permission_exists('dialplan_advanced_view') && strlen($app_uuid) == 0) { + echo " \n"; + } + else { + echo " \n"; + } + echo "
\n"; + echo " \n"; + + if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4") { + //inbound routes + echo " Route incoming calls to destinations based on one \n"; + echo " or more conditions. It can send incoming calls to an IVR Menu, \n"; + echo " Call Group, Extension, External Number, Script. Order is important when an \n"; + echo " anti-action is used or when there are multiple conditions that match. \n"; + } + elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3") { + //outbound routes + echo " Route outbound calls to gateways, tdm, enum and more. \n"; + echo " When a call matches the conditions the call to outbound routes . \n"; + } + elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1") { + //time conditions + echo " Time conditions route calls based on time conditions. You can \n"; + echo " use time conditions to send calls to an IVR Menu, External numbers, \n"; + echo " Scripts, or other destinations. \n"; + } + else { + //dialplan + if (if_group("superadmin")) { + echo " The dialplan is used to setup call destinations based on conditions and context.\n"; + echo " You can use the dialplan to send calls to gateways, auto attendants, external numbers,\n"; + echo " to scripts, or any destination.\n"; + } + else { + echo " The dialplan provides a view of some of the feature codes, as well as the IVR Menu, \n"; + echo " Conferences, Queues and other destinations.\n"; + } + } + echo " \n"; + echo "
"; + + echo "
"; + echo "
"; + + //get the number of rows in the dialplan + $sql = ""; + $sql .= " select count(*) as num_rows from v_dialplans "; + $sql .= "where domain_uuid = '$domain_uuid' "; + if (strlen($app_uuid) == 0) { + //hide inbound routes + $sql .= "and app_uuid <> 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' "; + //hide outbound routes + $sql .= "and app_uuid <> '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' "; + } + else { + $sql .= "and app_uuid = '".$app_uuid."' "; + } + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + unset($prep_statement, $result); + + $rows_per_page = 150; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + $sql = ""; + $sql .= " select * from v_dialplans "; + $sql .= " where domain_uuid = '$domain_uuid' "; + if (strlen($app_uuid) == 0) { + //hide inbound routes + $sql .= "and app_uuid <> 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' "; + //hide outbound routes + $sql .= "and app_uuid <> '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' "; + } + else { + $sql .= "and app_uuid = '".$app_uuid."' "; + } + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } else { $sql .= "order by dialplan_order asc, dialplan_name asc "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo th_order_by('dialplan_name', 'Name', $order_by, $order); + echo th_order_by('dialplan_number', 'Number', $order_by, $order); + echo th_order_by('dialplan_order', 'Order', $order_by, $order); + echo th_order_by('dialplan_enabled', 'Enabled', $order_by, $order); + echo th_order_by('dialplan_description', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + $app_uuid = $row['app_uuid']; + if (strlen($row['dialplan_number']) == 0) { + $sql = ""; + $sql .= "select * from v_dialplan_details "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_uuid = '".$row['dialplan_uuid']."' "; + $sql .= "and dialplan_detail_type = 'destination_number' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $tmp_result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($tmp_result as &$tmp) { + //prepare the extension number + preg_match_all('/[\|0-9\*]/',$tmp["dialplan_detail_data"], $tmp_match); + $dialplan_number = implode("",$tmp_match[0]); + $dialplan_number = str_replace("|", " ", $dialplan_number); + $row['dialplan_number'] = $dialplan_number; + //update the extension number + $sql = "update v_dialplans set "; + $sql .= "dialplan_number = '$dialplan_number', "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_uuid = '".$row['dialplan_uuid']."'"; + $db->exec($sql); + unset($sql); + break; //limit to 1 row + } + unset ($prep_statement); + } + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4") { + if (permission_exists('inbound_route_add')) { + echo " $v_link_label_add\n"; + } + } + elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3") { + if (permission_exists('outbound_route_add')) { + echo " $v_link_label_add\n"; + } + } + elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1") { + if (permission_exists('time_conditions_add')) { + echo " $v_link_label_add\n"; + } + } + else { + if (permission_exists('dialplan_add')) { + echo " $v_link_label_add\n"; + } + } + echo "
  ".$row['dialplan_name']."  ".$row['dialplan_number']."  ".$row['dialplan_order']."  ".$row['dialplan_enabled']."".$row['dialplan_description']." \n"; + if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4") { + if (permission_exists('inbound_route_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('inbound_route_delete')) { + echo " $v_link_label_delete\n"; + } + } + elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3") { + if (permission_exists('outbound_route_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('outbound_route_delete')) { + echo " $v_link_label_delete\n"; + } + } + elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1") { + if (permission_exists('time_conditions_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('time_conditions_delete')) { + echo " $v_link_label_delete\n"; + } + } + else { + if (permission_exists('dialplan_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('dialplan_delete')) { + echo " $v_link_label_delete\n"; + } + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo "  "; + if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4") { + if (permission_exists('inbound_route_add')) { + echo " $v_link_label_add\n"; + } + } + elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3") { + if (permission_exists('outbound_route_add')) { + echo " $v_link_label_add\n"; + } + } + elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1") { + if (permission_exists('time_conditions_add')) { + echo " $v_link_label_add\n"; + } + } + else { + if (permission_exists('dialplan_add')) { + echo " $v_link_label_add\n"; + } + } + + echo "
\n"; + echo "
\n"; + echo "
\n"; + if ($v_path_show) { + echo $_SESSION['switch']['dialplan']['dir']; + } + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +require_once "includes/footer.php"; +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); +?> \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/100_call-direction.xml b/app/dialplan/resources/xml/dialplan/100_call-direction.xml new file mode 100644 index 0000000000..535496e549 --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/100_call-direction.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/220_global-intercept.xml b/app/dialplan/resources/xml/dialplan/220_global-intercept.xml new file mode 100644 index 0000000000..13c622d4a2 --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/220_global-intercept.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/230_group-intercept.xml b/app/dialplan/resources/xml/dialplan/230_group-intercept.xml new file mode 100644 index 0000000000..3fbc3e024e --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/230_group-intercept.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/240_redial.xml b/app/dialplan/resources/xml/dialplan/240_redial.xml new file mode 100644 index 0000000000..eec6b5e93f --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/240_redial.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/245_page.xml b/app/dialplan/resources/xml/dialplan/245_page.xml new file mode 100644 index 0000000000..7d7467c283 --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/245_page.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/250_global.xml b/app/dialplan/resources/xml/dialplan/250_global.xml new file mode 100644 index 0000000000..df2810ec88 --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/250_global.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/260_eavesdrop.xml b/app/dialplan/resources/xml/dialplan/260_eavesdrop.xml new file mode 100644 index 0000000000..51db9d1b73 --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/260_eavesdrop.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/270_call_privacy.xml b/app/dialplan/resources/xml/dialplan/270_call_privacy.xml new file mode 100644 index 0000000000..66f101cbd8 --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/270_call_privacy.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/280_call_return.xml b/app/dialplan/resources/xml/dialplan/280_call_return.xml new file mode 100644 index 0000000000..662d10c1c3 --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/280_call_return.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/290_intercept-ext.xml b/app/dialplan/resources/xml/dialplan/290_intercept-ext.xml new file mode 100644 index 0000000000..e7e4976da8 --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/290_intercept-ext.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/300_extension-intercom.xml b/app/dialplan/resources/xml/dialplan/300_extension-intercom.xml new file mode 100644 index 0000000000..2f26115c4e --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/300_extension-intercom.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/310_send_to_voicemail.xml b/app/dialplan/resources/xml/dialplan/310_send_to_voicemail.xml new file mode 100644 index 0000000000..12a583b4e3 --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/310_send_to_voicemail.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/320_vmain.xml b/app/dialplan/resources/xml/dialplan/320_vmain.xml new file mode 100644 index 0000000000..8d5c728882 --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/320_vmain.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/330_vmain_user.xml b/app/dialplan/resources/xml/dialplan/330_vmain_user.xml new file mode 100644 index 0000000000..be6a457345 --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/330_vmain_user.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/340_delay_echo.xml b/app/dialplan/resources/xml/dialplan/340_delay_echo.xml new file mode 100644 index 0000000000..5b8d201044 --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/340_delay_echo.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/350_echo.xml b/app/dialplan/resources/xml/dialplan/350_echo.xml new file mode 100644 index 0000000000..9d365e512f --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/350_echo.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/360_milliwatt.xml b/app/dialplan/resources/xml/dialplan/360_milliwatt.xml new file mode 100644 index 0000000000..ce1db8d4cc --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/360_milliwatt.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/370_tone_stream.xml b/app/dialplan/resources/xml/dialplan/370_tone_stream.xml new file mode 100644 index 0000000000..b6573194fc --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/370_tone_stream.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/380_hold_music.xml b/app/dialplan/resources/xml/dialplan/380_hold_music.xml new file mode 100644 index 0000000000..532b1ff4e9 --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/380_hold_music.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/400_recordings.xml b/app/dialplan/resources/xml/dialplan/400_recordings.xml new file mode 100644 index 0000000000..6d2bcd199d --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/400_recordings.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/410_freeswitch_conference.xml b/app/dialplan/resources/xml/dialplan/410_freeswitch_conference.xml new file mode 100644 index 0000000000..92932f8459 --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/410_freeswitch_conference.xml @@ -0,0 +1,14 @@ + + + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/420_disa.xml b/app/dialplan/resources/xml/dialplan/420_disa.xml new file mode 100644 index 0000000000..a90c4a1cd4 --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/420_disa.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/430_directory.xml b/app/dialplan/resources/xml/dialplan/430_directory.xml new file mode 100644 index 0000000000..c375b28198 --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/430_directory.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/440_wake-up.xml b/app/dialplan/resources/xml/dialplan/440_wake-up.xml new file mode 100644 index 0000000000..8fccece90f --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/440_wake-up.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/450_park_in.xml b/app/dialplan/resources/xml/dialplan/450_park_in.xml new file mode 100644 index 0000000000..8e3f309846 --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/450_park_in.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/455_park_out.xml b/app/dialplan/resources/xml/dialplan/455_park_out.xml new file mode 100644 index 0000000000..f27b91e392 --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/455_park_out.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/460_park_slots.xml b/app/dialplan/resources/xml/dialplan/460_park_slots.xml new file mode 100644 index 0000000000..0c2f17fcb8 --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/460_park_slots.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/dialplan/resources/xml/dialplan/999_local_extension.xml b/app/dialplan/resources/xml/dialplan/999_local_extension.xml new file mode 100644 index 0000000000..3e6bedd90a --- /dev/null +++ b/app/dialplan/resources/xml/dialplan/999_local_extension.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/dialplan/root.php b/app/dialplan/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/dialplan/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/dialplan_inbound/app_config.php b/app/dialplan_inbound/app_config.php new file mode 100644 index 0000000000..157a5f72cc --- /dev/null +++ b/app/dialplan_inbound/app_config.php @@ -0,0 +1,36 @@ + \ No newline at end of file diff --git a/app/dialplan_inbound/app_defaults.php b/app/dialplan_inbound/app_defaults.php new file mode 100644 index 0000000000..93c598d04a --- /dev/null +++ b/app/dialplan_inbound/app_defaults.php @@ -0,0 +1,71 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2010 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//if there are multiple domains then update the public dir path to include the domain + if (count($_SESSION["domains"]) > 1) { + if (is_dir($_SESSION['switch']['dialplan']['dir'].'/public')) { + //clear out the old xml files + $v_needle = '_v_'; + if($dh = opendir($_SESSION['switch']['dialplan']['dir'].'/public')) { + $files = Array(); + while($file = readdir($dh)) { + if($file != "." && $file != ".." && $file[0] != '.') { + if(is_dir($dir . "/" . $file)) { + //this is a directory + } else { + if (strpos($file, $v_needle) !== false && substr($file,-4) == '.xml') { + unlink($_SESSION['switch']['dialplan']['dir'].'/public/'.$file); + } + } + } + } + closedir($dh); + } + } + } + +//if the public directory doesn't exist then create it + if (!is_dir($_SESSION['switch']['dialplan']['dir'].'/public')) { mkdir($_SESSION['switch']['dialplan']['dir'].'/public',0777,true); } + +//if multiple domains then make sure that the dialplan/public/domain_name.xml file exists + if (count($_SESSION["domains"]) > 1) { + //make sure the public directory and xml file exist + if (!is_dir($_SESSION['switch']['dialplan']['dir'].'/public'.$_SESSION['domains'][$domain_uuid]['domain_name'])) { + mkdir($_SESSION['switch']['dialplan']['dir'].'/public/'.$_SESSION['domains'][$domain_uuid]['domain_name'],0777,true); + } + $file = $_SESSION['switch']['dialplan']['dir']."/public/".$_SESSION['domains'][$domain_uuid]['domain_name'].".xml"; + if (!file_exists($file)) { + $fout = fopen($file,"w"); + $xml = "\n"; + $xml .= " \n"; + $xml .= "\n"; + fwrite($fout, $xml); + fclose($fout); + unset($xml,$file); + } + } + +?> \ No newline at end of file diff --git a/app/dialplan_inbound/dialplan_inbound_add.php b/app/dialplan_inbound/dialplan_inbound_add.php new file mode 100644 index 0000000000..a567206612 --- /dev/null +++ b/app/dialplan_inbound/dialplan_inbound_add.php @@ -0,0 +1,808 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('inbound_route_add')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get the http get values and set them as php variables + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + $action = $_GET["action"]; + +//get the http post values and set them as php variables + if (count($_POST)>0) { + $dialplan_name = check_str($_POST["dialplan_name"]); + $limit = check_str($_POST["limit"]); + $public_order = check_str($_POST["public_order"]); + $condition_field_1 = check_str($_POST["condition_field_1"]); + $condition_expression_1 = check_str($_POST["condition_expression_1"]); + $condition_field_2 = check_str($_POST["condition_field_2"]); + $condition_expression_2 = check_str($_POST["condition_expression_2"]); + + $action_1 = check_str($_POST["action_1"]); + //$action_1 = "transfer:1001 XML default"; + $action_1_array = explode(":", $action_1); + $action_application_1 = array_shift($action_1_array); + $action_data_1 = join(':', $action_1_array); + + $action_2 = check_str($_POST["action_2"]); + //$action_2 = "transfer:1001 XML default"; + $action_2_array = explode(":", $action_2); + $action_application_2 = array_shift($action_2_array); + $action_data_2 = join(':', $action_2_array); + + //$action_application_1 = check_str($_POST["action_application_1"]); + //$action_data_1 = check_str($_POST["action_data_1"]); + //$action_application_2 = check_str($_POST["action_application_2"]); + //$action_data_2 = check_str($_POST["action_data_2"]); + + if (if_group("superadmin") && $action == "advanced") { + //allow users in the superadmin group advanced control + } + else { + if (strlen($condition_field_1) == 0) { $condition_field_1 = "destination_number"; } + if (strlen($condition_expression_1) < 8) { $msg .= "The destination number must be 7 or more digits.
\n"; } + if (is_numeric($condition_expression_1)) { + //the number is numeric + $condition_expression_1 = '^'.$condition_expression_1.'$'; + } + else { + $msg .= "The destination number must be numeric.
\n"; + } + } + $dialplan_enabled = check_str($_POST["dialplan_enabled"]); + $dialplan_description = check_str($_POST["dialplan_description"]); + if (strlen($dialplan_enabled) == 0) { $dialplan_enabled = "true"; } //set default to enabled + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + //check for all required data + if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + if (strlen($dialplan_name) == 0) { $msg .= "Please provide: Extension Name
\n"; } + if (strlen($condition_field_1) == 0) { $msg .= "Please provide: Condition Field
\n"; } + if (strlen($condition_expression_1) == 0) { $msg .= "Please provide: Condition Expression
\n"; } + if (strlen($action_application_1) == 0) { $msg .= "Please provide: Action Application
\n"; } + //if (strlen($limit) == 0) { $msg .= "Please provide: Limit
\n"; } + //if (strlen($dialplan_enabled) == 0) { $msg .= "Please provide: Enabled True or False
\n"; } + //if (strlen($dialplan_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //remove the invalid characters from the extension name + $dialplan_name = str_replace(" ", "_", $dialplan_name); + $dialplan_name = str_replace("/", "", $dialplan_name); + + //start the atomic transaction + $count = $db->exec("BEGIN;"); //returns affected rows + + //add the main dialplan entry + $dialplan_uuid = uuid(); + $sql = "insert into v_dialplans "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "app_uuid, "; + $sql .= "dialplan_name, "; + $sql .= "dialplan_order , "; + $sql .= "dialplan_context, "; + $sql .= "dialplan_enabled, "; + $sql .= "dialplan_description "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4', "; + $sql .= "'$dialplan_name', "; + $sql .= "'$public_order', "; + $sql .= "'public', "; + $sql .= "'$dialplan_enabled', "; + $sql .= "'$dialplan_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //add condition public context + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data, "; + $sql .= "dialplan_detail_order "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$dialplan_detail_uuid', "; + $sql .= "'condition', "; + $sql .= "'context', "; + $sql .= "'public', "; + $sql .= "'10' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //add condition 1 + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data, "; + $sql .= "dialplan_detail_order "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$dialplan_detail_uuid', "; + $sql .= "'condition', "; + $sql .= "'$condition_field_1', "; + $sql .= "'$condition_expression_1', "; + $sql .= "'20' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //add condition 2 + if (strlen($condition_field_2) > 0) { + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data, "; + $sql .= "dialplan_detail_order "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$dialplan_detail_uuid', "; + $sql .= "'condition', "; + $sql .= "'$condition_field_2', "; + $sql .= "'$condition_expression_2', "; + $sql .= "'30' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + + //set domain + if (count($_SESSION["domains"]) > 1) { + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data, "; + $sql .= "dialplan_detail_order "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$dialplan_detail_uuid', "; + $sql .= "'action', "; + $sql .= "'set', "; + $sql .= "'domain=".$_SESSION['domain_name']."', "; + $sql .= "'40' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + + //set domain_name + if (count($_SESSION["domains"]) > 1) { + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data, "; + $sql .= "dialplan_detail_order "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$dialplan_detail_uuid', "; + $sql .= "'action', "; + $sql .= "'set', "; + $sql .= "'domain_name=".$_SESSION['domain_name']."', "; + $sql .= "'50' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + + //set call_direction + if (count($_SESSION["domains"]) > 1) { + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data, "; + $sql .= "dialplan_detail_order "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$dialplan_detail_uuid', "; + $sql .= "'action', "; + $sql .= "'set', "; + $sql .= "'call_direction=inbound', "; + $sql .= "'60' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + + //set limit + if (strlen($limit) > 0) { + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data, "; + $sql .= "dialplan_detail_order "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$dialplan_detail_uuid', "; + $sql .= "'action', "; + $sql .= "'limit', "; + $sql .= "'db \${domain} inbound ".$limit." !USER_BUSY', "; + $sql .= "'70' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + + //set answer + $tmp_app = false; + if ($action_application_1 == "ivr") { $tmp_app = true; } + if ($action_application_2 == "ivr") { $tmp_app = true; } + if ($action_application_1 == "conference") { $tmp_app = true; } + if ($action_application_2 == "conference") { $tmp_app = true; } + if ($tmp_app) { + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data, "; + $sql .= "dialplan_detail_order "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$dialplan_detail_uuid', "; + $sql .= "'action', "; + $sql .= "'answer', "; + $sql .= "'', "; + $sql .= "'80' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + unset($tmp_app); + + //add action 1 + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data, "; + $sql .= "dialplan_detail_order "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$dialplan_detail_uuid', "; + $sql .= "'action', "; + $sql .= "'$action_application_1', "; + $sql .= "'$action_data_1', "; + $sql .= "'90' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //add action 2 + if (strlen($action_application_2) > 0) { + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data, "; + $sql .= "dialplan_detail_order "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$dialplan_detail_uuid', "; + $sql .= "'action', "; + $sql .= "'$action_application_2', "; + $sql .= "'$action_data_2', "; + $sql .= "'100' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + + //commit the atomic transaction + $count = $db->exec("COMMIT;"); //returns affected rows + + //synchronize the xml config + save_dialplan_xml(); + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; +} //end if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +?> + + + +"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + else { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + + if (permission_exists("inbound_route_edit") && $action=="advanced") { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo ""; + + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Inbound Call Routing\n"; + echo " \n"; + echo " \n"; + if (permission_exists("inbound_route_edit") && $action == "advanced") { + echo " \n"; + } + else { + echo " \n"; + } + echo " \n"; + echo "
\n"; + echo " \n"; + echo " The public dialplan is used to route incoming calls to destinations based on one or more conditions and context. It can send incoming calls to an auto attendant, huntgroup, extension, external number, or a script.\n"; + echo " \n"; + echo "
\n"; + echo " \n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if (permission_exists("inbound_route_edit") && $action == "advanced") { + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Please enter an inbound route name.
\n"; + echo "
\n"; + echo " Condition 1:\n"; + echo "\n"; + ?> + + \n"; + echo "
Field:\n"; + + echo " \n"; + echo " \n"; + echo "
\n"; + echo "
  Expression:\n"; + echo " \n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo " Condition 2:\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " Field:\n"; + echo " \n"; + ?> + + \n"; + echo " \n"; + if (strlen($condition_field_2) > 0) { + echo " \n"; + } + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "
\n"; + echo "   Expression:\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo " Destination Number:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Please enter the destination number. In North America this is usually a 10 or 11 digit number.\n"; + echo "
\n"; + if (permission_exists("inbound_route_edit") && $action=="advanced") { + echo " Action 1:\n"; + } + else { + echo " Action:\n"; + } + echo "\n"; + + //switch_select_destination(select_type, select_label, select_name, select_value, select_style, action); + switch_select_destination("dialplan", "", "action_1", $action_1, "width: 60%;", ""); + + echo "
\n"; + echo " Action 2:\n"; + echo "\n"; + + //switch_select_destination(select_type, select_label, select_name, select_value, select_style, action); + switch_select_destination("dialplan", "", "action_2", $action_2, "width: 60%;", ""); + + echo "
\n"; + echo " Limit:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Order:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + echo ""; + + echo "
"; + echo "
"; + + echo "

"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/dialplan_inbound/root.php b/app/dialplan_inbound/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/dialplan_inbound/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/dialplan_outbound/app_config.php b/app/dialplan_outbound/app_config.php new file mode 100644 index 0000000000..ca4d7b669c --- /dev/null +++ b/app/dialplan_outbound/app_config.php @@ -0,0 +1,40 @@ + \ No newline at end of file diff --git a/app/dialplan_outbound/app_defaults.php b/app/dialplan_outbound/app_defaults.php new file mode 100644 index 0000000000..af8bd44d63 --- /dev/null +++ b/app/dialplan_outbound/app_defaults.php @@ -0,0 +1,39 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//make sure that enum uses sofia internal in the enum.conf.xml file + $file_contents = file_get_contents($switch_conf_dir."/autoload_configs/enum.conf.xml"); + $file_contents_new = str_replace("service=\"E2U+SIP\" regex=\"sip:(.*)\" replace=\"sofia/\${use_profile}/\$1", "service=\"E2U+SIP\" regex=\"sip:(.*)\" replace=\"sofia/internal/\$1", $file_contents); + if ($file_contents != $file_contents_new) { + $fout = fopen($switch_conf_dir."/autoload_configs/enum.conf.xml","w"); + fwrite($fout, $file_contents_new); + fclose($fout); + if ($display_type == "text") { + echo " enum.conf.xml: updated\n"; + } + } + +?> \ No newline at end of file diff --git a/app/dialplan_outbound/dialplan_outbound_add.php b/app/dialplan_outbound/dialplan_outbound_add.php new file mode 100644 index 0000000000..0ba1b7722c --- /dev/null +++ b/app/dialplan_outbound/dialplan_outbound_add.php @@ -0,0 +1,987 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('outbound_route_add')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//show the header + require_once "includes/header.php"; + require_once "includes/paging.php"; + +//get the http post values and set theme as php variables + if (count($_POST)>0) { + $dialplan_name = check_str($_POST["dialplan_name"]); + $dialplan_order = check_str($_POST["dialplan_order"]); + $dialplan_expression = check_str($_POST["dialplan_expression"]); + $prefix_number = check_str($_POST["prefix_number"]); + $condition_field_1 = check_str($_POST["condition_field_1"]); + $condition_expression_1 = check_str($_POST["condition_expression_1"]); + $condition_field_2 = check_str($_POST["condition_field_2"]); + $condition_expression_2 = check_str($_POST["condition_expression_2"]); + $gateway = check_str($_POST["gateway"]); + $limit = check_str($_POST["limit"]); + + //set the default type + $gateway_type = 'gateway'; + $gateway_2_type = 'gateway'; + $gateway_3_type = 'gateway'; + + //set the gateway type to enum + if (strtolower(substr($gateway, 0, 7)) == "enum") { + $gateway_type = 'enum'; + } + //set the gateway type to freetdm + if (strtolower(substr($gateway, 0, 7)) == "freetdm") { + $gateway_type = 'freetdm'; + } + //set the gateway type to dingaling + if (strtolower(substr($gateway, 0, 4)) == "xmpp") { + $gateway_type = 'xmpp'; + } + //set the gateway_uuid and gateway_name + if ($gateway_type == "gateway") { + $gateway_array = explode(":",$gateway); + $gateway_uuid = $gateway_array[0]; + $gateway_name = $gateway_array[1]; + } + else { + $gateway_name = ''; + $gateway_uuid = ''; + } + + //set the gateway_2 variable + $gateway_2 = check_str($_POST["gateway_2"]); + //set the gateway type to enum + if (strtolower(substr($gateway_2, 0, 4)) == "enum") { + $gateway_2_type = 'enum'; + } + //set the gateway type to freetdm + if (strtolower(substr($gateway_2, 0, 7)) == "freetdm") { + $gateway_2_type = 'freetdm'; + } + //set the gateway type to dingaling + if (strtolower(substr($gateway_2, 0, 4)) == "xmpp") { + $gateway_2_type = 'xmpp'; + } + //set the gateway_2_id and gateway_2_name + if ($gateway_2_type == "gateway" && strlen($_POST["gateway_2"]) > 0) { + $gateway_2_array = explode(":",$gateway_2); + $gateway_2_id = $gateway_2_array[0]; + $gateway_2_name = $gateway_2_array[1]; + } + else { + $gateway_2_id = ''; + $gateway_2_name = ''; + } + + //set the gateway_3 variable + $gateway_3 = check_str($_POST["gateway_3"]); + //set the gateway type to enum + if (strtolower(substr($gateway_3, 0, 4)) == "enum") { + $gateway_3_type = 'enum'; + } + //set the gateway type to freetdm + if (strtolower(substr($gateway_3, 0, 7)) == "freetdm") { + $gateway_3_type = 'freetdm'; + } + //set the gateway type to dingaling + if (strtolower(substr($gateway_3, 0, 4)) == "xmpp") { + $gateway_3_type = 'xmpp'; + } + //set the gateway_3_id and gateway_3_name + if ($gateway_3_type == "gateway" && strlen($_POST["gateway_3"]) > 0) { + $gateway_3_array = explode(":",$gateway_3); + $gateway_3_id = $gateway_3_array[0]; + $gateway_3_name = $gateway_3_array[1]; + } + else { + $gateway_3_id = ''; + $gateway_3_name = ''; + } + + if (permission_exists('outbound_route_any_gateway')) { + //get the domain_uuid for gateway + $sql = ""; + $sql .= "select * from v_gateways "; + $sql .= "where gateway_uuid = '$gateway_uuid' "; + $sql .= "and gateway = '$gateway_name' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $gateway_domain_uuid = $row["domain_uuid"]; + break; + } + unset ($prep_statement); + //get the domain_uuid for gateway_2 + $sql = ""; + $sql .= "select * from v_gateways "; + $sql .= "where gateway_uuid = '$gateway_2_id' "; + $sql .= "and gateway = '$gateway_2_name' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $gateway_2_domain_uuid = $row["domain_uuid"]; + break; + } + unset ($prep_statement); + //get the domain_uuid for gateway_3 + $sql = ""; + $sql .= "select * from v_gateways "; + $sql .= "where gateway_uuid = '$gateway_3_id' "; + $sql .= "and gateway = '$gateway_3_name' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $gateway_3_domain_uuid = $row["domain_uuid"]; + break; + } + unset ($prep_statement); + } + + $dialplan_enabled = check_str($_POST["dialplan_enabled"]); + $dialplan_description = check_str($_POST["dialplan_description"]); + if (strlen($dialplan_enabled) == 0) { $dialplan_enabled = "true"; } //set default to enabled + } + +//process the http form values + if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + //check for all required data + if (strlen($gateway) == 0) { $msg .= "Please provide: Gateway Name
\n"; } + //if (strlen($gateway_2) == 0) { $msg .= "Please provide: Alternat 1
\n"; } + //if (strlen($gateway_3) == 0) { $msg .= "Please provide: Alternat 2
\n"; } + if (strlen($dialplan_expression) == 0) { $msg .= "Please provide: Dialplan Expression
\n"; } + //if (strlen($dialplan_name) == 0) { $msg .= "Please provide: Extension Name
\n"; } + //if (strlen($condition_field_1) == 0) { $msg .= "Please provide: Condition Field
\n"; } + //if (strlen($condition_expression_1) == 0) { $msg .= "Please provide: Condition Expression
\n"; } + //if (strlen($limit) == 0) { $msg .= "Please provide: Limit
\n"; } + //if (strlen($dialplan_enabled) == 0) { $msg .= "Please provide: Enabled True or False
\n"; } + //if (strlen($description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + if (strlen(trim($_POST['dialplan_expression']))> 0) { + + $tmp_array = explode("\n", $_POST['dialplan_expression']); + + foreach($tmp_array as $dialplan_expression) { + $dialplan_expression = trim($dialplan_expression); + if (strlen($dialplan_expression)>0) { + if (count($_SESSION["domains"]) > 1) { + if (permission_exists('outbound_route_any_gateway')) { + $tmp_gateway_name = $_SESSION['domains'][$gateway_domain_uuid]['domain_name'] .'-'.$gateway_name; + } + else { + $tmp_gateway_name = $_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'] .'-'.$gateway_name; + } + if (strlen($gateway_2_name) > 0) { + if (permission_exists('outbound_route_any_gateway')) { + $tmp_gateway_2_name = $_SESSION['domains'][$gateway_2_domain_uuid]['domain_name'] .'-'.$gateway_2_name; + } + else { + $tmp_gateway_2_name = $_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'] .'-'.$gateway_2_name; + } + } + if (strlen($gateway_3_name) > 0) { + if (permission_exists('outbound_route_any_gateway')) { + $tmp_gateway_3_name = $_SESSION['domains'][$gateway_3_domain_uuid]['domain_name'] .'-'.$gateway_3_name; + } + else { + $tmp_gateway_3_name = $_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name'] .'-'.$gateway_3_name; + } + } + } + else { + $tmp_gateway_name = $gateway_name; + if (strlen($gateway_2_name) > 0) { + $tmp_gateway_2_name = $gateway_2_name; + } + if (strlen($gateway_3_name) > 0) { + $tmp_gateway_3_name = $gateway_3_name; + } + } + switch ($dialplan_expression) { + case "^(\d{7})$": + $label = "7 digits"; + $abbrv = "7d"; + break; + case "^(\d{8})$": + $label = "8 digits"; + $abbrv = "8d"; + break; + case "^(\d{9})$": + $label = "9 digits"; + $abbrv = "9d"; + break; + case "^(\d{10})$": + $label = "10 digits"; + $abbrv = "10d"; + break; + case "^\+?(\d{11})$": + $label = "11 digits"; + $abbrv = "11d"; + break; + case "^(\d{12})$": + $label = "12 digits"; + $abbrv = "12d"; + break; + case "^(\d{13})$": + $label = "13 digits"; + $abbrv = "13d"; + break; + case "^(\d{14})$": + $label = "14 digits"; + $abbrv = "14d"; + break; + case "^(\d{12,15})$": + $label = "International"; + $abbrv = "Intl"; + break; + case "^(311)$": + $label = "311"; + $abbrv = "311"; + break; + case "^(411)$": + $label = "411"; + $abbrv = "411"; + break; + case "^(911)$": + $label = "911"; + $abbrv = "911"; + break; + case "^9(\d{3})$": + $label = "dial 9, 3 digits"; + $abbrv = "9.3d"; + break; + case "^9(\d{4})$": + $label = "dial 9, 4 digits"; + $abbrv = "9.4d"; + break; + case "^9(\d{7})$": + $label = "dial 9, 7 digits"; + $abbrv = "9.7d"; + break; + case "^9(\d{10})$": + $label = "dial 9, 10 digits"; + $abbrv = "9.10d"; + break; + case "^9(\d{11})$": + $label = "dial 9, 11 digits"; + $abbrv = "9.11d"; + break; + case "^9(\d{12})$": + $label = "dial 9, 12 digits"; + $abbrv = "9.Intl"; + break; + case "^9(\d{13})$": + $label = "dial 9, 13 digits"; + $abbrv = "9.13d"; + break; + case "^9(\d{14})$": + $label = "dial 9, 14 digits"; + break; + case "^9(\d{12,15})$": + $label = "dial 9, International"; + $abbrv = "9.Intl"; + break; + case "^1?(8(00|55|66|77|88)[2-9]\d{6})$": + $label = "toll free"; + $abbrv = "tollfree"; + break; + default: + $label = $dialplan_expression; + $abbrv = filename_safe($dialplan_expression); + } + + if ($gateway_type == "gateway") { + $dialplan_name = $gateway_name.".".$abbrv; + $action_data = "sofia/gateway/".$tmp_gateway_name."/".$prefix_number."\$1"; + } + if (strlen($gateway_2_name) > 0 && $gateway_2_type == "gateway") { + $extension_2_name = $gateway_2_name.".".$abbrv; + $bridge_2_data .= "sofia/gateway/".$tmp_gateway_2_name."/".$prefix_number."\$1"; + } + if (strlen($gateway_3_name) > 0 && $gateway_3_type == "gateway") { + $extension_3_name = $gateway_3_name.".".$abbrv; + $bridge_3_data .= "sofia/gateway/".$tmp_gateway_3_name."/".$prefix_number."\$1"; + } + if ($gateway_type == "freetdm") { + $dialplan_name = "freetdm.".$abbrv; + $action_data = $gateway."/1/a/".$prefix_number."\$1"; + } + if ($gateway_2_type == "freetdm") { + $extension_2_name = "freetdm.".$abbrv; + $bridge_2_data .= $gateway_2."/1/a/".$prefix_number."\$1"; + } + if ($gateway_3_type == "freetdm") { + $extension_3_name = "freetdm.".$abbrv; + $bridge_3_data .= $gateway_3."/1/a/".$prefix_number."\$1"; + } + if ($gateway_type == "xmpp") { + $dialplan_name = "xmpp.".$abbrv; + $action_data = "dingaling/gtalk/+".$prefix_number."\$1@voice.google.com"; + } + if ($gateway_2_type == "xmpp") { + $extension_2_name = "xmpp.".$abbrv; + $bridge_2_data .= "dingaling/gtalk/+".$prefix_number."\$1@voice.google.com"; + } + if ($gateway_3_type == "xmpp") { + $extension_3_name = "xmpp.".$abbrv; + $bridge_3_data .= "dingaling/gtalk/+".$prefix_number."\$1@voice.google.com"; + } + if ($gateway_type == "enum") { + if (strlen($bridge_2_data) == 0) { + $dialplan_name = "enum.".$abbrv; + } + else { + $dialplan_name = $extension_2_name; + } + $action_data = "\${enum_auto_route}"; + } + if ($gateway_2_type == "enum") { + $bridge_2_data .= "\${enum_auto_route}"; + } + if ($gateway_3_type == "enum") { + $bridge_3_data .= "\${enum_auto_route}"; + } + if (strlen($dialplan_order) == 0) { + $dialplan_order ='333'; + } + $dialplan_context = $_SESSION['context']; + $dialplan_continue = 'false'; + $app_uuid = '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3'; + + //add the main dialplan include entry + $dialplan_uuid = uuid(); + $sql = "insert into v_dialplans "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "app_uuid, "; + $sql .= "dialplan_name, "; + $sql .= "dialplan_order, "; + $sql .= "dialplan_continue, "; + $sql .= "dialplan_context, "; + $sql .= "dialplan_enabled, "; + $sql .= "dialplan_description "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$_SESSION['domain_uuid']."', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$app_uuid', "; + $sql .= "'$dialplan_name', "; + $sql .= "'$dialplan_order', "; + $sql .= "'$dialplan_continue', "; + $sql .= "'$dialplan_context', "; + $sql .= "'$dialplan_enabled', "; + $sql .= "'$dialplan_description' "; + $sql .= ")"; + if ($v_debug) { + echo $sql."
"; + } + $db->exec(check_sql($sql)); + unset($sql); + + $dialplan_detail_tag = 'condition'; //condition, action, antiaction + $dialplan_detail_type = 'destination_number'; + $dialplan_detail_data = $dialplan_expression; + $dialplan_detail_order = '005'; + $dialplan_detail_group = ''; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + $dialplan_detail_data = 'sip_h_X-accountcode=${accountcode}'; + $dialplan_detail_order = '010'; + $dialplan_detail_group = ''; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + $dialplan_detail_data = 'call_direction=outbound'; + $dialplan_detail_order = '015'; + $dialplan_detail_group = ''; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + $dialplan_detail_data = 'hangup_after_bridge=true'; + $dialplan_detail_order = '020'; + $dialplan_detail_group = ''; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + $dialplan_detail_data = 'effective_caller_id_name=${outbound_caller_id_name}'; + $dialplan_detail_order = '025'; + $dialplan_detail_group = ''; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + if ($dialplan_expression == '^(911)$') { + $dialplan_detail_data = 'effective_caller_id_number=${emergency_caller_id_number}'; + } + else { + $dialplan_detail_data = 'effective_caller_id_number=${outbound_caller_id_number}'; + } + $dialplan_detail_order = '030'; + $dialplan_detail_group = ''; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + $dialplan_detail_data = 'inherit_codec=true'; + $dialplan_detail_order = '035'; + $dialplan_detail_group = ''; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + if (strlen($bridge_2_data) > 0) { + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + $dialplan_detail_data = 'continue_on_fail=true'; + $dialplan_detail_order = '040'; + $dialplan_detail_group = ''; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + } + + if ($gateway_type == "enum" || $gateway_2_type == "enum") { + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'enum'; + $dialplan_detail_data = $prefix_number."$1 e164.org"; + $dialplan_detail_order = '045'; + $dialplan_detail_group = ''; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + } + + if (strlen($limit) > 0) { + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'limit'; + $dialplan_detail_data = "db \${domain} outbound ".$limit." !USER_BUSY"; + $dialplan_detail_order = '050'; + $dialplan_detail_group = ''; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + } + + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'bridge'; + $dialplan_detail_data = $action_data; + $dialplan_detail_order = '055'; + $dialplan_detail_group = ''; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + if (strlen($bridge_2_data) > 0) { + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'bridge'; + $dialplan_detail_data = $bridge_2_data; + $dialplan_detail_order = '060'; + $dialplan_detail_group = ''; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + } + + if (strlen($bridge_3_data) > 0) { + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'bridge'; + $dialplan_detail_data = $bridge_3_data; + $dialplan_detail_order = '065'; + $dialplan_detail_group = ''; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + } + + unset($bridge_2_data); + unset($bridge_3_data); + unset($label); + unset($abbrv); + unset($dialplan_expression); + unset($action_data); + } //if strlen + } //end for each + + //synchronize the xml config + save_dialplan_xml(); + + //changes in the dialplan may affect routes in the hunt groups + save_hunt_group_xml(); + } + + //synchronize the xml config + save_dialplan_xml(); + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //end if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) +?> + + + +"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo ""; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Outbound Routes\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " \n"; + echo " Outbound dialplans have one or more conditions that are matched to attributes of a call. \n"; + echo " When a call matches the conditions the call is then routed to the gateway.\n"; + echo " \n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo " \n"; + echo " \n"; + echo ""; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo ""; + + echo "
\n"; + echo " Gateway:\n"; + echo "\n"; + + if (if_group("superadmin")) { + echo "\n"; + echo "\n"; + } + + //set the onchange + if (if_group("superadmin")) { $onchange = "onchange='changeToInput(this);'"; } else { $onchange = ''; } + + $sql = ""; + $sql .= " select * from v_gateways "; + if (permission_exists('outbound_route_any_gateway')) { + $sql .= " order by domain_uuid = '$domain_uuid' "; + } + else { + $sql .= " where domain_uuid = '$domain_uuid' "; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset ($prep_statement, $sql); + echo "\n"; + echo "
\n"; + echo "Select the gateway to use with this outbound route.\n"; + echo "
\n"; + echo " Alternate 1:\n"; + echo "\n"; + $sql = ""; + $sql .= " select * from v_gateways "; + if (permission_exists('outbound_route_any_gateway')) { + $sql .= " order by domain_uuid = '$domain_uuid' "; + } + else { + $sql .= " where domain_uuid = '$domain_uuid' "; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset ($prep_statement, $sql); + echo "\n"; + echo "
\n"; + echo "Select another gateway as an alternative to use if the first one fails.\n"; + echo "
\n"; + echo " Alternate 2:\n"; + echo "\n"; + $sql = ""; + $sql .= " select * from v_gateways "; + if (permission_exists('outbound_route_any_gateway')) { + $sql .= " order by domain_uuid = '$domain_uuid' "; + } + else { + $sql .= " where domain_uuid = '$domain_uuid' "; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset ($prep_statement, $sql); + echo "\n"; + echo "
\n"; + echo "Select another gateway as an alternative to use if the second one fails.\n"; + echo "
Dialplan Expression:"; + echo " \n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " Shortcut to create the outbound dialplan entries for this Gateway. \n"; + echo "
\n"; + echo " Prefix:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter a prefix number to add to the beginning of the destination number.\n"; + echo "
\n"; + echo " Limit:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter limit to restrict the number of outbound calls.\n"; + echo "
\n"; + echo " Order:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Select the order number. The order number determines the order of the outbound routes when there is more than one.\n"; + echo "
\n"; + echo " Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Choose to enable or disable the outbound route.\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter a description for the outbound route.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo "
"; + echo "
"; + + echo "
"; + echo ""; + + echo "

"; + +//show the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/dialplan_outbound/root.php b/app/dialplan_outbound/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/dialplan_outbound/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/exec/app_config.php b/app/exec/app_config.php new file mode 100644 index 0000000000..3a0e8c97e9 --- /dev/null +++ b/app/exec/app_config.php @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/app/exec/root.php b/app/exec/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/exec/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/exec/v_exec.php b/app/exec/v_exec.php new file mode 100644 index 0000000000..e67237910d --- /dev/null +++ b/app/exec/v_exec.php @@ -0,0 +1,204 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('exec_command_line') || permission_exists('exec_php_command') || permission_exists('exec_switch')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the html values and set them as variables + if (count($_POST)>0) { + $shell_cmd = trim($_POST["shell_cmd"]); + $php_cmd = trim($_POST["php_cmd"]); + $switch_cmd = trim($_POST["switch_cmd"]); + } + +//show the header + require_once "includes/header.php"; + +//edit area + echo " \n"; + echo " \n"; + + echo " "; + +//show the header + echo "
"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + +//show the result + if (count($_POST)>0) { + echo " \n"; + echo " \n"; + echo " "; + } + +//html form + echo "\n"; + + if (permission_exists('exec_command_line')) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if (if_group("superadmin")) { + if (strlen($user_context) == 0) { + if (count($_SESSION["domains"]) > 1) { + $user_context = $_SESSION['domain_name']; + } + else { + $user_context = "default"; + } + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + //--- begin: show_advanced ----------------------- + echo "\n"; + echo "\n"; + echo "\n"; + //--- end: show_advanced ----------------------- + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Execute Command
\n"; + echo " Provides a conventient way to execute system, PHP, and switch commands.\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + + //shell_cmd + if (strlen($shell_cmd) > 0 && permission_exists('exec_command_line')) { + echo "$shell_cmd\n"; + echo "\n"; + echo "
";
+			echo htmlentities($shell_result);
+			echo "
\n"; + } + + //php_cmd + if (strlen($php_cmd) > 0 && permission_exists('exec_php_command')) { + //echo "\n"; + echo "
";
+			$php_result = eval($php_cmd);
+			echo htmlentities($php_result);
+			echo "
\n"; + } + + //fs cmd + if (strlen($switch_cmd) > 0 && permission_exists('exec_switch')) { + echo "$switch_cmd\n"; + echo "
";
+			$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
+			if ($fp) {
+				$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
+				//$switch_result = eval($switch_cmd);
+				echo htmlentities($switch_result);
+			}
+			echo "
\n"; + } + echo "
\n"; + echo "
\n"; + echo " Shell command:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "If a MAC address is not in the select list it can be added manually.
MAC Address:Line Number\n"; + echo "
\n"; + echo "
\n"; + echo " Voicemail Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enable/disable voicemail for this extension.\n"; + echo "
\n"; + echo " Voicemail Mail To:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Optional: Enter the email address to send voicemail to.\n"; + echo "
\n"; + echo " Voicemail Attach File:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Choose whether to attach the file to the email.\n"; + echo "
\n"; + echo " VM Keep Local After Email:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Keep local file after sending the email. \n"; + echo "
\n"; + echo " Toll Allow:\n"; + echo "\n"; + if (permission_exists('extension_toll')) { + echo " \n"; + echo "
\n"; + echo "Enter the toll allow value here. example: domestic,international,local\n"; + } + echo "
\n"; + echo " Call Group:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the user call group here. Groups available by default: sales, support, billing\n"; + echo "
\n"; + echo " User Context:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the user context here.\n"; + echo "
\n"; + + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Show Advanced\n"; + echo " \n"; + echo "
\n"; + echo "
\n"; + + echo "
\n"; + echo " \n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo " Hold Music:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the hold music here.\n"; + echo "
\n"; + echo " Auth ACL:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the Auth ACL here.\n"; + echo "
\n"; + echo " CIDR:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the cidr here.\n"; + echo "
\n"; + echo " SIP Force Contact:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Choose whether to rewrite the contact port, or rewrite both the contact IP and port.\n"; + echo "
\n"; + echo " SIP Force Expires:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the sip force expire seconds.\n"; + echo "
\n"; + echo " Nibblebill Account:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the account number for nibblebill to use.\n"; + echo "
\n"; + echo " MWI Account:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "MWI Account with user@domain of the voicemail to monitor.\n"; + echo "
\n"; + echo " SIP Bypass Media:\n"; echo "\n"; + echo " \n"; + echo "
\n"; + echo "Choose whether to send the media stream point to point or in transparent proxy mode.\n"; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo " Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo " "; + echo " "; + echo ""; + echo "
"; + +require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/fax/app_config.php b/app/fax/app_config.php new file mode 100644 index 0000000000..4e282a4b13 --- /dev/null +++ b/app/fax/app_config.php @@ -0,0 +1,190 @@ + \ No newline at end of file diff --git a/app/fax/root.php b/app/fax/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/fax/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/fax/v_fax.php b/app/fax/v_fax.php new file mode 100644 index 0000000000..bb0aebdae9 --- /dev/null +++ b/app/fax/v_fax.php @@ -0,0 +1,180 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('fax_extension_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get the http get values and set them as php variables + $order_by = check_str($_GET["order_by"]); + $order = check_str($_GET["order"]); + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "

FAX
\n"; + echo " To receive a FAX setup a fax extension and then direct the incoming to it.\n"; + echo "

\n"; + echo "
\n"; + echo "
"; + + if (if_group("superadmin") || if_group("admin")) { + //show all fax extensions + $sql = "select count(*) as num_rows from v_fax "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + } + else { + //show only assigned fax extensions + $sql = "select count(*) as num_rows from v_fax as f, v_fax_users as u "; + $sql .= "where f.fax_uuid = u.fax_uuid "; + $sql .= "and f.domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and u.user_uuid = '".$_SESSION['user_uuid']."' "; + } + if ($prep_statement) { + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + unset($prep_statement, $result); + + $rows_per_page = 150; + $param = ""; + $page = check_str($_GET['page']); + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + if (if_group("superadmin") || if_group("admin")) { + //show all fax extensions + $sql = "select * from v_fax "; + $sql .= "where domain_uuid = '$domain_uuid' "; + } + else { + //show only assigned fax extensions + $sql = "select * from v_fax as f, v_fax_users as u "; + $sql .= "where f.fax_uuid = u.fax_uuid "; + $sql .= "and f.domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and u.user_uuid = '".$_SESSION['user_uuid']."' "; + } + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo th_order_by('fax_extension', 'Extension', $order_by, $order); + echo th_order_by('fax_name', 'Name', $order_by, $order); + echo th_order_by('fax_email', 'Email', $order_by, $order); + echo th_order_by('fax_description', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + if (permission_exists('fax_extension_add')) { + echo " $v_link_label_add\n"; + } + echo "
".$row['fax_extension']."".$row['fax_name']."".$row['fax_email']." ".$row['fax_description']." \n"; + if (permission_exists('fax_extension_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('fax_extension_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('fax_extension_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//show the footer + require_once "includes/footer.php"; +?> diff --git a/app/fax/v_fax_delete.php b/app/fax/v_fax_delete.php new file mode 100644 index 0000000000..1cf8a126cc --- /dev/null +++ b/app/fax/v_fax_delete.php @@ -0,0 +1,97 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('fax_extension_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the http get value and set it as a php variable + if (count($_GET)>0) { + $fax_uuid = check_str($_GET["id"]); + } + +//delete the fax extension + if (strlen($fax_uuid)>0) { + + //get the dialplan uuid + $sql = "select * from v_fax "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and fax_uuid = '$fax_uuid' "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + while($row = $prep_statement->fetch(PDO::FETCH_ASSOC)) { + $dialplan_uuid = $row['dialplan_uuid']; + } + + //delete the fax entry + $sql = ""; + $sql .= "delete from v_fax "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and fax_uuid = '$fax_uuid' "; + $db->query($sql); + unset($sql); + + //delete the dialplan entry + $sql = ""; + $sql .= "delete from v_dialplans "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + //echo $sql."
\n"; + $db->query($sql); + unset($sql); + + //delete the dialplan details + $sql = ""; + $sql .= "delete from v_dialplan_details "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + //echo $sql."
\n"; + $db->query($sql); + unset($sql); + + //syncrhonize configuration + save_dialplan_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + } + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/fax/v_fax_edit.php b/app/fax/v_fax_edit.php new file mode 100644 index 0000000000..4b19a438df --- /dev/null +++ b/app/fax/v_fax_edit.php @@ -0,0 +1,631 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('fax_extension_add') || permission_exists('fax_extension_edit') || permission_exists('fax_extension_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the fax_extension and save it as a variable + if (strlen($_REQUEST["fax_extension"]) > 0) { + $fax_extension = check_str($_REQUEST["fax_extension"]); + } + +//set the fax directory + if (count($_SESSION["domains"]) > 1) { + $v_fax_dir = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name']; + } + else { + $v_fax_dir = $_SESSION['switch']['storage']['dir'].'/fax'; + } + +//get the fax extension + if (strlen($fax_extension) > 0) { + //set the fax directories. example /usr/local/freeswitch/storage/fax/329/inbox + $dir_fax_inbox = $v_fax_dir.'/'.$fax_extension.'/inbox'; + $dir_fax_sent = $v_fax_dir.'/'.$fax_extension.'/sent'; + $dir_fax_temp = $v_fax_dir.'/'.$fax_extension.'/temp'; + + //make sure the directories exist + if (!is_dir($_SESSION['switch']['storage']['dir'])) { + mkdir($_SESSION['switch']['storage']['dir']); + chmod($dir_fax_sent,0774); + } + if (!is_dir($v_fax_dir.'/'.$fax_extension)) { + mkdir($v_fax_dir.'/'.$fax_extension,0774,true); + chmod($v_fax_dir.'/'.$fax_extension,0774); + } + if (!is_dir($dir_fax_inbox)) { + mkdir($dir_fax_inbox,0774,true); + chmod($dir_fax_inbox,0774); + } + if (!is_dir($dir_fax_sent)) { + mkdir($dir_fax_sent,0774,true); + chmod($dir_fax_sent,0774); + } + if (!is_dir($dir_fax_temp)) { + mkdir($dir_fax_temp,0774,true); + chmod($dir_fax_temp,0774); + } + } + +//set the action as an add or an update + if (isset($_REQUEST["id"])) { + $action = "update"; + $fax_uuid = check_str($_REQUEST["id"]); + $dialplan_uuid = check_str($_REQUEST["dialplan_uuid"]); + } + else { + $action = "add"; + } + +//get the http post values and set them as php variables + if (count($_POST)>0) { + $fax_name = check_str($_POST["fax_name"]); + $fax_email = check_str($_POST["fax_email"]); + $fax_pin_number = check_str($_POST["fax_pin_number"]); + $fax_caller_id_name = check_str($_POST["fax_caller_id_name"]); + $fax_caller_id_number = check_str($_POST["fax_caller_id_number"]); + $fax_forward_number = check_str($_POST["fax_forward_number"]); + if (strlen($fax_forward_number) > 0) { + $fax_forward_number = preg_replace("~[^0-9]~", "",$fax_forward_number); + } + $fax_description = check_str($_POST["fax_description"]); + } + +//delete the user from the v_fax_users + if ($_GET["a"] == "delete" && permission_exists("fax_extension_delete")) { + //set the variables + $user_uuid = check_str($_REQUEST["user_uuid"]); + $fax_uuid = check_str($_REQUEST["id"]); + //delete the group from the users + $sql = "delete from v_fax_users "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and fax_uuid = '".$fax_uuid."' "; + $sql .= "and user_uuid = '".$user_uuid."' "; + $db->exec(check_sql($sql)); + //redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
Delete Complete
"; + require_once "includes/footer.php"; + return; + } + +//add the user to the v_fax_users + if (strlen($_REQUEST["user_uuid"]) > 0 && strlen($_REQUEST["id"]) > 0 && $_GET["a"] != "delete") { + //set the variables + $user_uuid = check_str($_REQUEST["user_uuid"]); + $fax_uuid = check_str($_REQUEST["id"]); + //assign the user to the fax extension + $sql_insert = "insert into v_fax_users "; + $sql_insert .= "("; + $sql_insert .= "fax_user_uuid, "; + $sql_insert .= "domain_uuid, "; + $sql_insert .= "fax_uuid, "; + $sql_insert .= "user_uuid "; + $sql_insert .= ")"; + $sql_insert .= "values "; + $sql_insert .= "("; + $sql_insert .= "'".uuid()."', "; + $sql_insert .= "'".$_SESSION['domain_uuid']."', "; + $sql_insert .= "'".$fax_uuid."', "; + $sql_insert .= "'".$user_uuid."' "; + $sql_insert .= ")"; + $db->exec($sql_insert); + //redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
Add Complete
"; + require_once "includes/footer.php"; + return; + } + +//clear file status cache + clearstatcache(); + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update" && permission_exists('fax_extension_edit')) { + $fax_uuid = check_str($_POST["fax_uuid"]); + } + + //check for all required data + if (strlen($fax_extension) == 0) { $msg .= "Please provide: Extension
\n"; } + if (strlen($fax_name) == 0) { $msg .= "Please provide: A file to Fax
\n"; } + //if (strlen($fax_email) == 0) { $msg .= "Please provide: Email
\n"; } + //if (strlen($fax_pin_number) == 0) { $msg .= "Please provide: Pin Number
\n"; } + //if (strlen($fax_caller_id_name) == 0) { $msg .= "Please provide: Caller ID Name
\n"; } + //if (strlen($fax_caller_id_number) == 0) { $msg .= "Please provide: Caller ID Number
\n"; } + //if (strlen($fax_forward_number) == 0) { $msg .= "Please provide: Forward Number
\n"; } + //if (strlen($fax_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //set the PHP_BIN + if (file_exists(PHP_BINDIR."/php")) { define(PHP_BIN, 'php'); } + if (file_exists(PHP_BINDIR."/php.exe")) { define(PHP_BIN, 'php.exe'); } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('fax_extension_add')) { + //prepare the unique identifiers + $fax_uuid = uuid(); + $dialplan_uuid = uuid(); + + //add the fax extension to the database + $sql = "insert into v_fax "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "fax_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "fax_extension, "; + $sql .= "fax_name, "; + $sql .= "fax_email, "; + $sql .= "fax_pin_number, "; + $sql .= "fax_caller_id_name, "; + $sql .= "fax_caller_id_number, "; + if (strlen($fax_forward_number) > 0) { + $sql .= "fax_forward_number, "; + } + $sql .= "fax_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$_SESSION['domain_uuid']."', "; + $sql .= "'$fax_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$fax_extension', "; + $sql .= "'$fax_name', "; + $sql .= "'$fax_email', "; + $sql .= "'$fax_pin_number', "; + $sql .= "'$fax_caller_id_name', "; + $sql .= "'$fax_caller_id_number', "; + if (strlen($fax_forward_number) > 0) { + $sql .= "'$fax_forward_number', "; + } + $sql .= "'$fax_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //create the dialplan entry for fax + $dialplan_name = $fax_name; + $dialplan_order ='333'; + $dialplan_context = $_SESSION['context']; + $dialplan_enabled = 'true'; + $dialplan_description = $fax_description; + $app_uuid = '24108154-4ac3-1db6-1551-4731703a4440'; + dialplan_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_name, $dialplan_order, $dialplan_context, $dialplan_enabled, $dialplan_description, $app_uuid); + + // + // + $dialplan_detail_tag = 'condition'; //condition, action, antiaction + $dialplan_detail_type = 'destination_number'; + $dialplan_detail_data = '^'.$fax_extension.'$'; + $dialplan_detail_order = '000'; + $dialplan_detail_group = ''; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + // + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + $dialplan_detail_data = "api_hangup_hook=system ".PHP_BINDIR."/".PHP_BIN." ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/fax_to_email.php "; + $dialplan_detail_data .= "email=".$fax_email." "; + $dialplan_detail_data .= "extension=".$fax_extension." "; + $dialplan_detail_data .= "name=\\\\\\\${last_fax} "; + $dialplan_detail_data .= "messages='result: \\\\\\\${fax_result_text} sender:\\\\\\\${fax_remote_station_id} pages:\\\\\\\${fax_document_total_pages}' "; + $dialplan_detail_data .= "domain=".$_SESSION['domain_name']." "; + $dialplan_detail_data .= "caller_id_name='\\\\\\\${caller_id_name}' "; + $dialplan_detail_data .= "caller_id_number=\\\\\\\${caller_id_number} "; + + $dialplan_detail_order = '010'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + // + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'answer'; + $dialplan_detail_data = ''; + $dialplan_detail_order = '010'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + //// + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + $dialplan_detail_data = 'fax_enable_t38=true'; + $dialplan_detail_order = '015'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + //// + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + $dialplan_detail_data = 'fax_enable_t38_request=true'; + $dialplan_detail_order = '020'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + // + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + $dialplan_detail_data = 'last_fax=${caller_id_number}-${strftime(%Y-%m-%d-%H-%M-%S)}'; + $dialplan_detail_order = '025'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + // + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'playback'; + $dialplan_detail_data = 'silence_stream://2000'; + $dialplan_detail_order = '030'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + // + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'rxfax'; + if (count($_SESSION["domains"]) > 1) { + $dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name'].'/'.$fax_extension.'/inbox/${last_fax}.tif'; + } + else { + $dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$fax_extension.'/inbox/${last_fax}.tif'; + } + $dialplan_detail_order = '035'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + // + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'hangup'; + $dialplan_detail_data = ''; + $dialplan_detail_order = '040'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + //save the xml + save_dialplan_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + + //redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update" && permission_exists('fax_extension_edit')) { + //update the fax extension in the database + $sql = "update v_fax set "; + $sql .= "fax_extension = '$fax_extension', "; + $sql .= "fax_name = '$fax_name', "; + $sql .= "fax_email = '$fax_email', "; + $sql .= "fax_pin_number = '$fax_pin_number', "; + $sql .= "fax_caller_id_name = '$fax_caller_id_name', "; + $sql .= "fax_caller_id_number = '$fax_caller_id_number', "; + if (strlen($fax_forward_number) > 0) { + $sql .= "fax_forward_number = '$fax_forward_number', "; + } + else { + $sql .= "fax_forward_number = null, "; + } + $sql .= "fax_description = '$fax_description' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and fax_uuid = '$fax_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + + //udpate the fax dialplan + $sql = "update v_dialplans set "; + $sql .= "dialplan_name = '$fax_name', "; + if (strlen($dialplan_order) > 0) { + $sql .= "dialplan_order = '333', "; + } + $sql .= "dialplan_context = '".$_SESSION['context']."', "; + $sql .= "dialplan_enabled = 'true', "; + $sql .= "dialplan_description = '$fax_description' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $db->query($sql); + unset($sql); + + //update dialplan detail condition + $sql = ""; + $sql = "update v_dialplan_details set "; + $sql .= "dialplan_detail_data = '^".$fax_extension."$' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_detail_tag = 'condition' "; + $sql .= "and dialplan_detail_type = 'destination_number' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $db->query($sql); + unset($sql); + + //update dialplan detail action + if (count($_SESSION["domains"]) > 1) { + $dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name'].'/'.$fax_extension.'/inbox/${last_fax}.tif'; + } + else { + $dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$fax_extension.'/inbox/${last_fax}.tif'; + } + $sql = ""; + $sql = "update v_dialplan_details set "; + $sql .= "dialplan_detail_data = '".$dialplan_detail_data."' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_detail_tag = 'action' "; + $sql .= "and dialplan_detail_type = 'rxfax' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $db->query($sql); + + //update dialplan detail action + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + $dialplan_detail_data = "api_hangup_hook=system ".PHP_BINDIR."/".PHP_BIN." ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/fax_to_email.php "; + $dialplan_detail_data .= "email=".$fax_email." "; + $dialplan_detail_data .= "extension=".$fax_extension." "; + $dialplan_detail_data .= "name=\\\\\\\${last_fax} "; + $dialplan_detail_data .= "messages='result: \\\\\\\${fax_result_text} sender:\\\\\\\${fax_remote_station_id} pages:\\\\\\\${fax_document_total_pages}' "; + $dialplan_detail_data .= "domain=".$_SESSION['domain_name']." "; + $dialplan_detail_data .= "caller_id_name='\\\\\\\${caller_id_name}' "; + $dialplan_detail_data .= "caller_id_number=\\\\\\\${caller_id_number} "; + $sql = "update v_dialplan_details set "; + $sql .= "dialplan_detail_data = '".check_str($dialplan_detail_data)."' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_detail_tag = 'action' "; + $sql .= "and dialplan_detail_type = 'set' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $sql .= "and dialplan_detail_data like 'api_hangup_hook=%' "; + $db->query(check_sql($sql)); + + //save the xml + save_dialplan_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + + //redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (strlen($_GET['id']) > 0 && $_POST["persistformvar"] != "true") { + $fax_uuid = check_str($_GET["id"]); + $sql = ""; + $sql .= "select * from v_fax "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and fax_uuid = '$fax_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + if (count($result) == 0) { + echo "access denied"; + exit; + } + foreach ($result as &$row) { + $dialplan_uuid = $row["dialplan_uuid"]; + $fax_extension = $row["fax_extension"]; + $fax_name = $row["fax_name"]; + $fax_email = $row["fax_email"]; + $fax_pin_number = $row["fax_pin_number"]; + $fax_caller_id_name = $row["fax_caller_id_name"]; + $fax_caller_id_number = $row["fax_caller_id_number"]; + $fax_forward_number = $row["fax_forward_number"]; + $fax_description = $row["fax_description"]; + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//fax extension form + echo "
"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if (if_group("admin") || if_group("superadmin")) { + if ($action == "update") { + echo " "; + echo " "; + echo " "; + echo " "; + } + } + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Fax AddFax Edit
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the name here.\n"; + echo "
\n"; + echo " Extension:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the fax extension here.\n"; + echo "
\n"; + echo " Email:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo " Enter the email address to send the FAX to.\n"; + echo "
\n"; + echo " PIN Number:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the PIN number here.\n"; + echo "
\n"; + echo " Caller ID Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the Caller ID name here.\n"; + echo "
\n"; + echo " Caller ID Number:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the Caller ID number here.\n"; + echo "
\n"; + echo " Forward Number:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the forward number here. Used to forward the fax to a registered extension or external number.\n"; + echo "
User List:"; + + echo " \n"; + $sql = "SELECT * FROM v_fax_users as e, v_users as u "; + $sql .= "where e.user_uuid = u.user_uuid "; + $sql .= "and e.domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and e.fax_uuid = '".$fax_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + $result_count = count($result); + foreach($result as $field) { + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + } + echo "
".$field['username']."\n"; + echo " $v_link_label_delete\n"; + echo "
\n"; + + echo "
\n"; + $sql = "SELECT * FROM v_users "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + echo " "; + echo " \n"; + unset($sql, $result); + echo "
\n"; + echo " Assign the users that are can manage this fax extension.\n"; + echo "
\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the description here.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + echo " \n"; + } + echo " \n"; + echo "
"; + echo "
"; + echo "
"; + + echo "
\n"; + echo "
\n"; + +//show the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/fax/v_fax_view.php b/app/fax/v_fax_view.php new file mode 100644 index 0000000000..2bc36fa9f9 --- /dev/null +++ b/app/fax/v_fax_view.php @@ -0,0 +1,725 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('fax_extension_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the fax_extension and save it as a variable + if (strlen($_REQUEST["fax_extension"]) > 0) { + $fax_extension = check_str($_REQUEST["fax_extension"]); + } + +//pre-populate the form + if (strlen($_GET['id']) > 0 && $_POST["persistformvar"] != "true") { + $fax_uuid = check_str($_GET["id"]); + if (if_group("superadmin") || if_group("admin")) { + //show all fax extensions + $sql = "select * from v_fax "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and fax_uuid = '$fax_uuid' "; + } + else { + //show only assigned fax extensions + $sql = "select * from v_fax as f, v_fax_users as u "; + $sql .= "where f.fax_uuid = u.fax_uuid "; + $sql .= "and f.domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and f.fax_uuid = '$fax_uuid' "; + $sql .= "and u.user_uuid = '".$_SESSION['user_uuid']."' "; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + if (count($result) == 0) { + if (if_group("superadmin") || if_group("admin")) { + //allow access + } + else { + echo "access denied"; + exit; + } + } + foreach ($result as &$row) { + //set database fields as variables + $fax_extension = $row["fax_extension"]; + $fax_name = $row["fax_name"]; + $fax_email = $row["fax_email"]; + $fax_pin_number = $row["fax_pin_number"]; + $fax_caller_id_name = $row["fax_caller_id_name"]; + $fax_caller_id_number = $row["fax_caller_id_number"]; + $fax_forward_number = $row["fax_forward_number"]; + $fax_description = $row["fax_description"]; + //limit to one row + break; + } + unset ($prep_statement); + } + +//set the fax directory + if (count($_SESSION["domains"]) > 1) { + $v_fax_dir = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name']; + } + else { + $v_fax_dir = $_SESSION['switch']['storage']['dir'].'/fax'; + } + +//delete a fax + if ($_GET['a'] == "del" && permission_exists('fax_inbox_delete')) { + $file_name = substr(check_str($_GET['filename']), 0, -4); + $file_ext = substr(check_str($_GET['filename']), -3); + if ($_GET['type'] == "fax_inbox") { + unlink($v_fax_dir.'/'.$fax_extension.'/inbox/'.$file_name.".tif"); + unlink($v_fax_dir.'/'.$fax_extension.'/inbox/'.$file_name.".pdf"); + } + if ($_GET['type'] == "fax_sent") { + unlink($v_fax_dir.'/'.$fax_extension.'/sent/'.$file_name.".tif"); + unlink($v_fax_dir.'/'.$fax_extension.'/sent/'.$file_name.".pdf"); + } + unset($file_name); + unset($file_ext); + } + +//download a fax + if ($_GET['a'] == "download") { + session_cache_limiter('public'); + //test to see if it is in the inbox or sent directory. + if ($_GET['type'] == "fax_inbox") { + if (file_exists($v_fax_dir.'/'.check_str($_GET['ext']).'/inbox/'.check_str($_GET['filename']))) { + $tmp_faxdownload_file = "".$v_fax_dir.'/'.check_str($_GET['ext']).'/inbox/'.check_str($_GET['filename']); + } + } + else if ($_GET['type'] == "fax_sent") { + if (file_exists($v_fax_dir.'/'.check_str($_GET['ext']).'/sent/'.check_str($_GET['filename']))) { + $tmp_faxdownload_file = "".$v_fax_dir.'/'.check_str($_GET['ext']).'/sent/'.check_str($_GET['filename']); + } + } + //let's see if we found it. + if (strlen($tmp_faxdownload_file) > 0) { + $fd = fopen($tmp_faxdownload_file, "rb"); + if ($_GET['t'] == "bin") { + header("Content-Type: application/force-download"); + header("Content-Type: application/octet-stream"); + header("Content-Type: application/download"); + header("Content-Description: File Transfer"); + header('Content-Disposition: attachment; filename="'.check_str($_GET['filename']).'"'); + } + else { + $file_ext = substr(check_str($_GET['filename']), -3); + if ($file_ext == "tif") { + header("Content-Type: image/tiff"); + } + else if ($file_ext == "png") { + header("Content-Type: image/png"); + } + else if ($file_ext == "jpg") { + header('Content-Type: image/jpeg'); + } + else if ($file_ext == "pdf") { + header("Content-Type: application/pdf"); + } + } + header('Accept-Ranges: bytes'); + header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 + header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // date in the past + header("Content-Length: " . filesize($tmp_faxdownload_file)); + fpassthru($fd); + } + else { + echo "File not found."; + } + exit; + } + +//get the fax extension + if (strlen($fax_extension) > 0) { + //set the fax directories. example /usr/local/freeswitch/storage/fax/329/inbox + $dir_fax_inbox = $v_fax_dir.'/'.$fax_extension.'/inbox'; + $dir_fax_sent = $v_fax_dir.'/'.$fax_extension.'/sent'; + $dir_fax_temp = $v_fax_dir.'/'.$fax_extension.'/temp'; + + //make sure the directories exist + if (!is_dir($_SESSION['switch']['storage']['dir'])) { + mkdir($_SESSION['switch']['storage']['dir']); + chmod($dir_fax_sent,0774); + } + if (!is_dir($v_fax_dir.'/'.$fax_extension)) { + mkdir($v_fax_dir.'/'.$fax_extension,0774,true); + chmod($v_fax_dir.'/'.$fax_extension,0774); + } + if (!is_dir($dir_fax_inbox)) { + mkdir($dir_fax_inbox,0774,true); + chmod($dir_fax_inbox,0774); + } + if (!is_dir($dir_fax_sent)) { + mkdir($dir_fax_sent,0774,true); + chmod($dir_fax_sent,0774); + } + if (!is_dir($dir_fax_temp)) { + mkdir($dir_fax_temp,0774,true); + chmod($dir_fax_temp,0774); + } + } + +//set the action as an add or an update + if (isset($_REQUEST["id"])) { + $action = "update"; + $fax_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get the http post values and set them as php variables + if (count($_POST)>0) { + $fax_name = check_str($_POST["fax_name"]); + $fax_email = check_str($_POST["fax_email"]); + $fax_pin_number = check_str($_POST["fax_pin_number"]); + $fax_caller_id_name = check_str($_POST["fax_caller_id_name"]); + $fax_caller_id_number = check_str($_POST["fax_caller_id_number"]); + $fax_forward_number = check_str($_POST["fax_forward_number"]); + if (strlen($fax_forward_number) > 0) { + $fax_forward_number = preg_replace("~[^0-9]~", "",$fax_forward_number); + } + $fax_description = check_str($_POST["fax_description"]); + } + +//clear file status cache + clearstatcache(); + +//upload and send the fax + if (($_POST['type'] == "fax_send") && is_uploaded_file($_FILES['fax_file']['tmp_name'])) { + + $fax_number = check_str($_POST['fax_number']); + if (strlen($fax_number) > 0) { + $fax_number = preg_replace("~[^0-9]~", "",$fax_number); + } + $fax_name = $_FILES['fax_file']['name']; + $fax_name = str_replace(" ", "_", $fax_name); + $fax_name = str_replace(".tif", "", $fax_name); + $fax_name = str_replace(".tiff", "", $fax_name); + $fax_name = str_replace(".pdf", "", $fax_name); + $provider_type = check_str($_POST['provider_type']); + $fax_uuid = check_str($_POST["id"]); + + $fax_caller_id_name = check_str($_POST['fax_caller_id_name']); + $fax_caller_id_number = check_str($_POST['fax_caller_id_number']); + $fax_forward_number = check_str($_POST['fax_forward_number']); + if (strlen($fax_forward_number) > 0) { + $fax_forward_number = preg_replace("~[^0-9]~", "",$fax_forward_number); + } + + //get the fax file extension + $fax_file_extension = substr($dir_fax_temp.'/'.$_FILES['fax_file']['name'], -4); + if ($fax_file_extension == "tiff") { $fax_file_extension = ".tif"; } + + //upload the file + move_uploaded_file($_FILES['fax_file']['tmp_name'], $dir_fax_temp.'/'.$fax_name.$fax_file_extension); + + if ($fax_file_extension == ".pdf") { + chdir($dir_fax_temp); + exec("gs -q -sDEVICE=tiffg3 -r204x98 -dNOPAUSE -sOutputFile=".$fax_name.".tif -- ".$fax_name.".pdf -c quit"); + //exec("rm ".$dir_fax_temp.'/'.$fax_name.".pdf"); + } + + //send the fax + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + if ($fp) { + //prepare the fax originate command + $route_array = outbound_route_to_bridge($fax_number); + $fax_file = $dir_fax_temp."/".$fax_name.".tif"; + if (count($route_array) == 0) { + //send the internal call to the registered extension + $fax_uri = "user/".$fax_number."@".$_SESSION['domain_name']; + $t38 = ""; + } + else { + //send the external call + $fax_uri = $route_array[0]; + $t38 = "fax_enable_t38=true,fax_enable_t38_request=true,"; + } + $cmd = "api originate {origination_caller_id_name='".$fax_caller_id_name."',origination_caller_id_number='".$fax_caller_id_number."',fax_ident='".$fax_caller_id_number."',fax_header='".$fax_caller_id_name."',fax_uri=".$fax_uri.",fax_file='".$fax_file."',fax_retry_attempts=1,fax_retry_limit=20,fax_retry_sleep=180,fax_verbose=true,fax_use_ecm=off,".$t38."api_hangup_hook='lua fax_retry.lua'}".$fax_uri." &txfax('".$fax_file."')"; + //send the command to event socket + $response = event_socket_request($fp, $cmd); + $response = str_replace("\n", "", $response); + $uuid = str_replace("+OK ", "", $response); + fclose($fp); + } + + //wait for a few seconds + sleep(5); + + //copy the .tif to the sent directory + exec("cp ".$dir_fax_temp.'/'.$fax_name.".tif ".$dir_fax_sent.'/'.$fax_name.".tif"); + + //convert the tif to pdf + chdir($dir_fax_sent); + exec("gs -q -sDEVICE=tiffg3 -g1728x1078 -dNOPAUSE -sOutputFile=".$fax_name.".pdf -- ".$fax_name.".tif -c quit"); + + //delete the .tif from the temp directory + //exec("rm ".$dir_fax_temp.'/'.$fax_name.".tif"); + + //convert the tif to pdf and png + chdir($dir_fax_sent); + //which tiff2pdf + if (is_file("/usr/local/bin/tiff2png")) { + exec($_SESSION['switch']['bin']['dir']."/tiff2png ".$dir_fax_sent.$fax_name.".tif"); + exec($_SESSION['switch']['bin']['dir']."/tiff2pdf -f -o ".$fax_name.".pdf ".$dir_fax_sent.$fax_name.".tif"); + } + + header("Location: v_fax_view.php?id=".$fax_uuid."&msg=".$response); + exit; + } //end upload and send fax + +//delete the fax + if ($_GET['a'] == "del") { + $fax_extension = check_str($_GET["fax_extension"]); + if ($_GET['type'] == "fax_inbox" && permission_exists('fax_inbox_delete')) { + unlink($v_fax_dir.'/'.$fax_extension.'/inbox/'.check_str($_GET['filename'])); + } + if ($_GET['type'] == "fax_sent" && permission_exists('fax_sent_delete')) { + unlink($v_fax_dir.'/'.$fax_extension.'/sent/'.check_str($_GET['filename'])); + } + } + +//download the fax + if ($_GET['a'] == "download") { + session_cache_limiter('public'); + //test to see if it is in the inbox or sent directory. + if ($_GET['type'] == "fax_inbox" && permission_exists('fax_inbox_view')) { + if (file_exists($v_fax_dir.'/'.check_str($_GET['ext']).'/inbox/'.check_str($_GET['filename']))) { + $tmp_faxdownload_file = "".$v_fax_dir.'/'.check_str($_GET['ext']).'/inbox/'.check_str($_GET['filename']); + } + }else if ($_GET['type'] == "fax_sent" && permission_exists('fax_sent_view')) { + if (file_exists($v_fax_dir.'/'.check_str($_GET['ext']).'/sent/'.check_str($_GET['filename']))) { + $tmp_faxdownload_file = "".$v_fax_dir.'/'.check_str($_GET['ext']).'/sent/'.check_str($_GET['filename']); + } + } + //check to see if it was found. + if (strlen($tmp_faxdownload_file) > 0) { + $fd = fopen($tmp_faxdownload_file, "rb"); + if ($_GET['t'] == "bin") { + header("Content-Type: application/force-download"); + header("Content-Type: application/octet-stream"); + header("Content-Type: application/download"); + header("Content-Description: File Transfer"); + header('Content-Disposition: attachment; filename="'.check_str($_GET['filename']).'"'); + } + else { + $file_ext = substr(check_str($_GET['filename']), -3); + if ($file_ext == "tif") { + header("Content-Type: image/tiff"); + } else if ($file_ext == "png") { + header("Content-Type: image/png"); + } else if ($file_ext == "jpg") { + header('Content-Type: image/jpeg'); + } else if ($file_ext == "pdf") { + header("Content-Type: application/pdf"); + } + } + header('Accept-Ranges: bytes'); + header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 + header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past + header("Content-Length: " . filesize($tmp_faxdownload_file)); + fpassthru($fd); + } + else { + echo "File not found."; + } + //exit the code execution + exit; + } + +//show the header + require_once "includes/header.php"; + +//fax extension form + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + echo "
\n"; + echo " Fax Server\n"; + echo " \n"; + if (permission_exists('fax_extension_add') || permission_exists('fax_extension_edit')) { + echo " \n"; + } + echo " \n"; + echo "
\n"; + echo "
\n"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " "; + echo "
\n"; + //pkg_add -r ghostscript8-nox11; rehash + echo " To send a fax you can upload a .tif file or if ghost script has been installed then you can also send a fax by uploading a PDF. \n"; + echo " When sending a fax you can view status of the transmission by viewing the logs from the Status tab or by watching the response from the console.\n"; + echo "

\n"; + echo "
\n"; + echo " Fax Number:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the Number here.\n"; + echo "
\n"; + echo " Upload:\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " Select the file to upload and send as a fax.\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
"; + echo "
\n"; + echo "
\n"; + +//show the inbox + if (permission_exists('fax_inbox_view')) { + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " Inbox $fax_extension\n"; + echo " "; + if ($v_path_show) { + echo "location: "; + echo $dir_fax_inbox."     "; + } + echo "
\n"; + echo "\n"; + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo " \n"; + echo " \n"; + echo " "; + + + if ($handle = opendir($dir_fax_inbox)) { + //build an array of the files in the inbox + $i = 0; + $files = array(); + while (false !== ($file = readdir($handle))) { + if ($file != "." && $file != ".." && is_file($dir_fax_inbox.'/'.$file)) { + $file_path = $dir_fax_inbox.'/'.$file; + $modified = filemtime($file_path); + $index = $modified.$file; + $files[$index]['file'] = $file; + $files[$index]['name'] = substr($file, 0, -4); + $files[$index]['ext'] = substr($file, -3); + //$files[$index]['path'] = $file_path; + $files[$index]['size'] = filesize($file_path); + $files[$index]['size_bytes'] = byte_convert(filesize($file_path)); + $files[$index]['modified'] = filemtime($file_path); + $file_name_array[$i++] = $index; + } + } + closedir($handle); + //order the index array + sort($file_name_array,SORT_STRING); + + //loop through the file array + foreach($file_name_array as $i) { + if (strtolower($files[$i]['ext']) == "tif") { + $file = $files[$i]['file']; + $file_name = $files[$i]['name']; + $file_ext = $files[$i]['ext']; + $file_modified = $files[$i]['modified']; + $file_size_bytes = byte_convert($files[$i]['size']); + if (!file_exists($dir_fax_inbox.'/'.$file_name.".pdf")) { + //convert the tif to pdf + chdir($dir_fax_inbox); + if (is_file("/usr/local/bin/tiff2pdf")) { + exec("/usr/local/bin/tiff2pdf -f -o ".$file_name.".pdf ".$dir_fax_inbox.'/'.$file_name.".tif"); + } + if (is_file("/usr/bin/tiff2pdf")) { + exec("/usr/bin/tiff2pdf -f -o ".$file_name.".pdf ".$dir_fax_inbox.'/'.$file_name.".tif"); + } + } + //if (!file_exists($dir_fax_inbox.'/'.$file_name.".jpg")) { + // //convert the tif to jpg + // chdir($dir_fax_inbox); + // if (is_file("/usr/local/bin/tiff2rgba")) { + // exec("/usr/local/bin/tiff2rgba ".$file_name.".tif ".$dir_fax_inbox.'/'.$file_name.".jpg"); + // } + // if (is_file("/usr/bin/tiff2rgba")) { + // exec("/usr/bin/tiff2rgba ".$file_name.".tif ".$dir_fax_inbox.'/'.$file_name.".jpg"); + // } + //} + echo "\n"; + echo " \n"; + + echo " \n"; + + //echo " \n"; + + echo " \n"; + + echo " \n"; + + echo " \n"; + echo "\n"; + } + } + } + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
File Name (download)\n"; + echo " View\n"; + echo " Last Modified\n"; + echo " Size\n"; + echo "
\n"; + echo " \n"; + echo " $file_name"; + echo " "; + echo " \n"; + if (file_exists($dir_fax_inbox.'/'.$file_name.".pdf")) { + echo " \n"; + echo " PDF"; + echo " "; + } + else { + echo " \n"; + } + echo " \n"; + //if (file_exists($dir_fax_inbox.'/'.$file_name.".jpg")) { + // echo " \n"; + // echo " jpg"; + // echo " "; + //} + //else { + // echo " \n"; + //} + //echo "  \n"; + echo " ".date("F d Y H:i:s", $file_modified); + echo " \n"; + echo " ".$file_size_bytes; + echo " \n"; + echo " \n"; + echo " \n"; + if (permission_exists('fax_inbox_delete')) { + echo " \n"; + } + echo " \n"; + echo "
$v_link_label_delete
\n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + } + +//show the sent box + if (permission_exists('fax_sent_view')) { + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " Sent\n"; + echo " \n"; + if ($v_path_show) { + echo "location: \n"; + echo $dir_fax_sent."     \n"; + } + echo "
\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + + if ($handle = opendir($dir_fax_sent)) { + //build an array of the files in the inbox + $i = 0; + $files = array(); + while (false !== ($file = readdir($handle))) { + if ($file != "." && $file != ".." && is_file($dir_fax_sent.'/'.$file)) { + $file_path = $dir_fax_sent.'/'.$file; + $modified = filemtime($file_path); + $index = $modified.$file; + $files[$index]['file'] = $file; + $files[$index]['name'] = substr($file, 0, -4); + $files[$index]['ext'] = substr($file, -3); + //$files[$index]['path'] = $file_path; + $files[$index]['size'] = filesize($file_path); + $files[$index]['size_bytes'] = byte_convert(filesize($file_path)); + $files[$index]['modified'] = filemtime($file_path); + $file_name_array[$i++] = $index; + } + } + closedir($handle); + //order the index array + sort($file_name_array,SORT_STRING); + + //loop through the file array + foreach($file_name_array as $i) { + if (strtolower($files[$i]['ext']) == "tif") { + $file = $files[$i]['file']; + $file_name = $files[$i]['name']; + $file_ext = $files[$i]['ext']; + $file_modified = $files[$i]['modified']; + $file_size_bytes = byte_convert($files[$i]['size']); + + if (!file_exists($dir_fax_sent.'/'.$file_name.".pdf")) { + //convert the tif to pdf + chdir($dir_fax_sent); + if (is_file("/usr/local/bin/tiff2pdf")) { + exec("/usr/local/bin/tiff2pdf -f -o ".$file_name.".pdf ".$dir_fax_sent.'/'.$file_name.".tif"); + } + if (is_file("/usr/bin/tiff2pdf")) { + exec("/usr/bin/tiff2pdf -f -o ".$file_name.".pdf ".$dir_fax_sent.'/'.$file_name.".tif"); + } + } + if (!file_exists($dir_fax_sent.'/'.$file_name.".jpg")) { + //convert the tif to jpg + //chdir($dir_fax_sent); + //if (is_file("/usr/local/bin/tiff2rgba")) { + // exec("/usr/local/bin/tiff2rgba -c jpeg -n ".$file_name.".tif ".$dir_fax_sent.'/'.$file_name.".jpg"); + //} + //if (is_file("/usr/bin/tiff2rgba")) { + // exec("/usr/bin/tiff2rgba -c lzw -n ".$file_name.".tif ".$dir_fax_sent.'/'.$file_name.".jpg"); + //} + } + echo "\n"; + echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + + echo " \n"; + + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //check if the file is a .tif file + } + } + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
File Name (download)\n"; + echo " View\n"; + echo " Last Modified\n"; + echo " Size\n"; + echo "
\n"; + echo " \n"; + echo " $file"; + echo " "; + echo " \n"; + if (file_exists($dir_fax_sent.'/'.$file_name.".pdf")) { + echo " \n"; + echo " PDF"; + echo " "; + } + else { + echo " \n"; + } + echo " \n"; + //if (file_exists($dir_fax_sent.'/'.$file_name.".jpg")) { + // echo " \n"; + // echo " jpg"; + // echo " "; + //} + //else { + // echo " \n"; + //} + //echo " \n"; + echo " ".date("F d Y H:i:s", $file_modified); + echo " \n"; + echo " ".$file_size_bytes; + echo " \n"; + echo " \n"; + echo " \n"; + if (permission_exists('fax_sent_delete')) { + echo " \n"; + } + echo " \n"; + echo "
$v_link_label_delete
\n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + } + echo "
"; + echo "
"; + +//show the footer + require_once "includes/footer.php"; +?> diff --git a/app/fifo/app_config.php b/app/fifo/app_config.php new file mode 100644 index 0000000000..08856e556e --- /dev/null +++ b/app/fifo/app_config.php @@ -0,0 +1,36 @@ + \ No newline at end of file diff --git a/app/fifo/root.php b/app/fifo/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/fifo/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/fifo/v_fifo.php b/app/fifo/v_fifo.php new file mode 100644 index 0000000000..bfbf07ef41 --- /dev/null +++ b/app/fifo/v_fifo.php @@ -0,0 +1,194 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('fifo_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get http values and set them as variables + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo ""; + echo ""; + echo "
\n"; + echo "
"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "
Queues\n"; + echo " \n"; + echo " \n"; + //echo " \n"; + echo "
\n"; + echo " \n"; + echo " Queues are used to setup waiting lines for callers. Also known as FIFO Queues.\n"; + echo " \n"; + echo "
"; + + echo "
"; + echo "
"; + +//get the number of rows in the dialplan + $sql = ""; + $sql .= " select count(*) as num_rows from v_dialplans "; + $sql .= " where domain_uuid = '$domain_uuid' "; + $sql .= " and app_uuid = '16589224-c876-aeb3-f59f-523a1c0801f7' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } else { $sql .= "order by dialplan_order, dialplan_name asc "; } + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + unset($prep_statement, $result); + +//paging prep + $rows_per_page = 20; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + +//get the dialplans + $sql = ""; + $sql .= " select * from v_dialplans "; + $sql .= " where domain_uuid = '$domain_uuid' "; + $sql .= " and app_uuid = '16589224-c876-aeb3-f59f-523a1c0801f7' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } else { $sql .= "order by dialplan_order, dialplan_name asc "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo th_order_by('dialplan_name', 'Extension Name', $order_by, $order); + echo th_order_by('dialplan_order', 'Order', $order_by, $order); + echo th_order_by('dialplan_enabled', 'Enabled', $order_by, $order); + echo th_order_by('dialplan_description', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + if (permission_exists('fifo_add')) { + echo " $v_link_label_add\n"; + } + echo "
  ".$row['dialplan_name']."  ".$row['dialplan_order']."  ".$row['dialplan_enabled']."".$row['dialplan_description']." \n"; + if (permission_exists('fifo_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('fifo_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('fifo_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
\n"; + echo "
\n"; + if ($v_path_show) { + echo $_SESSION['switch']['conf']['dir']."/dialplan/default/"; + } + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//show the footer + require_once "includes/footer.php"; + unset ($result_count); + unset ($result); + unset ($key); + unset ($val); + unset ($c); +?> \ No newline at end of file diff --git a/app/fifo/v_fifo_add.php b/app/fifo/v_fifo_add.php new file mode 100644 index 0000000000..6443332208 --- /dev/null +++ b/app/fifo/v_fifo_add.php @@ -0,0 +1,426 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('fifo_add')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get http values and set them as variables + if (count($_POST)>0) { + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + $extension_name = check_str($_POST["extension_name"]); + $queue_extension_number = check_str($_POST["queue_extension_number"]); + $agent_queue_extension_number = check_str($_POST["agent_queue_extension_number"]); + $agent_login_logout_extension_number = check_str($_POST["agent_login_logout_extension_number"]); + $dialplan_order = check_str($_POST["dialplan_order"]); + $pin_number = check_str($_POST["pin_number"]); + $profile = check_str($_POST["profile"]); + $flags = check_str($_POST["flags"]); + $dialplan_enabled = check_str($_POST["dialplan_enabled"]); + $dialplan_description = check_str($_POST["dialplan_description"]); + if (strlen($dialplan_enabled) == 0) { $dialplan_enabled = "true"; } //set default to enabled + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + //check for all required data + if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + if (strlen($extension_name) == 0) { $msg .= "Please provide: Extension Name
\n"; } + if (strlen($queue_extension_number) == 0) { $msg .= "Please provide: Extension Number 1
\n"; } + //if (strlen($agent_queue_extension_number) == 0) { $msg .= "Please provide: Queue Extension Number
\n"; } + //if (strlen($agent_queue_extension_number) == 0) { $msg .= "Please provide: Agent Login Logout Extension Number
\n"; } + //if (strlen($pin_number) == 0) { $msg .= "Please provide: PIN Number
\n"; } + //if (strlen($profile) == 0) { $msg .= "Please provide: profile
\n"; } + //if (strlen($flags) == 0) { $msg .= "Please provide: Flags
\n"; } + //if (strlen($dialplan_enabled) == 0) { $msg .= "Please provide: Enabled True or False
\n"; } + //if (strlen($dialplan_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + if (strlen($queue_extension_number) > 0) { + //-------------------------------------------------------- + //Caller Queue [FIFO in] + // + // + // + // + // + // + // + //-------------------------------------------------------- + $extension_name = $extension_name."_call_queue"; + $dialplan_context = $_SESSION['context']; + $app_uuid = '16589224-c876-aeb3-f59f-523a1c0801f7'; + $dialplan_uuid = uuid(); + dialplan_add($domain_uuid, $dialplan_uuid, $extension_name, $dialplan_order, $dialplan_context, $dialplan_enabled, $dialplan_description, $app_uuid); + if (strlen($dialplan_uuid) > 0) { + //set the destination number + $dialplan_detail_tag = 'condition'; //condition, action, antiaction + $dialplan_detail_type = 'destination_number'; + $dialplan_detail_data = '^'.$queue_extension_number.'$'; + $dialplan_detail_order = '000'; + $dialplan_detail_group = ''; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + //set the hold music + //if (strlen($hold_music) > 0) { + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + $dialplan_detail_data = 'fifo_music=$${hold_music}'; + $dialplan_detail_order = '001'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + //} + //action answer + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'answer'; + $dialplan_detail_data = ''; + $dialplan_detail_order = '002'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + //action fifo + //if (strlen($pin_number) > 0) { $pin_number = "+".$pin_number; } + //if (strlen($flags) > 0) { $flags = "+{".$flags."}"; } + //$queue_action_data = $extension_name."@\${domain_name}".$profile.$flags.$pin_number; + $queue_action_data = $extension_name."@\${domain_name} in"; + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'fifo'; + $dialplan_detail_data = $queue_action_data; + $dialplan_detail_order = '003'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + } + } //end if queue_extension_number + + + // Caller Queue / Agent Queue + if (strlen($agent_queue_extension_number) > 0) { + //-------------------------------------------------------- + // Agent Queue [FIFO out] + // + // + // + // + // + // + // + //-------------------------------------------------------- + $extension_name = $extension_name."_agent_queue"; + $dialplan_context = $_SESSION['context']; + $app_uuid = '16589224-c876-aeb3-f59f-523a1c0801f7'; + $dialplan_uuid = uuid(); + dialplan_add($domain_uuid, $dialplan_uuid, $extension_name, $dialplan_order, $dialplan_context, $dialplan_enabled, $dialplan_description, $app_uuid); + if (strlen($dialplan_uuid) > 0) { + //set the destination number + $dialplan_detail_tag = 'condition'; //condition, action, antiaction + $dialplan_detail_type = 'destination_number'; + $dialplan_detail_data = '^'.$agent_queue_extension_number.'$'; + $dialplan_detail_order = '000'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + //set the hold music + //if (strlen($hold_music) > 0) { + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + $dialplan_detail_data = 'fifo_music=$${hold_music}'; + $dialplan_detail_order = '001'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + //} + //action answer + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'answer'; + $dialplan_detail_data = ''; + $dialplan_detail_order = '002'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + //action fifo + //if (strlen($pin_number) > 0) { $pin_number = "+".$pin_number; } + //if (strlen($flags) > 0) { $flags = "+{".$flags."}"; } + //$queue_action_data = $extension_name."@\${domain_name}".$profile.$flags.$pin_number; + $queue_action_data = $extension_name."@\${domain_name} out wait"; + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'fifo'; + $dialplan_detail_data = $queue_action_data; + $dialplan_detail_order = '003'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + } + } + + // agent or member login / logout + if (strlen($agent_login_logout_extension_number) > 0) { + //-------------------------------------------------------- + // Agent Queue [FIFO out] + // + // + // + // + // + // + // + //-------------------------------------------------------- + $extension_name = $extension_name."_agent_login_logout"; + $dialplan_context = $_SESSION['context']; + $app_uuid = '16589224-c876-aeb3-f59f-523a1c0801f7'; + $dialplan_uuid = uuid(); + $dialplan_uuid = dialplan_add($domain_uuid, $dialplan_uuid, $extension_name, $dialplan_order, $dialplan_context, $dialplan_enabled, $dialplan_description, $app_uuid); + if (strlen($dialplan_uuid) > 0) { + //set the destination number + $dialplan_detail_tag = 'condition'; //condition, action, antiaction + $dialplan_detail_type = 'destination_number'; + $dialplan_detail_data = '^'.$agent_login_logout_extension_number.'$'; + $dialplan_detail_order = '000'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + //set the queue_name + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + $dialplan_detail_data = 'queue_name='.$extension_name.'@\${domain_name}'; + $dialplan_detail_order = '001'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + //set the fifo_simo + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + $dialplan_detail_data = 'fifo_simo=1'; + $dialplan_detail_order = '002'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + //set the fifo_timeout + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + $dialplan_detail_data = 'fifo_timeout=10'; + $dialplan_detail_order = '003'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + //set the fifo_lag + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + $dialplan_detail_data = 'fifo_lag=10'; + $dialplan_detail_order = '004'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + //set the pin_number + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + $dialplan_detail_data = 'pin_number='; + $dialplan_detail_order = '005'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + //action lua + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'lua'; + $dialplan_detail_data = 'fifo_member.lua'; + $dialplan_detail_order = '006'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + } + } + + //synchronize the xml config + save_dialplan_xml(); + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +} //end if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " Queues\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " \n"; + echo " In simple terms queues are holding patterns for callers to wait until someone is available to take the call. Also known as FIFO Queues.\n"; + echo " \n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo " Queue Name:\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " The name the queue will be assigned.\n"; + echo "
\n"; + echo " Extension Number:\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " The number that will be assigned to the queue.\n"; + echo "
\n"; + echo " Order:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo "

\n"; + echo " Agent Details\n"; + echo "
\n"; + echo "  \n"; + echo "
\n"; + echo " Queue Extension Number:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "The extension number for the Agent FIFO Queue. This is the holding pattern for agents wating to service calls in the caller FIFO queue.\n"; + echo "
\n"; + echo " Login/Logout Extension Number:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Agents use this extension number to login or logout of the Queue. After logging into the agent will be ready to receive calls from the Queue. \n"; + echo "
\n"; + + + echo "\n"; + echo "\n"; + echo " \n"; + echo ""; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + + echo "
"; + + echo "
\n"; + echo "
"; + echo "

"; + +//show the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/fifo/v_fifo_delete.php b/app/fifo/v_fifo_delete.php new file mode 100644 index 0000000000..9b374e91a4 --- /dev/null +++ b/app/fifo/v_fifo_delete.php @@ -0,0 +1,81 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('fifo_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the id + if (count($_GET)>0) { + $id = $_GET["id"]; + } + +if (strlen($id)>0) { + + //start the atomic transaction + $count = $db->exec("BEGIN;"); + + //delete child data + $sql = ""; + $sql .= "delete from v_dialplan_details "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_uuid = '$id' "; + //echo $sql; + $db->query($sql); + unset($sql); + + //delete parent data + $sql = ""; + $sql .= "delete from v_dialplans "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_uuid = '$id' "; + //echo $sql; + $db->query($sql); + unset($sql); + + //commit the atomic transaction + $count = $db->exec("COMMIT;"); + + //synchronize the xml config + save_dialplan_xml(); +} + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/fifo/v_fifo_details_delete.php b/app/fifo/v_fifo_details_delete.php new file mode 100644 index 0000000000..5c9dc1118e --- /dev/null +++ b/app/fifo/v_fifo_details_delete.php @@ -0,0 +1,66 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("fifo_delete")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = $_GET["id"]; + $dialplan_uuid = check_str($_REQUEST["id2"]); +} + +if (strlen($id)>0) { + //delete the data + $sql = ""; + $sql .= "delete from v_dialplan_details "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_detail_uuid = '$id' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $db->query($sql); + unset($sql); + //synchronize the xml config + save_dialplan_xml(); +} + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + +//show the footer + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/fifo/v_fifo_details_edit.php b/app/fifo/v_fifo_details_edit.php new file mode 100644 index 0000000000..7282da61b6 --- /dev/null +++ b/app/fifo/v_fifo_details_edit.php @@ -0,0 +1,456 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('fifo_add') || permission_exists('fifo_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} +//if (permission_exists('fifo_add')) { + +//set the action as an add or an update + if (isset($_REQUEST["id"])) { + $action = "update"; + $dialplan_detail_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + $dialplan_uuid = check_str($_REQUEST["id2"]); + } + if (isset($_REQUEST["id2"])) { + $dialplan_uuid = check_str($_REQUEST["id2"]); + } + +//get http values and set them as php variables + if (count($_POST)>0) { + if (isset($_REQUEST["dialplan_uuid"])) { + $dialplan_uuid = check_str($_POST["dialplan_uuid"]); + } + $dialplan_detail_tag = check_str($_POST["dialplan_detail_tag"]); + $dialplan_detail_order = check_str($_POST["dialplan_detail_order"]); + $dialplan_detail_type = check_str($_POST["dialplan_detail_type"]); + $dialplan_detail_data = check_str($_POST["dialplan_detail_data"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $dialplan_detail_uuid = check_str($_POST["dialplan_detail_uuid"]); + } + + //check for all required data + if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + if (strlen($dialplan_detail_tag) == 0) { $msg .= "Please provide: Tag
\n"; } + if (strlen($dialplan_detail_order) == 0) { $msg .= "Please provide: Order
\n"; } + //if (strlen($dialplan_detail_type) == 0) { $msg .= "Please provide: Type
\n"; } + //if (strlen($dialplan_detail_data) == 0) { $msg .= "Please provide: Data
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('fifo_add')) { + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_order, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$dialplan_detail_uuid', "; + $sql .= "'$dialplan_detail_tag', "; + $sql .= "'$dialplan_detail_order', "; + $sql .= "'$dialplan_detail_type', "; + $sql .= "'$dialplan_detail_data' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //synchronize the xml config + save_dialplan_xml(); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update" && permission_exists('fifo_edit')) { + $sql = "update v_dialplan_details set "; + $sql .= "domain_uuid = '$domain_uuid', "; + $sql .= "dialplan_uuid = '$dialplan_uuid', "; + $sql .= "dialplan_detail_tag = '$dialplan_detail_tag', "; + $sql .= "dialplan_detail_order = '$dialplan_detail_order', "; + $sql .= "dialplan_detail_type = '$dialplan_detail_type', "; + $sql .= "dialplan_detail_data = '$dialplan_detail_data' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_detail_uuid = '$dialplan_detail_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + //synchronize the xml config + save_dialplan_xml(); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $dialplan_detail_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_dialplan_details "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_detail_uuid = '$dialplan_detail_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $dialplan_uuid = $row["dialplan_uuid"]; + $dialplan_detail_tag = $row["dialplan_detail_tag"]; + $dialplan_detail_order = $row["dialplan_detail_order"]; + $dialplan_detail_type = $row["dialplan_detail_type"]; + $dialplan_detail_data = $row["dialplan_detail_data"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + //echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + + ?> + + \n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Queue Detail AddQueue Detail Update
\n"; + echo " Tag:\n"; + echo "\n"; + echo " \n"; + + //condition + //field expression + //action + //application + //data + //antiaction + //application + //data + //param + //name + //value + //echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Order:\n"; + echo "\n"; + echo " \n"; + + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Type:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Data:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " \n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + //echo "
\n"; + echo "
"; + + echo " \n"; + echo " \n"; + echo " + +
\n"; + + if ($v_path_show) { + echo "
\n"; + echo "
\n"; + echo "Additional Information\n"; + echo "
\n"; + echo "
\n"; + + } + ?> + Conditions +
+
+ Conditions are pattern matching tags that help decide if the current call should be processed in this extension or not. When matching conditions against the current call you have several fields that you can compare against. +
    +
  • context
  • +
  • rdnis Redirected Number, the directory number to which the call was last presented.
  • +
  • destination_number Called Number, the number this call is trying to reach (within a given context)
  • +
  • dialplan Name of the dialplan module that are used, the name is provided by each dialplan module. Example: XML
  • +
  • caller_id_name Name of the caller (provided by the User Agent that has called us).
  • +
  • caller_id_number Directory Number of the party who called (callee) -- can be masked (hidden)
  • +
  • ani Automatic Number Identification, the number of the calling party (callee) -- cannot be masked
  • +
  • ani2 The type of device placing the call [1]
  • +
  • uuid Unique identifier of the current call? (looks like a GUID)
  • +
  • source Name of the module that received the call (e.g. PortAudio)
  • +
  • chan_name Name of the current channel (Example: PortAudio/1234). Give us examples when this one can be used.
  • +
  • network_addr IP address of the signalling source for a VoIP call.
  • +
+ In addition to the above you can also do variables using the syntax ${variable} or api functions using the syntax %{api} {args} +
+
+ Variables may be used in either the field or the expression, as follows + +
+
+
+
+ + Action and Anti-Actions +
+
+ Actions are executed when the condition matches. Anti-Actions are executed when the condition does NOT match. +
+
+
+ The following is a partial list of applications. +
    +
  • answer answer the call
  • +
  • bridge bridge the call
  • +
  • cond
  • +
  • db is a a runtime database either sqlite by default or odbc
  • +
  • global_set allows setting of global vars similar to the ones found in vars.xml
  • +
  • group allows grouping of several extensions for things like ring groups
  • +
  • expr
  • +
  • hangup hangs up the call
  • +
  • info sends call info to the console
  • +
  • javascript run javascript .js files
  • +
  • playback
  • +
  • reject reject the call
  • +
  • respond
  • +
  • ring_ready
  • +
  • set set a variable
  • +
  • set_user
  • +
  • sleep
  • +
  • sofia_contact
  • +
  • transfer transfer the call to another extension or number
  • +
  • voicemail send the call to voicemail
  • +
+ +
+
+ + +
+ +
+
+
+
+
+ +"; + echo "
"; + echo "
"; + +//show the footer + require_once "includes/footer.php"; +?> diff --git a/app/fifo/v_fifo_edit.php b/app/fifo/v_fifo_edit.php new file mode 100644 index 0000000000..ef51907d1b --- /dev/null +++ b/app/fifo/v_fifo_edit.php @@ -0,0 +1,515 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "includes/paging.php"; +if (permission_exists('fifo_add') || permission_exists('fifo_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//set the action to an add or an update + if (isset($_REQUEST["id"])) { + $action = "update"; + $dialplan_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http values and set them as variables + if (count($_POST)>0) { + //$domain_uuid = check_str($_POST["domain_uuid"]); + $dialplan_name = check_str($_POST["dialplan_name"]); + $dialplan_order = check_str($_POST["dialplan_order"]); + $dialplan_continue = check_str($_POST["dialplan_continue"]); + $dialplan_context = check_str($_POST["dialplan_context"]); + $dialplan_enabled = check_str($_POST["dialplan_enabled"]); + $dialplan_description = check_str($_POST["dialplan_description"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $dialplan_uuid = check_str($_POST["dialplan_uuid"]); + } + + //check for all required data + if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + if (strlen($dialplan_name) == 0) { $msg .= "Please provide: Extension Name
\n"; } + if (strlen($dialplan_order) == 0) { $msg .= "Please provide: Order
\n"; } + //if (strlen($dialplan_context) == 0) { $msg .= "Please provide: Context
\n"; } + if (strlen($dialplan_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } + //if (strlen($dialplan_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //set the default dialplan_continue to false + if (strlen($dialplan_continue) == 0) { $dialplan_continue = 'false'; } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('fifo_add')) { + $dialplan_context = $_SESSION['context']; + $dialplan_uuid = uuid(); + $sql = "insert into v_dialplans "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "app_uuid, "; + $sql .= "dialplan_name, "; + $sql .= "dialplan_order, "; + $sql .= "dialplan_continue, "; + $sql .= "dialplan_context, "; + $sql .= "dialplan_enabled, "; + $sql .= "dialplan_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'16589224-c876-aeb3-f59f-523a1c0801f7', "; + $sql .= "'$dialplan_name', "; + $sql .= "'$dialplan_order', "; + $sql .= "'$dialplan_continue', "; + $sql .= "'$dialplan_context', "; + $sql .= "'$dialplan_enabled', "; + $sql .= "'$dialplan_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //synchronize the xml config + save_dialplan_xml(); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update" && permission_exists('fifo_edit')) { + $sql = "update v_dialplans set "; + $sql .= "domain_uuid = '$domain_uuid', "; + $sql .= "dialplan_name = '$dialplan_name', "; + $sql .= "dialplan_order = '$dialplan_order', "; + $sql .= "dialplan_continue = '$dialplan_continue', "; + $sql .= "dialplan_context = '$dialplan_context', "; + $sql .= "dialplan_enabled = '$dialplan_enabled', "; + $sql .= "dialplan_description = '$dialplan_description' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + //synchronize the xml config + save_dialplan_xml(); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $dialplan_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_dialplans "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $dialplan_name = $row["dialplan_name"]; + $dialplan_order = $row["dialplan_order"]; + $dialplan_continue = $row["dialplan_continue"]; + $dialplan_context = $row["dialplan_context"]; + $dialplan_enabled = $row["dialplan_enabled"]; + $dialplan_description = $row["dialplan_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "

\n"; + echo " Queues
\n"; + echo "
\n"; + echo "

\n"; + echo " Queues are used to setup waiting lines for callers. Also known as FIFO Queues.\n"; + echo "

\n"; + echo "
"; + echo "
\n"; + + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + //echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Order:\n"; + echo "\n"; + echo " \n"; + //echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + //echo " Context:\n"; + //echo "\n"; + //echo " \n"; + //echo "
\n"; + //echo "\n"; + //echo "
\n"; + echo " Continue:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Extension Continue in most cases is false.\n"; + echo "
\n"; + echo " Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + + //v_dialplan_details + if ($action == "update" && permission_exists('fifo_edit')) { + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "

Conditions and Actions
\n"; + echo "
\n"; + echo " The following conditions, actions and anti-actions are used in the dialplan to direct \n"; + echo " call flow. Each is processed in order until you reach the action dialplan_detail_tag which tells what action to perform. \n"; + echo " You are not limited to only one condition or action dialplan_detail_tag for a given extension.\n"; + echo "

"; + echo "
\n"; + + $sql = ""; + $sql .= " select * from v_dialplan_details "; + $sql .= " where domain_uuid = '$domain_uuid' "; + $sql .= " and dialplan_uuid = '$dialplan_uuid' "; + $sql .= " and dialplan_detail_tag = 'condition' "; + $sql .= " order by dialplan_detail_order asc"; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + //v_dialplan_details dialplan_detail_tag: action + $sql = ""; + $sql .= " select * from v_dialplan_details "; + $sql .= " where domain_uuid = '$domain_uuid' "; + $sql .= " and dialplan_uuid = '$dialplan_uuid' "; + $sql .= " and dialplan_detail_tag = 'action' "; + $sql .= " order by dialplan_detail_order asc"; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + //v_dialplan_details dialplan_detail_tag: anti-action + $sql = ""; + $sql .= " select * from v_dialplan_details "; + $sql .= " where domain_uuid = '$domain_uuid' "; + $sql .= " and dialplan_uuid = '$dialplan_uuid' "; + $sql .= " and dialplan_detail_tag = 'anti-action' "; + $sql .= " order by dialplan_detail_order asc"; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + if ($result_count == 0) { + //no results + } + else { //received results + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
TagTypeDataOrder\n"; + if (permission_exists('fifo_add')) { + echo " $v_link_label_add\n"; + } + echo "
  ".$row[dialplan_detail_tag]."  ".$row[dialplan_detail_type]."  ".$row[dialplan_detail_data]."  ".$row[dialplan_detail_order]."\n"; + if (permission_exists('fifo_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('fifo_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
  ".$row[dialplan_detail_tag]."  ".$row[dialplan_detail_type]."  ".$row[dialplan_detail_data]."  ".$row[dialplan_detail_order]."\n"; + if (permission_exists('fifo_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('fifo_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
  ".$row[dialplan_detail_tag]."  ".$row[dialplan_detail_type]."  ".$row[dialplan_detail_data]."  ".$row[dialplan_detail_order]."\n"; + if (permission_exists('fifo_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('fifo_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('fifo_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + } //end if update + +//show the footer + require_once "includes/footer.php"; +?> diff --git a/app/fifo_agents/app_config.php b/app/fifo_agents/app_config.php new file mode 100644 index 0000000000..f070c44b99 --- /dev/null +++ b/app/fifo_agents/app_config.php @@ -0,0 +1,39 @@ + \ No newline at end of file diff --git a/app/fifo_agents/fifo_agent/root.php b/app/fifo_agents/fifo_agent/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/fifo_agents/fifo_agent/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/fifo_agents/fifo_agent/v_fifo_agent.php b/app/fifo_agents/fifo_agent/v_fifo_agent.php new file mode 100644 index 0000000000..cc0923651d --- /dev/null +++ b/app/fifo_agents/fifo_agent/v_fifo_agent.php @@ -0,0 +1,186 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("agent") || if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Active Agents 
\n"; + echo "Shows the agents that are currently logged into the queues.

\n"; + echo "
\n"; + echo " login"; + echo " logout"; + echo "
\n"; + + + $sql = ""; + $sql .= " select * from v_fifo_agents "; + $sql .= " where agent_username = '".$_SESSION["username"]."' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $num_rows = count($result); + unset ($prep_statement, $result, $sql); + $rows_per_page = 10; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + $sql = ""; + $sql .= " select * from v_fifo_agents "; + $sql .= " where agent_username = '".$_SESSION["username"]."' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + //$sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo th_order_by('fifo_name', 'Queue Name', $order_by, $order); + echo th_order_by('agent_username', 'Username', $order_by, $order); + echo th_order_by('agent_priority', 'Agent Priority', $order_by, $order); + echo th_order_by('agent_status', 'Status', $order_by, $order); + echo th_order_by('agent_last_call', 'Last Call', $order_by, $order); + echo th_order_by('agent_contact_number', 'Contact Number', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count == 0) { //no results + } + else { //received results + foreach($result as $row) { + //set the php variables + $agent_last_call = $row[agent_last_call]; + date_default_timezone_set('America/Boise'); + + //format the last call time + $agent_last_call_desc = date("g:i:s a j M Y",$agent_last_call); + + //get the agent status description + $x=1; + $agent_status_desc = ''; + foreach($_SESSION["array_agent_status"] as $value) { + if ($row[agent_status] == $x) { + $agent_status_desc = $value; + } + $x++; + } + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "
\n"; + //echo " $v_link_label_add\n"; + echo "
".$row[fifo_name]."".$row[agent_username]."".$row[agent_priority]."".$agent_status_desc."".$agent_last_call_desc."".$row[agent_contact_number]."\n"; + echo " $v_link_label_edit\n"; + //echo " $v_link_label_delete\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + //echo " $v_link_label_add\n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + + echo "
"; + echo "
"; + echo "

"; + + +require_once "includes/footer.php"; +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); +?> diff --git a/app/fifo_agents/fifo_agent/v_fifo_agent_edit.php b/app/fifo_agents/fifo_agent/v_fifo_agent_edit.php new file mode 100644 index 0000000000..e4b16dfc39 --- /dev/null +++ b/app/fifo_agents/fifo_agent/v_fifo_agent_edit.php @@ -0,0 +1,412 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("agent") || if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//save the uuid to a variable from the http GET + $uuid = check_str($_GET["uuid"]); + +//POST to PHP variables + if (count($_POST)>0) { + //$domain_uuid = check_str($_POST["domain_uuid"]); + $resolution_code = check_str($_POST["resolution_code"]); + $transaction_id = check_str($_POST["transaction_id"]); + $action_item = check_str($_POST["action_item"]); + $uuid = check_str($_POST["uuid"]); + $notes = check_str($_POST["notes"]); + //$fifo_name = check_str($_POST["fifo_name"]); + //$agent_username = check_str($_POST["agent_username"]); + //$agent_priority = check_str($_POST["agent_priority"]); + $agent_status = check_str($_POST["agent_status"]); + //$agent_last_call = check_str($_POST["agent_last_call"]); + //$agent_contact_number = check_str($_POST["agent_contact_number"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + //check for all required data + if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + //if (strlen($resolution_code) == 0) { $msg .= "Please provide: Resolution Code
\n"; } + //if (strlen($transaction_id) == 0) { $msg .= "Please provide: Transaction ID
\n"; } + //if (strlen($action_item) == 0) { $msg .= "Please provide: Action Item
\n"; } + //if (strlen($uuid) == 0) { $msg .= "Please provide: UUID
\n"; } + //if (strlen($notes) == 0) { $msg .= "Please provide: Notes
\n"; } + //if (strlen($fifo_name) == 0) { $msg .= "Please provide: Queue Name
\n"; } + //if (strlen($agent_username) == 0) { $msg .= "Please provide: Username
\n"; } + //if (strlen($agent_priority) == 0) { $msg .= "Please provide: Agent Priority
\n"; } + if (strlen($agent_status) == 0) { $msg .= "Please provide: Status
\n"; } + //if (strlen($agent_last_call) == 0) { $msg .= "Please provide: Last Call
\n"; } + //if (strlen($agent_contact_number) == 0) { $msg .= "Please provide: Contact Number
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //update the database + if ($_POST["persistformvar"] != "true") { + //do not insert {uuid} into the database + if ($uuid == "{uuid}") { $uuid = ''; } + + //add to the agent call logs + if (strlen($uuid) > 0) { + $sql = "insert into v_fifo_agent_call_logs "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "resolution_code, "; + $sql .= "transaction_id, "; + $sql .= "action_item, "; + $sql .= "uuid, "; + $sql .= "notes, "; + $sql .= "add_user, "; + $sql .= "add_date "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$resolution_code', "; + $sql .= "'$transaction_id', "; + $sql .= "'$action_item', "; + $sql .= "'$uuid', "; + $sql .= "'$notes', "; + $sql .= "'".$_SESSION["username"]."', "; + $sql .= "now() "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + + //update the status + $sql = "update v_fifo_agents set "; + $sql .= "domain_uuid = '$domain_uuid', "; + //$sql .= "fifo_name = '$fifo_name', "; + //$sql .= "agent_username = '$agent_username', "; + //$sql .= "agent_priority = '$agent_priority', "; + $sql .= "agent_status = '$agent_status', "; + $sql .= "agent_status_epoch = ".time()." "; + //$sql .= "agent_last_call = '$agent_last_call', "; + //$sql .= "agent_contact_number = '$agent_contact_number' "; + $sql .= " where agent_username = '".$_SESSION["username"]."' "; + $db->exec(check_sql($sql)); + unset($sql); + + //agent status log + if (strlen($agent_status) > 0) { + $sql = "insert into v_fifo_agent_status_logs "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "username, "; + $sql .= "agent_status, "; + $sql .= "uuid, "; + $sql .= "add_date "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'".$_SESSION["username"]."', "; + $sql .= "'$agent_status', "; + $sql .= "'$uuid', "; + $sql .= "now() "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($_POST["persistformvar"] != "true") { + +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if ($_POST["persistformvar"] != "true") { + $login_status = false; + $sql = ""; + $sql .= "select * from v_fifo_agents "; + $sql .= " where agent_username = '".$_SESSION["username"]."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $domain_uuid = $row["domain_uuid"]; + //$fifo_name = $row["fifo_name"]; + //$agent_username = $row["agent_username"]; + //$agent_priority = $row["agent_priority"]; + $agent_status = $row["agent_status"]; + $agent_last_call = $row["agent_last_call"]; + $agent_last_uuid = $row["agent_last_uuid"]; + //$agent_contact_number = $row["agent_contact_number"]; + $login_status = true; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//format the last call time + if ($agent_last_call == 0) { + $agent_last_call_desc = ''; + } + else { + $agent_last_call_desc = date("g:i:s a j M Y",$agent_last_call); + } + +//show the content + require_once "includes/header.php"; + +//if the agent_status is available and the uuid has been supplied then refrsh the page + //until the status changes or until a time out has been reached + if ($agent_status == '2' && strlen($uuid) > 0 && $uuid != "{uuid}") { + if (count($_GET["refresh"]) < 10) { + if (substr($_SERVER["SERVER_PROTOCOL"], 0,5) == "HTTP/") { + $meta_refresh_url = "http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]."&refresh[]=".count($_SERVER["refresh"]); + } + else { + $meta_refresh_url = "https://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]."&refresh[]=".count($_SERVER["refresh"]); + } + echo "\n"; + } + } + + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + //echo "
"; + + + echo "
\n"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + //echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + + if ($login_status) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + /* + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + */ + + if ($login_status && $agent_status == '9') { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + if ($login_status) { + echo " \n"; + echo " \n"; + echo " "; + } + + + echo "
Agent\n"; + if (!$login_status) { + echo " \n"; + } + if ($login_status) { + echo " \n"; + } + + //echo " \n"; + echo "
\n"; + echo "Enables the agent to set their status.

\n"; + echo "
\n"; + echo " Username:\n"; + echo "\n"; + echo " ".$_SESSION["username"].""; + echo "
\n"; + echo "\n"; + echo "
\n"; + //echo " Last Call:\n"; + //echo "\n"; + //echo $agent_last_call_desc; + //echo " \n"; + //echo "
\n"; + //echo "\n"; + //echo "
\n"; + echo " Status:\n"; + echo "\n"; + //generate the agent status select list + $sql = "SELECT var_name, var_value FROM v_vars "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and var_cat = 'Queues Agent Status' "; + $sql .= "and var_name not like 'system%' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + echo ""; + $_SESSION["array_agent_status"] = ""; + if (!is_array($_SESSION["array_agent_status"])) { + foreach($result as $field) { + $_SESSION["array_agent_status"][$field[var_value]] = $field[var_name]; + } + } + /* + foreach($result as $field) { + $_SESSION["array_agent_status"][$field[var_value]] = $field[var_name]; + } + + $x=1; + foreach($_SESSION["array_agent_status"] as $value) { + echo "$x $value
\n"; + $x++; + } + */ + unset($sql, $result); + + echo "
\n"; + echo "Enter the status of the Agent.\n"; + echo "
\n"; + echo "  \n"; + echo "\n"; + echo "
\n"; + echo "
\n"; + echo " Contact Number:\n"; + echo "\n"; + echo $agent_contact_number; + //echo " \n"; + echo "
\n"; + //echo "Enter the agent contact number.\n"; + echo "
\n"; + echo " Resolution Code:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the resolution code.\n"; + echo "
\n"; + echo " Transaction ID:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the Transaction ID.\n"; + echo "
\n"; + echo " Action Item:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the Action Item.\n"; + echo "
\n"; + echo " Notes:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the notes.\n"; + echo "
\n"; + if (strlen($uuid) == 0) { + $uuid = $agent_last_uuid; + } + echo " \n"; + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + + +require_once "includes/footer.php"; +?> diff --git a/app/fifo_agents/fifo_agent/v_fifo_agent_login.php b/app/fifo_agents/fifo_agent/v_fifo_agent_login.php new file mode 100644 index 0000000000..270261dd17 --- /dev/null +++ b/app/fifo_agents/fifo_agent/v_fifo_agent_login.php @@ -0,0 +1,297 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("agent") || if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//Action add or update +if (isset($_REQUEST["id"])) { + $action = "update"; + $fifo_agent_id = check_str($_REQUEST["id"]); +} +else { + $action = "add"; +} + +//POST to PHP variables +if (count($_POST)>0) { + //$fifo_name = check_str($_POST["fifo_name"]); + $fifo_agent_profile_id = check_str($_POST["fifo_agent_profile_id"]); + $agent_username = $_SESSION["username"]; + $agent_contact_number = check_str($_POST["agent_contact_number"]); +} + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + + ////recommend moving this to the config.php file + $uploadtempdir = $_ENV["TEMP"]."\\"; + ini_set('upload_tmp_dir', $uploadtempdir); + ////$imagedir = $_ENV["TEMP"]."\\"; + ////$filedir = $_ENV["TEMP"]."\\"; + + if ($action == "update") { + $fifo_agent_id = check_str($_POST["fifo_agent_id"]); + } + + //check for all required data + if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + if (strlen($fifo_agent_profile_id) == 0) { $msg .= "Please provide: profile
\n"; } + //if (strlen($fifo_name) == 0) { $msg .= "Please provide: Queue Name
\n"; } + //if (strlen($agent_username) == 0) { $msg .= "Please provide: Username
\n"; } + //if (strlen($agent_priority) == 0) { $msg .= "Please provide: Agent Priority
\n"; } + if (strlen($agent_contact_number) == 0) { $msg .= "Please provide: Contact Number
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + + $fifo_agent_profile_member_id = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_fifo_agent_profile_members "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and fifo_agent_profile_id = '$fifo_agent_profile_id' "; + $sql .= "and agent_username = '$agent_username' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $fifo_agent_profile_member_id = $row["fifo_agent_profile_member_id"]; + $fifo_agent_profile_id = $row["fifo_agent_profile_id"]; + $fifo_name = $row["fifo_name"]; + $agent_priority = $row["agent_priority"]; + $agent_status = '2'; //available + $agent_last_call = 0; + + $sql = "insert into v_fifo_agents "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "fifo_name, "; + $sql .= "agent_username, "; + $sql .= "agent_priority, "; + $sql .= "agent_status, "; + $sql .= "agent_status_epoch, "; + $sql .= "agent_last_call, "; + $sql .= "agent_contact_number "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$fifo_name', "; + $sql .= "'$agent_username', "; + $sql .= "'$agent_priority', "; + $sql .= "'$agent_status', "; + $sql .= "'".time()."', "; + $sql .= "'$agent_last_call', "; + $sql .= "'$agent_contact_number' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //agent status log login + $agent_status = '1'; //login + $sql = "insert into v_fifo_agent_status_logs "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "username, "; + $sql .= "agent_status, "; + $sql .= "add_date "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'".$_SESSION["username"]."', "; + $sql .= "'$agent_status', "; + $sql .= "now() "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + } + unset ($prep_statement); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Login Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + /* + if ($action == "update") { + $sql = "update v_fifo_agents set "; + $sql .= "domain_uuid = '$domain_uuid', "; + $sql .= "fifo_name = '$fifo_name', "; + $sql .= "agent_username = '$agent_username', "; + $sql .= "agent_priority = '$agent_priority', "; + $sql .= "agent_contact_number = '$agent_contact_number' "; + $sql .= "where fifo_agent_id = '$fifo_agent_id'"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + */ + } //if ($_POST["persistformvar"] != "true") + +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + /* + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $fifo_agent_id = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_fifo_agents "; + $sql .= "where fifo_agent_id = '$fifo_agent_id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $domain_uuid = $row["domain_uuid"]; + $fifo_name = $row["fifo_name"]; + $agent_username = $row["agent_username"]; + $agent_priority = $row["agent_priority"]; + $agent_contact_number = $row["agent_contact_number"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + */ + +//begin the content + require_once "includes/header.php"; + + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + if ($action == "add") { + echo "\n"; + } + //if ($action == "update") { + // echo "\n"; + //} + echo "\n"; + echo "\n"; + + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " "; + echo "
Agent LoginAgent Login
\n"; + echo " Profile Name:\n"; + echo "\n"; + + $sql = ""; + $sql .= "select * from v_fifo_agent_profiles "; + $sql .= "where domain_uuid = '$domain_uuid' "; + //$sql .= "and fifo_agent_profile_id = '$fifo_agent_profile_id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $x = 0; + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + echo "\n"; + unset ($prep_statement); + + + echo "
\n"; + echo " Contact Number:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the agent contact number.\n"; + echo "
\n"; + //if ($action == "update") { + // echo " \n"; + //} + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + + +require_once "includes/footer.php"; +?> diff --git a/app/fifo_agents/fifo_agent/v_fifo_agent_logout.php b/app/fifo_agents/fifo_agent/v_fifo_agent_logout.php new file mode 100644 index 0000000000..1847a73a59 --- /dev/null +++ b/app/fifo_agents/fifo_agent/v_fifo_agent_logout.php @@ -0,0 +1,74 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("agent") || if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//agent logout + $sql = ""; + $sql .= "delete from v_fifo_agents "; + $sql .= "where agent_username = '".$_SESSION["username"]."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + +//agent status log login + $agent_status = '0'; //login + $sql = "insert into v_fifo_agent_status_logs "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "username, "; + $sql .= "agent_status, "; + $sql .= "add_date "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'".$_SESSION["username"]."', "; + $sql .= "'$agent_status', "; + $sql .= "now() "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + +//redirect + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Logout Complete\n"; + echo "
\n"; + +require_once "includes/footer.php"; +return; + +?> \ No newline at end of file diff --git a/app/fifo_agents/fifo_agent/v_fifo_agent_remote.php b/app/fifo_agents/fifo_agent/v_fifo_agent_remote.php new file mode 100644 index 0000000000..26227d3097 --- /dev/null +++ b/app/fifo_agents/fifo_agent/v_fifo_agent_remote.php @@ -0,0 +1,52 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("agent") || if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//show the header + require_once "includes/header.php"; + +echo "
\n"; +echo " \n"; +echo "   \n"; +echo "
\n"; + +//show the iframe + echo "\n"; + +//show the footer + require_once "includes/footer.php"; +?> diff --git a/app/fifo_agents/fifo_agent_call_logs/root.php b/app/fifo_agents/fifo_agent_call_logs/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/fifo_agents/fifo_agent_call_logs/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/fifo_agents/fifo_agent_call_logs/v_fifo_agent_call_logs.php b/app/fifo_agents/fifo_agent_call_logs/v_fifo_agent_call_logs.php new file mode 100644 index 0000000000..825f985a6e --- /dev/null +++ b/app/fifo_agents/fifo_agent_call_logs/v_fifo_agent_call_logs.php @@ -0,0 +1,170 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Fifo Agent Call Data 
\n"; + echo "The agent call data show a list of call calls agents have received.

\n"; + echo "
\n"; + + + $sql = ""; + $sql .= " select * from v_fifo_agent_call_logs "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $num_rows = count($result); + unset ($prep_statement, $result, $sql); + $rows_per_page = 10; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + $sql = ""; + //$sql .= " select * from v_fifo_agent_call_logs "; + $sql .= " select * from v_fifo_agent_call_data "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo th_order_by('call_uuid', 'Call UUID', $order_by, $order); + echo th_order_by('resolution_code', 'Resolution Code', $order_by, $order); + echo th_order_by('transaction_id', 'Transaction ID', $order_by, $order); + echo th_order_by('action_item', 'Action Item', $order_by, $order); + echo th_order_by('notes', 'Notes', $order_by, $order); + echo th_order_by('add_user', 'Add User', $order_by, $order); + echo th_order_by('add_date', 'Add Date', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count == 0) { //no results + } + else { //received results + foreach($result as $row) { + //print_r( $row ); + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "
\n"; + echo " $v_link_label_add\n"; + //echo " \n"; + echo "
".$row[call_uuid]."".$row[resolution_code]."".$row[transaction_id]."".$row[action_item]."".$row[notes]."".$row[add_user]."".$row[add_date]."\n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + //echo " \n"; + //echo " \n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + //echo " \n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + + echo "
"; + echo "
"; + echo "

"; + + +require_once "includes/footer.php"; +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); +?> diff --git a/app/fifo_agents/fifo_agent_call_logs/v_fifo_agent_call_logs.sql b/app/fifo_agents/fifo_agent_call_logs/v_fifo_agent_call_logs.sql new file mode 100644 index 0000000000..dcad41b95a --- /dev/null +++ b/app/fifo_agents/fifo_agent_call_logs/v_fifo_agent_call_logs.sql @@ -0,0 +1 @@ +CREATE TABLE v_fifo_agent_call_logs ( fifo_agent_call_log_id INTEGER PRIMARY KEY, v_id TEXT, resolution_code TEXT, transaction_id TEXT, action_item TEXT, uuid TEXT, notes TEXT, add_user TEXT, add_date TEXT ); diff --git a/app/fifo_agents/fifo_agent_call_logs/v_fifo_agent_call_logs_delete.php b/app/fifo_agents/fifo_agent_call_logs/v_fifo_agent_call_logs_delete.php new file mode 100644 index 0000000000..1b88a20292 --- /dev/null +++ b/app/fifo_agents/fifo_agent_call_logs/v_fifo_agent_call_logs_delete.php @@ -0,0 +1,61 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); +} + +if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_fifo_agent_call_logs "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and fifo_agent_call_log_id = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); +} + +require_once "includes/header.php"; +echo "\n"; +echo "
\n"; +echo "Delete Complete\n"; +echo "
\n"; + +require_once "includes/footer.php"; +return; + +?> + diff --git a/app/fifo_agents/fifo_agent_call_logs/v_fifo_agent_call_logs_edit.php b/app/fifo_agents/fifo_agent_call_logs/v_fifo_agent_call_logs_edit.php new file mode 100644 index 0000000000..39b2927552 --- /dev/null +++ b/app/fifo_agents/fifo_agent_call_logs/v_fifo_agent_call_logs_edit.php @@ -0,0 +1,299 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//Action add or update +if (isset($_REQUEST["id"])) { + $action = "update"; + $fifo_agent_call_log_id = check_str($_REQUEST["id"]); +} +else { + $action = "add"; +} + +//POST to PHP variables +if (count($_POST)>0) { + $resolution_code = check_str($_POST["resolution_code"]); + $transaction_id = check_str($_POST["transaction_id"]); + $action_item = check_str($_POST["action_item"]); + $uuid = check_str($_POST["uuid"]); + $notes = check_str($_POST["notes"]); + $add_user = check_str($_POST["add_user"]); + $add_date = check_str($_POST["add_date"]); +} + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + + if ($action == "update") { + $fifo_agent_call_log_id = check_str($_POST["fifo_agent_call_log_id"]); + } + + //check for all required data + //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + //if (strlen($resolution_code) == 0) { $msg .= "Please provide: Resolution Code
\n"; } + //if (strlen($transaction_id) == 0) { $msg .= "Please provide: Transaction ID
\n"; } + //if (strlen($action_item) == 0) { $msg .= "Please provide: Action Item
\n"; } + //if (strlen($uuid) == 0) { $msg .= "Please provide: UUID
\n"; } + //if (strlen($notes) == 0) { $msg .= "Please provide: Notes
\n"; } + //if (strlen($add_user) == 0) { $msg .= "Please provide: Add User
\n"; } + //if (strlen($add_date) == 0) { $msg .= "Please provide: Add Date
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $sql = "insert into v_fifo_agent_call_logs "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "resolution_code, "; + $sql .= "transaction_id, "; + $sql .= "action_item, "; + $sql .= "uuid, "; + $sql .= "notes, "; + $sql .= "add_user, "; + $sql .= "add_date "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$resolution_code', "; + $sql .= "'$transaction_id', "; + $sql .= "'$action_item', "; + $sql .= "'$uuid', "; + $sql .= "'$notes', "; + $sql .= "'$add_user', "; + $sql .= "'$add_date' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_fifo_agent_call_logs set "; + $sql .= "resolution_code = '$resolution_code', "; + $sql .= "transaction_id = '$transaction_id', "; + $sql .= "action_item = '$action_item', "; + $sql .= "uuid = '$uuid', "; + $sql .= "notes = '$notes', "; + $sql .= "add_user = '$add_user', "; + $sql .= "add_date = '$add_date' "; + $sql .= "where domain_uuid = '$domain_uuid'"; + $sql .= "and fifo_agent_call_log_id = '$fifo_agent_call_log_id'"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") + +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form +if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $fifo_agent_call_log_id = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_fifo_agent_call_logs "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and fifo_agent_call_log_id = '$fifo_agent_call_log_id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $resolution_code = $row["resolution_code"]; + $transaction_id = $row["transaction_id"]; + $action_item = $row["action_item"]; + $uuid = $row["uuid"]; + $notes = $row["notes"]; + $add_user = $row["add_user"]; + $add_date = $row["add_date"]; + break; //limit to 1 row + } + unset ($prep_statement); +} + +//begin the content + require_once "includes/header.php"; + + + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + + echo "
\n"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Fifo Agent Call Log AddFifo Agent Call Log Edit
\n"; + echo "The agent call logs show a list of call calls agents have received.

\n"; + echo "
\n"; + echo " Resolution Code:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the resolution code.\n"; + echo "
\n"; + echo " Transaction ID:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the Transaction ID.\n"; + echo "
\n"; + echo " Action Item:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the Action Item.\n"; + echo "
\n"; + echo " UUID:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the UUID.\n"; + echo "
\n"; + echo " Notes:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the notes.\n"; + echo "
\n"; + echo " Add User:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Add Date:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + + +require_once "includes/footer.php"; +?> diff --git a/app/fifo_agents/fifo_agent_profiles/root.php b/app/fifo_agents/fifo_agent_profiles/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/fifo_agents/fifo_agent_profiles/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profile_members.php b/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profile_members.php new file mode 100644 index 0000000000..689e8013cb --- /dev/null +++ b/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profile_members.php @@ -0,0 +1,161 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Agent Member List 
\n"; + + + $sql = ""; + $sql .= " select * from v_fifo_agent_profile_members "; + $sql .= " where domain_uuid = '$domain_uuid' "; + $sql .= " and fifo_agent_profile_id = '$fifo_agent_profile_id' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $num_rows = count($result); + unset ($prep_statement, $result, $sql); + $rows_per_page = 100; + $param = "&id=".$_GET['id']; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + $sql = ""; + $sql .= " select * from v_fifo_agent_profile_members "; + $sql .= " where domain_uuid = '$domain_uuid' "; + $sql .= " and fifo_agent_profile_id = '$fifo_agent_profile_id' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo th_order_by('fifo_name', 'FIFO Name', $order_by, $order); + echo th_order_by('agent_username', 'Agent', $order_by, $order); + echo th_order_by('agent_priority', 'Agent Priority', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count == 0) { //no results + } + else { //received results + foreach($result as $row) { + //print_r( $row ); + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "
\n"; + echo " $v_link_label_add\n"; + //echo " \n"; + echo "
".$row[fifo_name]."".$row[agent_username]."".$row[agent_priority]."\n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + //echo " \n"; + //echo " \n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + //echo " \n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + + echo "
"; + echo "
"; + echo "

"; + + +require_once "includes/footer.php"; +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); +?> diff --git a/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profile_members.sql b/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profile_members.sql new file mode 100644 index 0000000000..8d5c990d3e --- /dev/null +++ b/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profile_members.sql @@ -0,0 +1 @@ +CREATE TABLE v_fifo_agent_profile_members (fifo_agent_profile_member_id INTEGER PRIMARY KEY, v_id NUMBER, fifo_agent_profile_id NUMBER, fifo_name TEXT, agent_priority TEXT, agent_username TEXT); diff --git a/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profile_members_delete.php b/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profile_members_delete.php new file mode 100644 index 0000000000..2de2f84828 --- /dev/null +++ b/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profile_members_delete.php @@ -0,0 +1,62 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); + $fifo_agent_profile_id = check_str($_GET["fifo_agent_profile_id"]); +} + +if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_fifo_agent_profile_members "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and fifo_agent_profile_member_id = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); +} + +require_once "includes/header.php"; +echo "\n"; +echo "
\n"; +echo "Delete Complete\n"; +echo "
\n"; + +require_once "includes/footer.php"; +return; + +?> + diff --git a/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profile_members_edit.php b/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profile_members_edit.php new file mode 100644 index 0000000000..5d8738660a --- /dev/null +++ b/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profile_members_edit.php @@ -0,0 +1,358 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//Action add or update +if (isset($_REQUEST["id"])) { + $action = "update"; + $fifo_agent_profile_member_id = check_str($_REQUEST["id"]); +} +else { + $action = "add"; +} + +if (strlen($_GET["fifo_agent_profile_id"]) > 0) { + $fifo_agent_profile_id = check_str($_GET["fifo_agent_profile_id"]); +} + +//POST to PHP variables +if (count($_POST)>0) { + //$domain_uuid = check_str($_POST["domain_uuid"]); + $fifo_agent_profile_id = check_str($_POST["fifo_agent_profile_id"]); + $fifo_name = check_str($_POST["fifo_name"]); + $agent_priority = check_str($_POST["agent_priority"]); + $agent_username = check_str($_POST["agent_username"]); +} + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + + ////recommend moving this to the config.php file + $uploadtempdir = $_ENV["TEMP"]."\\"; + ini_set('upload_tmp_dir', $uploadtempdir); + ////$imagedir = $_ENV["TEMP"]."\\"; + ////$filedir = $_ENV["TEMP"]."\\"; + + if ($action == "update") { + $fifo_agent_profile_member_id = check_str($_POST["fifo_agent_profile_member_id"]); + } + + //check for all required data + if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + if (strlen($fifo_agent_profile_id) == 0) { $msg .= "Please provide: fifo_agent_profile_id
\n"; } + //if (strlen($fifo_name) == 0) { $msg .= "Please provide: FIFO Name
\n"; } + //if (strlen($agent_priority) == 0) { $msg .= "Please provide: Agent Priority
\n"; } + //if (strlen($agent_username) == 0) { $msg .= "Please provide: Agent
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + +//add or update the database +if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $sql = "insert into v_fifo_agent_profile_members "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "fifo_agent_profile_id, "; + $sql .= "fifo_name, "; + $sql .= "agent_priority, "; + $sql .= "agent_username "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$fifo_agent_profile_id', "; + $sql .= "'$fifo_name', "; + $sql .= "'$agent_priority', "; + $sql .= "'$agent_username' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_fifo_agent_profile_members set "; + $sql .= "fifo_agent_profile_id = '$fifo_agent_profile_id', "; + $sql .= "fifo_name = '$fifo_name', "; + $sql .= "agent_priority = '$agent_priority', "; + $sql .= "agent_username = '$agent_username' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and fifo_agent_profile_member_id = '$fifo_agent_profile_member_id'"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") +} //if ($_POST["persistformvar"] != "true") { + +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form +if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $fifo_agent_profile_member_id = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_fifo_agent_profile_members "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and fifo_agent_profile_member_id = '$fifo_agent_profile_member_id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $fifo_agent_profile_id = $row["fifo_agent_profile_id"]; + $fifo_name = $row["fifo_name"]; + $agent_priority = $row["agent_priority"]; + $agent_username = $row["agent_username"]; + break; //limit to 1 row + } + unset ($prep_statement); +} + + + require_once "includes/header.php"; + + + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + + + + echo "
\n"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " "; + echo "
Agent Member List AddAgent Member List Edit
\n"; + echo " Queue Name:\n"; + echo "\n"; + //echo " \n"; + + //generate the fifo name select list + $sql = ""; + $sql .= "select * from v_dialplan_details "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $x = 0; + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + echo "\n"; + unset ($prep_statement); + + + echo "
\n"; + echo "Select the queue name.\n"; + echo "
\n"; + echo " Agent:\n"; + echo "\n"; + //echo " \n"; + + //generate the user list + $sql = "SELECT * FROM v_users "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + + echo ""; + unset($sql, $result); + + echo "
\n"; + echo "Select the agent.\n"; + echo "
\n"; + echo " Agent Priority:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Select the agent priority.\n"; + echo "
\n"; + echo " \n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + + +require_once "includes/footer.php"; +?> diff --git a/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profiles.php b/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profiles.php new file mode 100644 index 0000000000..569b20430c --- /dev/null +++ b/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profiles.php @@ -0,0 +1,156 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Agent Profile List 
\n"; + + + $sql = ""; + $sql .= "select * from v_fifo_agent_profiles "; + $sql .= "where domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $num_rows = count($result); + unset ($prep_statement, $result, $sql); + $rows_per_page = 10; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + $sql = ""; + $sql .= "select * from v_fifo_agent_profiles "; + $sql .= "where domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo th_order_by('profile_name', 'Profile Name', $order_by, $order); + echo th_order_by('profile_desc', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count == 0) { //no results + } + else { //received results + foreach($result as $row) { + //print_r( $row ); + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "
\n"; + echo " $v_link_label_add\n"; + //echo " \n"; + echo "
".$row[profile_name]."".$row[profile_desc]."\n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + //echo " \n"; + //echo " \n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + //echo " \n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + + echo "
"; + echo "
"; + echo "

"; + + +require_once "includes/footer.php"; +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); +?> diff --git a/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profiles.sql b/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profiles.sql new file mode 100644 index 0000000000..07ab882606 --- /dev/null +++ b/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profiles.sql @@ -0,0 +1 @@ +CREATE TABLE v_fifo_agent_profiles (fifo_agent_profile_id INTEGER PRIMARY KEY, v_id NUMBER, profile_name TEXT, profile_desc TEXT); diff --git a/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profiles_delete.php b/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profiles_delete.php new file mode 100644 index 0000000000..b02c5e21eb --- /dev/null +++ b/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profiles_delete.php @@ -0,0 +1,72 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); +} + +if (strlen($id)>0) { + + //delete child data + $sql = ""; + $sql .= "delete from v_fifo_agent_profile_members "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and fifo_agent_profile_id = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql, $prep_statement); + + //delete parent data + $sql = ""; + $sql .= "delete from v_fifo_agent_profiles "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and fifo_agent_profile_id = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql, $prep_statement); +} + +require_once "includes/header.php"; +echo "\n"; +echo "
\n"; +echo "Delete Complete\n"; +echo "
\n"; + +require_once "includes/footer.php"; +return; + +?> + diff --git a/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profiles_edit.php b/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profiles_edit.php new file mode 100644 index 0000000000..89381c9159 --- /dev/null +++ b/app/fifo_agents/fifo_agent_profiles/v_fifo_agent_profiles_edit.php @@ -0,0 +1,222 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//Action add or update +if (isset($_REQUEST["id"])) { + $action = "update"; + $fifo_agent_profile_id = check_str($_REQUEST["id"]); +} +else { + $action = "add"; +} + +//POST to PHP variables +if (count($_POST)>0) { + //$domain_uuid = check_str($_POST["domain_uuid"]); + $profile_name = check_str($_POST["profile_name"]); + $profile_desc = check_str($_POST["profile_desc"]); +} + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + + ////recommend moving this to the config.php file + $uploadtempdir = $_ENV["TEMP"]."\\"; + ini_set('upload_tmp_dir', $uploadtempdir); + ////$imagedir = $_ENV["TEMP"]."\\"; + ////$filedir = $_ENV["TEMP"]."\\"; + + if ($action == "update") { + $fifo_agent_profile_id = check_str($_POST["fifo_agent_profile_id"]); + } + + //check for all required data + if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + if (strlen($profile_name) == 0) { $msg .= "Please provide: Profile Name
\n"; } + if (strlen($profile_desc) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $sql = "insert into v_fifo_agent_profiles "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "profile_name, "; + $sql .= "profile_desc "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$profile_name', "; + $sql .= "'$profile_desc' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_fifo_agent_profiles set "; + $sql .= "domain_uuid = '$domain_uuid', "; + $sql .= "profile_name = '$profile_name', "; + $sql .= "profile_desc = '$profile_desc' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and fifo_agent_profile_id = '$fifo_agent_profile_id'"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") + +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form +if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $fifo_agent_profile_id = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_fifo_agent_profiles "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and fifo_agent_profile_id = '$fifo_agent_profile_id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $domain_uuid = $row["domain_uuid"]; + $profile_name = $row["profile_name"]; + $profile_desc = $row["profile_desc"]; + break; //limit to 1 row + } + unset ($prep_statement); +} + + + require_once "includes/header.php"; + + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + + echo "
\n"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Agent Profile AddAgent Profile Edit
\n"; + echo " Profile Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the profile name.\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the description.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + if ($action == "update") { + require "v_fifo_agent_profile_members.php"; + } + + echo "
"; + echo "
"; + + +require_once "includes/footer.php"; +?> diff --git a/app/fifo_agents/fifo_agent_status_logs/root.php b/app/fifo_agents/fifo_agent_status_logs/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/fifo_agents/fifo_agent_status_logs/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/fifo_agents/fifo_agent_status_logs/v_fifo_agent_status_logs.php b/app/fifo_agents/fifo_agent_status_logs/v_fifo_agent_status_logs.php new file mode 100644 index 0000000000..e26d8177dc --- /dev/null +++ b/app/fifo_agents/fifo_agent_status_logs/v_fifo_agent_status_logs.php @@ -0,0 +1,185 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + +//get the agent status session array + //unset($_SESSION["array_agent_status"]); + if (!is_array($_SESSION["array_agent_status"])) { + $sql = "SELECT var_name, var_value FROM v_vars "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and var_cat = 'Queues Agent Status' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach($result as $field) { + $_SESSION["array_agent_status"][$field[var_value]] = $field[var_name]; + } + } + +//send the content to the browser + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Fifo Agent Status Log List 
\n"; + echo "Agent Status History

\n"; + echo "
\n"; + + + $sql = ""; + $sql .= " select * from v_fifo_agent_status_logs "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $num_rows = count($result); + unset ($prep_statement, $result, $sql); + $rows_per_page = 100; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + $sql = ""; + $sql .= " select * from v_fifo_agent_status_logs "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo th_order_by('username', 'Username', $order_by, $order); + echo th_order_by('agent_status', 'Status', $order_by, $order); + echo th_order_by('uuid', 'UUID', $order_by, $order); + echo th_order_by('add_date', 'Add Date', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count == 0) { //no results + } + else { //received results + foreach($result as $row) { + //print_r( $row ); + //set the php variables + $agent_status = $row[agent_status]; + + //get the agent description + $agent_status_desc = $_SESSION["array_agent_status"][$agent_status]; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "
\n"; + echo " $v_link_label_add\n"; + //echo " \n"; + echo "
".$row[username]."".$agent_status_desc."".$row[uuid]." ".$row[add_date]."\n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + //echo " \n"; + //echo " \n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + //echo " \n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + + echo "
"; + echo "
"; + echo "

"; + + +require_once "includes/footer.php"; +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); +?> diff --git a/app/fifo_agents/fifo_agent_status_logs/v_fifo_agent_status_logs.sql b/app/fifo_agents/fifo_agent_status_logs/v_fifo_agent_status_logs.sql new file mode 100644 index 0000000000..5d8c919e35 --- /dev/null +++ b/app/fifo_agents/fifo_agent_status_logs/v_fifo_agent_status_logs.sql @@ -0,0 +1 @@ +CREATE TABLE v_fifo_agent_status_logs (fifo_agent_status_log_id INTEGER PRIMARY KEY, v_id NUMBER, username TEXT, agent_status TEXT, uuid TEXT, add_date TEXT) diff --git a/app/fifo_agents/fifo_agent_status_logs/v_fifo_agent_status_logs_delete.php b/app/fifo_agents/fifo_agent_status_logs/v_fifo_agent_status_logs_delete.php new file mode 100644 index 0000000000..2ab49480f8 --- /dev/null +++ b/app/fifo_agents/fifo_agent_status_logs/v_fifo_agent_status_logs_delete.php @@ -0,0 +1,60 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); +} + +if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_fifo_agent_status_logs "; + $sql .= "where fifo_agent_status_log_id = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); +} + +require_once "includes/header.php"; +echo "\n"; +echo "
\n"; +echo "Delete Complete\n"; +echo "
\n"; + +require_once "includes/footer.php"; +return; + +?> + diff --git a/app/fifo_agents/fifo_agent_status_logs/v_fifo_agent_status_logs_edit.php b/app/fifo_agents/fifo_agent_status_logs/v_fifo_agent_status_logs_edit.php new file mode 100644 index 0000000000..93fe33aa9f --- /dev/null +++ b/app/fifo_agents/fifo_agent_status_logs/v_fifo_agent_status_logs_edit.php @@ -0,0 +1,262 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $fifo_agent_status_log_id = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//POST to PHP variables + if (count($_POST)>0) { + $username = check_str($_POST["username"]); + $agent_status = check_str($_POST["agent_status"]); + $uuid = check_str($_POST["uuid"]); + $add_date = check_str($_POST["add_date"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $fifo_agent_status_log_id = check_str($_POST["fifo_agent_status_log_id"]); + } + + //check for all required data + //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + //if (strlen($username) == 0) { $msg .= "Please provide: Username
\n"; } + //if (strlen($agent_status) == 0) { $msg .= "Please provide: Status
\n"; } + //if (strlen($uuid) == 0) { $msg .= "Please provide: UUID
\n"; } + //if (strlen($add_date) == 0) { $msg .= "Please provide: Add Date
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $sql = "insert into v_fifo_agent_status_logs "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "username, "; + $sql .= "agent_status, "; + $sql .= "uuid, "; + $sql .= "add_date "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$username', "; + $sql .= "'$agent_status', "; + $sql .= "'$uuid', "; + $sql .= "now() "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_fifo_agent_status_logs set "; + $sql .= "domain_uuid = '$domain_uuid', "; + $sql .= "username = '$username', "; + $sql .= "agent_status = '$agent_status', "; + $sql .= "uuid = '$uuid', "; + $sql .= "add_date = '$add_date' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and fifo_agent_status_log_id = '$fifo_agent_status_log_id'"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") + +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $fifo_agent_status_log_id = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_fifo_agent_status_logs "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and fifo_agent_status_log_id = '$fifo_agent_status_log_id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $domain_uuid = $row["domain_uuid"]; + $username = $row["username"]; + $agent_status = $row["agent_status"]; + $uuid = $row["uuid"]; + $add_date = $row["add_date"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + + +//send the content + require_once "includes/header.php"; + + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + + echo "
\n"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Fifo Agent Status Log AddFifo Agent Status Log Edit
\n"; + echo "Agent Status History

\n"; + echo "
\n"; + echo " domain_uuid:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Username:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the Username.\n"; + echo "
\n"; + echo " Status:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the agent status.\n"; + echo "
\n"; + echo " UUID:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the UUID.\n"; + echo "
\n"; + echo " Add Date:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo " Enter the date.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + + +require_once "includes/footer.php"; +?> diff --git a/app/fifo_agents/fifo_languages/root.php b/app/fifo_agents/fifo_languages/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/fifo_agents/fifo_languages/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/fifo_agents/fifo_languages/v_fifo_agent_languages.php b/app/fifo_agents/fifo_languages/v_fifo_agent_languages.php new file mode 100644 index 0000000000..68c4d6fded --- /dev/null +++ b/app/fifo_agents/fifo_languages/v_fifo_agent_languages.php @@ -0,0 +1,161 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Fifo Agent Language List 
\n"; + echo "Matches the Agent with languages they can speak with their proficiency level.

\n"; + echo "
\n"; + + + $sql = ""; + $sql .= " select * from v_fifo_agent_languages "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $num_rows = count($result); + unset ($prep_statement, $result, $sql); + $rows_per_page = 10; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + $sql = ""; + $sql .= " select * from v_fifo_agent_languages "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo th_order_by('username', 'Username', $order_by, $order); + echo th_order_by('language', 'Language', $order_by, $order); + echo th_order_by('proficiency', 'Proficiency', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count == 0) { //no results + } + else { //received results + foreach($result as $row) { + //print_r( $row ); + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "
\n"; + echo " $v_link_label_add\n"; + //echo " \n"; + echo "
".$row[username]."".$row[language]."".$row[proficiency]."\n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + //echo " \n"; + //echo " \n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + //echo " \n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + + echo "
"; + echo "
"; + echo "

"; + + +require_once "includes/footer.php"; +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); +?> diff --git a/app/fifo_agents/fifo_languages/v_fifo_agent_languages.sql b/app/fifo_agents/fifo_languages/v_fifo_agent_languages.sql new file mode 100644 index 0000000000..70e91ae3a3 --- /dev/null +++ b/app/fifo_agents/fifo_languages/v_fifo_agent_languages.sql @@ -0,0 +1 @@ +CREATE TABLE v_fifo_agent_languages (fifo_agent_language_id INTEGER PRIMARY KEY, v_id TEXT, username TEXT, language TEXT, proficiency TEXT); diff --git a/app/fifo_agents/fifo_languages/v_fifo_agent_languages_delete.php b/app/fifo_agents/fifo_languages/v_fifo_agent_languages_delete.php new file mode 100644 index 0000000000..20010421c2 --- /dev/null +++ b/app/fifo_agents/fifo_languages/v_fifo_agent_languages_delete.php @@ -0,0 +1,60 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); +} + +if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_fifo_agent_languages "; + $sql .= "where fifo_agent_language_id = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); +} + +require_once "includes/header.php"; +echo "\n"; +echo "
\n"; +echo "Delete Complete\n"; +echo "
\n"; + +require_once "includes/footer.php"; +return; + +?> + diff --git a/app/fifo_agents/fifo_languages/v_fifo_agent_languages_edit.php b/app/fifo_agents/fifo_languages/v_fifo_agent_languages_edit.php new file mode 100644 index 0000000000..6ddcfcf3fc --- /dev/null +++ b/app/fifo_agents/fifo_languages/v_fifo_agent_languages_edit.php @@ -0,0 +1,336 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//Action add or update +if (isset($_REQUEST["id"])) { + $action = "update"; + $fifo_agent_language_id = check_str($_REQUEST["id"]); +} +else { + $action = "add"; +} + +//POST to PHP variables + if (count($_POST)>0) { + $username = check_str($_POST["username"]); + $language = check_str($_POST["language"]); + $proficiency = check_str($_POST["proficiency"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + + if ($action == "update") { + $fifo_agent_language_id = check_str($_POST["fifo_agent_language_id"]); + } + + //check for all required data + //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + //if (strlen($username) == 0) { $msg .= "Please provide: Username
\n"; } + //if (strlen($language) == 0) { $msg .= "Please provide: Language
\n"; } + //if (strlen($proficiency) == 0) { $msg .= "Please provide: Proficiency
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + + //Add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $sql = "insert into v_fifo_agent_languages "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "username, "; + $sql .= "language, "; + $sql .= "proficiency "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$username', "; + $sql .= "'$language', "; + $sql .= "'$proficiency' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_fifo_agent_languages set "; + $sql .= "domain_uuid = '$domain_uuid', "; + $sql .= "username = '$username', "; + $sql .= "language = '$language', "; + $sql .= "proficiency = '$proficiency' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and fifo_agent_language_id = '$fifo_agent_language_id'"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") + +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $fifo_agent_language_id = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_fifo_agent_languages "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and fifo_agent_language_id = '$fifo_agent_language_id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $domain_uuid = $row["domain_uuid"]; + $username = $row["username"]; + $language = $row["language"]; + $proficiency = $row["proficiency"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//begin the content + require_once "includes/header.php"; + + + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + + echo "
\n"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Fifo Agent Language AddFifo Agent Language Edit
\n"; + echo "Matches the Agent with languages they can speak with their proficiency level.

\n"; + echo "
\n"; + echo " Username:\n"; + echo "\n"; + + //generate the user list + $sql = "SELECT * FROM v_users "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + + echo ""; + unset($sql, $result); + + echo "
\n"; + echo "Select the Username from the list.\n"; + echo "
\n"; + echo " Language:\n"; + echo "\n"; + + //generate the language select list + $sql = "SELECT var_name, var_value FROM v_vars "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and var_cat = 'Languages' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + echo ""; + + echo "
\n"; + echo "Enter the two letter language code.\n"; + echo "
\n"; + echo " Proficiency:\n"; + echo "\n"; + + echo " \n"; + echo "
\n"; + echo "Select the language proficiency level.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + + +require_once "includes/footer.php"; +?> diff --git a/app/fifo_agents/root.php b/app/fifo_agents/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/fifo_agents/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/fifo_agents/v_fifo_agents.php b/app/fifo_agents/v_fifo_agents.php new file mode 100644 index 0000000000..b4f0038b2d --- /dev/null +++ b/app/fifo_agents/v_fifo_agents.php @@ -0,0 +1,206 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + + +//$time_start = microtime(true); +//sleep for a while +//usleep(1000000); + + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + + + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Active Agents 
\n"; + echo "Shows the agents that are currently logged into the queues.

\n"; + echo "
\n"; + + //set the default order by and order asc, desc + if (strlen($order_by) == 0) { + $order_by = 'fifo_name'; + $order = 'asc'; + } + + //run the sql queries + $sql = ""; + $sql .= " select * from v_fifo_agents "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + //$sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo th_order_by('fifo_name', 'Queue Name', $order_by, $order); + echo th_order_by('agent_username', 'Username', $order_by, $order); + echo th_order_by('agent_priority', 'Agent Priority', $order_by, $order); + echo th_order_by('agent_status', 'Status', $order_by, $order); + echo th_order_by('agent_last_call', 'Last Call', $order_by, $order); + echo th_order_by('agent_last_uuid', 'Last UUID', $order_by, $order); + echo th_order_by('agent_contact_number', 'Contact Number', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count == 0) { //no results + } + else { //received results + foreach($result as $row) { + //set the php variables + $agent_last_call = $row[agent_last_call]; + $agent_status = $row[agent_status]; + + //format the last call time + if ($agent_last_call == 0) { + $agent_last_call_desc = ''; + } + else { + $agent_last_call_desc = date("g:i:s a j M Y",$agent_last_call); + } + + //get the agent status session array + //unset($_SESSION["array_agent_status"]); + if (!is_array($_SESSION["array_agent_status"])) { + $sql = "SELECT var_name, var_value FROM v_vars "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and var_cat = 'Queues Agent Status' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach($result as $field) { + $_SESSION["array_agent_status"][$field[var_value]] = $field[var_name]; + } + } + + //get the agent description + $agent_status_desc = $_SESSION["array_agent_status"][$agent_status]; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + + echo "\n"; + echo "\n"; + echo "\n"; + + + echo "
\n"; + echo " $v_link_label_add\n"; + //echo " \n"; + echo "
".$row[fifo_name]."".$row[agent_username]."".$row[agent_priority]."".$agent_status_desc."".$agent_last_call_desc." ".$row[agent_last_uuid]." ".$row[agent_contact_number]."\n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + //echo " \n"; + //echo " \n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + //echo " \n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + +//sleep(1); +//$time_end = microtime(true); +//$time = $time_end - $time_start; +//if ($time < 2) { +// echo "use cache "; +//} +//else { +// echo "expired the cache "; +//} +//echo "load time $time seconds\n"; + + echo "
"; + echo "
"; + echo "

"; + + +require_once "includes/footer.php"; +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); +?> diff --git a/app/fifo_agents/v_fifo_agents.sql b/app/fifo_agents/v_fifo_agents.sql new file mode 100644 index 0000000000..39e9bc5aa7 --- /dev/null +++ b/app/fifo_agents/v_fifo_agents.sql @@ -0,0 +1 @@ +CREATE TABLE v_fifo_agents (fifo_agent_id INTEGER PRIMARY KEY, v_id NUMBER, fifo_name TEXT, agent_username TEXT, agent_priority TEXT, agent_status TEXT, agent_status_epoch NUMBER, agent_last_call NUMBER, agent_last_uuid TEXT, agent_contact_number NUMBER) diff --git a/app/fifo_agents/v_fifo_agents_delete.php b/app/fifo_agents/v_fifo_agents_delete.php new file mode 100644 index 0000000000..ea3778c349 --- /dev/null +++ b/app/fifo_agents/v_fifo_agents_delete.php @@ -0,0 +1,60 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); +} + +if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_fifo_agents "; + $sql .= "where fifo_agent_id = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); +} + +require_once "includes/header.php"; +echo "\n"; +echo "
\n"; +echo "Delete Complete\n"; +echo "
\n"; + +require_once "includes/footer.php"; +return; + +?> + diff --git a/app/fifo_agents/v_fifo_agents_edit.php b/app/fifo_agents/v_fifo_agents_edit.php new file mode 100644 index 0000000000..d6ebd799ac --- /dev/null +++ b/app/fifo_agents/v_fifo_agents_edit.php @@ -0,0 +1,479 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $fifo_agent_id = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $fifo_name = check_str($_POST["fifo_name"]); + $agent_username = check_str($_POST["agent_username"]); + $agent_priority = check_str($_POST["agent_priority"]); + $agent_status = check_str($_POST["agent_status"]); + $agent_last_call = check_str($_POST["agent_last_call"]); + $agent_last_uuid = check_str($_POST["agent_last_uuid"]); + $agent_contact_number = check_str($_POST["agent_contact_number"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + + ////recommend moving this to the config.php file + $uploadtempdir = $_ENV["TEMP"]."\\"; + ini_set('upload_tmp_dir', $uploadtempdir); + ////$imagedir = $_ENV["TEMP"]."\\"; + ////$filedir = $_ENV["TEMP"]."\\"; + + if ($action == "update") { + $fifo_agent_id = check_str($_POST["fifo_agent_id"]); + } + + //check for all required data + if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + if (strlen($fifo_name) == 0) { $msg .= "Please provide: Queue Name
\n"; } + if (strlen($agent_username) == 0) { $msg .= "Please provide: Username
\n"; } + if (strlen($agent_priority) == 0) { $msg .= "Please provide: Agent Priority
\n"; } + if (strlen($agent_status) == 0) { $msg .= "Please provide: Status
\n"; } + //if (strlen($agent_last_call) == 0) { $msg .= "Please provide: Last Call
\n"; } + //if (strlen($agent_last_uuid) == 0) { $msg .= "Please provide: Last UUID
\n"; } + //if (strlen($agent_contact_number) == 0) { $msg .= "Please provide: Contact Number
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //Add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $sql = "insert into v_fifo_agents "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "fifo_name, "; + $sql .= "agent_username, "; + $sql .= "agent_priority, "; + $sql .= "agent_status, "; + $sql .= "agent_last_call, "; + $sql .= "agent_last_uuid, "; + $sql .= "agent_contact_number "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$fifo_name', "; + $sql .= "'$agent_username', "; + $sql .= "'$agent_priority', "; + $sql .= "'$agent_status', "; + $sql .= "'$agent_last_call', "; + $sql .= "'$agent_last_uuid', "; + $sql .= "'$agent_contact_number' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_fifo_agents set "; + $sql .= "domain_uuid = '$domain_uuid', "; + $sql .= "fifo_name = '$fifo_name', "; + $sql .= "agent_username = '$agent_username', "; + $sql .= "agent_priority = '$agent_priority', "; + $sql .= "agent_status = '$agent_status', "; + $sql .= "agent_status_epoch = ".time()." "; + $sql .= "agent_last_call = '$agent_last_call', "; + $sql .= "agent_last_uuid = '$agent_last_uuid', "; + $sql .= "agent_contact_number = '$agent_contact_number' "; + $sql .= "where fifo_agent_id = '$fifo_agent_id'"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") + +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $fifo_agent_id = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_fifo_agents "; + $sql .= "where fifo_agent_id = '$fifo_agent_id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $fifo_name = $row["fifo_name"]; + $agent_username = $row["agent_username"]; + $agent_priority = $row["agent_priority"]; + $agent_status = $row["agent_status"]; + $agent_last_call = $row["agent_last_call"]; + $agent_last_uuid = $row["agent_last_uuid"]; + $agent_contact_number = $row["agent_contact_number"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//send the content to the browser + require_once "includes/header.php"; + + + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + + echo "
\n"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Agent LoginFifo Agent Edit
\n"; + echo "List the agents assigned to a Queue.

\n"; + echo "
\n"; + echo " Queue Name:\n"; + echo "\n"; + //echo " \n"; + + //generate the fifo name select list + $sql = ""; + $sql .= "select * from v_dialplan_details "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $x = 0; + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + echo "\n"; + unset ($prep_statement); + + echo "
\n"; + echo "Select the queue name.\n"; + echo "
\n"; + echo " Username:\n"; + echo "\n"; + //echo " \n"; + + //generate the user list + $sql = "SELECT * FROM v_users "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + + echo ""; + unset($sql, $result); + + echo "
\n"; + echo "Select the username.\n"; + echo "
\n"; + echo " Agent Priority:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Select a priority.\n"; + echo "
\n"; + echo " Status:\n"; + echo "\n"; + //generate the agent status select list + $sql = "SELECT var_name, var_value FROM v_vars "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and var_cat = 'Queues Agent Status' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + echo ""; + /* + foreach($result as $field) { + $_SESSION["array_agent_status"][$field[var_value]] = $field[var_name]; + } + + $x=1; + foreach($_SESSION["array_agent_status"] as $value) { + echo "$x $value
\n"; + $x++; + } + */ + + if (!is_array($_SESSION["array_agent_status"])) { + echo "not an array"; + foreach($result as $field) { + $_SESSION["array_agent_status"][$field[var_value]] = $field[var_name]; + } + } + else { + //echo "is an array"; + //unset($_SESSION["array_agent_status"]); + } + unset($sql, $result); + + /* + echo " \n"; + */ + echo "
\n"; + echo "Enter the status of the Agent.\n"; + echo "
\n"; + echo " Last Call:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Last UUID:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the UUID for the last call.\n"; + echo "
\n"; + echo " Contact Number:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the agent contact number.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + + +require_once "includes/footer.php"; +?> diff --git a/app/fifo_list/app_config.php b/app/fifo_list/app_config.php new file mode 100644 index 0000000000..4ce044124f --- /dev/null +++ b/app/fifo_list/app_config.php @@ -0,0 +1,37 @@ + \ No newline at end of file diff --git a/app/fifo_list/root.php b/app/fifo_list/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/fifo_list/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/fifo_list/v_fifo_exec.php b/app/fifo_list/v_fifo_exec.php new file mode 100644 index 0000000000..cebb25d850 --- /dev/null +++ b/app/fifo_list/v_fifo_exec.php @@ -0,0 +1,89 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('active_queues_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $switch_cmd = trim($_GET["cmd"]); + $action = trim($_GET["action"]); + $direction = trim($_GET["direction"]); +} + + +//GET to PHP variables +if (count($_GET)>0) { + + //fs cmd + if (strlen($switch_cmd) > 0) { + /* + if ($action == "energy") { + //conference 3001-example.dyndns.org energy 103 + $switch_result = event_socket_request($fp, 'api '.$switch_cmd); + $result_array = explode("=",$switch_result); + $tmp_value = $result_array[1]; + if ($direction == "up") { $tmp_value = $tmp_value + 100; } + if ($direction == "down") { $tmp_value = $tmp_value - 100; } + //echo "energy $tmp_value
\n"; + $switch_result = event_socket_request($fp, 'api '.$switch_cmd.' '.$tmp_value); + } + if ($action == "volume_in") { + $switch_result = event_socket_request($fp, 'api '.$switch_cmd); + $result_array = explode("=",$switch_result); + $tmp_value = $result_array[1]; + if ($direction == "up") { $tmp_value = $tmp_value + 1; } + if ($direction == "down") { $tmp_value = $tmp_value - 1; } + //echo "volume $tmp_value
\n"; + $switch_result = event_socket_request($fp, 'api '.$switch_cmd.' '.$tmp_value); + } + if ($action == "volume_out") { + $switch_result = event_socket_request($fp, 'api '.$switch_cmd); + $result_array = explode("=",$switch_result); + $tmp_value = $result_array[1]; + if ($direction == "up") { $tmp_value = $tmp_value + 1; } + if ($direction == "down") { $tmp_value = $tmp_value - 1; } + //echo "volume $tmp_value
\n"; + $switch_result = event_socket_request($fp, 'api '.$switch_cmd.' '.$tmp_value); + } + */ + //connect to the event socket + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + //send the command over event socket + if ($fp) { + $switch_result = event_socket_request($fp, 'api '.$switch_cmd); + } + } + +} + +?> diff --git a/app/fifo_list/v_fifo_interactive.php b/app/fifo_list/v_fifo_interactive.php new file mode 100644 index 0000000000..cd1313ec01 --- /dev/null +++ b/app/fifo_list/v_fifo_interactive.php @@ -0,0 +1,143 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('active_queues_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the fifo_name from http and set it to a php variable + $fifo_name = trim($_REQUEST["c"]); + +//if not the user is not a member of the superadmin then restrict to viewing their own domain + if (!if_group("superadmin")) { + if (stripos($fifo_name, $_SESSION['domain_name']) === false) { + echo "access denied"; + exit; + } + } + +//remove the domain from fifo name + $tmp_fifo_name = str_replace('_', ' ', $fifo_name); + $tmp_fifo_array = explode('@', $tmp_fifo_name); + $tmp_fifo_name = $tmp_fifo_array[0]; + +//show the header + require_once "includes/header.php"; + +?> + + +"; + +echo "\n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
Queues
\n"; +echo " Use this to monitor queue activty for the $tmp_fifo_name queue.\n"; +echo "
\n"; + +echo "\n"; +echo " \n"; +echo " "; +echo " "; +echo "
\n"; +echo "
\n"; +echo "
".date('Y-m-d-s')."
\n"; +echo "
"; + +echo ""; + +require_once "includes/footer.php"; +?> diff --git a/app/fifo_list/v_fifo_interactive_inc.php b/app/fifo_list/v_fifo_interactive_inc.php new file mode 100644 index 0000000000..1cefa7adf5 --- /dev/null +++ b/app/fifo_list/v_fifo_interactive_inc.php @@ -0,0 +1,206 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('active_queues_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//set variables + $fifo_name = trim($_REQUEST["c"]); + +//if not the user is not a member of the superadmin then restrict to viewing their own domain + if (!if_group("superadmin")) { + if (stripos($fifo_name, $_SESSION['domain_name']) === false) { + echo "access denied"; + exit; + } + } + +//prepare and send the api command over event socket + $switch_cmd = 'fifo list_verbose '.$fifo_name.''; + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + if (!$fp) { + $msg = "
Connection to Event Socket failed.
"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Message
$msg
\n"; + echo "
\n"; + } + else { + //send the api command over event socket + $xml_str = trim(event_socket_request($fp, 'api '.$switch_cmd)); + + //parse the response as xml + try { + $xml = new SimpleXMLElement($xml_str); + } + catch(Exception $e) { + //echo $e->getMessage(); + } + + //set variables from the xml + //$name = $xml->conference['name']; + //$member_count = $xml->conference['member-count']; + //$locked = $xml->conference['locked']; + + //set the alternating row styles + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + //response div tag + echo "
\n"; + echo "
\n"; + + //show the content + echo "\n"; + /* + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + */ + + echo "\n"; + echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + foreach ($xml->fifo->callers->caller as $row) { + /* + $username = $row->caller_profile->username; + $dialplan = $row->caller_profile->dialplan; + $caller_id_name = urldecode($row->caller_profile->caller_id_name); + $caller_id_number = $row->caller_profile->caller_id_number; + $ani = $row->caller_profile->ani; + $aniii = $row->caller_profile->aniii; + $network_addr = $row->caller_profile->network_addr; + $destination_number = $row->destination_number->rdnis; + $rdnis = $row->caller_profile->rdnis; + $uuid = $row->caller_profile->uuid; + $source = $row->caller_profile->source; + $context = $row->caller_profile->context; + $chan_name = $row->caller_profile->chan_name; + $default_language = $row->variables->default_language; + $fifo_position = $row->variables->fifo_position; + $fifo_priority = $row->variables->fifo_priority; + $fifo_status = $row->variables->fifo_status; + $fifo_timestamp = urldecode($row->variables->fifo_timestamp); + $fifo_time = strtotime($fifo_timestamp); + $fifo_duration = time() - $fifo_time; + $fifo_duration_formatted = str_pad(intval(intval($fifo_duration/3600)),2,"0",STR_PAD_LEFT).":" . str_pad(intval(($fifo_duration / 60) % 60),2,"0",STR_PAD_LEFT).":" . str_pad(intval($fifo_duration % 60),2,"0",STR_PAD_LEFT) ; + */ + + $username = $row->cdr->callflow->caller_profile->username; + $dialplan = $row->cdr->callflow->caller_profile->dialplan; + $caller_id_name = urldecode($row->cdr->callflow->caller_profile->caller_id_name); + $caller_id_number = $row->cdr->callflow->caller_profile->caller_id_number; + $ani = $row->cdr->callflow->caller_profile->ani; + $aniii = $row->cdr->callflow->caller_profile->aniii; + $network_addr = $row->cdr->callflow->caller_profile->network_addr; + $destination_number = $row->cdr->callflow->caller_profile->destination_number; + $rdnis = $row->cdr->callflow->caller_profile->rdnis; + $uuid = $row->cdr->callflow->caller_profile->uuid; + $source = $row->cdr->callflow->caller_profile->source; + $context = $row->cdr->callflow->caller_profile->context; + $chan_name = $row->cdr->callflow->caller_profile->chan_name; + $default_language = $row->cdr->variables->default_language; + $fifo_position = $row->cdr->variables->fifo_position; + $fifo_priority = $row->cdr->variables->fifo_priority; + $fifo_status = $row->cdr->variables->fifo_status; + $fifo_timestamp = urldecode($row->cdr->variables->fifo_timestamp); + $fifo_time = strtotime($fifo_timestamp); + $fifo_duration = time() - $fifo_time; + $fifo_duration_formatted = str_pad(intval(intval($fifo_duration/3600)),2,"0",STR_PAD_LEFT).":" . str_pad(intval(($fifo_duration / 60) % 60),2,"0",STR_PAD_LEFT).":" . str_pad(intval($fifo_duration % 60),2,"0",STR_PAD_LEFT) ; + + echo "\n"; + echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } + echo "
\n"; + //echo " Count: $member_count\n"; + echo "\n"; + echo "  \n"; + echo "\n"; + echo " Queues Tools: \n"; + echo " Start Record \n"; + echo " Stop Record \n"; + if ($locked == "true") { + echo " Unlock \n"; + } + else { + echo " Lock \n"; + } + echo "
UsernameDialplanCaller ID NameCaller ID NumberLanguageANIANIIINetwork AddrDestination NumberRDNISUUIDSourceContextChan NamePositionPriorityStatusDuration
$username  $dialplan  $caller_id_name  $caller_id_number  $default_language  $ani  $aniii  $network_addr  $destination_number  $rdnis  $uuid  $source  $context  $chan_name  $fifo_position  $fifo_priority  $fifo_status  $fifo_duration_formatted  
\n"; + } +?> diff --git a/app/fifo_list/v_fifo_list.php b/app/fifo_list/v_fifo_list.php new file mode 100644 index 0000000000..2badb68042 --- /dev/null +++ b/app/fifo_list/v_fifo_list.php @@ -0,0 +1,112 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('active_queues_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +require_once "includes/header.php"; +?> + +"; + +echo "\n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
Active Queues
\n"; +echo " List all the queues that are currently active with one or more callers.\n"; +echo "
\n"; + +echo "\n"; +echo "\n"; +echo " "; +echo " "; +echo "
\n"; + +echo "
\n"; +echo "
\n"; + +echo "
"; +echo ""; + +require_once "includes/footer.php"; +?> diff --git a/app/fifo_list/v_fifo_list_inc.php b/app/fifo_list/v_fifo_list_inc.php new file mode 100644 index 0000000000..5768a081a0 --- /dev/null +++ b/app/fifo_list/v_fifo_list_inc.php @@ -0,0 +1,121 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('active_queues_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$switch_cmd = 'fifo list'; +$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); +if ($fp) { + $xml_str = trim(event_socket_request($fp, 'api '.$switch_cmd)); + try { + $xml = new SimpleXMLElement($xml_str); + } + catch(Exception $e) { + //echo $e->getMessage(); + } + + /* + + + + + + + + + + + + + + + */ + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + foreach ($xml->fifo as $row) { + + foreach($row->attributes() as $tmp_name => $tmp_value) { + $$tmp_name = $tmp_value; + } + unset($tmp_name, $tmp_value); + + //remove the domain from name + $tmp_name = str_replace('_', ' ', $name); + $tmp_name_array = explode('@', $name); + $tmp_name = $tmp_name_array[0]; + + if (if_group("superadmin")) { + //show all fifo queues + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + else { + //show only the fifo queues that match the domain_name + if (stripos($name, $_SESSION['domain_name']) !== false) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + } + + if ($c==0) { $c=1; } else { $c=0; } + } + echo "
NameConsumer CountCaller CountWaiting CountImportance 
".$tmp_name."".$consumer_count."".$caller_count."".$waiting_count."".$importance."view
".$tmp_name."".$consumer_count."".$caller_count."".$waiting_count."".$importance."view
\n"; +} + +?> \ No newline at end of file diff --git a/app/gateways/app_config.php b/app/gateways/app_config.php new file mode 100644 index 0000000000..ed02fb416f --- /dev/null +++ b/app/gateways/app_config.php @@ -0,0 +1,166 @@ + \ No newline at end of file diff --git a/app/gateways/root.php b/app/gateways/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/gateways/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/gateways/v_gateways.php b/app/gateways/v_gateways.php new file mode 100644 index 0000000000..86e701ded0 --- /dev/null +++ b/app/gateways/v_gateways.php @@ -0,0 +1,252 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('gateways_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + +//connect to event socket +$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); +if ($fp) { + if (strlen($_GET["a"]) > 0) { + $profile = $_GET["profile"]; + if (strlen($profile) == 0) { + $profile = 'external'; + } + if ($_GET["a"] == "stop") { + $gateway_name = $_GET["gateway"]; + if (count($_SESSION["domains"]) > 1) { + $cmd = 'api sofia profile '.$profile.' killgw '.$_SESSION['domain_name'].'-'.$gateway_name; + } + else { + $cmd = 'api sofia profile '.$profile.' killgw '.$gateway_name; + } + $response = trim(event_socket_request($fp, $cmd)); + $msg = 'Stop Gateway:
'.$response.'
'; + } + if ($_GET["a"] == "start") { + $gateway_name = $_GET["gateway"]; + $cmd = 'api sofia profile '.$profile.' rescan'; + $response = trim(event_socket_request($fp, $cmd)); + $msg = 'Start Gateway:
'.$response.'
'; + } + } + + if (!function_exists('switch_gateway_status')) { + function switch_gateway_status($gateway_name, $result_type = 'xml') { + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + if (count($_SESSION["domains"]) > 1) { + $cmd = 'api sofia xmlstatus gateway '.$_SESSION['domain_name'].'-'.$gateway_name; + } + else { + $cmd = 'api sofia xmlstatus gateway '.$gateway_name; + } + return trim(event_socket_request($fp, $cmd)); + } + } +} + +echo "
"; +echo "\n"; +echo "\n"; +echo " "; +echo ""; +echo "
\n"; +echo "
"; + +echo "\n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
Gateways\n"; +echo " \n"; +echo " "; +echo "
\n"; +echo " \n"; +echo " Gateways provide access into other voice networks. These can be voice providers or other systems that require SIP registration.\n"; +echo " \n"; +echo "
"; + +echo "
\n"; +echo "
\n"; + +$sql = ""; +$sql .= " select * from v_gateways "; +$sql .= "where domain_uuid = '$domain_uuid' "; +if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } +$prep_statement = $db->prepare(check_sql($sql)); +$prep_statement->execute(); +$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); +$num_rows = count($result); +unset ($prep_statement, $result, $sql); + +$rows_per_page = 10; +$param = ""; +$page = $_GET['page']; +if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } +list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); +$offset = $rows_per_page * $page; + +$sql = ""; +$sql .= " select * from v_gateways "; +$sql .= "where domain_uuid = '$domain_uuid' "; +if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } +$sql .= " limit $rows_per_page offset $offset "; +$prep_statement = $db->prepare(check_sql($sql)); +$prep_statement->execute(); +$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); +$result_count = count($result); +unset ($prep_statement, $sql); + +$c = 0; +$row_style["0"] = "row_style0"; +$row_style["1"] = "row_style1"; + +echo "
\n"; +echo "\n"; +echo "\n"; +echo th_order_by('gateway', 'Gateway', $order_by, $order); +echo th_order_by('context', 'Context', $order_by, $order); +if ($fp) { + echo "\n"; + echo "\n"; + echo "\n"; +} +echo th_order_by('enabled', 'Enabled', $order_by, $order); +echo th_order_by('description', 'Gateway Description', $order_by, $order); +echo "\n"; +echo "\n"; + +if ($result_count == 0) { + //no results +} +else { //received results + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + + if ($fp) { + if ($row["enabled"] == "true") { + $response = switch_gateway_status($row["gateway"]); + if ($response == "Invalid Gateway!") { + //not running + echo " \n"; + echo " \n"; + echo " \n"; + } + else { + //running + try { + $xml = new SimpleXMLElement($response); + $state = $xml->state; + echo " \n"; + echo " \n"; + echo " \n"; + } + catch(Exception $e) { + //echo $e->getMessage(); + } + } + } + else { + echo " \n"; + echo " \n"; + echo " \n"; + } + } + + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); +} //end if results + +echo "\n"; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "\n"; + +echo "
StatusActionState\n"; +if (permission_exists('gateways_add')) { + echo " $v_link_label_add\n"; +} +echo "
".$row["gateway"]."".$row["context"]."StoppedStart RunningStop".$state."   ".$row["enabled"]."".$row["description"]."\n"; + if (permission_exists('gateways_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('gateways_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
 $paging_controls\n"; +if (permission_exists('gateways_add')) { + echo " $v_link_label_add\n"; +} +echo "
\n"; +echo "
\n"; +echo "
\n"; +if ($v_path_show) { + echo $_SESSION['switch']['gateways']['dir']."/sip_profiles\n"; +} +echo "
"; +echo "
"; +echo "

"; +echo "

"; + +echo "
"; +echo "
"; +echo "

"; + +require_once "includes/footer.php"; +?> diff --git a/app/gateways/v_gateways_copy.php b/app/gateways/v_gateways_copy.php new file mode 100644 index 0000000000..e9328c2a91 --- /dev/null +++ b/app/gateways/v_gateways_copy.php @@ -0,0 +1,161 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "includes/paging.php"; +if (permission_exists('gateways_add')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//set the http get/post variable(s) to a php variable + if (isset($_REQUEST["id"])) { + $gateway_uuid = check_str($_REQUEST["id"]); + } + +//get the data + $sql = ""; + $sql .= "select * from v_gateways "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and gateway_uuid = '$gateway_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $gateway = $row["gateway"]; + $username = $row["username"]; + $password = $row["password"]; + $auth_username = $row["auth_username"]; + $realm = $row["realm"]; + $from_user = $row["from_user"]; + $from_domain = $row["from_domain"]; + $proxy = $row["proxy"]; + $register_proxy = $row["register_proxy"]; + $outbound_proxy = $row["outbound_proxy"]; + $expire_seconds = $row["expire_seconds"]; + $register = $row["register"]; + $register_transport = $row["register_transport"]; + $retry_seconds = $row["retry_seconds"]; + $extension = $row["extension"]; + $ping = $row["ping"]; + $caller_id_in_from = $row["caller_id_in_from"]; + $supress_cng = $row["supress_cng"]; + $extension_in_contact = $row["extension_in_contact"]; + $effective_caller_id_name = $row["effective_caller_id_name"]; + $effective_caller_id_number = $row["effective_caller_id_number"]; + $outbound_caller_id_name = $row["outbound_caller_id_name"]; + $outbound_caller_id_number = $row["outbound_caller_id_number"]; + $context = $row["context"]; + $enabled = $row["enabled"]; + $description = 'copy: '.$row["description"]; + break; //limit to 1 row + } + unset ($prep_statement); + +//copy the gateways + $gateway_uuid = uuid(); + $sql = "insert into v_gateways "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "gateway_uuid, "; + $sql .= "gateway, "; + $sql .= "username, "; + $sql .= "password, "; + $sql .= "auth_username, "; + $sql .= "realm, "; + $sql .= "from_user, "; + $sql .= "from_domain, "; + $sql .= "proxy, "; + $sql .= "register_proxy, "; + $sql .= "outbound_proxy, "; + $sql .= "expire_seconds, "; + $sql .= "register, "; + $sql .= "register_transport, "; + $sql .= "retry_seconds, "; + $sql .= "extension, "; + $sql .= "ping, "; + $sql .= "caller_id_in_from, "; + $sql .= "supress_cng, "; + $sql .= "extension_in_contact, "; + $sql .= "effective_caller_id_name, "; + $sql .= "effective_caller_id_number, "; + $sql .= "outbound_caller_id_name, "; + $sql .= "outbound_caller_id_number, "; + $sql .= "context, "; + $sql .= "enabled, "; + $sql .= "description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$gateway_uuid', "; + $sql .= "'$gateway', "; + $sql .= "'$username', "; + $sql .= "'$password', "; + $sql .= "'$auth_username', "; + $sql .= "'$realm', "; + $sql .= "'$from_user', "; + $sql .= "'$from_domain', "; + $sql .= "'$proxy', "; + $sql .= "'$register_proxy', "; + $sql .= "'$outbound_proxy', "; + $sql .= "'$expire_seconds', "; + $sql .= "'$register', "; + $sql .= "'$register_transport', "; + $sql .= "'$retry_seconds', "; + $sql .= "'$extension', "; + $sql .= "'$ping', "; + $sql .= "'$caller_id_in_from', "; + $sql .= "'$supress_cng', "; + $sql .= "'$extension_in_contact', "; + $sql .= "'$effective_caller_id_name', "; + $sql .= "'$effective_caller_id_number', "; + $sql .= "'$outbound_caller_id_name', "; + $sql .= "'$outbound_caller_id_number', "; + $sql .= "'$context', "; + $sql .= "'$enabled', "; + $sql .= "'$description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + +//synchronize the xml config + save_gateway_xml(); + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Copy Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/gateways/v_gateways_delete.php b/app/gateways/v_gateways_delete.php new file mode 100644 index 0000000000..9c965156cf --- /dev/null +++ b/app/gateways/v_gateways_delete.php @@ -0,0 +1,122 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('gateways_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (strlen($_GET["id"])>0) { + //set the variable + $id = $_GET["id"]; + + //get the gateway name + $sql = ""; + $sql .= "select * from v_gateways "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and gateway_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $gateway = $row["gateway"]; + $profile = $row["profile"]; + break; //limit to 1 row + } + unset ($prep_statement); + + //delete the xml file + if (count($_SESSION["domains"]) > 1) { + $gateway_xml_file = $_SESSION['switch']['gateways']['dir']."/".$profile."/v_".$_SESSION['domain_name'].'-'.$gateway.".xml"; + } + else { + $gateway_xml_file = $_SESSION['switch']['gateways']['dir']."/".$profile."/v_".$gateway.".xml"; + } + unlink($gateway_xml_file); + + //create the event socket connection and stop the gateway + if (!$fp) { + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + } + if ($fp) { + //send the api gateway stop command over event socket + if (count($_SESSION["domains"]) > 1) { + $tmp_cmd = 'api sofia profile '.$profile.' killgw '.$_SESSION['domain_name'].'-'.$gateway; + } + else { + $tmp_cmd = 'api sofia profile '.$profile.' killgw '.$gateway; + } + $response = event_socket_request($fp, $tmp_cmd); + unset($tmp_cmd); + } + + //delete gateway + $sql = "delete from v_gateways "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and gateway_uuid = '$id' "; + $db->query($sql); + unset($sql); + + //syncrhonize configuration + save_gateway_xml(); + + //synchronize the xml config + save_dialplan_xml(); + + //rescan the sip profile to look for new or stopped gateways + //create the event socket connection and send a command + if (!$fp) { + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + } + if ($fp) { + //send the api commandover event socket + $tmp_cmd = 'api sofia profile '.$profile.' rescan'; + $response = event_socket_request($fp, $tmp_cmd); + unset($tmp_cmd); + //close the connection + fclose($fp); + } + usleep(1000); + + //clear the apply settings reminder + $_SESSION["reload_xml"] = false; +} + +//redirect the users + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/gateways/v_gateways_edit.php b/app/gateways/v_gateways_edit.php new file mode 100644 index 0000000000..70893d3a38 --- /dev/null +++ b/app/gateways/v_gateways_edit.php @@ -0,0 +1,797 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('gateways_add') || permission_exists('gateways_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//add or update the database + if (isset($_REQUEST["id"])) { + $action = "update"; + $gateway_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get the http values and set them as php variables + if (count($_POST)>0) { + //$domain_uuid = check_str($_POST["domain_uuid"]); + $gateway = check_str($_POST["gateway"]); + $username = check_str($_POST["username"]); + $password = check_str($_POST["password"]); + $distinct_to = check_str($_POST["distinct_to"]); + $auth_username = check_str($_POST["auth_username"]); + $realm = check_str($_POST["realm"]); + $from_user = check_str($_POST["from_user"]); + $from_domain = check_str($_POST["from_domain"]); + $proxy = check_str($_POST["proxy"]); + $register_proxy = check_str($_POST["register_proxy"]); + $outbound_proxy = check_str($_POST["outbound_proxy"]); + $expire_seconds = check_str($_POST["expire_seconds"]); + $register = check_str($_POST["register"]); + $register_transport = check_str($_POST["register_transport"]); + $retry_seconds = check_str($_POST["retry_seconds"]); + $extension = check_str($_POST["extension"]); + $ping = check_str($_POST["ping"]); + $caller_id_in_from = check_str($_POST["caller_id_in_from"]); + $supress_cng = check_str($_POST["supress_cng"]); + $sip_cid_type = check_str($_POST["sip_cid_type"]); + $extension_in_contact = check_str($_POST["extension_in_contact"]); + $context = check_str($_POST["context"]); + $profile = check_str($_POST["profile"]); + $enabled = check_str($_POST["enabled"]); + $description = check_str($_POST["description"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $gateway_uuid = check_str($_POST["gateway_uuid"]); + } + + //check for all required data + //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + if (strlen($gateway) == 0) { $msg .= "Please provide: Gateway
\n"; } + if ($register == "true") { + if (strlen($username) == 0) { $msg .= "Please provide: Username
\n"; } + if (strlen($password) == 0) { $msg .= "Please provide: Password
\n"; } + } + //if (strlen($distinct_to) == 0) { $msg .= "Please provide: Distinct To
\n"; } + //if (strlen($auth_username) == 0) { $msg .= "Please provide: Auth username
\n"; } + //if (strlen($realm) == 0) { $msg .= "Please provide: Realm
\n"; } + //if (strlen($from_user) == 0) { $msg .= "Please provide: From user
\n"; } + //if (strlen($from_domain) == 0) { $msg .= "Please provide: From domain
\n"; } + //if (strlen($proxy) == 0) { $msg .= "Please provide: Proxy
\n"; } + if (strlen($expire_seconds) == 0) { $msg .= "Please provide: Expire seconds
\n"; } + if (strlen($register) == 0) { $msg .= "Please provide: Register
\n"; } + //if (strlen($register_transport) == 0) { $msg .= "Please provide: Register transport
\n"; } + if (strlen($retry_seconds) == 0) { $msg .= "Please provide: Retry seconds
\n"; } + //if (strlen($extension) == 0) { $msg .= "Please provide: Extension
\n"; } + //if (strlen($ping) == 0) { $msg .= "Please provide: Ping
\n"; } + //if (strlen($caller_id_in_from) == 0) { $msg .= "Please provide: Caller ID in from
\n"; } + //if (strlen($supress_cng) == 0) { $msg .= "Please provide: Supress CNG
\n"; } + //if (strlen($sip_cid_type) == 0) { $msg .= "Please provide: SIP CID Type
\n"; } + //if (strlen($extension_in_contact) == 0) { $msg .= "Please provide: Extension in Contact
\n"; } + if (strlen($context) == 0) { $msg .= "Please provide: Context
\n"; } + //if (strlen($profile) == 0) { $msg .= "Please provide: Profile
\n"; } + if (strlen($enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } + //if (strlen($description) == 0) { $msg .= "Please provide: Gateway Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //remove the invalid characters from the gateway name + $gateway = str_replace(" ", "_", $gateway); + $gateway = str_replace("/", "", $gateway); + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('gateways_add')) { + $gateway_uuid = uuid(); + $sql = "insert into v_gateways "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "gateway_uuid, "; + $sql .= "gateway, "; + $sql .= "username, "; + $sql .= "password, "; + $sql .= "distinct_to, "; + $sql .= "auth_username, "; + $sql .= "realm, "; + $sql .= "from_user, "; + $sql .= "from_domain, "; + $sql .= "proxy, "; + $sql .= "register_proxy, "; + $sql .= "outbound_proxy, "; + $sql .= "expire_seconds, "; + $sql .= "register, "; + $sql .= "register_transport, "; + $sql .= "retry_seconds, "; + $sql .= "extension, "; + $sql .= "ping, "; + $sql .= "caller_id_in_from, "; + $sql .= "supress_cng, "; + $sql .= "sip_cid_type, "; + $sql .= "extension_in_contact, "; + $sql .= "context, "; + $sql .= "profile, "; + $sql .= "enabled, "; + $sql .= "description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$gateway_uuid', "; + $sql .= "'$gateway', "; + $sql .= "'$username', "; + $sql .= "'$password', "; + $sql .= "'$distinct_to', "; + $sql .= "'$auth_username', "; + $sql .= "'$realm', "; + $sql .= "'$from_user', "; + $sql .= "'$from_domain', "; + $sql .= "'$proxy', "; + $sql .= "'$register_proxy', "; + $sql .= "'$outbound_proxy', "; + $sql .= "'$expire_seconds', "; + $sql .= "'$register', "; + $sql .= "'$register_transport', "; + $sql .= "'$retry_seconds', "; + $sql .= "'$extension', "; + $sql .= "'$ping', "; + $sql .= "'$caller_id_in_from', "; + $sql .= "'$supress_cng', "; + $sql .= "'$sip_cid_type', "; + $sql .= "'$extension_in_contact', "; + $sql .= "'$context', "; + $sql .= "'$profile', "; + $sql .= "'$enabled', "; + $sql .= "'$description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //syncrhonize configuration + save_gateway_xml(); + + } //if ($action == "add") + + if ($action == "update" && permission_exists('gateways_edit')) { + $sql = "update v_gateways set "; + //$sql .= "domain_uuid = '$domain_uuid', "; + $sql .= "gateway = '$gateway', "; + $sql .= "username = '$username', "; + $sql .= "password = '$password', "; + $sql .= "distinct_to = '$distinct_to', "; + $sql .= "auth_username = '$auth_username', "; + $sql .= "realm = '$realm', "; + $sql .= "from_user = '$from_user', "; + $sql .= "from_domain = '$from_domain', "; + $sql .= "proxy = '$proxy', "; + $sql .= "register_proxy = '$register_proxy', "; + $sql .= "outbound_proxy = '$outbound_proxy', "; + $sql .= "expire_seconds = '$expire_seconds', "; + $sql .= "register = '$register', "; + $sql .= "register_transport = '$register_transport', "; + $sql .= "retry_seconds = '$retry_seconds', "; + $sql .= "extension = '$extension', "; + $sql .= "ping = '$ping', "; + $sql .= "caller_id_in_from = '$caller_id_in_from', "; + $sql .= "supress_cng = '$supress_cng', "; + $sql .= "sip_cid_type = '$sip_cid_type', "; + $sql .= "extension_in_contact = '$extension_in_contact', "; + $sql .= "context = '$context', "; + $sql .= "profile = '$profile', "; + $sql .= "enabled = '$enabled', "; + $sql .= "description = '$description' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and gateway_uuid = '$gateway_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + //syncrhonize configuration + save_gateway_xml(); + + //synchronize the xml config + save_dialplan_xml(); + + } //if ($action == "update") + + //rescan the external profile to look for new or stopped gateways + //create the event socket connection + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + $tmp_cmd = 'api sofia profile external rescan'; + $response = event_socket_request($fp, $tmp_cmd); + unset($tmp_cmd); + usleep(1000); + //close the connection + fclose($fp); + //clear the apply settings reminder + $_SESSION["reload_xml"] = false; + } //if ($_POST["persistformvar"] != "true") + + //redirect the user + if (isset($action)) { + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + if ($action == "add") { + echo "Add Complete\n"; + } + if ($action == "update") { + echo "Edit Complete\n"; + } + echo "
\n"; + require_once "includes/footer.php"; + return; + } +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $gateway_uuid = $_GET["id"]; + $sql = "select * from v_gateways "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and gateway_uuid = '$gateway_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $domain_uuid = $row["domain_uuid"]; + $gateway = $row["gateway"]; + $username = $row["username"]; + $password = $row["password"]; + $distinct_to = $row["distinct_to"]; + $auth_username = $row["auth_username"]; + $realm = $row["realm"]; + $from_user = $row["from_user"]; + $from_domain = $row["from_domain"]; + $proxy = $row["proxy"]; + $register_proxy = $row["register_proxy"]; + $outbound_proxy = $row["outbound_proxy"]; + $expire_seconds = $row["expire_seconds"]; + $register = $row["register"]; + $register_transport = $row["register_transport"]; + $retry_seconds = $row["retry_seconds"]; + $extension = $row["extension"]; + $ping = $row["ping"]; + $caller_id_in_from = $row["caller_id_in_from"]; + $supress_cng = $row["supress_cng"]; + $sip_cid_type = $row["sip_cid_type"]; + $extension_in_contact = $row["extension_in_contact"]; + $context = $row["context"]; + $profile = $row["profile"]; + $enabled = $row["enabled"]; + $description = $row["description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo ""; + + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + //--- begin: show_advanced ----------------------- + echo "\n"; + echo "\n"; + echo "\n"; + //--- end: show_advanced ----------------------- + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
\n"; + + echo "\n"; + echo " \n"; + echo " "; + echo " \n"; + echo " "; + echo " "; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " Gateway Edit
\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " Defines a connections to a SIP Provider or another SIP server.
\n"; + echo "
\n"; + echo "
\n"; + + echo "
\n"; + echo " Gateway:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the gateway name here.\n"; + echo "
\n"; + echo " Username:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the username here.\n"; + echo "
\n"; + echo " Password:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the password here. \n"; + echo "
\n"; + echo " From user:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the from-user here.\n"; + echo "
\n"; + echo " From domain:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the from-domain here.\n"; + echo "
\n"; + echo " Proxy:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the domain or IP address of the proxy.\n"; + echo "
\n"; + echo " Realm:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the realm here.\n"; + echo "
\n"; + echo " Expire seconds:\n"; + echo "\n"; + if (strlen($expire_seconds) == 0) { $expire_seconds = "800"; } + echo " \n"; + echo "
\n"; + echo "Enter the expire-seconds here.\n"; + echo "
\n"; + echo " Register:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Choose whether to register. \n"; + echo "
\n"; + echo " Retry seconds:\n"; + echo "\n"; + if (strlen($retry_seconds) == 0) { $retry_seconds = "60"; } + echo " \n"; + echo "
\n"; + echo "Enter the retry-seconds here.\n"; + echo "
\n"; + + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Show Advanced\n"; + echo " \n"; + echo "
\n"; + echo "
\n"; + + echo "
\n"; + echo " \n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo " Distinct To:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the distinct_to here.\n"; + echo "
\n"; + echo " Auth username:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the auth-username here.\n"; + echo "
\n"; + echo " Extension:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the extension here.\n"; + echo "
\n"; + echo " Register transport:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Choose whether to register-transport. \n"; + echo "
\n"; + echo " Register Proxy:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the register proxy here.\n"; + echo "
\n"; + echo " Outbound Proxy:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the outbound proxy here.\n"; + echo "
\n"; + echo " Caller ID in from:\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "Enter the caller-id-in-from.\n"; + echo "
\n"; + echo " Supress CNG:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the supress-cng.\n"; + echo "
\n"; + echo " SIP CID Type:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the sip_cid_type: none, pid, and rpid.\n"; + echo "
\n"; + echo " Extension in Contact:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the extension_in_contact.\n"; + echo "
\n"; + echo " Ping:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the ping interval here in seconds.\n"; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo " Context:\n"; + echo "\n"; + if (strlen($context) == 0) { $context = "public"; } + echo " \n"; + echo "
\n"; + echo "Enter the context here.\n"; + echo "
\n"; + echo " Profile:\n"; + echo "\n"; + if (strlen($profile) == 0) { $profile = "external"; } + echo " \n"; + echo "
\n"; + echo "Enter the profile here.\n"; + echo "
\n"; + echo " Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Gateway Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the description of the gateway here.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//show footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/grammar_edit/app_config.php b/app/grammar_edit/app_config.php new file mode 100644 index 0000000000..4649825910 --- /dev/null +++ b/app/grammar_edit/app_config.php @@ -0,0 +1,28 @@ + \ No newline at end of file diff --git a/app/grammar_edit/clipadd.php b/app/grammar_edit/clipadd.php new file mode 100644 index 0000000000..044f922b9b --- /dev/null +++ b/app/grammar_edit/clipadd.php @@ -0,0 +1,126 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('grammar_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_POST)>0) { + $clip_name = check_str($_POST["clip_name"]); + $clip_folder = check_str($_POST["clip_folder"]); + $clip_text_start = check_str($_POST["clip_text_start"]); + $clip_text_end = check_str($_POST["clip_text_end"]); + $clip_desc = check_str($_POST["clip_desc"]); + $clip_order = check_str($_POST["clip_order"]); + if (strlen($clip_order) == 0) { $clip_order = 0; } + + $sql = "insert into v_clips "; + $sql .= "("; + $sql .= "clip_uuid, "; + $sql .= "clip_name, "; + $sql .= "clip_folder, "; + $sql .= "clip_text_start, "; + $sql .= "clip_text_end, "; + $sql .= "clip_desc, "; + $sql .= "clip_order "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$clip_name', "; + $sql .= "'$clip_folder', "; + $sql .= "'$clip_text_start', "; + $sql .= "'$clip_text_end', "; + $sql .= "'$clip_desc', "; + $sql .= "'$clip_order' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql,$db); + + require_once "header.php"; + echo "\n"; + echo "Add Complete"; + require_once "footer.php"; + return; +} + +//show the content + require_once "header.php"; + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + + //echo "Clip Library"; + //echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo "
Name:
Folder:
Before Selection:
"; + echo " "; + echo "
After Selection:
"; + echo " "; + echo "
Notes:
"; + echo " "; + echo "
"; + echo "
"; + + echo "
"; + echo "
"; + + require_once "footer.php"; +?> \ No newline at end of file diff --git a/app/grammar_edit/clipdelete.php b/app/grammar_edit/clipdelete.php new file mode 100644 index 0000000000..63951df09a --- /dev/null +++ b/app/grammar_edit/clipdelete.php @@ -0,0 +1,56 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('grammar_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the uuid from http values + $clip_uuid = check_str($_GET["id"]); + +//delete the clip + if (strlen($_GET["id"])>0) { + $sql = "delete from v_clips "; + $sql .= "where clip_uuid = '".$clip_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql,$db); + } + +//redirect the browser + require_once "header.php"; + echo "\n"; + echo "Delete Complete"; + require_once "footer.php"; + return; + +?> diff --git a/app/grammar_edit/cliplist.php b/app/grammar_edit/cliplist.php new file mode 100644 index 0000000000..2f7c8d97f5 --- /dev/null +++ b/app/grammar_edit/cliplist.php @@ -0,0 +1,235 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "includes/checkauth.php"; +if (permission_exists('grammar_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +//require_once "edit/header.php"; + +echo ""; +echo ""; +echo ""; + +function isfile($filename) { + if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function space($count) { + $r=''; $i=0; + while($i < $count) { + $r .= ' '; + $i++; + } + return $r; +} + +echo ""; + +echo ""; + +echo ""; +echo ""; +echo "
"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
Clip Library
\n"; //display:none + +$sql = "select * from v_clips "; +$sql .= "order by clip_folder "; +$prep_statement = $db->prepare(check_sql($sql)); +$prep_statement->execute(); +$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); +$result_count = count($result); + +if ($result_count > 0) { //no results + $last_folder = ''; + $tag_open = ''; + $x = 0; + $current_depth = 0; + $previous_depth = 0; + foreach($result as $row) { + $current_depth = count(explode ("/", $row['clip_folder'])); + if ($current_depth < $previous_depth) { + $count = ($previous_depth - $current_depth); + $i=0; + while($i < $count){ + echo "
\n"; + $i++; + } + echo "
\n"; + } + + if ($last_folder != $row['clip_folder']) { + $clip_folder_name = str_replace ($previous_folder_name, "", $row['clip_folder']); + $clip_folder_name = str_replace ("/", "", $clip_folder_name); + echo "
 ".$clip_folder_name."  
\n\n"; + $tag_open = 1; + } + + $previous_depth = $current_depth; + $previous_folder_name = $row['clip_folder']; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "".$row['clip_name']."\n"; + echo "
\n"; + echo "\n\n"; + + $last_folder = $row['clip_folder']; + + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + +} //end if results + +echo "\n"; +echo "
\n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo "
"; + +echo "

"; +//require_once "includes/footer.php"; + +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); + +echo ""; +echo ""; + +?> diff --git a/app/grammar_edit/clipoptions.php b/app/grammar_edit/clipoptions.php new file mode 100644 index 0000000000..8be0d61402 --- /dev/null +++ b/app/grammar_edit/clipoptions.php @@ -0,0 +1,71 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('grammar_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "header.php"; + +echo "
"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Selected Clip:
"; +echo " "; +echo ""; + +echo " "; +//echo " \n"; +//echo " \n"; +//echo " \n"; + +echo " \n"; +echo " \n"; +//echo " \n"; +echo " \n"; +echo " \n"; + +echo " \n"; +echo "
Options











"; + +echo "
"; +echo "
"; + +require_once "footer.php"; +?> diff --git a/app/grammar_edit/clipoptionslist.php b/app/grammar_edit/clipoptionslist.php new file mode 100644 index 0000000000..5a5dc5b127 --- /dev/null +++ b/app/grammar_edit/clipoptionslist.php @@ -0,0 +1,228 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('grammar_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +echo ""; +echo ""; + +echo ""; + +function isfile($filename) { + if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function space($count) { + $r=''; $i=0; + while($i < $count) { + $r .= ' '; + $i++; + } + return $r; +} + +//show the content + echo ""; + + echo ""; + +echo ""; +echo ""; + + echo "
"; + echo "\n"; + + echo "\n"; + echo "
\n"; + echo "
Clip Library
\n"; //display:none + + $sql = "select * from v_clips "; + $sql .= "order by clip_folder "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + if ($result_count > 0) { //no results + $last_folder = ''; + $tag_open = ''; + $x = 0; + $current_depth = 0; + $previous_depth = 0; + foreach($result as $row) { + $current_depth = count(explode("/", $row[clip_folder])); + if ($current_depth < $previous_depth) { + $count = ($previous_depth - $current_depth); + $i=0; + while($i < $count){ + echo "
\n"; + $i++; + } + echo "
\n"; + + } + + if ($last_folder != $row['clip_folder']) { + $clip_folder_name = str_replace ($previous_folder_name, "", $row['clip_folder']); + $clip_folder_name = str_replace ("/", "", $clip_folder_name); + echo "
 ".$clip_folder_name."  
\n\n"; + $tag_open = 1; + } + + $previous_depth = $current_depth; + $previous_folder_name = $row['clip_folder']; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "".$row['clip_name']."\n"; + + echo "
\n"; + echo "\n\n"; + + $last_folder = $row['clip_folder']; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
"; + + echo "

"; + + unset ($result_count); + unset ($result); + unset ($key); + unset ($val); + unset ($c); + + echo ""; + echo ""; + +?> diff --git a/app/grammar_edit/clipsearch.php b/app/grammar_edit/clipsearch.php new file mode 100644 index 0000000000..cf19239107 --- /dev/null +++ b/app/grammar_edit/clipsearch.php @@ -0,0 +1,180 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/checkauth.php"; +if (permission_exists('grammar_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_POST)>0) { + $clip_uuid = $_POST["id"]; + $clip_name = $_POST["clip_name"]; + $clip_folder = $_POST["clip_folder"]; + $clip_text_start = $_POST["clip_text_start"]; + $clip_text_end = $_POST["clip_text_end"]; + $clip_desc = $_POST["clip_desc"]; + $clip_order = $_POST["clip_order"]; + + require_once "header.php"; + echo "
"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + + } //end if results + + echo "
\n"; + echo "
"; + + $sql .= "select * from v_clips "; + $sql .= "where "; + if (strlen($clip_uuid) > 0) { $sql .= "and id = '$clip_uuid' "; } + if (strlen($clip_name) > 0) { $sql .= "and clip_name like '%$clip_name%' "; } + if (strlen($clip_folder) > 0) { $sql .= "and clip_folder like '%$clip_folder%' "; } + if (strlen($clip_text_start) > 0) { $sql .= "and clip_text_start like '%$clip_text_start%' "; } + if (strlen($clip_text_end) > 0) { $sql .= "and clip_text_end like '%$clip_text_end%' "; } + if (strlen($clip_desc) > 0) { $sql .= "and clip_desc like '%$clip_desc%' "; } + if (strlen($clip_order) > 0) { $sql .= "and clip_order like '%$clip_order%' "; } + + $sql = trim($sql); + if (substr($sql, -5) == "where"){ $sql = substr($sql, 0, (strlen($sql)-5)); } + $sql = str_replace ("where and", "where", $sql); + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + $c = 0; + $row_style["0"] = "background-color: #F5F5DC;"; + $row_style["1"] = "background-color: #FFFFFF;"; + + echo "
\n"; + echo "\n"; + echo ""; + + if ($result_count == 0) { + //no results + echo ""; + } + else { //received results + echo ""; + //echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + echo "\n"; + + foreach($result as $row) { + //print_r( $row ); + echo "\n"; + //echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach unset($sql, $result, $row_count); + echo "
 
    Id        clip_name Search         clip_folder        clip_text_start        clip_text_end        clip_desc        clip_order   
".$row[id]."".$row[clip_name]."".$row[clip_folder]."".$row[clip_text_start]."".$row[clip_text_end]."".$row[clip_desc]."".$row[clip_order]."
\n"; + echo "
\n"; + + echo "

"; + echo "
\n"; + echo "
"; + echo "

"; + require_once "footer.php"; + + unset ($result_count); + unset ($result); + unset ($key); + unset ($val); + unset ($c); + +} +else { + + //show the content + require_once "header.php"; + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + echo " "; + echo " "; + echo " "; + echo "
Name:
Folder:
Start:
End:
Desc:
clip_order:
"; + echo "
"; + + echo "
"; + echo "
"; + + require_once "footer.php"; + +} //end if not post +?> diff --git a/app/grammar_edit/clipupdate.php b/app/grammar_edit/clipupdate.php new file mode 100644 index 0000000000..c69ca0af1c --- /dev/null +++ b/app/grammar_edit/clipupdate.php @@ -0,0 +1,138 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('grammar_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_POST)>0) { + $clip_uuid = check_str($_POST["id"]); + $clip_name = check_str($_POST["clip_name"]); + $clip_folder = check_str($_POST["clip_folder"]); + $clip_text_start = check_str($_POST["clip_text_start"]); + $clip_text_end = check_str($_POST["clip_text_end"]); + $clip_desc = check_str($_POST["clip_desc"]); + $clip_order = check_str($_POST["clip_order"]); + + //sql update + $sql = "update v_clips set "; + $sql .= "clip_name = '$clip_name', "; + $sql .= "clip_folder = '$clip_folder', "; + $sql .= "clip_text_start = '$clip_text_start', "; + $sql .= "clip_text_end = '$clip_text_end', "; + $sql .= "clip_desc = '$clip_desc', "; + $sql .= "clip_order = '$clip_order' "; + $sql .= "where clip_uuid = '$clip_uuid' "; + $count = $db->exec(check_sql($sql)); + //echo "affected rows: ".$count; + + //redirect the browser + require_once "header.php"; + echo "\n"; + echo "Update Complete"; + require_once "footer.php"; + return; +} +else { + //get the uuid from http values + $clip_uuid = check_str($_GET["id"]); + + //get the clip + $sql = "select * from v_clips "; + $sql .= "where clip_uuid = '$clip_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $clip_name = $row["clip_name"]; + $clip_folder = $row["clip_folder"]; + $clip_text_start = $row["clip_text_start"]; + $clip_text_end = $row["clip_text_end"]; + $clip_desc = $row["clip_desc"]; + $clip_order = $row["clip_order"]; + break; //limit to 1 row + } +} + +//show the content + require_once "header.php"; + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
Name:
Folder:
Before Selection:
"; + echo " "; + echo "
After Selection:
"; + echo " "; + echo "
Notes:
"; + echo " "; + echo "
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + + echo "
"; + echo "
"; + + require_once "footer.php"; +?> diff --git a/app/grammar_edit/filedelete.php b/app/grammar_edit/filedelete.php new file mode 100644 index 0000000000..1f6522c8b5 --- /dev/null +++ b/app/grammar_edit/filedelete.php @@ -0,0 +1,84 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('grammar_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +$folder = str_replace ("\\", "/", $folder); +if (substr($folder, -1) != "/") { $folder = $folder.'/'; } +$file = $_GET["file"]; + +if (strlen($folder) > 0 && strlen($file) > 0) { + unlink($folder.$file); + header("Location: fileoptions.php"); +} +else { + //display form + require_once "header.php"; + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Path:
".$folder.$file."
"; + + echo "
"; + + echo ""; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
File Name:
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + + require_once "footer.php"; +} +?> diff --git a/app/grammar_edit/filelist.php b/app/grammar_edit/filelist.php new file mode 100644 index 0000000000..546d762ac2 --- /dev/null +++ b/app/grammar_edit/filelist.php @@ -0,0 +1,252 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('grammar_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "header.php"; + +function isfile($filename) { + //if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function space($count) { + $r=''; $i=0; + while($i < $count) { + $r .= ' '; + $i++; + } + return $r; +} + +function recur_dir($dir) { + clearstatcache(); + $htmldirlist = ''; + $htmlfilelist = ''; + $dirlist = opendir($dir); + $dir_array = array(); + while (false !== ($file = readdir($dirlist))) { + if ($file != "." AND $file != ".."){ + $newpath = $dir.'/'.$file; + $level = explode('/',$newpath); + if (substr($newpath, -4) == ".svn") { + //ignore .svn dir and subdir + } + elseif (substr($newpath, -3) == ".db") { + //ignore .db files + } + else { + $dir_array[] = $newpath; + } + if ($x > 1000) { break; }; + $x++; + } + } + + asort($dir_array); + foreach ($dir_array as $newpath){ + $level = explode('/',$newpath); + + if (is_dir($newpath)) { + /*$mod_array[] = array( + 'level'=>count($level)-1, + 'path'=>$newpath, + 'name'=>end($level), + 'type'=>'dir', + 'mod_time'=>filemtime($newpath), + 'size'=>''); + $mod_array[] = recur_dir($newpath); + */ + $dirname = end($level); + $htmldirlist .= space(count($level))."
$dirname
\n"; + //$htmldirlist .= space(count($level))."
Tools
\n"; + //$htmldirlist .= space(count($level))."
New Folder
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
New File
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
Options
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + $htmldirlist .= recur_dir($newpath); + $htmldirlist .= space(count($level))."
\n"; + } + else { + /*$mod_array[] = array( + 'level'=>count($level)-1, + 'path'=>$newpath, + 'name'=>end($level), + 'type'=>'file', + 'mod_time'=>filemtime($newpath), + 'size'=>filesize($newpath)); + */ + $filename = end($level); + $filesize = round(filesize($newpath)/1024, 2); + $htmlfilelist .= space(count($level))."
$filename
\n"; + $htmlfilelist .= space(count($level))."
\n"; + } + } + closedir($dirlist); + return $htmldirlist ."\n". $htmlfilelist; +} + +echo ""; + + +echo ""; + +echo "
"; +echo "\n"; +echo "\n"; +echo " \n"; + echo "\n"; + echo "
\n"; +//echo "
"; + +echo "\n"; +echo " \n"; +echo "\n"; +echo "
Files
\n"; //display:none +//echo "
Files
\n"; //display:none +echo recur_dir($_SESSION['switch']['grammar']['dir']); +echo "
\n"; + +echo "
\n"; +echo ""; + +echo "

"; +require_once "footer.php"; + +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); + +echo ""; +echo ""; + +?> diff --git a/app/grammar_edit/filenew.php b/app/grammar_edit/filenew.php new file mode 100644 index 0000000000..63ced8c921 --- /dev/null +++ b/app/grammar_edit/filenew.php @@ -0,0 +1,88 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('grammar_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +$folder = str_replace ("\\", "/", $folder); +if (substr($folder, -1) != "/") { $folder = $folder.'/'; } +$file = $_GET["file"]; + +if (strlen($folder) > 0 && strlen($file) > 0) { + //create new file + $handle = fopen($folder.$file, 'wb') or die("Error!!"); + $content = ""; + fwrite($handle, $content); + fclose($handle); + header("Location: fileoptions.php"); +} +else { + require_once "header.php"; + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Path:
".$folder.$file."
"; + + echo "
"; + + echo ""; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
File Name:
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + + require_once "footer.php"; +} + +?> diff --git a/app/grammar_edit/fileoptions.php b/app/grammar_edit/fileoptions.php new file mode 100644 index 0000000000..6780000b20 --- /dev/null +++ b/app/grammar_edit/fileoptions.php @@ -0,0 +1,85 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('grammar_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "header.php"; + +$file = $_GET["file"]; +$file = str_replace ("\\", "/", $file); +$folder = $_GET["folder"]; +$folder = str_replace ($file, "", $folder); +$urlpath = str_replace ($_SERVER["DOCUMENT_ROOT"], "", $folder); + +echo "
"; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
"; + +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "
Path:
File:
"; + +echo "
"; +echo " "; +echo ""; + +echo "
"; +echo ""; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "





"; +echo "
"; + +echo "
"; +echo "
"; + +require_once "footer.php"; +?> diff --git a/app/grammar_edit/fileoptionslist.php b/app/grammar_edit/fileoptionslist.php new file mode 100644 index 0000000000..27a7420c65 --- /dev/null +++ b/app/grammar_edit/fileoptionslist.php @@ -0,0 +1,246 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('grammar_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "header.php"; + +function isfile($filename) { + if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function space($count) { + $r=''; $i=0; + while($i < $count) { + $r .= ' '; + $i++; + } + return $r; +} + +function recur_dir($dir) { + clearstatcache(); + $htmldirlist = ''; + $htmlfilelist = ''; + $dirlist = opendir($dir); + while ($file = readdir ($dirlist)) { + if ($file != '.' && $file != '..') { + $newpath = $dir.'/'.$file; + $level = explode('/',$newpath); + + if (is_dir($newpath)) { + /*$mod_array[] = array( + 'level'=>count($level)-1, + 'path'=>$newpath, + 'name'=>end($level), + 'type'=>'dir', + 'mod_time'=>filemtime($newpath), + 'size'=>''); + $mod_array[] = recur_dir($newpath); + */ + $dirname = end($level); + $htmldirlist .= space(count($level))."
$dirname
\n"; + //$htmldirlist .= space(count($level))."
Tools
\n"; + //$htmldirlist .= space(count($level))."
New Folder
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
New File
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
Options
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + $htmldirlist .= recur_dir($newpath); + $htmldirlist .= space(count($level))."
\n"; + } + else { + /*$mod_array[] = array( + 'level'=>count($level)-1, + 'path'=>$newpath, + 'name'=>end($level), + 'type'=>'file', + 'mod_time'=>filemtime($newpath), + 'size'=>filesize($newpath)); + */ + $filename = end($level); + $filesize = round(filesize($newpath)/1024, 2); + $newpath = str_replace ($filename, "", $newpath); + $htmlfilelist .= space(count($level))."
$filename
\n"; + $htmlfilelist .= space(count($level))."
\n"; + } + } + } + + closedir($dirlist); + return $htmldirlist ."\n". $htmlfilelist; +} + +echo "\n"; + +echo "\n"; + +echo "
"; +echo "\n"; + +echo "\n"; +echo "
\n"; +echo "\n"; +echo " \n"; +echo "\n"; +echo "
Files
\n"; //display:none +//echo "
Files
\n"; //display:none + +//echo "
Tools
\n"; +//echo "
New Folder
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' +//echo "
\n"; +//echo "
New File
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' +//echo "
\n"; +//echo "
\n"; + +echo recur_dir($_SESSION['switch']['grammar']['dir']); + +echo "
\n"; + + +echo "
\n"; +echo ""; + +echo "

"; +require_once "footer.php"; + +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); + +echo ""; +echo ""; + +?> \ No newline at end of file diff --git a/app/grammar_edit/fileread.php b/app/grammar_edit/fileread.php new file mode 100644 index 0000000000..273bda234c --- /dev/null +++ b/app/grammar_edit/fileread.php @@ -0,0 +1,49 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('grammar_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$filename = $_POST["file"]; +$filename = str_replace ("\\", "/", $filename); + +$handle = fopen($filename, "r"); +if ($handle) { + while (!feof($handle)) { + $buffer = fgets($handle, 4096); + echo $buffer; + } + fclose($handle); +} + +?> diff --git a/app/grammar_edit/filerename.php b/app/grammar_edit/filerename.php new file mode 100644 index 0000000000..e65f7eb19a --- /dev/null +++ b/app/grammar_edit/filerename.php @@ -0,0 +1,102 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('grammar_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +//$folder = str_replace ("\\", "/", $folder); +//if (substr($folder, -1) != "/") { $folder = $folder.'/'; } +$newfilename = $_GET["newfilename"]; +$filename = $_GET["filename"]; +//echo $folder.$file; + + +if (strlen($folder) > 0 && strlen($newfilename) > 0) { + //echo "new file: ".$newfilename."
"; + //echo "folder: ".$folder."
"; + //echo "orig filename: ".$filename."
";; + rename($folder.$filename, $folder.$newfilename); + header("Location: fileoptions.php"); +} +else { //display form + + require_once "header.php"; + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Path:
".$folder.$filename."

Original file name:
".$filename."
"; + + echo "
"; + + echo ""; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
Rename file to:
"; + echo " "; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + + require_once "footer.php"; + +} + +?> diff --git a/app/grammar_edit/filesave.php b/app/grammar_edit/filesave.php new file mode 100644 index 0000000000..f3ccabc8d3 --- /dev/null +++ b/app/grammar_edit/filesave.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('grammar_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$filename = $_POST["file"]; //filename with the path +$filename = str_replace ("\\", "/", $filename); +$content = $_POST["content"]; + +$handle = fopen($filename, 'wb') or die("Error!!"); +fwrite($handle, $content); +fclose($handle); + +//set the reload_xml value to true + $_SESSION["reload_xml"] = true; + +echo $content; + +?> diff --git a/app/grammar_edit/folderdelete.php b/app/grammar_edit/folderdelete.php new file mode 100644 index 0000000000..763f22bd5d --- /dev/null +++ b/app/grammar_edit/folderdelete.php @@ -0,0 +1,46 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('grammar_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +$folder = str_replace ("\\", "/", $folder); + +if (strlen($folder) > 0) { + //delete the folder + rmdir($folder); //, 0700 + header("Location: fileoptions.php"); +} + +?> \ No newline at end of file diff --git a/app/grammar_edit/foldernew.php b/app/grammar_edit/foldernew.php new file mode 100644 index 0000000000..35f2aff035 --- /dev/null +++ b/app/grammar_edit/foldernew.php @@ -0,0 +1,83 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('grammar_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +$folder = str_replace ("\\", "/", $folder); +$foldername = $_GET["foldername"]; + +if (strlen($folder) > 0 && strlen($foldername) > 0) { + //create new folder + mkdir($folder.'/'.$foldername); //, 0700 + header("Location: fileoptions.php"); +} +else { //display form + require_once "header.php"; + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Path:
".$folder."
"; + + echo "
"; + + echo ""; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
Folder Name:
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + + require_once "footer.php"; +} +?> diff --git a/app/grammar_edit/footer.php b/app/grammar_edit/footer.php new file mode 100644 index 0000000000..3e7b9037ab --- /dev/null +++ b/app/grammar_edit/footer.php @@ -0,0 +1,43 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +/* +echo "

"; +echo "
"; + +echo ""; +echo "fusionpbx "; +echo "        "; +echo "http://fusionpbx.com"; +echo "        "; +echo "Author: Mark J. Crane "; + +echo ""; +*/ +echo "
"; +echo ""; +echo ""; + +?> diff --git a/app/grammar_edit/header.php b/app/grammar_edit/header.php new file mode 100644 index 0000000000..b07b45c390 --- /dev/null +++ b/app/grammar_edit/header.php @@ -0,0 +1,83 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +echo ""; +echo ""; +echo ""; +//echo ""; +echo ""; + + +echo ""; +echo ""; +echo ""; +echo "
"; + +?> diff --git a/app/grammar_edit/images/Thumbs.db b/app/grammar_edit/images/Thumbs.db new file mode 100644 index 0000000000..46593a8c2e Binary files /dev/null and b/app/grammar_edit/images/Thumbs.db differ diff --git a/app/grammar_edit/images/file.gif b/app/grammar_edit/images/file.gif new file mode 100644 index 0000000000..a6cf9845fc Binary files /dev/null and b/app/grammar_edit/images/file.gif differ diff --git a/app/grammar_edit/images/file.png b/app/grammar_edit/images/file.png new file mode 100644 index 0000000000..33b5f5f374 Binary files /dev/null and b/app/grammar_edit/images/file.png differ diff --git a/app/grammar_edit/images/folder.gif b/app/grammar_edit/images/folder.gif new file mode 100644 index 0000000000..50ab253cc7 Binary files /dev/null and b/app/grammar_edit/images/folder.gif differ diff --git a/app/grammar_edit/images/gear.png b/app/grammar_edit/images/gear.png new file mode 100644 index 0000000000..1adf1e778f Binary files /dev/null and b/app/grammar_edit/images/gear.png differ diff --git a/app/grammar_edit/images/leaf.gif b/app/grammar_edit/images/leaf.gif new file mode 100644 index 0000000000..50ab253cc7 Binary files /dev/null and b/app/grammar_edit/images/leaf.gif differ diff --git a/app/grammar_edit/images/minus.gif b/app/grammar_edit/images/minus.gif new file mode 100644 index 0000000000..1094ab912b Binary files /dev/null and b/app/grammar_edit/images/minus.gif differ diff --git a/app/grammar_edit/images/plus.gif b/app/grammar_edit/images/plus.gif new file mode 100644 index 0000000000..fdacf8efe5 Binary files /dev/null and b/app/grammar_edit/images/plus.gif differ diff --git a/app/grammar_edit/images/program.gif b/app/grammar_edit/images/program.gif new file mode 100644 index 0000000000..dc3dfa1104 Binary files /dev/null and b/app/grammar_edit/images/program.gif differ diff --git a/app/grammar_edit/images/thumbnails/Thumbs.db b/app/grammar_edit/images/thumbnails/Thumbs.db new file mode 100644 index 0000000000..c4e4684b24 Binary files /dev/null and b/app/grammar_edit/images/thumbnails/Thumbs.db differ diff --git a/app/grammar_edit/images/thumbnails/cliplibrary.png b/app/grammar_edit/images/thumbnails/cliplibrary.png new file mode 100644 index 0000000000..bc70f332fd Binary files /dev/null and b/app/grammar_edit/images/thumbnails/cliplibrary.png differ diff --git a/app/grammar_edit/images/thumbnails/filemanagement.png b/app/grammar_edit/images/thumbnails/filemanagement.png new file mode 100644 index 0000000000..88cb7661b1 Binary files /dev/null and b/app/grammar_edit/images/thumbnails/filemanagement.png differ diff --git a/app/grammar_edit/images/thumbnails/phpeditor.png b/app/grammar_edit/images/thumbnails/phpeditor.png new file mode 100644 index 0000000000..c6f7f369bb Binary files /dev/null and b/app/grammar_edit/images/thumbnails/phpeditor.png differ diff --git a/app/grammar_edit/index.php b/app/grammar_edit/index.php new file mode 100644 index 0000000000..a440cc8a70 --- /dev/null +++ b/app/grammar_edit/index.php @@ -0,0 +1,200 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('grammar_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +echo "\n"; +echo "\n"; +echo " \n"; +echo " "; + + echo "\n"; + + echo ""; + ?> + + + + + + + + +
+ + + + \n"; + echo "\n"; + } + else { + echo "\n"; + } + ?> + +
+ + diff --git a/app/grammar_edit/list.php b/app/grammar_edit/list.php new file mode 100644 index 0000000000..aa5bb86c81 --- /dev/null +++ b/app/grammar_edit/list.php @@ -0,0 +1,107 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/checkauth.php"; +if (permission_exists('grammar_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "admin/edit/header.php"; +echo "
"; +echo "\n"; +echo "\n"; +echo " \n"; + echo "\n"; +} //end if results +echo "
\n"; +echo "
"; + +$sql = "select * from v_clips "; +$prep_statement = $db->prepare(check_sql($sql)); +$prep_statement->execute(); +$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); +$result_count = count($result); + +$c = 0; +$row_style["0"] = "background-color: #F5F5DC;"; +$row_style["1"] = "background-color: #FFFFFF;"; + +echo "
\n"; +echo "\n"; +echo ""; + +if ($result_count == 0) { //no results + echo ""; +} +else { //received results + echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + echo "\n"; + + foreach($result as $row) { + echo "\n"; + //echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach unset($sql, $result, $row_count); + echo "
 
    clip name      clip_folder        clip_text_start        clip_text_end        clip_desc        clip_order   
".$row['clip_uuid']."".$row['clip_name']."".$row[clip_folder]."".$row[clip_text_start]."".$row[clip_text_end]."".$row[clip_desc]."".$row[clip_order]."
\n"; + echo "
\n"; + + echo "
\n"; + +echo "
\n"; +echo "   \n"; +echo "   \n"; +echo "
\n"; +echo ""; + +echo "

"; +require_once "admin/edit/footer.php"; + +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); + +?> diff --git a/app/grammar_edit/readme.txt b/app/grammar_edit/readme.txt new file mode 100644 index 0000000000..cafc4144ae --- /dev/null +++ b/app/grammar_edit/readme.txt @@ -0,0 +1,7 @@ +Notes + +IFrame +http://www.quirksmode.org/js/iframe.html + +Tree View +http://www.dddekerf.dds.nl/DHTML_Treeview/DHTML_Treeview.htm \ No newline at end of file diff --git a/app/grammar_edit/root.php b/app/grammar_edit/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/grammar_edit/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/hardware_phones/app_config.php b/app/hardware_phones/app_config.php new file mode 100644 index 0000000000..363fbaafe4 --- /dev/null +++ b/app/hardware_phones/app_config.php @@ -0,0 +1,115 @@ + \ No newline at end of file diff --git a/app/hardware_phones/root.php b/app/hardware_phones/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/hardware_phones/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/hardware_phones/v_hardware_phones.php b/app/hardware_phones/v_hardware_phones.php new file mode 100644 index 0000000000..8618990478 --- /dev/null +++ b/app/hardware_phones/v_hardware_phones.php @@ -0,0 +1,162 @@ + + Copyright (C) 2008-2012 All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('phone_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + +echo "
"; +echo "
\n"; +echo "\n"; +echo " "; +echo ""; +echo "
\n"; +echo "
"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Hardware Phone List 
\n"; + +echo "Phones in this list are automatically added to the list when they contact the provisioning \n"; +echo "server or added manually by an administrator. \n"; +echo "Items in this list can be assigned from the extensions page.

\n"; +echo "
\n"; + +$sql = ""; +$sql .= " select * from v_hardware_phones "; +$sql .= " where domain_uuid = '$domain_uuid' "; +if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } +$prep_statement = $db->prepare(check_sql($sql)); +$prep_statement->execute(); +$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); +$num_rows = count($result); +unset ($prep_statement, $result, $sql); +$rows_per_page = 10; +$param = ""; +$page = $_GET['page']; +if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } +list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); +$offset = $rows_per_page * $page; + +$sql = ""; +$sql .= " select * from v_hardware_phones "; +$sql .= " where domain_uuid = '$domain_uuid' "; +if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } +$sql .= " limit $rows_per_page offset $offset "; +$prep_statement = $db->prepare(check_sql($sql)); +$prep_statement->execute(); +$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); +$result_count = count($result); +unset ($prep_statement, $sql); + +$c = 0; +$row_style["0"] = "row_style0"; +$row_style["1"] = "row_style1"; + +echo "
\n"; +echo "\n"; +echo "\n"; +echo th_order_by('phone_mac_address', 'MAC Address', $order_by, $order); +echo th_order_by('phone_template', 'Template', $order_by, $order); +echo th_order_by('phone_vendor', 'Vendor', $order_by, $order); +//echo th_order_by('phone_model', 'Model', $order_by, $order); +echo th_order_by('phone_provision_enable', 'Enabled', $order_by, $order); +echo th_order_by('phone_description', 'Description', $order_by, $order); +echo "\n"; +echo "\n"; + +if ($result_count == 0) { //no results +} +else { //received results + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); +} //end if results + +echo "\n"; +echo "\n"; +echo "\n"; + +echo "
\n"; +if (permission_exists('phone_add')) { + echo " $v_link_label_add\n"; +} +echo "
".$row[phone_mac_address]." ".$row[phone_template]." ".$row[phone_vendor]." ".$row[phone_model]." ".$row[phone_provision_enable]." ".$row[phone_description]." \n"; + if (permission_exists('phone_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('phone_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
 $paging_controls\n"; +if (permission_exists('phone_add')) { + echo " $v_link_label_add\n"; +} +echo "
\n"; +echo "
"; +echo "
"; +echo "

"; +echo "

"; + +echo "
"; +echo "
"; +echo "

"; + +require_once "includes/footer.php"; +?> diff --git a/app/hardware_phones/v_hardware_phones_delete.php b/app/hardware_phones/v_hardware_phones_delete.php new file mode 100644 index 0000000000..202290790d --- /dev/null +++ b/app/hardware_phones/v_hardware_phones_delete.php @@ -0,0 +1,64 @@ + + Copyright (C) 2008-2012 All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('phone_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); +} + +//delete the data + if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_hardware_phones "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and hardware_phone_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + } + +//write the provision files + require_once "app/provision/provision_write.php"; + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> + diff --git a/app/hardware_phones/v_hardware_phones_edit.php b/app/hardware_phones/v_hardware_phones_edit.php new file mode 100644 index 0000000000..7644e2be42 --- /dev/null +++ b/app/hardware_phones/v_hardware_phones_edit.php @@ -0,0 +1,426 @@ + + Copyright (C) 2008-2012 All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; + +//check permissions + require_once "includes/checkauth.php"; + if (permission_exists('phone_add') || permission_exists('phone_edit')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $hardware_phone_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get the http post values and set them to php variables + if (count($_POST)>0) { + $phone_mac_address = check_str($_POST["phone_mac_address"]); + $phone_mac_address = strtolower($phone_mac_address); + $phone_label = check_str($_POST["phone_label"]); + $phone_vendor = check_str($_POST["phone_vendor"]); + $phone_model = check_str($_POST["phone_model"]); + $phone_firmware_version = check_str($_POST["phone_firmware_version"]); + $phone_provision_enable = check_str($_POST["phone_provision_enable"]); + $phone_template = check_str($_POST["phone_template"]); + $phone_username = check_str($_POST["phone_username"]); + $phone_password = check_str($_POST["phone_password"]); + $phone_time_zone = check_str($_POST["phone_time_zone"]); + $phone_description = check_str($_POST["phone_description"]); + } + +//add or update the database + if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $hardware_phone_uuid = check_str($_POST["hardware_phone_uuid"]); + } + + //check for all required data + if (strlen($phone_mac_address) == 0) { $msg .= "Please provide: MAC Address
\n"; } + //if (strlen($phone_label) == 0) { $msg .= "Please provide: Label
\n"; } + //if (strlen($phone_vendor) == 0) { $msg .= "Please provide: Vendor
\n"; } + //if (strlen($phone_model) == 0) { $msg .= "Please provide: Model
\n"; } + //if (strlen($phone_firmware_version) == 0) { $msg .= "Please provide: Firmware Version
\n"; } + //if (strlen($phone_provision_enable) == 0) { $msg .= "Please provide: Enabled
\n"; } + //if (strlen($phone_template) == 0) { $msg .= "Please provide: Template
\n"; } + //if (strlen($phone_username) == 0) { $msg .= "Please provide: Username
\n"; } + //if (strlen($phone_password) == 0) { $msg .= "Please provide: Password
\n"; } + //if (strlen($phone_time_zone) == 0) { $msg .= "Please provide: Time Zone
\n"; } + //if (strlen($phone_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('phone_add')) { + //sql add + $hardware_phone_uuid = uuid(); + $sql = "insert into v_hardware_phones "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "hardware_phone_uuid, "; + $sql .= "phone_mac_address, "; + $sql .= "phone_label, "; + $sql .= "phone_vendor, "; + $sql .= "phone_model, "; + $sql .= "phone_firmware_version, "; + $sql .= "phone_provision_enable, "; + $sql .= "phone_template, "; + $sql .= "phone_username, "; + $sql .= "phone_password, "; + $sql .= "phone_time_zone, "; + $sql .= "phone_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$hardware_phone_uuid', "; + $sql .= "'$phone_mac_address', "; + $sql .= "'$phone_label', "; + $sql .= "'$phone_vendor', "; + $sql .= "'$phone_model', "; + $sql .= "'$phone_firmware_version', "; + $sql .= "'$phone_provision_enable', "; + $sql .= "'$phone_template', "; + $sql .= "'$phone_username', "; + $sql .= "'$phone_password', "; + $sql .= "'$phone_time_zone', "; + $sql .= "'$phone_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //write the provision files + require_once "app/provision/provision_write.php"; + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update" && permission_exists('phone_edit')) { + //sql update + $sql = "update v_hardware_phones set "; + $sql .= "phone_mac_address = '$phone_mac_address', "; + $sql .= "phone_label = '$phone_label', "; + $sql .= "phone_vendor = '$phone_vendor', "; + $sql .= "phone_model = '$phone_model', "; + $sql .= "phone_firmware_version = '$phone_firmware_version', "; + $sql .= "phone_provision_enable = '$phone_provision_enable', "; + $sql .= "phone_template = '$phone_template', "; + $sql .= "phone_username = '$phone_username', "; + $sql .= "phone_password = '$phone_password', "; + $sql .= "phone_time_zone = '$phone_time_zone', "; + $sql .= "phone_description = '$phone_description' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and hardware_phone_uuid = '$hardware_phone_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + //write the provision files + require_once "app/provision/provision_write.php"; + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } + } //if ($_POST["persistformvar"] != "true") + } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $hardware_phone_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_hardware_phones "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and hardware_phone_uuid = '$hardware_phone_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $phone_mac_address = $row["phone_mac_address"]; + $phone_mac_address = strtolower($phone_mac_address); + $phone_label = $row["phone_label"]; + $phone_vendor = $row["phone_vendor"]; + $phone_model = $row["phone_model"]; + $phone_firmware_version = $row["phone_firmware_version"]; + $phone_provision_enable = $row["phone_provision_enable"]; + $phone_template = $row["phone_template"]; + $phone_username = $row["phone_username"]; + $phone_password = $row["phone_password"]; + $phone_time_zone = $row["phone_time_zone"]; + $phone_description = $row["phone_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//begin the content + require_once "includes/header.php"; + + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + + echo "
\n"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + /* + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + */ + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Hardware Phone AddHardware Phone Edit
\n"; + echo "The following information is used to provision phones.

\n"; + echo "
\n"; + echo " MAC Address:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the MAC address.\n"; + echo "
\n"; + echo " Label:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the phone label.\n"; + echo "
\n"; + echo " Template:\n"; + echo "\n"; + + echo "\n"; + echo "
\n"; + echo "Select a template.\n"; + echo "
\n"; + echo " Vendor:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the vendor name.\n"; + echo "
\n"; + echo " Model:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the model number.\n"; + echo "
\n"; + echo " Firmware Version:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the firmware version.\n"; + echo "
\n"; + echo " Username:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the username.\n"; + echo "
\n"; + echo " Password:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the password.\n"; + echo "
\n"; + echo " Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enable or disable provisioning for this phone.\n"; + echo "
\n"; + echo " Time Zone:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the time zone.\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the description.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//show the footer + require_once "includes/footer.php"; +?> diff --git a/app/hunt_group/app_config.php b/app/hunt_group/app_config.php new file mode 100644 index 0000000000..0ce8eec2db --- /dev/null +++ b/app/hunt_group/app_config.php @@ -0,0 +1,263 @@ + \ No newline at end of file diff --git a/app/hunt_group/root.php b/app/hunt_group/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/hunt_group/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/hunt_group/v_hunt_group.php b/app/hunt_group/v_hunt_group.php new file mode 100644 index 0000000000..5140675e3c --- /dev/null +++ b/app/hunt_group/v_hunt_group.php @@ -0,0 +1,182 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; + +//check permissions + if (permission_exists('hunt_group_view')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +require_once "includes/header.php"; +require_once "includes/paging.php"; + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + +echo "
"; +echo "\n"; +echo "\n"; +echo " "; +echo ""; +echo "
\n"; +echo "
"; + +echo "\n"; +echo "\n"; +echo " \n"; +echo "\n"; +echo "

Hunt Group
\n"; +echo "
\n"; +echo " A Hunt Group is a list of destinations that can be called in sequence or simultaneously.\n"; +echo "

\n"; +echo "
\n"; + +//get the number of rows in v_hunt_groups +$sql = "select count(*) as num_rows from v_hunt_groups "; +$sql .= "where domain_uuid = '$domain_uuid' "; +$prep_statement = $db->prepare(check_sql($sql)); +if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } +} +unset($prep_statement, $result); + +//prepare to page the results +$rows_per_page = 150; +$param = ""; +$page = $_GET['page']; +if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } +list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); +$offset = $rows_per_page * $page; + +//get the hunt group list +$sql = "select * from v_hunt_groups "; +$sql .= "where domain_uuid = '$domain_uuid' "; +if (strlen($order_by)> 0) { + $sql .= "order by $order_by $order "; +} +else { + $sql .= "order by hunt_group_extension asc "; +} +$sql .= " limit $rows_per_page offset $offset "; +$prep_statement = $db->prepare(check_sql($sql)); +$prep_statement->execute(); +$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); +$result_count = count($result); +unset ($prep_statement, $sql); + +$c = 0; +$row_style["0"] = "row_style0"; +$row_style["1"] = "row_style1"; + +echo "
\n"; +echo "\n"; +echo "\n"; +echo th_order_by('hunt_group_extension', 'Extension', $order_by, $order); +echo th_order_by('hunt_group_name', 'Hunt Group Name', $order_by, $order); +echo th_order_by('hunt_group_name', 'Enabled', $order_by, $order); +echo th_order_by('hunt_group_description', 'Description', $order_by, $order); +echo "\n"; +echo "\n"; + +if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); +} //end if results + +echo "\n"; +echo "\n"; +echo "\n"; + +if ($v_path_show) { + echo "\n"; + echo "\n"; + echo "\n"; +} + +echo "
\n"; +if (permission_exists('hunt_group_add')) { + echo " $v_link_label_add\n"; +} +echo "
".$row['hunt_group_extension']."".$row['hunt_group_name']."".$row['hunt_group_enabled']."".$row['hunt_group_description']." \n"; + if (permission_exists('hunt_group_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('hunt_group_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
 $paging_controls\n"; +if (permission_exists('hunt_group_add')) { + echo " $v_link_label_add\n"; +} +echo "
\n"; +echo "
\n"; + echo "
\n"; + echo $_SESSION['switch']['scripts']['dir']."\n"; + echo "
"; +echo "
"; +echo "

"; +echo "

"; + +echo "
"; +echo "
"; +echo "

"; + +require_once "includes/footer.php"; +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); +?> diff --git a/app/hunt_group/v_hunt_group_call_forward.php b/app/hunt_group/v_hunt_group_call_forward.php new file mode 100644 index 0000000000..7e1dae82c1 --- /dev/null +++ b/app/hunt_group/v_hunt_group_call_forward.php @@ -0,0 +1,130 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//check permissions +if (permission_exists('hunt_group_call_forward')) { + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + + echo "
"; + echo "\n"; + echo "\n"; + echo "
\n"; + + if ($is_included != "true") { + echo "
"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Hunt Group Call Forward
\n"; + echo " Use the links to configure hunt group call forward.\n"; + echo " The following hunt groups have been assigned to this user account. \n"; + echo "
\n"; + echo "
"; + } + + $sql = ""; + $sql .= "select * from v_hunt_groups "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and hunt_group_type <> 'dnd' "; + $sql .= "and hunt_group_type <> 'call_forward' "; + $sql .= "and hunt_group_type <> 'follow_me_simultaneous' "; + $sql .= "and hunt_group_type <> 'follow_me_sequence' "; + if (!(permission_exists('hunt_group_add') || permission_exists('hunt_group_edit'))) { + $sql .= "and hunt_group_user_list like '%|".$_SESSION["username"]."|%' "; + } + if (strlen($order_by)> 0) { + $sql .= "order by $order_by $order "; + } + else { + $sql .= "order by hunt_group_extension asc "; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + if ($is_included == "true" && $result_count == 0) { + //hide this when there is no result + } + else { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + if ($result_count == 0) { + //no results + } + else { //received results + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + + } //end if results + + if ($is_included == "true" && $result_count == 0) { + //hide this when there is no result + } + else { + echo "
Hunt Group ExtensionToolsDescription
".$row['hunt_group_extension']."\n"; + echo " Call Forward \n"; + echo " ".$row['hunt_group_description']." 
"; + + echo "
"; + echo "
"; + echo "
"; + } + + echo "
"; + echo "
"; + + if ($is_included != "true") { + require_once "includes/footer.php"; + } +} + +?> diff --git a/app/hunt_group/v_hunt_group_call_forward_edit.php b/app/hunt_group/v_hunt_group_call_forward_edit.php new file mode 100644 index 0000000000..004d92edd7 --- /dev/null +++ b/app/hunt_group/v_hunt_group_call_forward_edit.php @@ -0,0 +1,491 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; + +//check permissions + if (permission_exists('hunt_group_add') || permission_exists('hunt_group_edit') || permission_exists('hunt_group_call_forward')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +function destination_select($select_name, $select_value, $select_default) { + if (strlen($select_value) == 0) { $select_value = $select_default; } + echo " \n"; +} + +//show the header + require_once "includes/header.php"; + +//get the hunt_group_uuid + $hunt_group_uuid = $_REQUEST["id"]; + +//hunt_group information used to determine if this is an add or an update + $sql = ""; + $sql .= "select * from v_hunt_groups "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and hunt_group_uuid = '$hunt_group_uuid' "; + if (!(permission_exists('hunt_group_add') || permission_exists('hunt_group_edit'))) { + $sql .= "and hunt_group_user_list like '%|".$_SESSION["username"]."|%' "; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $hunt_group_uuid = $row["hunt_group_uuid"]; + $hunt_group_extension = $row["hunt_group_extension"]; + } + unset ($prep_statement); + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + //get http post variables and set them to php variables + if (count($_POST)>0) { + $call_forward_enabled = check_str($_POST["call_forward_enabled"]); + $call_forward_number = check_str($_POST["call_forward_number"]); + $hunt_group_call_prompt = check_str($_POST["hunt_group_call_prompt"]); + + if (strlen($call_forward_number) > 0) { + $call_forward_number = preg_replace("~[^0-9]~", "",$call_forward_number); + } + + //set the default + if (strlen($hunt_group_call_prompt) == 0) { + $hunt_group_call_prompt = 'false'; + } + } + + //check for all required data + //if (strlen($call_forward_enabled) == 0) { $msg .= "Please provide: Call Forward
\n"; } + //if (strlen($call_forward_number) == 0) { $msg .= "Please provide: Number
\n"; } + //if (strlen($hunt_group_call_prompt) == 0) { $msg .= "Please provide: call prompt
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //call forward is enabled so disable the hunt group + if ($call_forward_enabled == "true") { + $sql = "update v_hunt_groups set hunt_group_enabled = 'false' "; + $sql .= "where hunt_group_extension = '$hunt_group_extension' "; + $sql .= "and (hunt_group_type = 'simultaneous' or hunt_group_type = 'sequentially') "; + $db->exec(check_sql($sql)); + } + + //call forward is disabled so enable the hunt group + if ($call_forward_enabled == "false" || $call_forward_enabled == "") { + $sql = "update v_hunt_groups set hunt_group_enabled = 'true' "; + $sql .= "where hunt_group_extension = '$hunt_group_extension' "; + $sql .= "and (hunt_group_type = 'simultaneous' or hunt_group_type = 'sequentially') "; + $db->exec(check_sql($sql)); + } + + //set the default action to add + $call_forward_action = "add"; + + //hunt_group information used to determine if this is an add or an update + $sql = "select * from v_hunt_groups "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and hunt_group_type = 'call_forward' "; + $sql .= "and hunt_group_extension in ( "; + $sql .= "select hunt_group_extension from v_hunt_groups "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and hunt_group_uuid = '$hunt_group_uuid' "; + if (!(permission_exists('hunt_group_add') || permission_exists('hunt_group_edit'))) { + $sql .= "and hunt_group_user_list like '%|".$_SESSION["username"]."|%' "; + } + $sql .= ") "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + if ($row["hunt_group_type"] == 'call_forward') { + $call_forward_action = "update"; + $call_forward_uuid = $row["hunt_group_uuid"]; + } + } + unset ($prep_statement); + + //call forward config + $huntgroup_name = 'call_forward_'.$hunt_group_extension; + $hunt_group_type = 'call_forward'; + $hunt_group_context = $_SESSION['context']; + $hunt_group_timeout = '3600'; + $hunt_group_timeout_destination = $hunt_group_extension; + $hunt_group_timeout_type = 'voicemail'; + $hunt_group_ring_back = 'us-ring'; + $hunt_group_cid_name_prefix = ''; + $hunt_group_pin = ''; + $huntgroup_caller_announce = 'false'; + $hunt_group_user_list = ''; + $hunt_group_enabled = $call_forward_enabled; + $hunt_group_description = 'call forward '.$hunt_group_extension; + + if ($call_forward_action == "add" && permission_exists('hunt_group_add')) { + $call_forward_uuid = uuid(); + $sql = "insert into v_hunt_groups "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "hunt_group_uuid, "; + $sql .= "hunt_group_extension, "; + $sql .= "hunt_group_name, "; + $sql .= "hunt_group_type, "; + $sql .= "hunt_group_context, "; + $sql .= "hunt_group_timeout, "; + $sql .= "hunt_group_timeout_destination, "; + $sql .= "hunt_group_timeout_type, "; + $sql .= "hunt_group_ringback, "; + $sql .= "hunt_group_cid_name_prefix, "; + $sql .= "hunt_group_pin, "; + $sql .= "hunt_group_call_prompt, "; + $sql .= "hunt_group_caller_announce, "; + $sql .= "hunt_group_user_list, "; + $sql .= "hunt_group_enabled, "; + $sql .= "hunt_group_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$call_forward_uuid', "; + $sql .= "'$hunt_group_extension', "; + $sql .= "'$huntgroup_name', "; + $sql .= "'$hunt_group_type', "; + $sql .= "'$hunt_group_context', "; + $sql .= "'$hunt_group_timeout', "; + $sql .= "'$hunt_group_timeout_destination', "; + $sql .= "'$hunt_group_timeout_type', "; + $sql .= "'$hunt_group_ring_back', "; + $sql .= "'$hunt_group_cid_name_prefix', "; + $sql .= "'$hunt_group_pin', "; + $sql .= "'$hunt_group_call_prompt', "; + $sql .= "'$huntgroup_caller_announce', "; + $sql .= "'$hunt_group_user_list', "; + $sql .= "'$hunt_group_enabled', "; + $sql .= "'$hunt_group_description' "; + $sql .= ")"; + if ($v_debug) { + echo $sql."
"; + } + $db->exec(check_sql($sql)); + unset($sql); + + //delete related v_hunt_group_destinations + $sql = "delete from v_hunt_group_destinations where hunt_group_uuid = '$call_forward_uuid' "; + $db->exec(check_sql($sql)); + + if (extension_exists($call_forward_number)) { + $destination_data = $call_forward_number; + $destination_type = 'extension'; + } + $destination_profile = 'internal'; + $destination_timeout = ''; + $destination_order = '1'; + $destination_enabled = 'true'; + $destination_description = 'call forward'; + + $hunt_group_destination_uuid = uuid(); + $sql = "insert into v_hunt_group_destinations "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "hunt_group_uuid, "; + $sql .= "hunt_group_destination_uuid, "; + $sql .= "destination_data, "; + $sql .= "destination_type, "; + $sql .= "destination_profile, "; + $sql .= "destination_timeout, "; + $sql .= "destination_order, "; + $sql .= "destination_enabled, "; + $sql .= "destination_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$call_forward_uuid', "; + $sql .= "'$hunt_group_destination_uuid', "; + $sql .= "'$destination_data', "; + $sql .= "'$destination_type', "; + $sql .= "'$destination_profile', "; + $sql .= "'$destination_timeout', "; + $sql .= "'$destination_order', "; + $sql .= "'$destination_enabled', "; + $sql .= "'$destination_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } //if ($call_forward_action == "add") + + if ($call_forward_action == "update" && permission_exists('hunt_group_call_forward')) { + $sql = "update v_hunt_groups set "; + $sql .= "hunt_group_extension = '$hunt_group_extension', "; + $sql .= "hunt_group_name = '$huntgroup_name', "; + $sql .= "hunt_group_type = '$hunt_group_type', "; + $sql .= "hunt_group_context = '$hunt_group_context', "; + $sql .= "hunt_group_timeout = '$hunt_group_timeout', "; + $sql .= "hunt_group_timeout_destination = '$hunt_group_timeout_destination', "; + $sql .= "hunt_group_timeout_type = '$hunt_group_timeout_type', "; + $sql .= "hunt_group_ringback = '$hunt_group_ring_back', "; + $sql .= "hunt_group_cid_name_prefix = '$hunt_group_cid_name_prefix', "; + $sql .= "hunt_group_pin = '$hunt_group_pin', "; + $sql .= "hunt_group_call_prompt = '$hunt_group_call_prompt', "; + $sql .= "hunt_group_caller_announce = '$huntgroup_caller_announce', "; + $sql .= "hunt_group_user_list = '$hunt_group_user_list', "; + $sql .= "hunt_group_enabled = '$hunt_group_enabled', "; + $sql .= "hunt_group_description = '$hunt_group_description' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and hunt_group_uuid = '$call_forward_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + //set the variables + $destination_data = $call_forward_number; + if (extension_exists($call_forward_number)) { + $destination_type = 'extension'; + } + else { + $destination_type = 'sip uri'; + } + $destination_profile = 'internal'; + $destination_timeout = ''; + $destination_order = '1'; + $destination_enabled = 'true'; + $destination_description = 'call forward'; + + //delete related v_hunt_group_destinations + $sql = "delete from v_hunt_group_destinations where hunt_group_uuid = '$call_forward_uuid' "; + $db->exec(check_sql($sql)); + + //insert the v_hunt_group_destinations + $sql = "insert into v_hunt_group_destinations "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "hunt_group_uuid, "; + $sql .= "destination_data, "; + $sql .= "destination_type, "; + $sql .= "destination_profile, "; + $sql .= "destination_timeout, "; + $sql .= "destination_order, "; + $sql .= "destination_enabled, "; + $sql .= "destination_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$call_forward_uuid', "; + $sql .= "'$destination_data', "; + $sql .= "'$destination_type', "; + $sql .= "'$destination_profile', "; + $sql .= "'$destination_timeout', "; + $sql .= "'$destination_order', "; + $sql .= "'$destination_enabled', "; + $sql .= "'$destination_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } //if ($call_forward_action == "update") + + //synchronize the xml config + save_hunt_group_xml(); + + //synchronize the xml config + save_dialplan_xml(); + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete
\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//show the header + require_once "includes/header.php"; + +//pre-populate the form + $sql = ""; + $sql .= "select * from v_hunt_groups "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and hunt_group_type = 'call_forward' "; + $sql .= "and hunt_group_extension = '$hunt_group_extension' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $hunt_group_uuid = $row["hunt_group_uuid"]; + $hunt_group_extension = $row["hunt_group_extension"]; + $huntgroup_name = $row["hunt_group_name"]; + $hunt_group_type = $row["hunt_group_type"]; + $hunt_group_context = $row["hunt_group_context"]; + $hunt_group_timeout = $row["hunt_group_timeout"]; + $hunt_group_timeout_destination = $row["hunt_group_timeout_destination"]; + $hunt_group_timeout_type = $row["hunt_group_timeout_type"]; + $hunt_group_ring_back = $row["hunt_group_ringback"]; + $hunt_group_cid_name_prefix = $row["hunt_group_cid_name_prefix"]; + $hunt_group_pin = $row["hunt_group_pin"]; + $hunt_group_call_prompt = $row["hunt_group_call_prompt"]; + $huntgroup_caller_announce = $row["hunt_group_caller_announce"]; + $hunt_group_user_list = $row["hunt_group_user_list"]; + $hunt_group_enabled = $row["hunt_group_enabled"]; + $hunt_group_description = $row["hunt_group_description"]; + + if ($row["hunt_group_type"] == 'call_forward') { + $call_forward_enabled = $hunt_group_enabled; + } + + if ($row["hunt_group_type"] == 'call_forward') { + $sql = ""; + $sql .= "select * from v_hunt_group_destinations "; + $sql .= "where hunt_group_uuid = '$hunt_group_uuid' "; + $prep_statement_2 = $db->prepare(check_sql($sql)); + $prep_statement_2->execute(); + $result2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED); + $x=1; + foreach ($result2 as &$row2) { + if ($row["hunt_group_type"] == 'call_forward') { + if (strlen($row2["destination_data"]) > 0) { + $call_forward_number = $row2["destination_data"]; + } + } + } + unset ($prep_statement_2); + } + } + unset ($prep_statement); + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " "; + echo "
\n"; + echo " Hunt Group Call Forward\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo " Directs incoming calls for extension $hunt_group_extension.

\n"; + echo "
\n"; + echo " Call Forward:\n"; + echo "\n"; + if ($call_forward_enabled == "true") { + echo " Enabled \n"; + } + else { + echo " Enable \n"; + } + if ($call_forward_enabled == "false" || $call_forward_enabled == "") { + echo " Disabled \n"; + } + else { + echo " Disable \n"; + } + echo "
\n"; + echo "
\n"; + //echo "Enable or disable call forward.\n"; + echo "
\n"; + echo " Number:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + //echo "Enter the call forward number.\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo "
"; + + echo "
"; + echo "
"; + +//show the footer + require_once "includes/footer.php"; +?> diff --git a/app/hunt_group/v_hunt_group_copy.php b/app/hunt_group/v_hunt_group_copy.php new file mode 100644 index 0000000000..11b0c1457d --- /dev/null +++ b/app/hunt_group/v_hunt_group_copy.php @@ -0,0 +1,168 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "includes/paging.php"; + +//check permissions + if (permission_exists('hunt_group_add')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//set the http get/post variable(s) to a php variable + if (isset($_REQUEST["id"])) { + $hunt_group_uuid = check_str($_REQUEST["id"]); + } + +//get the v_hunt_group data + $sql = ""; + $sql .= "select * from v_hunt_groups "; + $sql .= "where hunt_group_uuid = '$hunt_group_uuid' "; + $sql .= "and domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $hunt_group_extension = $row["hunt_group_extension"]; + $hunt_group_name = $row["hunt_group_name"]; + $hunt_group_type = $row["hunt_group_type"]; + $hunt_group_context = $row["hunt_group_context"]; + $hunt_group_timeout = $row["hunt_group_timeout"]; + $hunt_group_timeout_destination = $row["hunt_group_timeout_destination"]; + $hunt_group_timeout_type = $row["hunt_group_timeout_type"]; + $hunt_group_ringback = $row["hunt_group_ringback"]; + $hunt_group_cid_name_prefix = $row["hunt_group_cid_name_prefix"]; + $hunt_group_pin = $row["hunt_group_pin"]; + $hunt_group_caller_announce = $row["hunt_group_caller_announce"]; + $hunt_group_enabled = $row["hunt_group_enabled"]; + $hunt_group_description = "copy: ".$row["hunt_group_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + + //copy the hunt group + $sql = "insert into v_hunt_groups "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "hunt_group_uuid, "; + $sql .= "hunt_group_extension, "; + $sql .= "hunt_group_name, "; + $sql .= "hunt_group_type, "; + $sql .= "hunt_group_context, "; + $sql .= "hunt_group_timeout, "; + $sql .= "hunt_group_timeout_destination, "; + $sql .= "hunt_group_timeout_type, "; + $sql .= "hunt_group_ringback, "; + $sql .= "hunt_group_cid_name_prefix, "; + $sql .= "hunt_group_pin, "; + $sql .= "hunt_group_caller_announce, "; + $sql .= "hunt_group_enabled, "; + $sql .= "hunt_group_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$hunt_group_uuid', "; + $sql .= "'$hunt_group_extension', "; + $sql .= "'$hunt_group_name', "; + $sql .= "'$hunt_group_type', "; + $sql .= "'$hunt_group_context', "; + $sql .= "'$hunt_group_timeout', "; + $sql .= "'$hunt_group_timeout_destination', "; + $sql .= "'$hunt_group_timeout_type', "; + $sql .= "'$hunt_group_ringback', "; + $sql .= "'$hunt_group_cid_name_prefix', "; + $sql .= "'$hunt_group_pin', "; + $sql .= "'$hunt_group_caller_announce', "; + $sql .= "'$hunt_group_enabled', "; + $sql .= "'$hunt_group_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //get the the hunt group destinations + $sql = ""; + $sql .= "select * from v_hunt_group_destinations "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and hunt_group_uuid = '$hunt_group_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $hunt_group_uuid = $row["hunt_group_uuid"]; + $destination_data = $row["destination_data"]; + $destination_type = $row["destination_type"]; + $destination_profile = $row["destination_profile"]; + $destination_order = $row["destination_order"]; + $destination_description = $row["destination_description"]; + + //copy the hunt group destinations + $hunt_group_destination_uuid = uuid(); + $sql = "insert into v_hunt_group_destinations "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "hunt_group_uuid, "; + $sql .= "hunt_group_destination_uuid, "; + $sql .= "destination_data, "; + $sql .= "destination_type, "; + $sql .= "destination_profile, "; + $sql .= "destination_order, "; + $sql .= "destination_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$db_hunt_group_uuid', "; + $sql .= "'$hunt_group_destination_uuid', "; + $sql .= "'$destination_data', "; + $sql .= "'$destination_type', "; + $sql .= "'$destination_profile', "; + $sql .= "'$destination_order', "; + $sql .= "'$destination_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + unset ($prep_statement); + + //synchronize the xml config + save_hunt_group_xml(); + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Copy Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/hunt_group/v_hunt_group_delete.php b/app/hunt_group/v_hunt_group_delete.php new file mode 100644 index 0000000000..9b4d295815 --- /dev/null +++ b/app/hunt_group/v_hunt_group_delete.php @@ -0,0 +1,105 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; + +//check permissions + if (permission_exists('hunt_group_delete')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +if (count($_GET)>0) { + $id = $_GET["id"]; +} + +if (strlen($id)>0) { + + //start the atomic transaction + $count = $db->exec("BEGIN;"); + + //get the dialplan uuid + $sql = "select * from v_hunt_groups "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and hunt_group_uuid = '$id' "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + while($row = $prep_statement->fetch(PDO::FETCH_ASSOC)) { + $dialplan_uuid = $row['dialplan_uuid']; + } + + //delete child data + $sql = "delete from v_hunt_group_destinations "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and hunt_group_uuid = '$id' "; + $db->query($sql); + unset($sql); + + //delete parent data + $sql = "delete from v_hunt_groups "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and hunt_group_uuid = '$id' "; + $db->query($sql); + unset($sql); + + //delete the dialplan entry + $sql = "delete from v_dialplans "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + //echo $sql."
\n"; + $db->query($sql); + unset($sql); + + //delete the dialplan details + $sql = "delete from v_dialplan_details "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + //echo $sql."
\n"; + $db->query($sql); + unset($sql); + + //commit the atomic transaction + $count = $db->exec("COMMIT;"); + + //synchronize the xml config + save_hunt_group_xml(); + +} + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/hunt_group/v_hunt_group_destinations_delete.php b/app/hunt_group/v_hunt_group_destinations_delete.php new file mode 100644 index 0000000000..4f2923e36d --- /dev/null +++ b/app/hunt_group/v_hunt_group_destinations_delete.php @@ -0,0 +1,67 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; + +//check permissions + if (permission_exists('hunt_group_delete')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +if (count($_GET)>0) { + $id = $_GET["id"]; + $hunt_group_uuid = check_str($_REQUEST["id2"]); +} + +if (strlen($id)>0) { + //delete the data + $sql = ""; + $sql .= "delete from v_hunt_group_destinations "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and hunt_group_destination_uuid = '$id' "; + $sql .= "and hunt_group_uuid = '$hunt_group_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + //synchronize the xml config + save_hunt_group_xml(); +} + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/hunt_group/v_hunt_group_destinations_edit.php b/app/hunt_group/v_hunt_group_destinations_edit.php new file mode 100644 index 0000000000..4147f7c9a2 --- /dev/null +++ b/app/hunt_group/v_hunt_group_destinations_edit.php @@ -0,0 +1,365 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; + +//check permissions + if (permission_exists('hunt_group_add') || permission_exists('hunt_group_edit')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//set the action as an add or an update + if (isset($_REQUEST["id"])) { + $action = "update"; + $hunt_group_destination_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + + if (isset($_REQUEST["id2"])) { + $hunt_group_uuid = check_str($_REQUEST["id2"]); + } + +//get the http values and set them as variables + if (count($_POST)>0) { + if (isset($_POST["hunt_group_uuid"])) { + $hunt_group_uuid = check_str($_POST["hunt_group_uuid"]); + } + $destination_data = check_str($_POST["destination_data"]); + $destination_type = check_str($_POST["destination_type"]); + $destination_timeout = check_str($_POST["destination_timeout"]); + $destination_order = check_str($_POST["destination_order"]); + $destination_enabled = check_str($_POST["destination_enabled"]); + $destination_description = check_str($_POST["destination_description"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $hunt_group_destination_uuid = check_str($_POST["hunt_group_destination_uuid"]); + } + + //check for all required data + if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + if (strlen($destination_data) == 0) { $msg .= "Please provide: Destination
\n"; } + if (strlen($destination_type) == 0) { $msg .= "Please provide: Type
\n"; } + //if (strlen($destination_timeout) == 0) { $msg .= "Please provide: Timeout
\n"; } + //if (strlen($destination_order) == 0) { $msg .= "Please provide: Order
\n"; } + //if (strlen($destination_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } + //if (strlen($destination_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('hunt_group_add')) { + $hunt_group_destination_uuid = uuid(); + $sql = "insert into v_hunt_group_destinations "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "hunt_group_uuid, "; + $sql .= "hunt_group_destination_uuid, "; + $sql .= "destination_data, "; + $sql .= "destination_type, "; + $sql .= "destination_timeout, "; + $sql .= "destination_order, "; + $sql .= "destination_enabled, "; + $sql .= "destination_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$hunt_group_uuid', "; + $sql .= "'$hunt_group_destination_uuid', "; + $sql .= "'$destination_data', "; + $sql .= "'$destination_type', "; + $sql .= "'$destination_timeout', "; + $sql .= "'$destination_order', "; + $sql .= "'$destination_enabled', "; + $sql .= "'$destination_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //synchronize the xml config + save_hunt_group_xml(); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update" && permission_exists('hunt_group_edit')) { + $sql = "update v_hunt_group_destinations set "; + $sql .= "domain_uuid = '$domain_uuid', "; + $sql .= "hunt_group_uuid = '$hunt_group_uuid', "; + $sql .= "destination_data = '$destination_data', "; + $sql .= "destination_type = '$destination_type', "; + $sql .= "destination_timeout = '$destination_timeout', "; + $sql .= "destination_order = '$destination_order', "; + $sql .= "destination_enabled = '$destination_enabled', "; + $sql .= "destination_description = '$destination_description' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and hunt_group_destination_uuid = '$hunt_group_destination_uuid'"; + $db->exec(check_sql($sql)); + + //synchronize the xml config + save_hunt_group_xml(); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $hunt_group_destination_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_hunt_group_destinations "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and hunt_group_destination_uuid = '$hunt_group_destination_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $hunt_group_uuid = $row["hunt_group_uuid"]; + $destination_data = $row["destination_data"]; + $destination_type = $row["destination_type"]; + $destination_timeout = $row["destination_timeout"]; + $destination_order = $row["destination_order"]; + $destination_enabled = $row["destination_enabled"]; + $destination_description = $row["destination_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " "; + echo "
Destination AddDestination Edit
\n"; + echo " Destination:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "extension: 1001
\n"; + echo "voicemail: 1001
\n"; + echo "sip uri (voicemail): sofia/internal/*98@\${domain}
\n"; + echo "sip uri (external number): sofia/gateway/gatewayname/12081231234
\n"; + echo "sip uri (auto attendant): sofia/internal/5002@\${domain}
\n"; + echo "sip uri (user): /user/1001@\${domain}\n"; + echo "
\n"; + echo " Type:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Timeout:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Select the destination timeout in seconds. \n"; + echo "
\n"; + echo " Order:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Processing of each destination is determined by this order. \n"; + echo "
\n"; + echo " Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "You may enter a description here for your reference (not parsed).\n"; + echo "
\n"; + echo " \n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//show the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/hunt_group/v_hunt_group_edit.php b/app/hunt_group/v_hunt_group_edit.php new file mode 100644 index 0000000000..f63656e51e --- /dev/null +++ b/app/hunt_group/v_hunt_group_edit.php @@ -0,0 +1,752 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "includes/paging.php"; + +//check permissions + if (permission_exists('hunt_group_add') || permission_exists('hunt_group_edit')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $hunt_group_uuid = check_str($_REQUEST["id"]); + $dialplan_uuid = check_str($_REQUEST["dialplan_uuid"]); + } + else { + $action = "add"; + } + +//get the http values and set them as variables + if (count($_POST)>0) { + $hunt_group_extension = check_str($_POST["hunt_group_extension"]); + $hunt_group_name = check_str($_POST["hunt_group_name"]); + $hunt_group_type = check_str($_POST["hunt_group_type"]); + //$hunt_group_context = check_str($_POST["hunt_group_context"]); + $hunt_group_timeout = check_str($_POST["hunt_group_timeout"]); + $hunt_group_timeout_destination = check_str($_POST["hunt_group_timeout_destination"]); + $hunt_group_timeout_type = check_str($_POST["hunt_group_timeout_type"]); + $hunt_group_ringback = check_str($_POST["hunt_group_ringback"]); + $hunt_group_cid_name_prefix = check_str($_POST["hunt_group_cid_name_prefix"]); + $hunt_group_pin = check_str($_POST["hunt_group_pin"]); + $hunt_group_caller_announce = check_str($_POST["hunt_group_caller_announce"]); + + //prepare the user list for the database + $hunt_group_user_list = $_POST["hunt_group_user_list"]; + if (strlen($hunt_group_user_list) > 0) { + $hunt_group_user_list_array = explode("\n", $hunt_group_user_list); + if (count($hunt_group_user_list_array) == 0) { + $hunt_group_user_list = ''; + } + else { + $hunt_group_user_list = '|'; + foreach($hunt_group_user_list_array as $user){ + if(strlen(trim($user)) > 0) { + $hunt_group_user_list .= check_str(trim($user))."|"; + } + } + } + } + + $hunt_group_enabled = check_str($_POST["hunt_group_enabled"]); + $hunt_group_description = check_str($_POST["hunt_group_description"]); + + //remove invalid characters + $hunt_group_cid_name_prefix = str_replace(":", "-", $hunt_group_cid_name_prefix); + $hunt_group_cid_name_prefix = str_replace("\"", "", $hunt_group_cid_name_prefix); + $hunt_group_cid_name_prefix = str_replace("@", "", $hunt_group_cid_name_prefix); + $hunt_group_cid_name_prefix = str_replace("\\", "", $hunt_group_cid_name_prefix); + $hunt_group_cid_name_prefix = str_replace("/", "", $hunt_group_cid_name_prefix); + + //set default + if (strlen($hunt_group_caller_announce) == 0) { $hunt_group_caller_announce = "false"; } + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $hunt_group_uuid = check_str($_POST["hunt_group_uuid"]); + } + + //check for all required data + if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + if (strlen($hunt_group_extension) == 0) { $msg .= "Please provide: Extension
\n"; } + if (strlen($hunt_group_name) == 0) { $msg .= "Please provide: Hunt Group Name
\n"; } + if (strlen($hunt_group_type) == 0) { $msg .= "Please provide: Type
\n"; } + //if (strlen($hunt_group_context) == 0) { $msg .= "Please provide: Context
\n"; } + if (strlen($hunt_group_timeout) == 0) { $msg .= "Please provide: Timeout
\n"; } + if (strlen($hunt_group_timeout_destination) == 0) { $msg .= "Please provide: Timeout Destination
\n"; } + if (strlen($hunt_group_timeout_type) == 0) { $msg .= "Please provide: Timeout Type
\n"; } + if (strlen($hunt_group_ringback) == 0) { $msg .= "Please provide: Ring Back
\n"; } + //if (strlen($hunt_group_cid_name_prefix) == 0) { $msg .= "Please provide: CID Prefix
\n"; } + //if (strlen($hunt_group_pin) == 0) { $msg .= "Please provide: PIN
\n"; } + if (strlen($hunt_group_caller_announce) == 0) { $msg .= "Please provide: Caller Announce
\n"; } + //if (strlen($hunt_group_user_list) == 0) { $msg .= "Please provide: User List
\n"; } + //if (strlen($hunt_group_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } + //if (strlen($hunt_group_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('hunt_group_add')) { + //add to the table + $dialplan_uuid = uuid(); + $hunt_group_uuid = uuid(); + $sql = "insert into v_hunt_groups "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "hunt_group_uuid, "; + $sql .= "hunt_group_extension, "; + $sql .= "hunt_group_name, "; + $sql .= "hunt_group_type, "; + $sql .= "hunt_group_context, "; + $sql .= "hunt_group_timeout, "; + $sql .= "hunt_group_timeout_destination, "; + $sql .= "hunt_group_timeout_type, "; + $sql .= "hunt_group_ringback, "; + $sql .= "hunt_group_cid_name_prefix, "; + $sql .= "hunt_group_pin, "; + $sql .= "hunt_group_caller_announce, "; + $sql .= "hunt_group_user_list, "; + $sql .= "hunt_group_enabled, "; + $sql .= "hunt_group_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + $sql .= "'$hunt_group_uuid', "; + $sql .= "'$hunt_group_extension', "; + $sql .= "'$hunt_group_name', "; + $sql .= "'$hunt_group_type', "; + $sql .= "'".$_SESSION['context']."', "; + $sql .= "'$hunt_group_timeout', "; + $sql .= "'$hunt_group_timeout_destination', "; + $sql .= "'$hunt_group_timeout_type', "; + $sql .= "'$hunt_group_ringback', "; + $sql .= "'$hunt_group_cid_name_prefix', "; + $sql .= "'$hunt_group_pin', "; + $sql .= "'$hunt_group_caller_announce', "; + $sql .= "'$hunt_group_user_list', "; + $sql .= "'$hunt_group_enabled', "; + $sql .= "'$hunt_group_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //synchronize the xml config + save_hunt_group_xml(); + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update" && permission_exists('hunt_group_edit')) { + //update the table + $sql = "update v_hunt_groups set "; + $sql .= "hunt_group_extension = '$hunt_group_extension', "; + $sql .= "hunt_group_name = '$hunt_group_name', "; + $sql .= "hunt_group_type = '$hunt_group_type', "; + $sql .= "hunt_group_context = '".$_SESSION['context']."', "; + $sql .= "hunt_group_timeout = '$hunt_group_timeout', "; + $sql .= "hunt_group_timeout_destination = '$hunt_group_timeout_destination', "; + $sql .= "hunt_group_timeout_type = '$hunt_group_timeout_type', "; + $sql .= "hunt_group_ringback = '$hunt_group_ringback', "; + $sql .= "hunt_group_cid_name_prefix = '$hunt_group_cid_name_prefix', "; + $sql .= "hunt_group_pin = '$hunt_group_pin', "; + $sql .= "hunt_group_caller_announce = '$hunt_group_caller_announce', "; + if (if_group("admin") || if_group("superadmin")) { + $sql .= "hunt_group_user_list = '$hunt_group_user_list', "; + } + $sql .= "hunt_group_enabled = '$hunt_group_enabled', "; + $sql .= "hunt_group_description = '$hunt_group_description' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and hunt_group_uuid = '$hunt_group_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + //update the dialplan entry + require_once "includes/classes/dialplan.php"; + $dialplan = new dialplan; + $dialplan->domain_uuid = $_SESSION['domain_uuid']; + $dialplan->app_uuid = $app_uuid; + $dialplan->dialplan_uuid = $dialplan_uuid; + $dialplan->dialplan_name = $hunt_group_name; + //$dialplan->dialplan_continue = $dialplan_continue; + //$dialplan->dialplan_order = '330'; + $dialplan->dialplan_context = $_SESSION['context']; + $dialplan->dialplan_enabled = $hunt_group_enabled; + $dialplan->dialplan_description = $hunt_group_description; + $dialplan->dialplan_update(); + unset($dialplan); + + //update the condition + $sql = "update v_dialplan_details set "; + $sql .= "dialplan_detail_data = '^".$hunt_group_extension."$' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_detail_tag = 'condition' "; + $sql .= "and dialplan_detail_type = 'destination_number' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $sql .= "and dialplan_detail_group = '1' "; + $db->query($sql); + unset($sql); + + //update the action + $sql = "update v_dialplan_details set "; + $sql .= "dialplan_detail_data = 'v_huntgroup_".$_SESSION['domain_name']."_".$hunt_group_extension.".lua', "; + $sql .= "dialplan_detail_type = 'lua' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_detail_tag = 'action' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $sql .= "and dialplan_detail_type = 'lua' "; + $sql .= "and dialplan_detail_group = '1' "; + $db->query($sql); + + //synchronize the xml config + save_hunt_group_xml(); + + //rediret the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $hunt_group_uuid = $_GET["id"]; + $sql = "select * from v_hunt_groups "; + $sql .= "where hunt_group_uuid = '$hunt_group_uuid' "; + $sql .= "and domain_uuid = '$domain_uuid' "; + $sql .- "hunt_group_enabled = 'true' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $dialplan_uuid = $row["dialplan_uuid"]; + $hunt_group_extension = $row["hunt_group_extension"]; + $hunt_group_name = $row["hunt_group_name"]; + $hunt_group_type = $row["hunt_group_type"]; + //$hunt_group_context = $row["hunt_group_context"]; + $hunt_group_timeout = $row["hunt_group_timeout"]; + $hunt_group_timeout_destination = $row["hunt_group_timeout_destination"]; + $hunt_group_timeout_type = $row["hunt_group_timeout_type"]; + $hunt_group_ringback = $row["hunt_group_ringback"]; + $hunt_group_cid_name_prefix = $row["hunt_group_cid_name_prefix"]; + $hunt_group_pin = $row["hunt_group_pin"]; + $hunt_group_caller_announce = $row["hunt_group_caller_announce"]; + $hunt_group_user_list = $row["hunt_group_user_list"]; + $hunt_group_enabled = $row["hunt_group_enabled"]; + $hunt_group_description = $row["hunt_group_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo ""; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if (!$fp) { + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + } + if (switch_module_is_running($fp, 'mod_spidermonkey')) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + if (if_group("admin") || if_group("superadmin")) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo " \n"; + echo " Hunt Group
\n"; + echo "
\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " A Hunt Group is a list of destinations that can be called in sequence or simultaneously. \n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + + echo "
\n"; + echo " Hunt Group Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Extension:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "example: 7002\n"; + echo "
\n"; + echo " Type:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Timeout:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "The timeout sets the time in seconds to continue to call before timing out. \n"; + echo "
\n"; + echo " Timeout Destination:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Destination. example: 1001\n"; + echo "
\n"; + echo " Timeout Type:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Ring Back:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Defines what the caller will hear while destination is being called. The choices are music (music on hold) ring (ring tone.) default: music \n"; + echo "
\n"; + echo " CID Prefix:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Set a prefix on the caller ID name.\n"; + echo "
\n"; + echo " PIN:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "If this is provided then the caller will be required to enter the PIN number.\n"; + echo "
\n"; + echo " Caller Announce:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " User List:\n"; + echo "\n"; + $onchange = "document.getElementById('hunt_group_user_list').value += document.getElementById('username').value + '\\n';"; + $table_name = 'v_users'; $field_name = 'username'; $field_current_value = ''; $sql_where_optional = "where domain_uuid = '$domain_uuid' "; + echo html_select_on_change($db, $table_name, $field_name, $sql_where_optional, $field_current_value, $onchange); + echo "
\n"; + echo "Use the select list to add users to the user list. This will assign users to this extension.\n"; + echo "
\n"; + echo "
\n"; + //replace the vertical bar with a line feed to display in the textarea + $hunt_group_user_list = trim($hunt_group_user_list, "|"); + $hunt_group_user_list_array = explode("|", $hunt_group_user_list); + $hunt_group_user_list = ''; + foreach($hunt_group_user_list_array as $user){ + $hunt_group_user_list .= trim($user)."\n"; + } + echo " \n"; + echo "
\n"; + echo "Assign the users that are can manage this hunt group extension.\n"; + echo "
\n"; + echo "
\n"; + echo " Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "You may enter a description here for your reference (not parsed). \n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//list hunt group destinations + if ($action == "update") { + + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "

\n"; + echo " \n"; + echo " Destinations
\n"; + echo "
\n"; + echo " The following destinations will be called.\n"; + echo "

\n"; + echo "
\n"; + + $sql = ""; + $sql .= " select * from v_hunt_group_destinations "; + $sql .= " where domain_uuid = '$domain_uuid' "; + $sql .= " and hunt_group_uuid = '$hunt_group_uuid' "; + $sql .= " order by destination_order, destination_data asc"; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
DestinationTypeProfileOrderDescription\n"; + if (permission_exists('hunt_group_add')) { + echo " $v_link_label_add\n"; + } + echo "
  ".$row['destination_data']."  ".$row['destination_type']."  ".$row['destination_profile']."  ".$row['destination_order']."".$row['destination_description']." \n"; + if (permission_exists('hunt_group_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('hunt_group_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('hunt_group_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + } //end if update + +//show the footer + require_once "includes/footer.php"; +?> diff --git a/app/ivr_menu/app_config.php b/app/ivr_menu/app_config.php new file mode 100644 index 0000000000..5e8f0adb8a --- /dev/null +++ b/app/ivr_menu/app_config.php @@ -0,0 +1,239 @@ + \ No newline at end of file diff --git a/app/ivr_menu/root.php b/app/ivr_menu/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/ivr_menu/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/ivr_menu/v_ivr_menu.php b/app/ivr_menu/v_ivr_menu.php new file mode 100644 index 0000000000..fc6b0138fa --- /dev/null +++ b/app/ivr_menu/v_ivr_menu.php @@ -0,0 +1,173 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('ivr_menu_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get the http values and set them as variables + if (isset($_GET["order_by"])) { + $order_by = check_str($_GET["order_by"]); + $order = check_str($_GET["order"]); + } + else { + $order_by = ''; + $order = ''; + } + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + //show the content header + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
IVR Menu 
\n"; + echo "The IVR Menu plays a recording or a pre-defined phrase that presents the caller with options to choose from. \n"; + echo "Each option has a corresponding destination. The destinations can be extensions, voicemail, other IVR menus, call groups, FAX extensions, and more.

\n"; + echo "
\n"; + + //get the count + require_once "includes/classes/database.php"; + require_once "includes/classes/switch_ivr_menu.php"; + $ivr = new switch_ivr_menu; + $ivr->domain_uuid = $_SESSION["domain_uuid"]; + $ivr->table = "v_ivr_menus"; + $where[0]['name'] = 'domain_uuid'; + $where[0]['value'] = $_SESSION["domain_uuid"]; + $where[0]['operator'] = '='; + $ivr->where = $where; + $num_rows = $ivr->count(); + + //prepare to page the results + $rows_per_page = 150; + $param = ""; + if (!isset($_GET['page'])) { $_GET['page'] = 0; } + $_GET['page'] = check_str($_GET['page']); + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $_GET['page']; + + //get the list from the db + if (isset($order_by)) { + if (strlen($order_by) > 0) { + $ivr->order_by = $order_by; + $ivr->order_type = $order; + } + } + $result = $ivr->find(); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo th_order_by('ivr_menu_name', 'Name', $order_by, $order); + echo th_order_by('ivr_menu_extension', 'Extension', $order_by, $order); + echo th_order_by('ivr_menu_direct_dial', 'Direct Dial', $order_by, $order); + echo th_order_by('ivr_menu_enabled', 'Enabled', $order_by, $order); + echo th_order_by('ivr_menu_description', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + if (permission_exists('ivr_menu_add')) { + echo " $v_link_label_add\n"; + } + echo "
".$row['ivr_menu_name']."".$row['ivr_menu_extension']." ".$row['ivr_menu_direct_dial']."".$row['ivr_menu_enabled']."".$row['ivr_menu_description']." \n"; + if (permission_exists('ivr_menu_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('ivr_menu_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('ivr_menu_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//show the footer + require_once "includes/footer.php"; +?> diff --git a/app/ivr_menu/v_ivr_menu_copy.php b/app/ivr_menu/v_ivr_menu_copy.php new file mode 100644 index 0000000000..45f2be4c42 --- /dev/null +++ b/app/ivr_menu/v_ivr_menu_copy.php @@ -0,0 +1,184 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "includes/paging.php"; +if (permission_exists('ivr_menu_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//set the http get/post variable(s) to a php variable + if (isset($_REQUEST["id"])) { + $ivr_menu_uuid = $_GET["id"]; + } + +//get the v_ivr_menus data + $sql = "select * from v_ivr_menus "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and ivr_menu_uuid = '$ivr_menu_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $ivr_menu_name = 'copy-'.$row["ivr_menu_name"]; + $ivr_menu_extension = $row["ivr_menu_extension"]; + $ivr_menu_greet_long = $row["ivr_menu_greet_long"]; + $ivr_menu_greet_short = $row["ivr_menu_greet_short"]; + $ivr_menu_invalid_sound = $row["ivr_menu_invalid_sound"]; + $ivr_menu_exit_sound = $row["ivr_menu_exit_sound"]; + $ivr_menu_confirm_macro = $row["ivr_menu_confirm_macro"]; + $ivr_menu_confirm_key = $row["ivr_menu_confirm_key"]; + $ivr_menu_tts_engine = $row["ivr_menu_tts_engine"]; + $ivr_menu_tts_voice = $row["ivr_menu_tts_voice"]; + $ivr_menu_confirm_attempts = $row["ivr_menu_confirm_attempts"]; + $ivr_menu_timeout = $row["ivr_menu_timeout"]; + $ivr_menu_inter_digit_timeout = $row["ivr_menu_inter_digit_timeout"]; + $ivr_menu_max_failures = $row["ivr_menu_max_failures"]; + $ivr_menu_max_timeouts = $row["ivr_menu_max_timeouts"]; + $ivr_menu_digit_len = $row["ivr_menu_digit_len"]; + $ivr_menu_direct_dial = $row["ivr_menu_direct_dial"]; + $ivr_menu_enabled = $row["ivr_menu_enabled"]; + $ivr_menu_description = 'copy: '.$row["ivr_menu_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + +//get the the ivr menu options + $sql = "select * from v_ivr_menu_options "; + $sql .= "where ivr_menu_uuid = '$ivr_menu_uuid' "; + $sql .= "and domain_uuid = '$domain_uuid' "; + $sql .= "order by ivr_menu_uuid asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result_options = $prep_statement->fetchAll(PDO::FETCH_NAMED); + +//copy the v_ivr_menus + $ivr_menu_uuid = uuid(); + $sql = "insert into v_ivr_menus "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "ivr_menu_uuid, "; + $sql .= "ivr_menu_name, "; + $sql .= "ivr_menu_extension, "; + $sql .= "ivr_menu_greet_long, "; + $sql .= "ivr_menu_greet_short, "; + $sql .= "ivr_menu_invalid_sound, "; + $sql .= "ivr_menu_exit_sound, "; + $sql .= "ivr_menu_confirm_macro, "; + $sql .= "ivr_menu_confirm_key, "; + $sql .= "ivr_menu_tts_engine, "; + $sql .= "ivr_menu_tts_voice, "; + $sql .= "ivr_menu_confirm_attempts, "; + $sql .= "ivr_menu_timeout, "; + $sql .= "ivr_menu_inter_digit_timeout, "; + $sql .= "ivr_menu_max_failures, "; + $sql .= "ivr_menu_max_timeouts, "; + $sql .= "ivr_menu_digit_len, "; + $sql .= "ivr_menu_direct_dial, "; + $sql .= "ivr_menu_enabled, "; + $sql .= "ivr_menu_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$ivr_menu_uuid', "; + $sql .= "'$ivr_menu_name', "; + $sql .= "'$ivr_menu_extension', "; + $sql .= "'$ivr_menu_greet_long', "; + $sql .= "'$ivr_menu_greet_short', "; + $sql .= "'$ivr_menu_invalid_sound', "; + $sql .= "'$ivr_menu_exit_sound', "; + $sql .= "'$ivr_menu_confirm_macro', "; + $sql .= "'$ivr_menu_confirm_key', "; + $sql .= "'$ivr_menu_tts_engine', "; + $sql .= "'$ivr_menu_tts_voice', "; + $sql .= "'$ivr_menu_confirm_attempts', "; + $sql .= "'$ivr_menu_timeout', "; + $sql .= "'$ivr_menu_inter_digit_timeout', "; + $sql .= "'$ivr_menu_max_failures', "; + $sql .= "'$ivr_menu_max_timeouts', "; + $sql .= "'$ivr_menu_digit_len', "; + $sql .= "'$ivr_menu_direct_dial', "; + $sql .= "'$ivr_menu_enabled', "; + $sql .= "'$ivr_menu_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + +//get the the ivr menu options + foreach ($result_options as &$row) { + $ivr_menu_option_digits = $row["ivr_menu_option_digits"]; + $ivr_menu_option_action = $row["ivr_menu_option_action"]; + $ivr_menu_option_param = $row["ivr_menu_option_param"]; + $ivr_menu_option_order = $row["ivr_menu_option_order"]; + $ivr_menu_option_description = $row["ivr_menu_option_description"]; + + //copy the ivr menu options + $ivr_menu_option_uuid = uuid(); + $sql = "insert into v_ivr_menu_options "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "ivr_menu_uuid, "; + $sql .= "ivr_menu_option_uuid, "; + $sql .= "ivr_menu_option_digits, "; + $sql .= "ivr_menu_option_action, "; + $sql .= "ivr_menu_option_param, "; + $sql .= "ivr_menu_option_order, "; + $sql .= "ivr_menu_option_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$ivr_menu_uuid', "; + $sql .= "'$ivr_menu_option_uuid', "; + $sql .= "'$ivr_menu_option_digits', "; + $sql .= "'$ivr_menu_option_action', "; + $sql .= "'$ivr_menu_option_param', "; + $sql .= "'$ivr_menu_option_order', "; + $sql .= "'$ivr_menu_option_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + +//synchronize the xml config + save_ivr_menu_xml(); + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Copy Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/ivr_menu/v_ivr_menu_delete.php b/app/ivr_menu/v_ivr_menu_delete.php new file mode 100644 index 0000000000..d00b9f3abe --- /dev/null +++ b/app/ivr_menu/v_ivr_menu_delete.php @@ -0,0 +1,67 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('ivr_menu_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); +} + +if (strlen($id)>0) { + + //include the ivr menu class + require_once "includes/classes/database.php"; + require_once "includes/classes/switch_ivr_menu.php"; + $ivr = new switch_ivr_menu; + $ivr->domain_uuid = $_SESSION["domain_uuid"]; + $ivr->ivr_menu_uuid = $id; + $ivr->delete(); + + //synchronize the xml config + save_ivr_menu_xml(); + + //synchronize the xml config + save_dialplan_xml(); +} + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/ivr_menu/v_ivr_menu_edit.php b/app/ivr_menu/v_ivr_menu_edit.php new file mode 100644 index 0000000000..7b77ab72be --- /dev/null +++ b/app/ivr_menu/v_ivr_menu_edit.php @@ -0,0 +1,817 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('ivr_menu_add') || permission_exists('ivr_menu_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} +/* +function recur_sounds_dir($dir) { + global $dir_array; + global $dir_path; + $dir_list = opendir($dir); + while ($file = readdir ($dir_list)) { + if ($file != '.' && $file != '..') { + $newpath = $dir.'/'.$file; + $level = explode('/',$newpath); + if (substr($newpath, -4) == ".svn") { + //ignore .svn dir and subdir + } + else { + if (is_dir($newpath)) { //directories + recur_sounds_dir($newpath); + } + else { //files + if (strlen($newpath) > 0) { + //make the path relative + $relative_path = substr($newpath, strlen($dir_path), strlen($newpath)); + //remove the 8000-48000 khz from the path + $relative_path = str_replace("/8000/", "/", $relative_path); + $relative_path = str_replace("/16000/", "/", $relative_path); + $relative_path = str_replace("/32000/", "/", $relative_path); + $relative_path = str_replace("/48000/", "/", $relative_path); + //remove the default_language, default_dialect, and default_voice (en/us/callie) from the path + $file_array = explode( "/", $relative_path ); + $x = 1; + $relative_path = ''; + foreach( $file_array as $tmp) { + if ($x == 5) { $relative_path .= $tmp; } + if ($x > 5) { $relative_path .= '/'.$tmp; } + $x++; + } + //add the file if it does not exist in the array + if (isset($dir_array[$relative_path])) { + //already exists + } + else { + //add the new path + if (strlen($relative_path) > 0) { $dir_array[$relative_path] = '0'; } + } + } + } + } + } + } + closedir($dir_list); +} +*/ + +//action add or update +if (isset($_REQUEST["id"])) { + $action = "update"; + $ivr_menu_uuid = check_str($_REQUEST["id"]); +} +else { + $action = "add"; +} + +//get http post values and set them to php variables +if (count($_POST)>0) { + $ivr_menu_name = check_str($_POST["ivr_menu_name"]); + $ivr_menu_extension = check_str($_POST["ivr_menu_extension"]); + $ivr_menu_greet_long = check_str($_POST["ivr_menu_greet_long"]); + $ivr_menu_greet_short = check_str($_POST["ivr_menu_greet_short"]); + $ivr_menu_invalid_sound = check_str($_POST["ivr_menu_invalid_sound"]); + $ivr_menu_exit_sound = check_str($_POST["ivr_menu_exit_sound"]); + $ivr_menu_confirm_macro = check_str($_POST["ivr_menu_confirm_macro"]); + $ivr_menu_confirm_key = check_str($_POST["ivr_menu_confirm_key"]); + $ivr_menu_tts_engine = check_str($_POST["ivr_menu_tts_engine"]); + $ivr_menu_tts_voice = check_str($_POST["ivr_menu_tts_voice"]); + $ivr_menu_confirm_attempts = check_str($_POST["ivr_menu_confirm_attempts"]); + $ivr_menu_timeout = check_str($_POST["ivr_menu_timeout"]); + $ivr_menu_inter_digit_timeout = check_str($_POST["ivr_menu_inter_digit_timeout"]); + $ivr_menu_max_failures = check_str($_POST["ivr_menu_max_failures"]); + $ivr_menu_max_timeouts = check_str($_POST["ivr_menu_max_timeouts"]); + $ivr_menu_digit_len = check_str($_POST["ivr_menu_digit_len"]); + $ivr_menu_direct_dial = check_str($_POST["ivr_menu_direct_dial"]); + $ivr_menu_enabled = check_str($_POST["ivr_menu_enabled"]); + $ivr_menu_description = check_str($_POST["ivr_menu_description"]); + + $ivr_menu_exit_action = check_str($_POST["ivr_menu_exit_action"]); + //$ivr_menu_exit_action = "transfer:1001 XML default"; + $timeout_action_array = explode(":", $ivr_menu_exit_action); + $ivr_menu_exit_app = array_shift($timeout_action_array); + $ivr_menu_exit_data = join(':', $timeout_action_array); +} + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $ivr_menu_uuid = check_str($_POST["ivr_menu_uuid"]); + } + + //check for all required data + //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + if (strlen($ivr_menu_name) == 0) { $msg .= "Please provide: Name
\n"; } + if (strlen($ivr_menu_extension) == 0) { $msg .= "Please provide: Extension
\n"; } + if (strlen($ivr_menu_greet_long) == 0) { $msg .= "Please provide: Greet Long
\n"; } + //if (strlen($ivr_menu_greet_short) == 0) { $msg .= "Please provide: Greet Short
\n"; } + if (strlen($ivr_menu_invalid_sound) == 0) { $msg .= "Please provide: Invalid Sound
\n"; } + //if (strlen($ivr_menu_exit_sound) == 0) { $msg .= "Please provide: Exit Sound
\n"; } + //if (strlen($ivr_menu_confirm_macro) == 0) { $msg .= "Please provide: Confirm Macro
\n"; } + //if (strlen($ivr_menu_confirm_key) == 0) { $msg .= "Please provide: Confirm Key
\n"; } + //if (strlen($ivr_menu_tts_engine) == 0) { $msg .= "Please provide: TTS Engine
\n"; } + //if (strlen($ivr_menu_tts_voice) == 0) { $msg .= "Please provide: TTS Voice
\n"; } + if (strlen($ivr_menu_confirm_attempts) == 0) { $msg .= "Please provide: Confirm Attempts
\n"; } + if (strlen($ivr_menu_timeout) == 0) { $msg .= "Please provide: Timeout
\n"; } + //if (strlen($ivr_menu_exit_app) == 0) { $msg .= "Please provide: Exit Action
\n"; } + //if (strlen($ivr_menu_exit_data) == 0) { $msg .= "Please provide: Timeout Data
\n"; } + if (strlen($ivr_menu_inter_digit_timeout) == 0) { $msg .= "Please provide: Inter Digit Timeout
\n"; } + if (strlen($ivr_menu_max_failures) == 0) { $msg .= "Please provide: Max Failures
\n"; } + if (strlen($ivr_menu_max_timeouts) == 0) { $msg .= "Please provide: Max Timeouts
\n"; } + if (strlen($ivr_menu_digit_len) == 0) { $msg .= "Please provide: Digit Length
\n"; } + if (strlen($ivr_menu_direct_dial) == 0) { $msg .= "Please provide: Direct Dial
\n"; } + if (strlen($ivr_menu_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } + //if (strlen($ivr_menu_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + //prepare the object + require_once "includes/classes/database.php"; + require_once "includes/classes/switch_ivr_menu.php"; + $ivr = new switch_ivr_menu; + $ivr->domain_uuid = $_SESSION["domain_uuid"]; + $ivr->ivr_menu_name = $ivr_menu_name; + $ivr->ivr_menu_extension = $ivr_menu_extension; + $ivr->ivr_menu_greet_long = $ivr_menu_greet_long; + $ivr->ivr_menu_greet_short = $ivr_menu_greet_short; + $ivr->ivr_menu_invalid_sound = $ivr_menu_invalid_sound; + $ivr->ivr_menu_exit_sound = $ivr_menu_exit_sound; + $ivr->ivr_menu_confirm_macro = $ivr_menu_confirm_macro; + $ivr->ivr_menu_confirm_key = $ivr_menu_confirm_key; + $ivr->ivr_menu_tts_engine = $ivr_menu_tts_engine; + $ivr->ivr_menu_tts_voice = $ivr_menu_tts_voice; + $ivr->ivr_menu_confirm_attempts = $ivr_menu_confirm_attempts; + $ivr->ivr_menu_timeout = $ivr_menu_timeout; + $ivr->ivr_menu_exit_app = $ivr_menu_exit_app; + $ivr->ivr_menu_exit_data = $ivr_menu_exit_data; + $ivr->ivr_menu_inter_digit_timeout = $ivr_menu_inter_digit_timeout; + $ivr->ivr_menu_max_failures = $ivr_menu_max_failures; + $ivr->ivr_menu_max_timeouts = $ivr_menu_max_timeouts; + $ivr->ivr_menu_max_timeouts = $ivr_menu_max_timeouts; + $ivr->ivr_menu_digit_len = $ivr_menu_digit_len; + $ivr->ivr_menu_digit_len = $ivr_menu_digit_len; + $ivr->ivr_menu_direct_dial = $ivr_menu_direct_dial; + $ivr->ivr_menu_direct_dial = $ivr_menu_direct_dial; + $ivr->ivr_menu_enabled = $ivr_menu_enabled; + $ivr->ivr_menu_description = $ivr_menu_description; + + //add the data + if ($action == "add" && permission_exists('ivr_menu_add')) { + $ivr->ivr_menu_uuid = uuid(); + $ivr->dialplan_uuid = uuid(); + $ivr->add(); + + //synchronize the xml config + save_ivr_menu_xml(); + + //synchronize the xml config + save_dialplan_xml(); + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } + //update the data + if ($action == "update" && permission_exists('ivr_menu_edit')) { + $ivr->ivr_menu_uuid = $ivr_menu_uuid; + $ivr->update(); + + //synchronize the xml config + save_ivr_menu_xml(); + + //synchronize the xml config + save_dialplan_xml(); + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $ivr_menu_uuid = $_GET["id"]; + require_once "includes/classes/switch_ivr_menu.php"; + $ivr = new switch_ivr_menu; + $ivr->domain_uuid = $_SESSION["domain_uuid"]; + $ivr->ivr_menu_uuid = $ivr_menu_uuid; + $result = $ivr->find(); + $result_count = count($result); + foreach ($result as &$row) { + $ivr_menu_name = $row["ivr_menu_name"]; + $ivr_menu_extension = $row["ivr_menu_extension"]; + $ivr_menu_greet_long = $row["ivr_menu_greet_long"]; + $ivr_menu_greet_short = $row["ivr_menu_greet_short"]; + $ivr_menu_invalid_sound = $row["ivr_menu_invalid_sound"]; + $ivr_menu_exit_sound = $row["ivr_menu_exit_sound"]; + $ivr_menu_confirm_macro = $row["ivr_menu_confirm_macro"]; + $ivr_menu_confirm_key = $row["ivr_menu_confirm_key"]; + $ivr_menu_tts_engine = $row["ivr_menu_tts_engine"]; + $ivr_menu_tts_voice = $row["ivr_menu_tts_voice"]; + $ivr_menu_confirm_attempts = $row["ivr_menu_confirm_attempts"]; + $ivr_menu_timeout = $row["ivr_menu_timeout"]; + $ivr_menu_exit_app = $row["ivr_menu_exit_app"]; + $ivr_menu_exit_data = $row["ivr_menu_exit_data"]; + $ivr_menu_inter_digit_timeout = $row["ivr_menu_inter_digit_timeout"]; + $ivr_menu_max_failures = $row["ivr_menu_max_failures"]; + $ivr_menu_max_timeouts = $row["ivr_menu_max_timeouts"]; + $ivr_menu_digit_len = $row["ivr_menu_digit_len"]; + $ivr_menu_direct_dial = $row["ivr_menu_direct_dial"]; + $ivr_menu_enabled = $row["ivr_menu_enabled"]; + $ivr_menu_description = $row["ivr_menu_description"]; + + if (strlen($ivr_menu_exit_app) > 0) { + $ivr_menu_exit_action = $ivr_menu_exit_app.":".$ivr_menu_exit_data; + } + break; //limit to 1 row + } + unset ($prep_statement); + } + +//set defaults + if (strlen($ivr_menu_timeout) == 0) { $ivr_menu_timeout = '3000'; } + if (strlen($ivr_menu_invalid_sound) == 0) { $ivr_menu_invalid_sound = 'ivr/ivr-that_was_an_invalid_entry.wav'; } + if (strlen($ivr_menu_tts_engine) == 0) { $ivr_menu_tts_engine = 'flite'; } + if (strlen($ivr_menu_tts_voice) == 0) { $ivr_menu_tts_voice = 'rms'; } + if (strlen($ivr_menu_confirm_attempts) == 0) { $ivr_menu_confirm_attempts = '3'; } + if (strlen($ivr_menu_inter_digit_timeout) == 0) { $ivr_menu_inter_digit_timeout = '2000'; } + if (strlen($ivr_menu_max_failures) == 0) { $ivr_menu_max_failures = '3'; } + if (strlen($ivr_menu_max_timeouts) == 0) { $ivr_menu_max_timeouts = '3'; } + if (strlen($ivr_menu_digit_len) == 0) { $ivr_menu_digit_len = '5'; } + if (strlen($ivr_menu_direct_dial) == 0) { $ivr_menu_direct_dial = 'false'; } + if (strlen($ivr_menu_enabled) == 0) { $ivr_menu_enabled = 'true'; } + +//content + require_once "includes/header.php"; + + echo ""; + + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + //--- begin: show_advanced ----------------------- + echo "\n"; + echo "\n"; + echo "\n"; + //--- end: show_advanced ----------------------- + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
IVR Menu AddIVR Menu Edit\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "The IVR Menu plays a recording or a pre-defined phrase that presents the caller with options to choose from. Each option has a corresponding destination. The destinations can be extensions, voicemail, IVR menus, hunt groups, FAX extensions, and more.

\n"; + echo "
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter a name for the IVR menu.\n"; + echo "
\n"; + echo " Extension:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the extension number. \n"; + echo "
\n"; + echo " Greet Long:\n"; + echo "\n"; + + if (if_group("superadmin")) { + echo "\n"; + echo "\n"; + } + if (if_group("superadmin")) { + echo " \n"; + } + echo " \n"; + //misc optgroup + if (if_group("superadmin")) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + } + //recordings + if($dh = opendir($_SESSION['switch']['recordings']['dir']."/")) { + $tmp_selected = false; + $files = Array(); + echo "\n"; + while($file = readdir($dh)) { + if($file != "." && $file != ".." && $file[0] != '.') { + if(is_dir($_SESSION['switch']['recordings']['dir'] . "/" . $file)) { + //this is a directory + } + else { + if ($ivr_menu_greet_long == $_SESSION['switch']['recordings']['dir']."/".$file && strlen($ivr_menu_greet_long) > 0) { + $tmp_selected = true; + echo " \n"; + } + else { + echo " \n"; + } + } + } + } + closedir($dh); + echo "\n"; + } + //sounds + //$dir_path = $_SESSION['switch']['sounds']['dir']; + //recur_sounds_dir($_SESSION['switch']['sounds']['dir']); + //echo "\n"; + //foreach ($dir_array as $key => $value) { + // if (strlen($value) > 0) { + // $tmp_dir = "\$\${sounds_dir}/\${default_language}/\${default_dialect}/\${default_voice}"; + // if ($ivr_menu_greet_long == $tmp_dir.'/'.$key) { + // $tmp_selected = true; + // echo " \n"; + // } + // else { + // echo " \n"; + // } + // } + //} + //echo "\n"; + //select + if (if_group("superadmin")) { + if (!$tmp_selected) { + echo "\n"; + if (file_exists($_SESSION['switch']['recordings']['dir']."/".$ivr_menu_greet_long)) { + echo " \n"; + } elseif (substr($ivr_menu_greet_long, -3) == "wav" || substr($ivr_menu_greet_long, -3) == "mp3") { + $tmp_dir = "\$\${sounds_dir}/\${default_language}/\${default_dialect}/\${default_voice}"; + echo " \n"; + } else { + echo " \n"; + } + + echo "\n"; + } + unset($tmp_selected); + } + echo " \n"; + + echo "
\n"; + echo "The long greeting is played when entering the menu.\n"; + echo "
\n"; + echo " Greet Short:\n"; + echo "\n"; + + echo "\n"; + echo " \n"; + + echo "
\n"; + echo "The short greeting is played when returning to the menu.\n"; + echo "
\n"; + echo " Timeout:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "The number of milliseconds to wait after playing the greeting or the confirm macro.\n"; + echo "
\n"; + echo " Exit Action:\n"; + echo "\n"; + //switch_select_destination(select_type, select_label, select_name, select_value, select_style, action); + switch_select_destination("dialplan", "", "ivr_menu_exit_action", $ivr_menu_exit_action, "", ""); + echo "
\n"; + echo " Select the exit action to be performed if the IVR exits.\n"; + echo "
\n"; + echo " Direct Dial:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Define whether callers can dial directly to extensions and feature codes.\n"; + echo "
\n"; + + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Show Advanced\n"; + echo " \n"; + echo "
\n"; + echo "
\n"; + + echo "
\n"; + echo " \n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo " Invalid Sound:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Played when and invalid option is chosen.\n"; + echo "
\n"; + echo " Exit Sound:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Played when leaving the menu.\n"; + echo "
\n"; + echo " Confirm Macro:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the confirm macro.\n"; + echo "
\n"; + echo " Confirm Key:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the confirm key.\n"; + echo "
\n"; + echo " TTS Engine:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Text to speech engine.\n"; + echo "
\n"; + echo " TTS Voice:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Text to speech voice.\n"; + echo "
\n"; + echo " Confirm Attempts:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "The maximum number of confirm attempts allowed.\n"; + echo "
\n"; + echo " Inter Digit Timeout:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "The number of milliseconds to wait between digits.\n"; + echo "
\n"; + echo " Max Failures:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Maximum number of retries before exit.\n"; + echo "
\n"; + echo " Max Timeouts:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Maximum number of timeouts before exit.\n"; + echo "
\n"; + echo " Digit Length:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Maximum number of digits allowed.\n"; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo " Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Define whether the IVR Menu is enabled or disabled.\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter a description.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + if ($action == "update") { + require "v_ivr_menu_options.php"; + } + + echo "
"; + echo "
"; + +require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/ivr_menu/v_ivr_menu_options.php b/app/ivr_menu/v_ivr_menu_options.php new file mode 100644 index 0000000000..2ee3a80e88 --- /dev/null +++ b/app/ivr_menu/v_ivr_menu_options.php @@ -0,0 +1,181 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('ivr_menu_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +require_once "includes/paging.php"; + +//get the http values and set them as variables + if (isset($_GET["order_by"])) { + $order_by = check_str($_GET["order_by"]); + $order = check_str($_GET["order"]); + } + +//begin content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
IVR Menu Option List 
\n"; + echo "The recording presents options to the caller. Options match key presses (DTMF digits) from the caller which directs the call to the destinations.

\n"; + echo "
\n"; + +//get the number of rows in v_ivr_menu_options + $sql = ""; + $sql .= " select count(*) as num_rows from v_ivr_menu_options "; + $sql .= " where domain_uuid = '$domain_uuid' "; + $sql .= " and ivr_menu_uuid = '$ivr_menu_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + unset($prep_statement, $result); + +//prepare to page the results + $rows_per_page = 150; + $param = $_SERVER["QUERY_STRING"]; + if (!isset($_GET['page'])) { $_GET['page'] = 0; } + $_GET['page'] = check_str($_GET['page']); + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $_GET['page']; + +//get the menu options + $sql = ""; + $sql .= "select * from v_ivr_menu_options "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and ivr_menu_uuid = '$ivr_menu_uuid' "; + $sql .= "order by ivr_menu_option_digits, ivr_menu_option_order asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if ($result_count == 0) { + //no results + } + else { //received results + foreach($result as $row) { + $ivr_menu_option_param = $row['ivr_menu_option_param']; + if (strlen(trim($ivr_menu_option_param)) == 0) { + $ivr_menu_option_param = $row['ivr_menu_option_action']; + } + $ivr_menu_option_param = str_replace("menu-", "", $ivr_menu_option_param); + $ivr_menu_option_param = str_replace("XML", "", $ivr_menu_option_param); + $ivr_menu_option_param = str_replace("\${domain_name}", "", $ivr_menu_option_param); + $ivr_menu_option_param = str_replace("\${domain}", "", $ivr_menu_option_param); + $ivr_menu_option_param = ucfirst(trim($ivr_menu_option_param)); + + echo "\n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
OptionDestinationOrderDescription\n"; + if (permission_exists('ivr_menu_add')) { + echo " $v_link_label_add\n"; + } + echo "
".$row['ivr_menu_option_digits']."".$row['ivr_menu_option_action']."".$ivr_menu_option_param."".$row['ivr_menu_option_order']." ".$row['ivr_menu_option_description']." \n"; + if (permission_exists('ivr_menu_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('ivr_menu_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('ivr_menu_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
"; + + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +?> diff --git a/app/ivr_menu/v_ivr_menu_options_delete.php b/app/ivr_menu/v_ivr_menu_options_delete.php new file mode 100644 index 0000000000..c4d23d073b --- /dev/null +++ b/app/ivr_menu/v_ivr_menu_options_delete.php @@ -0,0 +1,66 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('ivr_menu_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//set the http values as variables + if (count($_GET)>0) { + $id = check_str($_GET["id"]); + $ivr_menu_uuid = check_str($_GET["ivr_menu_uuid"]); + } + +//delete the ivr menu option + if (strlen($id)>0) { + //include the ivr menu class + require_once "includes/classes/database.php"; + require_once "includes/classes/switch_ivr_menu.php"; + $ivr = new switch_ivr_menu; + $ivr->domain_uuid = $_SESSION["domain_uuid"]; + $ivr->ivr_menu_option_uuid = $id; + $ivr->delete(); + + //synchronize the xml config + save_ivr_menu_xml(); + } + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/ivr_menu/v_ivr_menu_options_edit.php b/app/ivr_menu/v_ivr_menu_options_edit.php new file mode 100644 index 0000000000..62a5466984 --- /dev/null +++ b/app/ivr_menu/v_ivr_menu_options_edit.php @@ -0,0 +1,361 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('ivr_menu_add') || permission_exists('ivr_menu_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $ivr_menu_option_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get the menu id + if (strlen($_GET["ivr_menu_uuid"]) > 0) { + $ivr_menu_uuid = check_str($_GET["ivr_menu_uuid"]); + } + +//get the http post variables and set them to php variables + if (count($_POST)>0) { + //$domain_uuid = check_str($_POST["domain_uuid"]); + $ivr_menu_uuid = check_str($_POST["ivr_menu_uuid"]); + $ivr_menu_option_digits = check_str($_POST["ivr_menu_option_digits"]); + $ivr_menu_option_action = check_str($_POST["ivr_menu_option_action"]); + $ivr_menu_option_param = check_str($_POST["ivr_menu_option_param"]); + $ivr_menu_option_order = check_str($_POST["ivr_menu_option_order"]); + $ivr_menu_option_description = check_str($_POST["ivr_menu_option_description"]); + + //set the default ivr_menu_option_action + if (strlen($ivr_menu_option_action) == 0) { + $ivr_menu_option_action = "menu-exec-app"; + } + + //seperate the action and the param + $options_array = explode(":", $ivr_menu_option_param); + $ivr_menu_option_action = array_shift($options_array); + $ivr_menu_option_param = join(':', $options_array); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $ivr_menu_option_uuid = check_str($_POST["ivr_menu_option_uuid"]); + } + + //check for all required data + //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + //if (strlen($ivr_menu_uuid) == 0) { $msg .= "Please provide: ivr_menu_uuid
\n"; } + if (strlen($ivr_menu_option_digits) == 0) { $msg .= "Please provide: Option
\n"; } + //if (strlen($ivr_menu_option_action) == 0) { $msg .= "Please provide: Type
\n"; } + //if (strlen($ivr_menu_option_param) == 0) { $msg .= "Please provide: Destination
\n"; } + if (strlen($ivr_menu_option_order) == 0) { $msg .= "Please provide: Order
\n"; } + //if (strlen($ivr_menu_option_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + //create the object + require_once "includes/classes/database.php"; + require_once "includes/classes/switch_ivr_menu.php"; + $ivr = new switch_ivr_menu; + $ivr->domain_uuid = $_SESSION["domain_uuid"]; + $ivr->ivr_menu_uuid = $ivr_menu_uuid; + $ivr->ivr_menu_option_uuid = $ivr_menu_option_uuid; + $ivr->ivr_menu_option_digits = $ivr_menu_option_digits; + $ivr->ivr_menu_option_action = $ivr_menu_option_action; + $ivr->ivr_menu_option_param = $ivr_menu_option_param; + $ivr->ivr_menu_option_order = $ivr_menu_option_order; + $ivr->ivr_menu_option_description = $ivr_menu_option_description; + + if ($action == "add" && permission_exists('ivr_menu_add')) { + $ivr_menu_option_uuid = uuid(); + $ivr->ivr_menu_option_uuid = $ivr_menu_option_uuid; + $ivr->add(); + + //synchronize the xml config + save_ivr_menu_xml(); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update" && permission_exists('ivr_menu_edit')) { + $ivr->ivr_menu_option_uuid = $ivr_menu_option_uuid; + $ivr->update(); + + //synchronize the xml config + save_ivr_menu_xml(); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $ivr_menu_option_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_ivr_menu_options "; + $sql .= "where ivr_menu_option_uuid = '$ivr_menu_option_uuid' "; + $sql .= "and domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $domain_uuid = $row["domain_uuid"]; + $ivr_menu_uuid = $row["ivr_menu_uuid"]; + $ivr_menu_option_digits = $row["ivr_menu_option_digits"]; + $ivr_menu_option_action = $row["ivr_menu_option_action"]; + $ivr_menu_option_param = $row["ivr_menu_option_param"]; + + //if admin show only the param + if (if_group("admin")) { + $ivr_menu_options_label = $ivr_menu_option_param; + } + + //if superadmin show both the action and param + if (if_group("superadmin")) { + $ivr_menu_options_label = $ivr_menu_option_action.':'.$ivr_menu_option_param; + } + + $ivr_menu_option_order = $row["ivr_menu_option_order"]; + $ivr_menu_option_description = $row["ivr_menu_option_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//send the content to the browser + require_once "includes/header.php"; + + echo "
"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + /* + if (if_group("superadmin")) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + */ + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + + echo "
IVR Menu Option AddIVR Menu Option Edit
\n"; + echo "The recording presents options to the caller. Options match key presses (DTMF digits) from the caller which directs the call to the destinations.

\n"; + echo "
\n"; + echo " Option:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Any number between 1-5 digits or regular expressions.\n"; + echo "
\n"; + echo " Type:\n"; + echo "\n"; + + echo " \n"; + + echo "
\n"; + echo "The type is required when a custom destination is defined. \n"; + echo "
\n"; + echo " Destination:\n"; + echo "\n"; + + //switch_select_destination($select_type, $select_label, $select_name, $select_value, $select_style, $action='') + $tmp_select_value = ''; + if (strlen($ivr_menu_option_action.$ivr_menu_option_param) > 0) { + $tmp_select_value = $ivr_menu_option_action.':'.$ivr_menu_option_param; + } + switch_select_destination("ivr", $ivr_menu_options_label, "ivr_menu_option_param", $tmp_select_value, "", $ivr_menu_option_action); + unset($tmp_select_value); + + echo "
\n"; + echo "Select the destination.\n"; + echo "
\n"; + echo " Order:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Select the order.\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter a description here for your reference.\n"; + echo "
\n"; + echo " \n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + + echo "
\n"; + echo "
\n"; + +require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/log_viewer/app_config.php b/app/log_viewer/app_config.php new file mode 100644 index 0000000000..e049d7a3d6 --- /dev/null +++ b/app/log_viewer/app_config.php @@ -0,0 +1,27 @@ + \ No newline at end of file diff --git a/app/log_viewer/log_viewer.php b/app/log_viewer/log_viewer.php new file mode 100644 index 0000000000..2259b5ea8b --- /dev/null +++ b/app/log_viewer/log_viewer.php @@ -0,0 +1,250 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane + James Rose +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('log_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//define variables + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + +//set a default file size + if (strlen($_POST['fs']) == 0) { $_POST['fs'] = "32"; } + +if (permission_exists('log_download')) { + if ($_GET['a'] == "download") { + if ($_GET['t'] == "logs") { + $tmp = $_SESSION['switch']['log']['dir'].'/'; + $filename = 'freeswitch.log'; + } + session_cache_limiter('public'); + $fd = fopen($tmp.$filename, "rb"); + header("Content-Type: binary/octet-stream"); + header("Content-Length: " . filesize($tmp.$filename)); + header('Content-Disposition: attachment; filename="'.$filename.'"'); + fpassthru($fd); + exit; + } +} + +require_once "includes/header.php"; + +echo "
\n"; +echo "
\n"; + +echo "\n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "\n"; +echo "
\n"; +echo " Log Viewer
\n"; +echo "
\n"; +echo " \n"; +echo " \n"; +echo " \n"; +if (permission_exists('log_download')) { + echo " \n"; +} +echo "
"; + +if (permission_exists('log_view')) { + + $MAXEL = 3; //pattern2, pattern3|color2, color3 etc... + + $user_filesize = '0'; + $default_color = 'white'; + $default_type = 'normal'; + $default_font = 'monospace'; + $background_color = 'black'; + $default_fsize = '512000'; + $log_file = $_SESSION['switch']['log']['dir']."/freeswitch.log"; + + //put the color matches here... + $arr_filter[0]['pattern'] = '[NOTICE]'; + $arr_filter[0]['color'] = 'cyan'; + $arr_filter[0]['type'] = 'normal'; + $arr_filter[0]['font'] = 'monospace'; + + $arr_filter[1]['pattern'] = '[INFO]'; + $arr_filter[1]['color'] = 'chartreuse'; + $arr_filter[1]['type'] = 'normal'; + $arr_filter[1]['font'] = 'monospace'; + + $arr_filter[2]['pattern'] = 'Dialplan:'; + $arr_filter[2]['color'] = 'burlywood'; + $arr_filter[2]['type'] = 'normal'; + $arr_filter[2]['font'] = 'monospace'; + $arr_filter[2]['pattern2'] = 'Regex (PASS)'; + $arr_filter[2]['color2'] = 'chartreuse'; + $arr_filter[2]['pattern3'] = 'Regex (FAIL)'; + $arr_filter[2]['color3'] = 'red'; + + $arr_filter[3]['pattern'] = '[WARNING]'; + $arr_filter[3]['color'] = 'fuchsia'; + $arr_filter[3]['type'] = 'normal'; + $arr_filter[3]['font'] = 'monospace'; + + $arr_filter[4]['pattern'] = '[ERR]'; + $arr_filter[4]['color'] = 'red'; + $arr_filter[4]['type'] = 'bold'; + $arr_filter[4]['font'] = 'monospace'; + + $arr_filter[5]['pattern'] = '[DEBUG]'; + $arr_filter[5]['color'] = 'gold'; + $arr_filter[5]['type'] = 'bold'; + $arr_filter[5]['font'] = 'monospace'; + + $file_size = filesize($log_file); + + if (isset($_POST['submit'])) { + if (strlen($_POST['fs']) == 0) { $_POST['fs'] = "32"; } + } + + echo ""; + echo ""; + echo ""; +} + +echo "
Syntax Highlighted
"; + + $user_filesize = '32000'; + if (isset($_POST['submit'])) { + if (!is_numeric($_POST['fs'])){ + echo ""; + echo "Just what do you think you're doing, Dave?
"; + echo "
"; + //should generate log warning here... + $user_filesize='1000'; + } + else { + $user_filesize = $_POST['fs'] * 1000; + } + } + + //echo "Log File Size: " . $file_size . " bytes.
"; + echo "Viewing the last " . $user_filesize . " of " . $file_size . " bytes.

"; + + $file = fopen($log_file, "r") or exit("Unable to open file!"); + + //set pointer in file + if ($user_filesize >= '0') { + if ($user_filesize == '0'){ + $user_filesize = $default_fsize; + } + if ( $file_size >= $user_filesize ){ + //set an offset on fopen + $bytecount=$file_size-$user_filesize; + fseek($file, $bytecount); + //echo "opening at " . $bytecount . " bytes
"; + } + else { + if ( $file_size >= $default_fsize ){ + //set an offset on fopen + $bytecount=$file_size-$default_fsize; + fseek($file, $bytecount); + echo "opening at " . $bytecount . " bytes
"; + } + else { + //open the file + $bytecount='0'; + fseek($file, 0); + echo "
opening entire file
"; + } + } + } + else { + if ( $file_size >= $default_fsize ){ + //set an offset on fopen + $bytecount=$file_size-$default_fsize; + fseek($file, $bytecount); + echo "opening at " . $bytecount . " bytes
"; + } + else { + //open the file + $bytecount='0'; + fseek($file, 0); + echo "
opening entire file
"; + } + } + + //start processing + while(!feof($file)) + { + $log_line = fgets($file); + $byte_count++; + $noprint = false; + foreach ($arr_filter as $v1) { + $pos = strpos($log_line, $v1['pattern']); + //echo "
POS is: '$pos'
"; + if ($pos !== false){ + //color adjustments on words in log line + for ($i=2; $i<=$MAXEL; $i++){ + if (isset ($v1["pattern".$i])){ + $log_line = str_replace($v1["pattern".$i], "{$v1["pattern".$i]}", $log_line); + } + } + + echo "" ; + /* testing to see if style is what crashes firefox on large logfiles... + echo "

";*/ + echo $log_line; + echo "
"; + $noprint = true; + } + } + if ($noprint !== true){ + //more firefox workaround... + //echo "

"; + echo "" ; + echo $log_line; + //echo "

"; + echo "
"; + } + } + + fclose($file); + echo "
\n"; +echo "\n"; + +require_once "includes/footer.php"; + +?> diff --git a/app/log_viewer/root.php b/app/log_viewer/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/log_viewer/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/modules/app_config.php b/app/modules/app_config.php new file mode 100644 index 0000000000..e17f943224 --- /dev/null +++ b/app/modules/app_config.php @@ -0,0 +1,87 @@ + \ No newline at end of file diff --git a/app/modules/app_defaults.php b/app/modules/app_defaults.php new file mode 100644 index 0000000000..e8ee87f902 --- /dev/null +++ b/app/modules/app_defaults.php @@ -0,0 +1,39 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//use the module class to get the list of modules from the db and add any missing modules + require_once "includes/classes/switch_modules.php"; + $mod = new switch_modules; + $mod->db = $db; + $mod->dir = $_SESSION['switch']['mod']['dir']; + $mod->get_modules(); + $mod->synch(); + $msg = $mod->msg; + +// synchronize the modules + save_module_xml(); + +?> \ No newline at end of file diff --git a/app/modules/root.php b/app/modules/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/modules/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/modules/v_modules.php b/app/modules/v_modules.php new file mode 100644 index 0000000000..206a0ebf70 --- /dev/null +++ b/app/modules/v_modules.php @@ -0,0 +1,221 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('modules_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + +$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); +if (strlen($_GET["a"]) > 0) { + if ($_GET["a"] == "stop") { + $module_name = $_GET["m"]; + if ($fp) { + $cmd = "api unload $module_name"; + $response = trim(event_socket_request($fp, $cmd)); + $msg = 'Unload Module:
'.$response.'
'; + } + } + if ($_GET["a"] == "start") { + $module_name = $_GET["m"]; + if ($fp) { + $cmd = "api load $module_name"; + $response = trim(event_socket_request($fp, $cmd)); + $msg = 'Load Module:
'.$response.'
'; + } + } +} + +//use the module class to get the list of modules from the db and add any missing modules + require_once "includes/classes/switch_modules.php"; + $mod = new switch_modules; + $mod->db = $db; + $mod->dir = $_SESSION['switch']['mod']['dir']; + $mod->get_modules(); + $result = $mod->modules; + $module_count = count($result); + $mod->synch(); + $msg = $mod->msg; + +//show the msg + if ($msg) { + save_module_xml(); + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Message
$msg
\n"; + echo "
\n"; + } + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Module List 
\n"; + echo "Modules extend the features of the system. Use this page to enable or disable modules. "; + echo "
\n"; + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + $tmp_module_header = "\n"; + $tmp_module_header .= "\n"; + //$tmp_module_header .= "\n"; + $tmp_module_header .= "\n"; + //$tmp_module_header .= "\n"; + $tmp_module_header .= "\n"; + $tmp_module_header .= "\n"; + $tmp_module_header .= "\n"; + $tmp_module_header .= "\n"; + //$tmp_module_header .= "\n"; + $tmp_module_header .= "\n"; + $tmp_module_header .= "\n"; + + if ($module_count > 0) { + $prev_module_category = ''; + foreach($result as $row) { + if ($prev_module_category != $row["module_category"]) { + $c=0; + if (strlen($prev_module_category) > 0) { + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "\n"; + echo $tmp_module_header; + } + + echo "\n"; + //echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + if ($mod->active($row["module_name"])) { + echo " \n"; + echo " \n"; + } + else { + if ($row['module_enabled']=="true") { + echo " \n"; + } + else { + echo " \n"; + } + echo " \n"; + } + echo " \n"; + //echo " \n"; + echo " \n"; + echo "\n"; + + $prev_module_category = $row["module_category"]; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $modules, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
Module CategoryLabelModule NameDescriptionStatusActionEnabledDefault Enabled\n"; + $tmp_module_header .= " $v_link_label_add\n"; + $tmp_module_header .= "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
  \n"; + if (permission_exists('modules_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo " ".$row["module_category"]." 
".$row["module_category"]."".$row["module_label"]."".$row["module_name"]."".$row["module_description"]." RunningStopStoppedStopped $noticeStart".$row["module_enabled"]."".$row["module_default_enabled"]."\n"; + if (permission_exists('modules_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('modules_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('modules_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//show the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/modules/v_modules_delete.php b/app/modules/v_modules_delete.php new file mode 100644 index 0000000000..7da66272ec --- /dev/null +++ b/app/modules/v_modules_delete.php @@ -0,0 +1,58 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('modules_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = $_GET["id"]; +} + +if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_modules "; + $sql .= "where module_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); +} + +require_once "includes/header.php"; +echo "\n"; +echo "
\n"; +echo "Delete Complete\n"; +echo "
\n"; +require_once "includes/footer.php"; +return; + +?> \ No newline at end of file diff --git a/app/modules/v_modules_edit.php b/app/modules/v_modules_edit.php new file mode 100644 index 0000000000..f56396c548 --- /dev/null +++ b/app/modules/v_modules_edit.php @@ -0,0 +1,304 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('modules_add') || permission_exists('modules_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//determin the action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $module_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//set the http post variables to php variables + if (count($_POST)>0) { + $module_label = check_str($_POST["module_label"]); + $module_name = check_str($_POST["module_name"]); + $module_description = check_str($_POST["module_description"]); + $module_category = check_str($_POST["module_category"]); + $module_enabled = check_str($_POST["module_enabled"]); + $module_default_enabled = check_str($_POST["module_default_enabled"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $module_uuid = check_str($_POST["module_uuid"]); + } + + //check for all required data + if (strlen($module_label) == 0) { $msg .= "Please provide: Label
\n"; } + if (strlen($module_name) == 0) { $msg .= "Please provide: Module Name
\n"; } + //if (strlen($module_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($module_category) == 0) { $msg .= "Please provide: Module Category
\n"; } + if (strlen($module_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } + if (strlen($module_default_enabled) == 0) { $msg .= "Please provide: Default Enabled
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('modules_add')) { + $module_uuid = uuid(); + $sql = "insert into v_modules "; + $sql .= "("; + $sql .= "module_uuid, "; + $sql .= "module_label, "; + $sql .= "module_name, "; + $sql .= "module_description, "; + $sql .= "module_category, "; + $sql .= "module_enabled, "; + $sql .= "module_default_enabled "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$module_uuid', "; + $sql .= "'$module_label', "; + $sql .= "'$module_name', "; + $sql .= "'$module_description', "; + $sql .= "'$module_category', "; + $sql .= "'$module_enabled', "; + $sql .= "'$module_default_enabled' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + save_module_xml(); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update" && permission_exists('modules_edit')) { + $sql = "update v_modules set "; + $sql .= "module_label = '$module_label', "; + $sql .= "module_name = '$module_name', "; + $sql .= "module_description = '$module_description', "; + $sql .= "module_category = '$module_category', "; + $sql .= "module_enabled = '$module_enabled', "; + $sql .= "module_default_enabled = '$module_default_enabled' "; + $sql .= "where module_uuid = '$module_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + + save_module_xml(); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $module_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_modules "; + $sql .= "where module_uuid = '$module_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $module_label = $row["module_label"]; + $module_name = $row["module_name"]; + $module_description = $row["module_description"]; + $module_category = $row["module_category"]; + $module_enabled = $row["module_enabled"]; + $module_default_enabled = $row["module_default_enabled"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Module AddModule Update
\n"; + echo " Label:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Module Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Module Category:\n"; + echo "\n"; + $table_name = 'v_modules';$field_name = 'module_category';$sql_where_optional = "";$field_current_value = $module_category; + echo html_select_other($db, $table_name, $field_name, $sql_where_optional, $field_current_value); + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Default Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + + echo "
"; + echo "
"; + + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/music_on_hold/app_config.php b/app/music_on_hold/app_config.php new file mode 100644 index 0000000000..386febf7c1 --- /dev/null +++ b/app/music_on_hold/app_config.php @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/app/music_on_hold/root.php b/app/music_on_hold/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/music_on_hold/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/music_on_hold/slim.swf b/app/music_on_hold/slim.swf new file mode 100644 index 0000000000..24b36c9daf Binary files /dev/null and b/app/music_on_hold/slim.swf differ diff --git a/app/music_on_hold/v_music_on_hold.php b/app/music_on_hold/v_music_on_hold.php new file mode 100644 index 0000000000..1b186c2f55 --- /dev/null +++ b/app/music_on_hold/v_music_on_hold.php @@ -0,0 +1,228 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('music_on_hold_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +require_once "includes/paging.php"; + +$dir_music_on_hold_8000 = $_SESSION['switch']['sounds']['dir'].'/music/8000'; +ini_set(max_execution_time,7200); + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + +if ($_GET['a'] == "download") { + session_cache_limiter('public'); + if ($_GET['type'] = "moh") { + if (file_exists($dir_music_on_hold_8000."/".base64_decode($_GET['filename']))) { + $fd = fopen($dir_music_on_hold_8000."/".base64_decode($_GET['filename']), "rb"); + if ($_GET['t'] == "bin") { + header("Content-Type: application/force-download"); + header("Content-Type: application/octet-stream"); + header("Content-Type: application/download"); + header("Content-Description: File Transfer"); + header('Content-Disposition: attachment; filename="'.base64_decode($_GET['filename']).'"'); + } + else { + $file_ext = substr(base64_decode($_GET['filename']), -3); + if ($file_ext == "wav") { + header("Content-Type: audio/x-wav"); + } + if ($file_ext == "mp3") { + header("Content-Type: audio/mp3"); + } + } + header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 + header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past + header("Content-Length: " . filesize($dir_music_on_hold_8000."/".base64_decode($_GET['filename']))); + fpassthru($fd); + } + } + exit; +} + + +if (($_POST['submit'] == "Upload") && is_uploaded_file($_FILES['ulfile']['tmp_name'])) { + if ($_POST['type'] == 'moh' && permission_exists('music_on_hold_add')) { + move_uploaded_file($_FILES['ulfile']['tmp_name'], $dir_music_on_hold_8000."/".$_FILES['ulfile']['name']); + $savemsg = "Uploaded file to ".$dir_music_on_hold_8000."/".htmlentities($_FILES['ulfile']['name']); + //system('chmod -R 744 $dir_music_on_hold_8000*'); + unset($_POST['txtCommand']); + } +} + + +if ($_GET['act'] == "del" && permission_exists('music_on_hold_delete')) { + if ($_GET['type'] == 'moh') { + unlink($dir_music_on_hold_8000."/".base64_decode($_GET['filename'])); + header("Location: v_music_on_hold.php"); + exit; + } +} + +//include the header + require_once "includes/header.php"; + +//begin the content + echo ""; + + echo "
"; + echo "\n"; + echo "\n"; + echo ""; + echo ""; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "

\n"; + echo " Music on Hold
\n"; + echo " Music on hold can be in WAV or MP3 format. To play an MP3 file you must have\n"; + echo " mod_shout enabled on the 'Modules' tab. You can adjust the volume of the MP3\n"; + echo " audio from the 'Settings' tab. For best performance upload 16bit 8khz/16khz Mono WAV files.\n"; + echo "

\n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + if (permission_exists('music_on_hold_add')) { + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
"; + + if ($v_path_show) { + echo "location: "; + echo $dir_music_on_hold_8000; + } + + echo " \n"; + echo " \n"; + echo " \n"; + echo " File to upload:\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + } + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " "; + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + if ($handle = opendir($dir_music_on_hold_8000)) { + while (false !== ($file = readdir($handle))) { + if ($file != "." && $file != ".." && is_file($dir_music_on_hold_8000."/".$file)) { + + $tmp_filesize = filesize($dir_music_on_hold_8000."/".$file); + $tmp_filesize = byte_convert($tmp_filesize); + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + + } + } + closedir($handle); + } + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
File Name (download)Name (play)Last ModifiedSize 
\n"; + echo " \n"; + echo " $file"; + echo " "; + echo " \n"; + echo " \n"; + $tmp_file_array = explode("\.",$file); + echo " ".$tmp_file_array[0]; + echo " "; + echo " \n"; + echo date ("F d Y H:i:s", filemtime($dir_music_on_hold_8000."/".$file)); + echo " \n"; + echo " ".$tmp_filesize; + echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + if (permission_exists('music_on_hold_delete')) { + echo " \n"; + } + echo " \n"; + echo "
$v_link_label_delete
\n"; + echo "
\n"; + + echo "\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "includes/footer.php"; + +?> \ No newline at end of file diff --git a/app/music_on_hold/v_music_on_hold_play.php b/app/music_on_hold/v_music_on_hold_play.php new file mode 100644 index 0000000000..9993a9d537 --- /dev/null +++ b/app/music_on_hold/v_music_on_hold_play.php @@ -0,0 +1,78 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('music_on_hold_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$filename = base64_decode($_GET['filename']); +$type = $_GET['type']; //moh //rec + +?> + + + + + + + + + + + + +
+ file: +
+ "; + echo ""; + + echo "\n"; + + } + if ($file_ext == "mp3") { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + ?> +
+ + + diff --git a/app/php_edit/app_config.php b/app/php_edit/app_config.php new file mode 100644 index 0000000000..9b1681973f --- /dev/null +++ b/app/php_edit/app_config.php @@ -0,0 +1,61 @@ + \ No newline at end of file diff --git a/app/php_edit/app_defaults.php b/app/php_edit/app_defaults.php new file mode 100644 index 0000000000..0fac72d90f --- /dev/null +++ b/app/php_edit/app_defaults.php @@ -0,0 +1,66 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//if the number of rows is 0 then add example clips + $sql = "select count(*) as num_rows from v_clips "; + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] == 0) { + $clip_name = "\$_POST"; + $clip_folder = "PHP"; + $clip_text_start = "\$zzz = \$_POST[\""; + $clip_text_end = "\"];"; + $clip_desc = "Set HTTP POST value as a PHP variable."; + $clip_order = 0; + + $sql = "insert into v_clips "; + $sql .= "("; + $sql .= "clip_uuid, "; + $sql .= "clip_name, "; + $sql .= "clip_folder, "; + $sql .= "clip_text_start, "; + $sql .= "clip_text_end, "; + $sql .= "clip_desc, "; + $sql .= "clip_order "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$clip_name', "; + $sql .= "'$clip_folder', "; + $sql .= "'$clip_text_start', "; + $sql .= "'$clip_text_end', "; + $sql .= "'$clip_desc', "; + $sql .= "'$clip_order' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + } + +?> \ No newline at end of file diff --git a/app/php_edit/clipadd.php b/app/php_edit/clipadd.php new file mode 100644 index 0000000000..f060f81805 --- /dev/null +++ b/app/php_edit/clipadd.php @@ -0,0 +1,126 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_POST)>0) { + $clip_name = check_str($_POST["clip_name"]); + $clip_folder = check_str($_POST["clip_folder"]); + $clip_text_start = check_str($_POST["clip_text_start"]); + $clip_text_end = check_str($_POST["clip_text_end"]); + $clip_desc = check_str($_POST["clip_desc"]); + $clip_order = check_str($_POST["clip_order"]); + if (strlen($clip_order) == 0) { $clip_order = 0; } + + $sql = "insert into v_clips "; + $sql .= "("; + $sql .= "clip_uuid, "; + $sql .= "clip_name, "; + $sql .= "clip_folder, "; + $sql .= "clip_text_start, "; + $sql .= "clip_text_end, "; + $sql .= "clip_desc, "; + $sql .= "clip_order "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$clip_name', "; + $sql .= "'$clip_folder', "; + $sql .= "'$clip_text_start', "; + $sql .= "'$clip_text_end', "; + $sql .= "'$clip_desc', "; + $sql .= "'$clip_order' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql,$db); + + require_once "header.php"; + echo "\n"; + echo "Add Complete"; + require_once "footer.php"; + return; +} + +//show the content + require_once "header.php"; + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + + //echo "Clip Library"; + //echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo "
Name:
Folder:
Before Selection:
"; + echo " "; + echo "
After Selection:
"; + echo " "; + echo "
Notes:
"; + echo " "; + echo "
"; + echo "
"; + + echo "
"; + echo "
"; + + require_once "footer.php"; +?> \ No newline at end of file diff --git a/app/php_edit/clipdelete.php b/app/php_edit/clipdelete.php new file mode 100644 index 0000000000..2cb82b9666 --- /dev/null +++ b/app/php_edit/clipdelete.php @@ -0,0 +1,56 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the uuid from http values + $clip_uuid = check_str($_GET["id"]); + +//delete the clip + if (strlen($_GET["id"])>0) { + $sql = "delete from v_clips "; + $sql .= "where clip_uuid = '".$clip_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql,$db); + } + +//redirect the browser + require_once "header.php"; + echo "\n"; + echo "Delete Complete"; + require_once "footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/php_edit/cliplist.php b/app/php_edit/cliplist.php new file mode 100644 index 0000000000..39db5bcf52 --- /dev/null +++ b/app/php_edit/cliplist.php @@ -0,0 +1,235 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +//require_once "edit/header.php"; + +echo ""; +echo ""; +echo ""; + +function isfile($filename) { + if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function space($count) { + $r=''; $i=0; + while($i < $count) { + $r .= ' '; + $i++; + } + return $r; +} + +echo ""; + +echo ""; + +echo ""; +echo ""; +echo "
"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
Clip Library
\n"; //display:none + +$sql = "select * from v_clips "; +$sql .= "order by clip_folder "; +$prep_statement = $db->prepare(check_sql($sql)); +$prep_statement->execute(); +$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); +$result_count = count($result); + +if ($result_count > 0) { //no results + $last_folder = ''; + $tag_open = ''; + $x = 0; + $current_depth = 0; + $previous_depth = 0; + foreach($result as $row) { + $current_depth = count(explode ("/", $row['clip_folder'])); + if ($current_depth < $previous_depth) { + $count = ($previous_depth - $current_depth); + $i=0; + while($i < $count){ + echo "
\n"; + $i++; + } + echo "
\n"; + } + + if ($last_folder != $row['clip_folder']) { + $clip_folder_name = str_replace ($previous_folder_name, "", $row['clip_folder']); + $clip_folder_name = str_replace ("/", "", $clip_folder_name); + echo "
 ".$clip_folder_name."  
\n\n"; + $tag_open = 1; + } + + $previous_depth = $current_depth; + $previous_folder_name = $row['clip_folder']; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "".$row['clip_name']."\n"; + echo "
\n"; + echo "\n\n"; + + $last_folder = $row['clip_folder']; + + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + +} //end if results + +echo "\n"; +echo "
\n"; + +echo "
\n"; +echo "
"; + +echo "

"; +//require_once "includes/footer.php"; + +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); + +echo ""; +echo ""; + +?> \ No newline at end of file diff --git a/app/php_edit/clipoptions.php b/app/php_edit/clipoptions.php new file mode 100644 index 0000000000..b137b3b280 --- /dev/null +++ b/app/php_edit/clipoptions.php @@ -0,0 +1,71 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "header.php"; + +echo "
"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Selected Clip:
"; +echo " "; +echo ""; + +echo " "; +//echo " \n"; +//echo " \n"; +//echo " \n"; + +echo " \n"; +echo " \n"; +//echo " \n"; +echo " \n"; +echo " \n"; + +echo " \n"; +echo "
Options











"; + +echo "
"; +echo "
"; + +require_once "footer.php"; +?> \ No newline at end of file diff --git a/app/php_edit/clipoptionslist.php b/app/php_edit/clipoptionslist.php new file mode 100644 index 0000000000..ba406f8114 --- /dev/null +++ b/app/php_edit/clipoptionslist.php @@ -0,0 +1,228 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +echo ""; +echo ""; + +echo ""; + +function isfile($filename) { + if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function space($count) { + $r=''; $i=0; + while($i < $count) { + $r .= ' '; + $i++; + } + return $r; +} + +//show the content + echo ""; + + echo ""; + +echo ""; +echo ""; + + echo "
"; + echo "\n"; + + echo "\n"; + echo "
\n"; + echo "
Clip Library
\n"; //display:none + + $sql = "select * from v_clips "; + $sql .= "order by clip_folder "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + if ($result_count > 0) { //no results + $last_folder = ''; + $tag_open = ''; + $x = 0; + $current_depth = 0; + $previous_depth = 0; + foreach($result as $row) { + $current_depth = count(explode("/", $row[clip_folder])); + if ($current_depth < $previous_depth) { + $count = ($previous_depth - $current_depth); + $i=0; + while($i < $count){ + echo "
\n"; + $i++; + } + echo "
\n"; + + } + + if ($last_folder != $row['clip_folder']) { + $clip_folder_name = str_replace ($previous_folder_name, "", $row['clip_folder']); + $clip_folder_name = str_replace ("/", "", $clip_folder_name); + echo "
 ".$clip_folder_name."  
\n\n"; + $tag_open = 1; + } + + $previous_depth = $current_depth; + $previous_folder_name = $row['clip_folder']; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "".$row['clip_name']."\n"; + + echo "
\n"; + echo "\n\n"; + + $last_folder = $row['clip_folder']; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "
\n"; + + echo "
\n"; + echo "
"; + + echo "

"; + + unset ($result_count); + unset ($result); + unset ($key); + unset ($val); + unset ($c); + + echo ""; + echo ""; + +?> \ No newline at end of file diff --git a/app/php_edit/clipsearch.php b/app/php_edit/clipsearch.php new file mode 100644 index 0000000000..5db024d25b --- /dev/null +++ b/app/php_edit/clipsearch.php @@ -0,0 +1,180 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_POST)>0) { + $clip_uuid = $_POST["id"]; + $clip_name = $_POST["clip_name"]; + $clip_folder = $_POST["clip_folder"]; + $clip_text_start = $_POST["clip_text_start"]; + $clip_text_end = $_POST["clip_text_end"]; + $clip_desc = $_POST["clip_desc"]; + $clip_order = $_POST["clip_order"]; + + require_once "header.php"; + echo "
"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + + } //end if results + + echo "
\n"; + echo "
"; + + $sql .= "select * from v_clips "; + $sql .= "where "; + if (strlen($clip_uuid) > 0) { $sql .= "and id = '$clip_uuid' "; } + if (strlen($clip_name) > 0) { $sql .= "and clip_name like '%$clip_name%' "; } + if (strlen($clip_folder) > 0) { $sql .= "and clip_folder like '%$clip_folder%' "; } + if (strlen($clip_text_start) > 0) { $sql .= "and clip_text_start like '%$clip_text_start%' "; } + if (strlen($clip_text_end) > 0) { $sql .= "and clip_text_end like '%$clip_text_end%' "; } + if (strlen($clip_desc) > 0) { $sql .= "and clip_desc like '%$clip_desc%' "; } + if (strlen($clip_order) > 0) { $sql .= "and clip_order like '%$clip_order%' "; } + + $sql = trim($sql); + if (substr($sql, -5) == "where"){ $sql = substr($sql, 0, (strlen($sql)-5)); } + $sql = str_replace ("where and", "where", $sql); + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + $c = 0; + $row_style["0"] = "background-color: #F5F5DC;"; + $row_style["1"] = "background-color: #FFFFFF;"; + + echo "
\n"; + echo "\n"; + echo ""; + + if ($result_count == 0) { + //no results + echo ""; + } + else { //received results + echo ""; + //echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + echo "\n"; + + foreach($result as $row) { + //print_r( $row ); + echo "\n"; + //echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach unset($sql, $result, $row_count); + echo "
 
    Id        clip_name Search         clip_folder        clip_text_start        clip_text_end        clip_desc        clip_order   
".$row[id]."".$row[clip_name]."".$row[clip_folder]."".$row[clip_text_start]."".$row[clip_text_end]."".$row[clip_desc]."".$row[clip_order]."
\n"; + echo "
\n"; + + echo "

"; + echo "
\n"; + echo "
"; + echo "

"; + require_once "footer.php"; + + unset ($result_count); + unset ($result); + unset ($key); + unset ($val); + unset ($c); + +} +else { + + //show the content + require_once "header.php"; + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + echo " "; + echo " "; + echo " "; + echo "
Name:
Folder:
Start:
End:
Desc:
clip_order:
"; + echo "
"; + + echo "
"; + echo "
"; + + require_once "footer.php"; + +} //end if not post +?> diff --git a/app/php_edit/clipupdate.php b/app/php_edit/clipupdate.php new file mode 100644 index 0000000000..a93c10bdfe --- /dev/null +++ b/app/php_edit/clipupdate.php @@ -0,0 +1,138 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_POST)>0) { + $clip_uuid = check_str($_POST["id"]); + $clip_name = check_str($_POST["clip_name"]); + $clip_folder = check_str($_POST["clip_folder"]); + $clip_text_start = check_str($_POST["clip_text_start"]); + $clip_text_end = check_str($_POST["clip_text_end"]); + $clip_desc = check_str($_POST["clip_desc"]); + $clip_order = check_str($_POST["clip_order"]); + + //sql update + $sql = "update v_clips set "; + $sql .= "clip_name = '$clip_name', "; + $sql .= "clip_folder = '$clip_folder', "; + $sql .= "clip_text_start = '$clip_text_start', "; + $sql .= "clip_text_end = '$clip_text_end', "; + $sql .= "clip_desc = '$clip_desc', "; + $sql .= "clip_order = '$clip_order' "; + $sql .= "where clip_uuid = '$clip_uuid' "; + $count = $db->exec(check_sql($sql)); + //echo "affected rows: ".$count; + + //redirect the browser + require_once "header.php"; + echo "\n"; + echo "Update Complete"; + require_once "footer.php"; + return; +} +else { + //get the uuid from http values + $clip_uuid = check_str($_GET["id"]); + + //get the clip + $sql = "select * from v_clips "; + $sql .= "where clip_uuid = '$clip_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $clip_name = $row["clip_name"]; + $clip_folder = $row["clip_folder"]; + $clip_text_start = $row["clip_text_start"]; + $clip_text_end = $row["clip_text_end"]; + $clip_desc = $row["clip_desc"]; + $clip_order = $row["clip_order"]; + break; //limit to 1 row + } +} + +//show the content + require_once "header.php"; + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
Name:
Folder:
Before Selection:
"; + echo " "; + echo "
After Selection:
"; + echo " "; + echo "
Notes:
"; + echo " "; + echo "
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + + echo "
"; + echo "
"; + + require_once "footer.php"; +?> \ No newline at end of file diff --git a/app/php_edit/filedelete.php b/app/php_edit/filedelete.php new file mode 100644 index 0000000000..3808663da2 --- /dev/null +++ b/app/php_edit/filedelete.php @@ -0,0 +1,84 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +$folder = str_replace ("\\", "/", $folder); +if (substr($folder, -1) != "/") { $folder = $folder.'/'; } +$file = $_GET["file"]; + +if (strlen($folder) > 0 && strlen($file) > 0) { + unlink($folder.$file); + header("Location: fileoptions.php"); +} +else { + //display form + require_once "header.php"; + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Path:
".$folder.$file."
"; + + echo "
"; + + echo ""; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
File Name:
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + + require_once "footer.php"; +} +?> diff --git a/app/php_edit/filelist.php b/app/php_edit/filelist.php new file mode 100644 index 0000000000..cec466e2cb --- /dev/null +++ b/app/php_edit/filelist.php @@ -0,0 +1,287 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "header.php"; + +function isfile($filename) { + //if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function space($count) { + $r=''; $i=0; + while($i < $count) { + $r .= ' '; + $i++; + } + return $r; +} + +function recur_dir($dir) { + clearstatcache(); + $htmldirlist = ''; + $htmlfilelist = ''; + $dirlist = opendir($dir); + $dir_array = array(); + while (false !== ($file = readdir($dirlist))) { + if ($file != "." AND $file != ".."){ + $newpath = $dir.'/'.$file; + $level = explode('/',$newpath); + if (substr($newpath, -4) == ".svn") { + //ignore .svn dir and subdir + } + elseif (substr($newpath, -3) == ".db") { + //ignore .db files + } + else { + $dir_array[] = $newpath; + } + if ($x > 1000) { break; }; + $x++; + } + } + + asort($dir_array); + foreach ($dir_array as $newpath){ + $level = explode('/',$newpath); + + if (is_dir($newpath)) { + /*$mod_array[] = array( + 'level'=>count($level)-1, + 'path'=>$newpath, + 'name'=>end($level), + 'type'=>'dir', + 'mod_time'=>filemtime($newpath), + 'size'=>''); + $mod_array[] = recur_dir($newpath); + */ + $dirname = end($level); + $htmldirlist .= space(count($level))."
$dirname
\n"; + //$htmldirlist .= space(count($level))."
Tools
\n"; + //$htmldirlist .= space(count($level))."
New Folder
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
New File
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
Options
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + $htmldirlist .= recur_dir($newpath); + $htmldirlist .= space(count($level))."
\n"; + } + else { + /*$mod_array[] = array( + 'level'=>count($level)-1, + 'path'=>$newpath, + 'name'=>end($level), + 'type'=>'file', + 'mod_time'=>filemtime($newpath), + 'size'=>filesize($newpath)); + */ + $filename = end($level); + $filesize = round(filesize($newpath)/1024, 2); + $htmlfilelist .= space(count($level))."
$filename
\n"; + $htmlfilelist .= space(count($level))."
\n"; + } + } + closedir($dirlist); + return $htmldirlist ."\n". $htmlfilelist; +} + +echo ""; + + +echo ""; + +echo "
"; +echo "\n"; +echo "\n"; +echo " \n"; + echo "\n"; + echo "
\n"; +//echo "
"; + +echo "\n"; +echo " \n"; +echo "\n"; +echo "
Files
\n"; //display:none +//echo "
Files
\n"; //display:none + +//echo "
Tools
\n"; +//echo "
New Folder
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' +//echo "
\n"; +//echo "
New File
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' +//echo "
\n"; +//echo "
\n"; + +echo recur_dir($_SERVER["DOCUMENT_ROOT"]); + +echo "
\n"; + +/* +echo "
Files
\n"; +echo "\n"; +echo "
Folder 1
\n"; +echo "\n"; +echo "
demo1.php
\n"; +echo "
\n"; +echo "\n"; +echo "
demo2.php
\n"; +echo "
\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "
Folder 2
\n"; +echo "\n"; +echo "
demo3.php
\n"; +echo "
\n"; +echo "\n"; +echo "
demo4.php
\n"; +echo "
\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "
\n"; +*/ + +echo "
\n"; +echo ""; + +echo "

"; +require_once "footer.php"; + +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); + +echo ""; +echo ""; + +?> diff --git a/app/php_edit/filenew.php b/app/php_edit/filenew.php new file mode 100644 index 0000000000..1c17d5d164 --- /dev/null +++ b/app/php_edit/filenew.php @@ -0,0 +1,88 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +$folder = str_replace ("\\", "/", $folder); +if (substr($folder, -1) != "/") { $folder = $folder.'/'; } +$file = $_GET["file"]; + +if (strlen($folder) > 0 && strlen($file) > 0) { + //create new file + $handle = fopen($folder.$file, 'wb') or die("Error!!"); + $content = ""; + fwrite($handle, $content); + fclose($handle); + header("Location: fileoptions.php"); +} +else { + require_once "header.php"; + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Path:
".$folder.$file."
"; + + echo "
"; + + echo ""; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
File Name:
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + + require_once "footer.php"; +} + +?> diff --git a/app/php_edit/fileoptions.php b/app/php_edit/fileoptions.php new file mode 100644 index 0000000000..1c3adc1459 --- /dev/null +++ b/app/php_edit/fileoptions.php @@ -0,0 +1,85 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "header.php"; + +$file = $_GET["file"]; +$file = str_replace ("\\", "/", $file); +$folder = $_GET["folder"]; +$folder = str_replace ($file, "", $folder); +$urlpath = str_replace ($_SERVER["DOCUMENT_ROOT"], "", $folder); + +echo "
"; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
"; + +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "
Path:
File:
"; + +echo "
"; +echo " "; +echo ""; + +echo "
"; +echo ""; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "





"; +echo "
"; + +echo "
"; +echo "
"; + +require_once "footer.php"; +?> diff --git a/app/php_edit/fileoptionslist.php b/app/php_edit/fileoptionslist.php new file mode 100644 index 0000000000..87197513ba --- /dev/null +++ b/app/php_edit/fileoptionslist.php @@ -0,0 +1,270 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "header.php"; + +function isfile($filename) { + if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function space($count) { + $r=''; $i=0; + while($i < $count) { + $r .= ' '; + $i++; + } + return $r; +} + +function recur_dir($dir) { + clearstatcache(); + $htmldirlist = ''; + $htmlfilelist = ''; + $dirlist = opendir($dir); + while ($file = readdir ($dirlist)) { + if ($file != '.' && $file != '..') { + $newpath = $dir.'/'.$file; + $level = explode('/',$newpath); + + if (is_dir($newpath)) { + /*$mod_array[] = array( + 'level'=>count($level)-1, + 'path'=>$newpath, + 'name'=>end($level), + 'type'=>'dir', + 'mod_time'=>filemtime($newpath), + 'size'=>''); + $mod_array[] = recur_dir($newpath); + */ + $dirname = end($level); + $htmldirlist .= space(count($level))."
$dirname
\n"; + //$htmldirlist .= space(count($level))."
Tools
\n"; + //$htmldirlist .= space(count($level))."
New Folder
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
New File
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
Options
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + $htmldirlist .= recur_dir($newpath); + $htmldirlist .= space(count($level))."
\n"; + } + else { + /*$mod_array[] = array( + 'level'=>count($level)-1, + 'path'=>$newpath, + 'name'=>end($level), + 'type'=>'file', + 'mod_time'=>filemtime($newpath), + 'size'=>filesize($newpath)); + */ + $filename = end($level); + $filesize = round(filesize($newpath)/1024, 2); + $newpath = str_replace ($filename, "", $newpath); + $htmlfilelist .= space(count($level))."
$filename
\n"; + $htmlfilelist .= space(count($level))."
\n"; + } + } + } + + closedir($dirlist); + return $htmldirlist ."\n". $htmlfilelist; +} + +echo "\n"; + +echo "\n"; + +echo "
"; +echo "\n"; + +echo "\n"; +echo "
\n"; +echo "\n"; +echo " \n"; +echo "\n"; +echo "
Files
\n"; //display:none +//echo "
Files
\n"; //display:none + +//echo "
Tools
\n"; +//echo "
New Folder
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' +//echo "
\n"; +//echo "
New File
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' +//echo "
\n"; +//echo "
\n"; +echo recur_dir($_SERVER["DOCUMENT_ROOT"]); + +echo "
\n"; + +/* +echo "
Files
\n"; +echo "\n"; +echo "
Folder 1
\n"; +echo "\n"; +echo "
demo1.php
\n"; +echo "
\n"; +echo "\n"; +echo "
demo2.php
\n"; +echo "
\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "
Folder 2
\n"; +echo "\n"; +echo "
demo3.php
\n"; +echo "
\n"; +echo "\n"; +echo "
demo4.php
\n"; +echo "
\n"; +echo "\n"; +echo "
\n"; +echo "\n"; +echo "
\n"; +*/ + +echo "
\n"; +echo ""; + +echo "

"; +require_once "footer.php"; + +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); + +echo ""; +echo ""; + +?> \ No newline at end of file diff --git a/app/php_edit/fileread.php b/app/php_edit/fileread.php new file mode 100644 index 0000000000..463f9d2dc1 --- /dev/null +++ b/app/php_edit/fileread.php @@ -0,0 +1,49 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$filename = $_POST["file"]; +$filename = str_replace ("\\", "/", $filename); + +$handle = fopen($filename, "r"); +if ($handle) { + while (!feof($handle)) { + $buffer = fgets($handle, 4096); + echo $buffer; + } + fclose($handle); +} + +?> \ No newline at end of file diff --git a/app/php_edit/filerename.php b/app/php_edit/filerename.php new file mode 100644 index 0000000000..a27aa6e2b2 --- /dev/null +++ b/app/php_edit/filerename.php @@ -0,0 +1,102 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +//$folder = str_replace ("\\", "/", $folder); +//if (substr($folder, -1) != "/") { $folder = $folder.'/'; } +$newfilename = $_GET["newfilename"]; +$filename = $_GET["filename"]; +//echo $folder.$file; + + +if (strlen($folder) > 0 && strlen($newfilename) > 0) { + //echo "new file: ".$newfilename."
"; + //echo "folder: ".$folder."
"; + //echo "orig filename: ".$filename."
";; + rename($folder.$filename, $folder.$newfilename); + header("Location: fileoptions.php"); +} +else { //display form + + require_once "header.php"; + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Path:
".$folder.$filename."

Original file name:
".$filename."
"; + + echo "
"; + + echo ""; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
Rename file to:
"; + echo " "; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + + require_once "footer.php"; + +} + +?> \ No newline at end of file diff --git a/app/php_edit/filesave.php b/app/php_edit/filesave.php new file mode 100644 index 0000000000..51a650fb42 --- /dev/null +++ b/app/php_edit/filesave.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$filename = $_POST["file"]; //filename with the path +$filename = str_replace ("\\", "/", $filename); +$content = $_POST["content"]; + +$handle = fopen($filename, 'wb') or die("Error!!"); +fwrite($handle, $content); +fclose($handle); + +//set the reload_xml value to true + $_SESSION["reload_xml"] = true; + +echo $content; + +?> diff --git a/app/php_edit/folderdelete.php b/app/php_edit/folderdelete.php new file mode 100644 index 0000000000..67e1e7f1ec --- /dev/null +++ b/app/php_edit/folderdelete.php @@ -0,0 +1,46 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +$folder = str_replace ("\\", "/", $folder); + +if (strlen($folder) > 0) { + //delete the folder + rmdir($folder); //, 0700 + header("Location: fileoptions.php"); +} + +?> \ No newline at end of file diff --git a/app/php_edit/foldernew.php b/app/php_edit/foldernew.php new file mode 100644 index 0000000000..5328bd23c6 --- /dev/null +++ b/app/php_edit/foldernew.php @@ -0,0 +1,83 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +$folder = str_replace ("\\", "/", $folder); +$foldername = $_GET["foldername"]; + +if (strlen($folder) > 0 && strlen($foldername) > 0) { + //create new folder + mkdir($folder.'/'.$foldername); //, 0700 + header("Location: fileoptions.php"); +} +else { //display form + require_once "header.php"; + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Path:
".$folder."
"; + + echo "
"; + + echo ""; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
Folder Name:
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + + require_once "footer.php"; +} +?> diff --git a/app/php_edit/footer.php b/app/php_edit/footer.php new file mode 100644 index 0000000000..3e7b9037ab --- /dev/null +++ b/app/php_edit/footer.php @@ -0,0 +1,43 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +/* +echo "

"; +echo "
"; + +echo ""; +echo "fusionpbx "; +echo "        "; +echo "http://fusionpbx.com"; +echo "        "; +echo "Author: Mark J. Crane "; + +echo ""; +*/ +echo "
"; +echo ""; +echo ""; + +?> diff --git a/app/php_edit/header.php b/app/php_edit/header.php new file mode 100644 index 0000000000..b07b45c390 --- /dev/null +++ b/app/php_edit/header.php @@ -0,0 +1,83 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +echo ""; +echo ""; +echo ""; +//echo ""; +echo ""; + + +echo ""; +echo ""; +echo ""; +echo "
"; + +?> diff --git a/app/php_edit/images/Thumbs.db b/app/php_edit/images/Thumbs.db new file mode 100644 index 0000000000..46593a8c2e Binary files /dev/null and b/app/php_edit/images/Thumbs.db differ diff --git a/app/php_edit/images/file.gif b/app/php_edit/images/file.gif new file mode 100644 index 0000000000..a6cf9845fc Binary files /dev/null and b/app/php_edit/images/file.gif differ diff --git a/app/php_edit/images/file.png b/app/php_edit/images/file.png new file mode 100644 index 0000000000..33b5f5f374 Binary files /dev/null and b/app/php_edit/images/file.png differ diff --git a/app/php_edit/images/folder.gif b/app/php_edit/images/folder.gif new file mode 100644 index 0000000000..50ab253cc7 Binary files /dev/null and b/app/php_edit/images/folder.gif differ diff --git a/app/php_edit/images/gear.png b/app/php_edit/images/gear.png new file mode 100644 index 0000000000..1adf1e778f Binary files /dev/null and b/app/php_edit/images/gear.png differ diff --git a/app/php_edit/images/leaf.gif b/app/php_edit/images/leaf.gif new file mode 100644 index 0000000000..50ab253cc7 Binary files /dev/null and b/app/php_edit/images/leaf.gif differ diff --git a/app/php_edit/images/minus.gif b/app/php_edit/images/minus.gif new file mode 100644 index 0000000000..1094ab912b Binary files /dev/null and b/app/php_edit/images/minus.gif differ diff --git a/app/php_edit/images/plus.gif b/app/php_edit/images/plus.gif new file mode 100644 index 0000000000..fdacf8efe5 Binary files /dev/null and b/app/php_edit/images/plus.gif differ diff --git a/app/php_edit/images/program.gif b/app/php_edit/images/program.gif new file mode 100644 index 0000000000..dc3dfa1104 Binary files /dev/null and b/app/php_edit/images/program.gif differ diff --git a/app/php_edit/images/thumbnails/Thumbs.db b/app/php_edit/images/thumbnails/Thumbs.db new file mode 100644 index 0000000000..c4e4684b24 Binary files /dev/null and b/app/php_edit/images/thumbnails/Thumbs.db differ diff --git a/app/php_edit/images/thumbnails/cliplibrary.png b/app/php_edit/images/thumbnails/cliplibrary.png new file mode 100644 index 0000000000..bc70f332fd Binary files /dev/null and b/app/php_edit/images/thumbnails/cliplibrary.png differ diff --git a/app/php_edit/images/thumbnails/filemanagement.png b/app/php_edit/images/thumbnails/filemanagement.png new file mode 100644 index 0000000000..88cb7661b1 Binary files /dev/null and b/app/php_edit/images/thumbnails/filemanagement.png differ diff --git a/app/php_edit/images/thumbnails/phpeditor.png b/app/php_edit/images/thumbnails/phpeditor.png new file mode 100644 index 0000000000..c6f7f369bb Binary files /dev/null and b/app/php_edit/images/thumbnails/phpeditor.png differ diff --git a/app/php_edit/index.php b/app/php_edit/index.php new file mode 100644 index 0000000000..e91149af65 --- /dev/null +++ b/app/php_edit/index.php @@ -0,0 +1,224 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +echo "\n"; +echo "\n"; +echo " \n"; +echo " "; + + echo "\n"; + + echo ""; + ?> + + + + + + + + +
+ + + + \n"; + echo "\n"; + } + else { + echo "\n"; + } + ?> + +
+ + \ No newline at end of file diff --git a/app/php_edit/list.php b/app/php_edit/list.php new file mode 100644 index 0000000000..c1d3843ebb --- /dev/null +++ b/app/php_edit/list.php @@ -0,0 +1,107 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "admin/edit/header.php"; +echo "
"; +echo "\n"; +echo "\n"; +echo " \n"; + echo "\n"; +} //end if results +echo "
\n"; +echo "
"; + +$sql = "select * from v_clips "; +$prep_statement = $db->prepare(check_sql($sql)); +$prep_statement->execute(); +$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); +$result_count = count($result); + +$c = 0; +$row_style["0"] = "background-color: #F5F5DC;"; +$row_style["1"] = "background-color: #FFFFFF;"; + +echo "
\n"; +echo "\n"; +echo ""; + +if ($result_count == 0) { //no results + echo ""; +} +else { //received results + echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + echo "\n"; + + foreach($result as $row) { + echo "\n"; + //echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach unset($sql, $result, $row_count); + echo "
 
    clip name      clip_folder        clip_text_start        clip_text_end        clip_desc        clip_order   
".$row['clip_uuid']."".$row['clip_name']."".$row[clip_folder]."".$row[clip_text_start]."".$row[clip_text_end]."".$row[clip_desc]."".$row[clip_order]."
\n"; + echo "
\n"; + + echo "
\n"; + +echo "
\n"; +echo "   \n"; +echo "   \n"; +echo "
\n"; +echo ""; + +echo "

"; +require_once "admin/edit/footer.php"; + +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); + +?> \ No newline at end of file diff --git a/app/php_edit/readme.txt b/app/php_edit/readme.txt new file mode 100644 index 0000000000..cafc4144ae --- /dev/null +++ b/app/php_edit/readme.txt @@ -0,0 +1,7 @@ +Notes + +IFrame +http://www.quirksmode.org/js/iframe.html + +Tree View +http://www.dddekerf.dds.nl/DHTML_Treeview/DHTML_Treeview.htm \ No newline at end of file diff --git a/app/php_edit/root.php b/app/php_edit/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/php_edit/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/php_service/app_config.php b/app/php_service/app_config.php new file mode 100644 index 0000000000..1c47bbc137 --- /dev/null +++ b/app/php_service/app_config.php @@ -0,0 +1,82 @@ + \ No newline at end of file diff --git a/app/php_service/root.php b/app/php_service/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/php_service/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/php_service/v_php_service.php b/app/php_service/v_php_service.php new file mode 100644 index 0000000000..4f71f9a274 --- /dev/null +++ b/app/php_service/v_php_service.php @@ -0,0 +1,176 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_service_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +/* +function pkg_is_service_running($servicename) +{ + exec("/bin/ps ax | awk '{ print $5 }'", $psout); + array_shift($psout); + foreach($psout as $line) { + $ps[] = trim(array_pop(explode(' ', array_pop(explode('/', $line))))); + } + if(is_service_running($servicename, $ps) or is_process_running($servicename) ) { + return true; + } + else { + return false; + } +} +*/ + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + +//show the content + echo "
"; + echo "
\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
PHP Service 
\n"; + echo "Manages multiple dynamic and customizable services. There are many possible uses including alerts, ssh access control, scheduling commands to run, and many others uses that are yet to be discovered.

\n"; + echo "
\n"; + + $sql = ""; + $sql .= " select * from v_php_services "; + $sql .= " where domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $num_rows = count($result); + unset ($prep_statement, $result, $sql); + $rows_per_page = 10; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + $sql = ""; + $sql .= " select * from v_php_services "; + $sql .= " where domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo th_order_by('service_name', 'Name', $order_by, $order); + //echo th_order_by('service_group', 'Group', $order_by, $order); + echo th_order_by('service_enabled', 'Enabled', $order_by, $order); + echo th_order_by('service_description', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count == 0) { + //no results + } + else { //received results + foreach($result as $row) { + echo "\n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + if (permission_exists('php_service_add')) { + echo " $v_link_label_add\n"; + } + echo "
".$row[service_name]."".$row[service_group]."".$row[service_enabled]."".$row[service_description]." \n"; + if (permission_exists('php_service_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('php_service_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('php_service_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//show the footer + require_once "includes/footer.php"; +?> diff --git a/app/php_service/v_php_service_delete.php b/app/php_service/v_php_service_delete.php new file mode 100644 index 0000000000..7e718f5f34 --- /dev/null +++ b/app/php_service/v_php_service_delete.php @@ -0,0 +1,82 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_service_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); +} + +if (strlen($id)>0) { + $sql = ""; + $sql .= "select * from v_php_services "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and php_service_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $service_name = $row["service_name"]; + $tmp_service_name = str_replace(" ", "_", $service_name); + break; //limit to 1 row + } + unset ($prep_statement, $result, $row); + + //delete the php service file + unlink($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure/php_service_'.$tmp_service_name.'.php'); + //delete the start up script + unlink($startup_script_dir.'/php_service_'.$tmp_service_name.'.sh'); + //delete the pid file + unlink($tmp_dir.'/php_service_'.$tmp_service_name.'.pid'); + + $sql = ""; + $sql .= "delete from v_php_services "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and php_service_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); +} + +require_once "includes/header.php"; +echo "\n"; +echo "
\n"; +echo "Delete Complete\n"; +echo "
\n"; + +require_once "includes/footer.php"; +return; + +?> + diff --git a/app/php_service/v_php_service_edit.php b/app/php_service/v_php_service_edit.php new file mode 100644 index 0000000000..6534bd2161 --- /dev/null +++ b/app/php_service/v_php_service_edit.php @@ -0,0 +1,556 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_service_add') || permission_exists('php_service_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +/* +function pkg_is_service_running($servicename) { + exec("/bin/ps ax | awk '{ print $5 }'", $psout); + array_shift($psout); + foreach($psout as $line) { + $ps[] = trim(array_pop(explode(' ', array_pop(explode('/', $line))))); + } + if(is_service_running($servicename, $ps) or is_process_running($servicename) ) { + return true; + } + else { + return false; + } +} + +function byte_convert( $bytes ) { + if ($bytes<=0) + return '0 Byte'; + + $convention=1000; //[1000->10^x|1024->2^x] + $s=array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'); + $e=floor(log($bytes,$convention)); + return round($bytes/pow($convention,$e),2).' '.$s[$e]; +} +*/ + +function php_services_sync_package_php() { + global $db, $domain_uuid, $startup_script_dir, $tmp_dir; + $sql = ""; + $sql .= "select * from v_php_services "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $tmp_prep_statement = $db->prepare(check_sql($sql)); + $tmp_prep_statement->execute(); + $tmp_result = $tmp_prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($tmp_result as &$row) { + $service_name = $row["service_name"]; + $tmp_service_name = str_replace(" ", "_", $service_name); + $service_script = base64_decode($row["service_script"]); + //$service_enabled = $row["service_enabled"]; + $service_description = $row["service_description"]; + $php_service_file = "php_service_".$tmp_service_name.".php"; + + if ($row['service_enabled'] == "false") { + //delete the php service file + unlink($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure/php_service_'.$tmp_service_name.'.php'); + //delete the start up script + unlink($startup_script_dir.'/php_service_'.$tmp_service_name.'.sh'); + //delete the pid file + unlink($tmp_dir.'/php_service_'.$tmp_service_name.'.pid'); + } + else { + //write the php service + $tmp = "\\n\";\n"; + //$tmp .= " } else {\n"; + //$tmp .= " fwrite(\$fp, \$syslogmsg);\n"; + //$tmp .= " fclose(\$fp);\n"; + //$tmp .= " }\n"; + //$tmp .= "\n"; + //$tmp .= "}\n"; + //$tmp .= "\n"; + //$tmp .= "\n"; + //$tmp .= "//\$msg = \"1.begin loop. \".date('r').\"\\n\";\n"; + //$tmp .= "//\$fp = fopen('/tmp/".$tmp_service_name.".txt', 'a');\n"; + //$tmp .= "//fwrite(\$fp, \$msg.\"\\n\");\n"; + //$tmp .= "//fclose(\$fp);\n"; + + //$tmp .= "\n"; + $tmp .= $service_script; + $tmp .= "\n"; + $tmp .= "?>"; + + $fout = fopen($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure/'.$php_service_file,"w"); + fwrite($fout, $tmp); + unset($tmp); + fclose($fout); + + //add execute permissions to the php service script + chmod($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure/'.$php_service_file, 0776); + + //write the start up script + // CYGWIN_NT-5.1 + // Darwin + // FreeBSD + // HP-UX + // IRIX64 + // Linux + // NetBSD + // OpenBSD + // SunOS + // Unix + // WIN32 + // WINNT + // Windows + switch (PHP_OS) { + case "FreeBSD": + // make sure the start up directory i set + if (strlen($startup_script_dir) > 0) { + $startup_script_dir = "/usr/local/etc/rc.d"; + } + $tmp = ""; + $tmp = "#!/bin/sh\n"; + $tmp .= "# This file was automatically generated\n"; + $tmp .= "# by the PHP Service handler.\n"; + $tmp .= "# \n"; + $tmp .= "# Copy this script to the startup directory.\n"; + $tmp .= "# cp -a ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/php_service_".$tmp_service_name.".sh ".$startup_script_dir."/php_service_".$tmp_service_name.".sh"; + $tmp .= "# \n"; + $tmp .= "# Usage: ./php_service_".$tmp_service_name.".sh {start|stop|restart}\n"; + $tmp .= "# ".$startup_script_dir."/./php_service_".$tmp_service_name.".sh start"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= "rc_start() {\n"; + $tmp .= " ".PHP_BINDIR."/php ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/".$php_service_file." >> /var/log/php_service_".$tmp_service_name.".log &\n"; + $tmp .= "}\n"; + $tmp .= "\n"; + $tmp .= "rc_stop() {\n"; + $tmp .= " rm ".$tmp_dir."/php_service_".$tmp_service_name.".pid\n"; + $tmp .= "}\n"; + $tmp .= "\n"; + $tmp .= "case \"\$1\" in\n"; + $tmp .= " start)\n"; + $tmp .= " echo \"Starting the service. \"\n"; + $tmp .= " rc_start\n"; + $tmp .= " ;;\n"; + $tmp .= " stop)\n"; + $tmp .= " echo \"Stopping the service. \"\n"; + $tmp .= " rc_stop\n"; + $tmp .= " ;;\n"; + $tmp .= " restart)\n"; + $tmp .= " echo \"Restarting the service. \"\n"; + $tmp .= " rc_stop\n"; + $tmp .= " rc_start\n"; + $tmp .= " ;;\n"; + $tmp .= " *)\n"; + $tmp .= " echo \"Usage: ".$startup_script_dir."/php_service_".$tmp_service_name.".sh {start|stop|restart}\"\n"; + $tmp .= " exit 1\n"; + $tmp .= " ;;\n"; + $tmp .= "esac\n"; + $fout = fopen($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/php_service_".$tmp_service_name.".sh","w"); + fwrite($fout, $tmp); + unset($tmp); + fclose($fout); + + //add execute permissions to the start script + chmod($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/php_service_".$tmp_service_name.".sh", 0755); + + break; + default: + // make sure the start up directory i set + if (strlen($startup_script_dir) > 0) { + $startup_script_dir = "/etc/init.d"; + } + $tmp = ""; + $tmp .= "#!/bin/sh\n"; + $tmp .= "# /etc/init.d/".$tmp_service_name."\n"; + $tmp .= "# This file was automatically generated\n"; + $tmp .= "# by the PHP Service handler.\n"; + $tmp .= "# \n"; + $tmp .= "# Copy this script to the startup directory.\n"; + $tmp .= "# cp -a ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/php_service_".$tmp_service_name.".sh ".$startup_script_dir."/php_service_".$tmp_service_name.".sh"; + $tmp .= "# \n"; + $tmp .= "# Usage: ./php_service_".$tmp_service_name.".sh {start|stop|restart}\n"; + $tmp .= "# ".$startup_script_dir."/./php_service_".$tmp_service_name.".sh start"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= "rc_start() {\n"; + $tmp .= " ".PHP_BINDIR."/php ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/".$php_service_file." >> /var/log/".tmp_service_name.".log &\n"; + $tmp .= "}\n"; + $tmp .= "\n"; + $tmp .= "rc_stop() {\n"; + $tmp .= " rm ".$tmp_dir."/php_service_".$tmp_service_name.".pid\n"; + $tmp .= "}\n"; + $tmp .= "\n"; + $tmp .= "case \"\$1\" in\n"; + $tmp .= " start)\n"; + $tmp .= " echo \"Starting the service. \"\n"; + $tmp .= " rc_start\n"; + $tmp .= " ;;\n"; + $tmp .= " stop)\n"; + $tmp .= " echo \"Stopping the service. \"\n"; + $tmp .= " rc_stop\n"; + $tmp .= " ;;\n"; + $tmp .= " restart)\n"; + $tmp .= " echo \"Restarting the service. \"\n"; + $tmp .= " rc_stop\n"; + $tmp .= " rc_start\n"; + $tmp .= " ;;\n"; + $tmp .= " *)\n"; + $tmp .= " echo \"Usage: ".$startup_script_dir."/".$tmp_service_name.".sh {start|stop|restart}\"\n"; + $tmp .= " exit 1\n"; + $tmp .= " ;;\n"; + $tmp .= "esac\n"; + $tmp .= "\n"; + $tmp .= "exit 0"; + $fout = fopen($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/php_service_".$tmp_service_name.".sh","w"); + fwrite($fout, $tmp); + unset($tmp); + fclose($fout); + + //add execute permissions to the start script + chmod($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/php_service_".$tmp_service_name.".sh", 0755); + } + } //end if enabled + } +} + +//set the action as an add or an update + if (isset($_REQUEST["id"])) { + $action = "update"; + $php_service_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//set the http values to variabless +if (count($_POST)>0) { + $service_name = check_str($_POST["service_name"]); + $service_script = $_POST["service_script"]; + $service_enabled = check_str($_POST["service_enabled"]); + $service_description = check_str($_POST["service_description"]); + + //set defaults + $service_type = "php"; + + //setup the default script + $tmp_service_name = str_replace(" ", "_", $service_name); + if (strlen($service_script) == 0) { + $tmp = "\n"; + $tmp .= "\n"; + $tmp .= "\$x = 0;\n"; + $tmp .= "while(\$x == 0) {\n"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= " if(!file_exists('".$tmp_dir."/php_service_".$tmp_service_name.".pid')) { return; }\n"; + $tmp .= " usleep(1000000); //1 000 000 microseconds = 1 second\n"; + //$tmp .= " //if (\$x > 60){ exit; } //exit after 60 loops for testing\n"; + $tmp .= "} //end while\n"; + $service_script = $tmp; + } +} + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $php_service_uuid = check_str($_POST["php_service_uuid"]); + } + + //check for all required data + if (strlen($service_name) == 0) { $msg .= "Please provide: Name
\n"; } + //if (strlen($service_script) == 0) { $msg .= "Please provide: Script
\n"; } + if (strlen($service_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } + //if (strlen($service_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('php_service_add')) { + $php_service_uuid = uuid(); + $sql = "insert into v_php_services "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "php_service_uuid, "; + $sql .= "service_name, "; + $sql .= "service_script, "; + $sql .= "service_enabled, "; + $sql .= "service_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$php_service_uuid', "; + $sql .= "'$service_name', "; + $sql .= "'".base64_encode($service_script)."', "; + $sql .= "'$service_enabled', "; + $sql .= "'$service_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //create the php service files + php_services_sync_package_php(); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update" && permission_exists('php_service_edit')) { + $sql = "update v_php_services set "; + $sql .= "service_name = '$service_name', "; + $sql .= "service_script = '".base64_encode($service_script)."', "; + $sql .= "service_enabled = '$service_enabled', "; + $sql .= "service_description = '$service_description' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and php_service_uuid = '$php_service_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + + //create the php service files + php_services_sync_package_php(); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $php_service_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_php_services "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and php_service_uuid = '$php_service_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $service_name = $row["service_name"]; + $tmp_service_name = str_replace(" ", "_", $service_name); + $service_script = base64_decode($row["service_script"]); + $service_enabled = $row["service_enabled"]; + $service_description = $row["service_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//include the header + require_once "includes/header.php"; + +// edit area + echo " \n"; + echo " \n"; + + echo " "; + +//show the form + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
PHP Service AddPHP Service Edit
\n"; + echo "Manages multiple dynamic and customizable services. There are many possible uses including alerts, ssh access control, scheduling commands to run, and many others uses that are yet to be discovered.

\n"; + echo "
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter a name.\n"; + echo "
\n"; + echo " Script:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the PHP script here.\n"; + echo "
\n"; + echo " Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/provision/app_config.php b/app/provision/app_config.php new file mode 100644 index 0000000000..6a2ff46ea3 --- /dev/null +++ b/app/provision/app_config.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/app/provision/index.php b/app/provision/index.php new file mode 100644 index 0000000000..1c93a279c0 --- /dev/null +++ b/app/provision/index.php @@ -0,0 +1,400 @@ + + Copyright (C) 2008-2012 All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; + +//set default variables + $dir_count = 0; + $file_count = 0; + $row_count = 0; + $tmp_array = ''; + $phone_template = ''; + +//get any system -> variables defined in the 'provision; + $sql .= "select * from v_vars "; + $sql .= "where var_enabled = 'true' "; + $sql .= "and var_cat = 'Provision' "; + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $provision_variables_array = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($provision_variables_array as &$row) { + if ($row['var_name'] == "password") { + $var_name = $row['var_name']; + $var_value = $row['var_value']; + $$var_name = $var_value; + } + } + } + +//if password was defined in the system -> variables page then require the password. + if (strlen($password) > 0) { + //deny access if the password doesn't match + if ($password != $_REQUEST['password']) { + //Log the failed auth attempt to the system, to be available for fail2ban. + openlog('FusionPBX', LOG_NDELAY, LOG_AUTH); + syslog(LOG_WARNING, '['.$_SERVER['REMOTE_ADDR']."] provision attempt bad password for ".$_REQUEST['mac']); + closelog(); + + usleep(rand(1000000,3500000));//1-3.5 seconds. + echo "access denied"; + return; + } + } + +//send a request to a remote server to validate the MAC address and secret + if (strlen($_SERVER['auth_server']) > 0) { + $result = send_http_request($_SERVER['auth_server'], 'mac='.$_REQUEST['mac'].'&secret='.$_REQUEST['secret']); + if ($result == "false") { + echo "access denied"; + exit; + } + } + +//define variables from HTTP GET + $mac = $_REQUEST['mac']; + if (strlen($_REQUEST['template']) > 0) { + $phone_template = $_REQUEST['template']; + } + + if(empty($mac)){//check alternate MAC source + if($_SERVER['HTTP_USER_AGENT'][strlen($_SERVER['HTTP_USER_AGENT'])-17-1]==" ") { + $mac= substr($_SERVER['HTTP_USER_AGENT'],-17); + }//Yealink: 17 digit mac appended to the user agent, so check for a space exactly 17 digits before the end. + }//check alternates + + $mac = strtolower($mac); + $mac = str_replace(":", "-", $mac); + if (strlen($mac) == 12) { + $mac = substr($mac, 0,2).'-'.substr($mac, 2,2).'-'.substr($mac, 4,2).'-'.substr($mac, 6,2).'-'.substr($mac, 8,2).'-'.substr($mac, 10,2); + } + $file = $_REQUEST['file']; + +//check to see if the mac_address exists in v_hardware_phones + if (mac_exists_in_v_hardware_phones($db, $mac)) { + //get the phone_template + if (strlen($phone_template) == 0) { + $sql = "SELECT * FROM v_hardware_phones "; + $sql .= "where domain_uuid=:domain_uuid "; + $sql .= "and phone_mac_address=:mac "; + $prep_statement_2 = $db->prepare(check_sql($sql)); + if ($prep_statement_2) { + $prep_statement_2->bindParam(':domain_uuid', $domain_uuid); + $prep_statement_2->bindParam(':mac', $mac); + $prep_statement_2->execute(); + $row = $prep_statement_2->fetch(); + $phone_label = $row["phone_label"]; + $phone_vendor = $row["phone_vendor"]; + $phone_model = $row["phone_model"]; + $phone_firmware_version = $row["phone_firmware_version"]; + $phone_provision_enable = $row["phone_provision_enable"]; + $phone_template = $row["phone_template"]; + $phone_username = $row["phone_username"]; + $phone_password = $row["phone_password"]; + $phone_time_zone = $row["phone_time_zone"]; + $phone_description = $row["phone_description"]; + } + } + //find a template that was defined on another phone and use that as the default. + if (strlen($phone_template) == 0) { + $sql = "SELECT * FROM v_hardware_phones "; + $sql .= "where domain_uuid=:domain_uuid "; + $sql .= "and phone_template like '%/%' "; + $prep_statement3 = $db->prepare(check_sql($sql)); + if ($prep_statement3) { + $prep_statement3->bindParam(':domain_uuid', $domain_uuid); + $prep_statement3->bindParam(':mac', $mac); + $prep_statement3->execute(); + $row = $prep_statement3->fetch(); + $phone_label = $row["phone_label"]; + $phone_vendor = $row["phone_vendor"]; + $phone_model = $row["phone_model"]; + $phone_firmware_version = $row["phone_firmware_version"]; + $phone_provision_enable = $row["phone_provision_enable"]; + $phone_template = $row["phone_template"]; + $phone_username = $row["phone_username"]; + $phone_password = $row["phone_password"]; + $phone_time_zone = $row["phone_time_zone"]; + $phone_description = $row["phone_description"]; + } + } + } + else { + //mac does not exist in v_hardware_phones add it to the table + //use the mac address to find the vendor + switch (substr($mac, 0, 8)) { + case "00-08-5d": + $phone_vendor = "aastra"; + break; + case "00-0e-08": + $phone_vendor = "linksys"; + break; + case "00-04-f2": + $phone_vendor = "polycom"; + break; + case "00-90-7a": + $phone_vendor = "polycom"; + break; + case "00-18-73": + $phone_vendor = "cisco"; + break; + case "00-04-5a": + $phone_vendor = "linksys"; + break; + case "00-06-25": + $phone_vendor = "linksys"; + break; + case "00-15-65": + $phone_vendor = "yealink"; + break; + default: + $phone_vendor = ""; + } + + //use the user_agent to pre-assign a template for 1-hit provisioning. Enter the a unique string to match in the user agent, and the template it should match. + $template_list=array( + "Linksys/SPA-2102"=>"linksys/spa2102", + "Linksys/SPA-3102"=>"linksys/spa3102" + ); + + foreach ($template_list as $key=>$val){ + if(stripos($_SERVER['HTTP_USER_AGENT'],$key)!== false) { + $phone_template=$val; + break; + } + } + unset($template_list); + + //the mac address does not exist in the table so add it + $hardware_phone_uuid = uuid(); + $sql = "insert into v_hardware_phones "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "hardware_phone_uuid, "; + $sql .= "phone_mac_address, "; + $sql .= "phone_vendor, "; + $sql .= "phone_model, "; + $sql .= "phone_provision_enable, "; + $sql .= "phone_template, "; + $sql .= "phone_username, "; + $sql .= "phone_password, "; + $sql .= "phone_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$hardware_phone_uuid', "; + $sql .= "'$mac', "; + $sql .= "'$phone_vendor', "; + $sql .= "'', "; + $sql .= "'true', "; + $sql .= "'$phone_template', "; + $sql .= "'', "; + $sql .= "'', "; + $sql .= "'auto {$_SERVER['HTTP_USER_AGENT']}' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + +//if $file is not provided then look for a default file that exists + if (strlen($file) == 0) { + if (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/provision/".$phone_template ."/{v_mac}")) { + $file = "{v_mac}"; + } + elseif (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/provision/".$phone_template ."/{v_mac}.xml")) { + $file = "{v_mac}.xml"; + } + elseif (file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/provision/".$phone_template ."/{v_mac}.cfg")) { + $file = "{v_mac}.cfg"; + } + else { + echo "file not found"; + exit; + } + } + else { + //make sure the file exists + if (!file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/provision/".$phone_template ."/".$file)) { + echo "file not found"; + exit; + } + } + +//log file for testing + //$tmp_file = "/tmp/provisioning_log.txt"; + //$fh = fopen($tmp_file, 'w') or die("can't open file"); + //$tmp_string = $mac."\n"; + //fwrite($fh, $tmp_string); + //fclose($fh); + + //set variables for testing + //$line1_displayname= "1001"; + //$line1_shortname= "1001"; + //$line1_user_id= "1001"; + //$line1_user_password= "1234."; + //$line1_server_address= "10.2.0.2"; + //$line2_server_address= ""; + //$line2_displayname= ""; + //$line2_shortname= ""; + //$line2_user_uuid= ""; + //$line2_user_password= ""; + //$line2_server_address= ""; + //$server1_address= "10.2.0.2"; + //$server2_address= ""; + //$server3_address= ""; + //$proxy1_address= "10.2.0.2"; + //$proxy2_address= ""; + //$proxy3_address= ""; + +//get the contents of the template + $file_contents = file_get_contents($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/provision/".$phone_template ."/".$file); + +//replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number + + //get the time zone + $time_zone_name = $_SESSION['domain']['time_zone']['name']; + if (strlen($time_zone_name) > 0) { + $time_zone_offset_raw = get_time_zone_offset($time_zone_name)/3600; + $time_zone_offset_hours = floor($time_zone_offset_raw); + $time_zone_offset_minutes = ($time_zone_offset_raw - $time_zone_offset_hours) * 60; + $time_zone_offset_minutes = number_pad($time_zone_offset_minutes, 2); + if ($time_zone_offset_raw > 0) { + $time_zone_offset_hours = number_pad($time_zone_offset_hours, 2); + $time_zone_offset_hours = "+".$time_zone_offset_hours; + } + else { + $time_zone_offset_hours = str_replace("-", "", $time_zone_offset_hours); + $time_zone_offset_hours = "-".number_pad($time_zone_offset_hours, 2); + } + $time_zone_offset = $time_zone_offset_hours.":".$time_zone_offset_minutes; + $file_contents = str_replace("{v_time_zone_offset}", $time_zone_offset, $file_contents); + } + + //lookup the provisioning information for this MAC address. + $sql = "select * from v_extensions "; + $sql .= "where provisioning_list like '%|".$mac.":%' "; + $sql .= "and domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $provisioning_list = $row["provisioning_list"]; + $provisioning_list_array = explode("|", $provisioning_list); + foreach ($provisioning_list_array as &$prov_row) { + $prov_row_array = explode(":", $prov_row); + if ($prov_row_array[0] == $mac) { + $line_number = $prov_row_array[1]; + $file_contents = str_replace("{v_line".$line_number."_server_address}", $_SESSION['domain_name'], $file_contents); + $file_contents = str_replace("{v_line".$line_number."_displayname}", $row["effective_caller_id_name"], $file_contents); + $file_contents = str_replace("{v_line".$line_number."_shortname}", $row["extension"], $file_contents); + $file_contents = str_replace("{v_line".$line_number."_user_id}", $row["extension"], $file_contents); + $file_contents = str_replace("{v_line".$line_number."_user_password}", $row["password"], $file_contents); + } + } + //$vm_password = $row["vm_password"]; + //$vm_password = str_replace("#", "", $vm_password); //preserves leading zeros + //$accountcode = $row["accountcode"]; + //$effective_caller_id_name = $row["effective_caller_id_name"]; + //$effective_caller_id_number = $row["effective_caller_id_number"]; + //$outbound_caller_id_name = $row["outbound_caller_id_name"]; + //$outbound_caller_id_number = $row["outbound_caller_id_number"]; + //$vm_mailto = $row["vm_mailto"]; + //$vm_attach_file = $row["vm_attach_file"]; + //$vm_keep_local_after_email = $row["vm_keep_local_after_email"]; + //$user_context = $row["user_context"]; + //$call_group = $row["call_group"]; + //$auth_acl = $row["auth_acl"]; + //$cidr = $row["cidr"]; + //$sip_force_contact = $row["sip_force_contact"]; + //$enabled = $row["enabled"]; + //$description = $row["description"]; + } + unset ($prep_statement); + + //replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number + $file_contents = str_replace("{v_mac}", $mac, $file_contents); + $file_contents = str_replace("{v_label}", $phone_label, $file_contents); + $file_contents = str_replace("{v_firmware_version}", $phone_firmware_version, $file_contents); + $file_contents = str_replace("{domain_time_zone}", $phone_time_zone, $file_contents); + $file_contents = str_replace("{domain_name}", $_SESSION['domain_name'], $file_contents); + $file_contents = str_replace("{v_project_path}", PROJECT_PATH, $file_contents); + $file_contents = str_replace("{v_server1_address}", $server1_address, $file_contents); + $file_contents = str_replace("{v_proxy1_address}", $proxy1_address, $file_contents); + $file_contents = str_replace("{v_password}", $password, $file_contents); + $file_contents = str_replace("{v_time_zone_offset}", $password, $file_contents); + + //cleanup any remaining variables + for ($i = 1; $i <= 100; $i++) { + $file_contents = str_replace("{v_line".$i."_server_address}", "", $file_contents); + $file_contents = str_replace("{v_line".$i."_displayname}", "", $file_contents); + $file_contents = str_replace("{v_line".$i."_shortname}", "", $file_contents); + $file_contents = str_replace("{v_line".$i."_user_id}", "", $file_contents); + $file_contents = str_replace("{v_line".$i."_user_password}", "", $file_contents); + } + + //replace the dynamic provision variables that are defined in the system -> variables page + foreach ($provision_variables_array as &$row) { + if (substr($var_name, 0, 2) == "v_") { + $file_contents = str_replace('{'.$row[var_name].'}', $row[var_value], $file_contents); + } + } + +//deliver the customized config over HTTP/HTTPS + + //need to make sure content-type is correct + $cfg_ext = ".cfg"; + if ($phone_vendor === "aastra" && strrpos($file, $cfg_ext, 0) === strlen($file) - strlen($cfg_ext)) { + header ("content-type: text/plain"); + } else { + header ("content-type: text/xml"); + } + echo $file_contents; + +function mac_exists_in_v_hardware_phones($db, $mac) { + global $domain_uuid; + $sql = "SELECT count(*) as count FROM v_hardware_phones "; + $sql .= "where domain_uuid=:domain_uuid "; + $sql .= "and phone_mac_address=:mac "; + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->bindParam(':domain_uuid', $domain_uuid); + $prep_statement->bindParam(':mac', $mac); + $prep_statement->execute(); + $row = $prep_statement->fetch(); + $count = $row['count']; + if ($row['count'] > 0) { + return true; + } + else { + return false; + } + } + else { + return false; + } +} + +?> \ No newline at end of file diff --git a/app/provision/provision_write.php b/app/provision/provision_write.php new file mode 100644 index 0000000000..688a19d6ce --- /dev/null +++ b/app/provision/provision_write.php @@ -0,0 +1,237 @@ + + Copyright (C) 2008-2012 All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//set default variables + $dir_count = 0; + $file_count = 0; + $row_count = 0; + $tmp_array = ''; + +//get any system -> variables defined in the 'provision; + $sql = "select * from v_vars "; + $sql .= "where var_enabled = 'true' "; + $sql .= "and var_cat = 'Provision' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $provision_variables_array = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($provision_variables_array as &$row) { + if ($row[var_name] == "password") { + $var_name = $row[var_name]; + $var_value = $row[var_value]; + $$var_name = $var_value; + } + } + +//get the hardware phone list + $sql = "select * from v_hardware_phones "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $phone_mac_address = $row["phone_mac_address"]; + $phone_mac_address = strtolower($phone_mac_address); + $phone_label = $row["phone_label"]; + $phone_vendor = $row["phone_vendor"]; + $phone_model = $row["phone_model"]; + $phone_firmware_version = $row["phone_firmware_version"]; + $phone_provision_enable = $row["phone_provision_enable"]; + $phone_template = $row["phone_template"]; + $phone_username = $row["phone_username"]; + $phone_password = $row["phone_password"]; + $phone_time_zone = $row["phone_time_zone"]; + $phone_description = $row["phone_description"]; + + //loop through the provision template directory + $provision_template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/provision/".$phone_template; + + clearstatcache(); + $dir_list = ''; + $file_list = ''; + $dir_list = opendir($provision_template_dir); + $dir_array = array(); + while (false !== ($file = readdir($dir_list))) { + if ($file != "." AND $file != ".."){ + $new_path = $dir.'/'.$file; + $level = explode('/',$new_path); + if (substr($new_path, -4) == ".svn") { + //ignore .svn dir and subdir + } + elseif (substr($new_path, -3) == ".db") { + //ignore .db files + } + else { + $dir_array[] = $new_path; + } + if ($x > 1000) { break; }; + $x++; + } + } + //asort($dir_array); + foreach ($dir_array as $new_path){ + $level = explode('/',$new_path); + if (is_dir($new_path)) { + //$mod_array[] = array( + //'level'=>count($level)-1, + //'path'=>$new_path, + //'name'=>end($level), + //'type'=>'dir', + //'mod_time'=>filemtime($new_path), + //'size'=>''); + //$mod_array[] = recur_dir($new_path); + $dir_name = end($level); + //$file_list .= "$dir_name\n"; + //$dir_list .= recur_dir($new_path); + } + else { + //$mod_array[] = array( + //'level'=>count($level)-1, + //'path'=>$new_path, + //'name'=>end($level), + //'type'=>'dir', + //'mod_time'=>filemtime($new_path), + //'size'=>''); + //$mod_array[] = recur_dir($new_path); + $file_name = end($level); + $file_size = round(filesize($new_path)/1024, 2); + + //get the contents of the template + $file_contents = file_get_contents($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/provision/".$phone_template ."/".$file_name); + + //prepare the files + //replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number + $file_contents = str_replace("{v_mac}", $phone_mac_address, $file_contents); + $file_contents = str_replace("{v_label}", $phone_label, $file_contents); + $file_contents = str_replace("{v_firmware_version}", $phone_firmware_version, $file_contents); + $file_contents = str_replace("{domain_time_zone}", $phone_time_zone, $file_contents); + $file_contents = str_replace("{domain_name}", $_SESSION['domain_name'], $file_contents); + $file_contents = str_replace("{v_server1_address}", $server1_address, $file_contents); + $file_contents = str_replace("{v_proxy1_address}", $proxy1_address, $file_contents); + + //replace the dynamic provision variables that are defined in the system -> variables page + foreach ($provision_variables_array as &$row) { + if (substr($var_name, 0, 2) == "v_") { + $file_contents = str_replace('{'.$row[var_name].'}', $row[var_value], $file_contents); + } + } + + //lookup the provisioning information for this MAC address. + $sql2 = "select * from v_extensions "; + $sql2 .= "where provisioning_list like '%$phone_mac_address%' "; + $sql2 .= "and domain_uuid = '$domain_uuid' "; + $prep_statement_2 = $db->prepare(check_sql($sql2)); + $prep_statement_2->execute(); + $result2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED); + foreach ($result2 as &$row2) { + $provisioning_list = $row2["provisioning_list"]; + if (strlen($provisioning_list) > 1) { + $provisioning_list_array = explode("|", $provisioning_list); + foreach ($provisioning_list_array as $prov_row) { + $prov_row_array = explode(":", $prov_row); + if (strlen($prov_row_array[0]) > 0) { + //echo "mac address: ".$prov_row_array[0]."
"; + //echo "line_number: ".$prov_row_array[1]."
"; + if ($prov_row_array[0] == $phone_mac_address) { + $line_number = $prov_row_array[1]; + //echo "prov_row: ".$prov_row."
"; + //echo "line_number: ".$line_number."
"; + //echo "

\n"; + } + $file_contents = str_replace("{v_line".$line_number."_server_address}", $_SESSION['domain_name'], $file_contents); + $file_contents = str_replace("{v_line".$line_number."_displayname}", $row2["effective_caller_id_name"], $file_contents); + $file_contents = str_replace("{v_line".$line_number."_shortname}", $row2["extension"], $file_contents); + $file_contents = str_replace("{v_line".$line_number."_user_id}", $row2["extension"], $file_contents); + $file_contents = str_replace("{v_line".$line_number."_user_password}", $row2["password"], $file_contents); + } + } + //$vm_password = $row["vm_password"]; + //$vm_password = str_replace("#", "", $vm_password); //preserves leading zeros + //$accountcode = $row["accountcode"]; + //$effective_caller_id_name = $row["effective_caller_id_name"]; + //$effective_caller_id_number = $row["effective_caller_id_number"]; + //$outbound_caller_id_name = $row["outbound_caller_id_name"]; + //$outbound_caller_id_number = $row["outbound_caller_id_number"]; + //$vm_enabled = $row["vm_enabled"]; + //$vm_mailto = $row["vm_mailto"]; + //$vm_attach_file = $row["vm_attach_file"]; + //$vm_keep_local_after_email = $row["vm_keep_local_after_email"]; + //$user_context = $row["user_context"]; + //$call_group = $row["call_group"]; + //$auth_acl = $row["auth_acl"]; + //$cidr = $row["cidr"]; + //$sip_force_contact = $row["sip_force_contact"]; + //$enabled = $row["enabled"]; + //$description = $row["description"] + } + } + unset ($prep_statement_2); + + //cleanup any remaining variables + for ($i = 1; $i <= 100; $i++) { + $file_contents = str_replace("{v_line".$i."_server_address}", "", $file_contents); + $file_contents = str_replace("{v_line".$i."_displayname}", "", $file_contents); + $file_contents = str_replace("{v_line".$i."_shortname}", "", $file_contents); + $file_contents = str_replace("{v_line".$i."_user_id}", "", $file_contents); + $file_contents = str_replace("{v_line".$i."_user_password}", "", $file_contents); + } + + //replace {v_mac} in the file name + if (substr($phone_mac_address, 0, 6) == "00085d") { + //upper case the mac address for aastra phones + $file_name = str_replace("{v_mac}", strtoupper($phone_mac_address), $file_name); + } + else { + //all other phones + $file_name = str_replace("{v_mac}", $phone_mac_address, $file_name); + } + + //write the configuration to the directory + if (strlen($_SESSION['switch']['provision']['dir']) > 0) { + $dir_array = explode(";", $_SESSION['switch']['provision']['dir']); + foreach($dir_array as $directory) { + //echo $directory.'/'.$file_name."\n"; + $fh = fopen($directory.'/'.$file_name,"w") or die("Unable to write to $directory for provisioning. Make sure the path exists and permissons are set correctly."); + fwrite($fh, $file_contents); + fclose($fh); + } + unset($file_name); + } + } + } //end for each + closedir($dir_list); + } + unset ($prep_statement); + +?> \ No newline at end of file diff --git a/app/provision/root.php b/app/provision/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/provision/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/provision_editor/app_config.php b/app/provision_editor/app_config.php new file mode 100644 index 0000000000..9aa7b9165a --- /dev/null +++ b/app/provision_editor/app_config.php @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/app/provision_editor/clip.db b/app/provision_editor/clip.db new file mode 100644 index 0000000000..5f15c2fb9e Binary files /dev/null and b/app/provision_editor/clip.db differ diff --git a/app/provision_editor/clipadd.php b/app/provision_editor/clipadd.php new file mode 100644 index 0000000000..7498d77045 --- /dev/null +++ b/app/provision_editor/clipadd.php @@ -0,0 +1,122 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "config.php"; + +if (count($_POST)>0) { + $clip_name = check_str($_POST["clip_name"]); + $clip_folder = check_str($_POST["clip_folder"]); + $clip_text_start = check_str($_POST["clip_text_start"]); + $clip_text_end = check_str($_POST["clip_text_end"]); + $clip_desc = check_str($_POST["clip_desc"]); + $clip_order = check_str($_POST["clip_order"]); + + $sql = "insert into v_clip_library "; + $sql .= "("; + $sql .= "clip_name, "; + $sql .= "clip_folder, "; + $sql .= "clip_text_start, "; + $sql .= "clip_text_end, "; + $sql .= "clip_desc, "; + $sql .= "clip_order "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$clip_name', "; + $sql .= "'$clip_folder', "; + $sql .= "'$clip_text_start', "; + $sql .= "'$clip_text_end', "; + $sql .= "'$clip_desc', "; + $sql .= "'$clip_order' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql,$db); + + require_once "header.php"; + echo "\n"; + echo "Add Complete"; + require_once "footer.php"; + return; +} + + require_once "header.php"; + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo "
Name:
Folder:
Before Selection:
"; + echo " "; + echo "
After Selection:
"; + echo " "; + echo "
Notes:
"; + echo " "; + echo "
"; + echo "
"; + + echo "
"; + echo "
"; + +require_once "footer.php"; +?> \ No newline at end of file diff --git a/app/provision_editor/clipdelete.php b/app/provision_editor/clipdelete.php new file mode 100644 index 0000000000..bdc059d619 --- /dev/null +++ b/app/provision_editor/clipdelete.php @@ -0,0 +1,54 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "config.php"; + +$id = $_GET["id"]; +if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_clip_library "; + $sql .= "where id = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql,$db); +} + +require_once "header.php"; +echo "\n"; +echo "Delete Complete"; +require_once "footer.php"; +return; + +?> diff --git a/app/provision_editor/cliplist.php b/app/provision_editor/cliplist.php new file mode 100644 index 0000000000..7235d6289f --- /dev/null +++ b/app/provision_editor/cliplist.php @@ -0,0 +1,221 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "config.php"; + +echo ""; +echo ""; +echo ""; + +function isfile($filename) { + if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function space($count) { + $r=''; $i=0; + while($i < $count) { + $r .= ' '; + $i++; + } + return $r; +} + +//show the content + echo ""; + + echo ""; + +echo ""; +echo ""; + + echo "
"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "
Clip Library
\n"; //display:none + + $sql = ""; + $sql .= "select * from v_clip_library "; + $sql .= "order by clip_folder "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + if ($result_count > 0) { + $last_folder = ''; + $tag_open = ''; + $x = 0; + $current_depth = 0; + $previous_depth = 0; + foreach($result as $row) { + $current_depth = count(explode ("/", $row[clip_folder])); + if ($current_depth < $previous_depth) { + $count = ($previous_depth - $current_depth); + $i=0; + while($i < $count){ + echo "
\n"; + $i++; + } + echo "
\n"; + } + + if ($last_folder != $row[clip_folder]) { + $clip_folder_name = str_replace ($previous_folder_name, "", $row[clip_folder]); + $clip_folder_name = str_replace ("/", "", $clip_folder_name); + echo "
 ".$clip_folder_name."  
\n\n"; + $tag_open = 1; + } + + $previous_depth = $current_depth; + $previous_folder_name = $row[clip_folder]; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "".$row[clip_name]."\n"; + echo "
\n"; + echo "\n\n"; + + $last_folder = $row[clip_folder]; + + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "
\n"; + + echo "
\n"; + echo "
"; + echo "

"; + + echo ""; + echo ""; + +?> \ No newline at end of file diff --git a/app/provision_editor/clipoptions.php b/app/provision_editor/clipoptions.php new file mode 100644 index 0000000000..fec1ac5e80 --- /dev/null +++ b/app/provision_editor/clipoptions.php @@ -0,0 +1,73 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "config.php"; +require_once "header.php"; + +echo "
"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Selected Clip:
"; + +echo " "; + +echo ""; + +echo " "; +//echo " \n"; +//echo " \n"; +//echo " \n"; + +echo " \n"; +echo " \n"; +//echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
Options











"; + +echo "
"; +echo "
"; + +require_once "footer.php"; +?> diff --git a/app/provision_editor/clipoptionslist.php b/app/provision_editor/clipoptionslist.php new file mode 100644 index 0000000000..e6c7ff579a --- /dev/null +++ b/app/provision_editor/clipoptionslist.php @@ -0,0 +1,247 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "config.php"; + +echo ""; +echo ""; + +echo ""; + +function isfile($filename) { + if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function space($count) { + $r=''; $i=0; + while($i < $count) { + $r .= ' '; + $i++; + } + return $r; +} + +//show the content + echo ""; + + echo ""; + +echo ""; +echo ""; + + echo "
"; + echo "\n"; + + echo "\n"; + echo "
\n"; + echo "
Clip Library
\n"; //display:none + + $sql = ""; + $sql .= "select * from v_clip_library "; + $sql .= "order by clip_folder "; + //$sql .= "and clip_name asc "; + + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + if ($result_count == 0) { + //no results + } + else { //received results + $last_folder = ''; + $tag_open = ''; + $x = 0; + $current_depth = 0; + $previous_depth = 0; + foreach($result as $row) { + $current_depth = count(explode("/", $row[clip_folder])); + if ($current_depth < $previous_depth) { + $count = ($previous_depth - $current_depth); + $i=0; + while($i < $count){ + echo "
\n"; + $i++; + } + echo "
\n"; + + } + + if ($last_folder != $row[clip_folder]) { + $clip_folder_name = str_replace ($previous_folder_name, "", $row[clip_folder]); + $clip_folder_name = str_replace ("/", "", $clip_folder_name); + echo "
 ".$clip_folder_name."  
\n\n"; + $tag_open = 1; + } + + $previous_depth = $current_depth; + $previous_folder_name = $row[clip_folder]; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "".$row[clip_name]."\n"; + echo "
\n"; + echo "\n\n"; + + $last_folder = $row[clip_folder]; + + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + + } //end if results + + echo "\n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
"; + + echo "

"; + echo ""; + echo ""; + +?> diff --git a/app/provision_editor/clipsearch.php b/app/provision_editor/clipsearch.php new file mode 100644 index 0000000000..c405fca466 --- /dev/null +++ b/app/provision_editor/clipsearch.php @@ -0,0 +1,187 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "config.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_POST)>0) { + $id = $_POST["id"]; + $clip_name = $_POST["clip_name"]; + $clip_folder = $_POST["clip_folder"]; + $clip_text_start = $_POST["clip_text_start"]; + $clip_text_end = $_POST["clip_text_end"]; + $clip_desc = $_POST["clip_desc"]; + $clip_order = $_POST["clip_order"]; + + require_once "header.php"; + echo "
"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + + } //end if results + + echo "
\n"; + echo "
"; + + $sql = ""; + $sql .= "select * from v_clip_library "; + $sql .= "where "; + if (strlen($id) > 0) { $sql .= "and id like '%$id%' "; } + if (strlen($clip_name) > 0) { $sql .= "and clip_name like '%$clip_name%' "; } + if (strlen($clip_folder) > 0) { $sql .= "and clip_folder like '%$clip_folder%' "; } + if (strlen($clip_text_start) > 0) { $sql .= "and clip_text_start like '%$clip_text_start%' "; } + if (strlen($clip_text_end) > 0) { $sql .= "and clip_text_end like '%$clip_text_end%' "; } + if (strlen($clip_desc) > 0) { $sql .= "and clip_desc like '%$clip_desc%' "; } + if (strlen($clip_order) > 0) { $sql .= "and clip_order like '%$clip_order%' "; } + + + $sql = trim($sql); + if (substr($sql, -5) == "where"){ $sql = substr($sql, 0, (strlen($sql)-5)); } + $sql = str_replace ("where and", "where", $sql); + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + $c = 0; + $row_style["0"] = "background-color: #F5F5DC;"; + $row_style["1"] = "background-color: #FFFFFF;"; + + echo "
\n"; + echo "\n"; + echo ""; + + if ($result_count == 0) { //no results + echo ""; + } + else { //received results + + echo ""; + //echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + echo "\n"; + + foreach($result as $row) { + //print_r( $row ); + echo "\n"; + //echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach unset($sql, $result, $row_count); + + echo "
 
    Id        clip_name Search         clip_folder        clip_text_start        clip_text_end        clip_desc        clip_order   
".$row[id]."".$row[clip_name]."".$row[clip_folder]."".$row[clip_text_start]."".$row[clip_text_end]."".$row[clip_desc]."".$row[clip_order]."
\n"; + echo "
\n"; + + + echo "

"; + echo "
\n"; + echo "
"; + + echo "

"; + require_once "footer.php"; + + unset ($result_count); + unset ($result); + unset ($key); + unset ($val); + unset ($c); + +} +else { + + require_once "header.php"; + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + echo " "; + echo " "; + echo " "; + echo "
Name:
Folder:
Start:
End:
Desc:
clip_order:
"; + echo "
"; + + echo "
"; + echo "
"; + + require_once "footer.php"; + +} //end if not post +?> diff --git a/app/provision_editor/clipupdate.php b/app/provision_editor/clipupdate.php new file mode 100644 index 0000000000..674d4cc7d1 --- /dev/null +++ b/app/provision_editor/clipupdate.php @@ -0,0 +1,142 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "config.php"; + +if (count($_POST)>0) { + $id = check_str($_POST["id"]); + $clip_name = check_str($_POST["clip_name"]); + $clip_folder = check_str($_POST["clip_folder"]); + $clip_text_start = check_str($_POST["clip_text_start"]); + $clip_text_end = check_str($_POST["clip_text_end"]); + $clip_desc = check_str($_POST["clip_desc"]); + $clip_order = check_str($_POST["clip_order"]); + + //sql update + $sql = "update v_clip_library set "; + $sql .= "clip_name = '$clip_name', "; + $sql .= "clip_folder = '$clip_folder', "; + $sql .= "clip_text_start = '$clip_text_start', "; + $sql .= "clip_text_end = '$clip_text_end', "; + $sql .= "clip_desc = '$clip_desc', "; + $sql .= "clip_order = '$clip_order' "; + $sql .= "where id = '$id' "; + $count = $db->exec(check_sql($sql)); + //echo "Affected Rows: ".$count; + + + //edit: make sure the meta redirect url is correct + require_once "header.php"; + echo "\n"; + echo "Update Complete"; + require_once "footer.php"; + return; +} +else { + //get data from the db + $id = $_GET["id"]; + + $sql = ""; + $sql .= "select * from v_clip_library "; + $sql .= "where id = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $clip_name = $row["clip_name"]; + $clip_folder = $row["clip_folder"]; + $clip_text_start = $row["clip_text_start"]; + $clip_text_end = $row["clip_text_end"]; + $clip_desc = $row["clip_desc"]; + $clip_order = $row["clip_order"]; + break; //limit to 1 row + } + echo ""; + echo "
";} + + require_once "header.php"; + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
Name:
Folder:
Before Selection:
"; + echo " "; + echo "
After Selection:
"; + echo " "; + echo "
Notes:
"; + echo " "; + echo "
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + + echo "
"; + echo "
"; + + require_once "footer.php"; +?> diff --git a/app/provision_editor/config.php b/app/provision_editor/config.php new file mode 100644 index 0000000000..9806b236e7 --- /dev/null +++ b/app/provision_editor/config.php @@ -0,0 +1,176 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +include "root.php"; + +error_reporting (E_ALL ^ E_NOTICE); + +$applicationname = 'Edit'; +$bodyoptions = ""; + +$dbfilename = "clip.db"; +$db_file_path = PROJECT_PATH."/xml_edit/"; + +//$temp = $_ENV["TEMP"]."\\"; +if (is_writable($db_file_path.$dbfilename)) { //is writable + //use database in current location + echo "yes"; +} +else { //not writable + /* + //running from a non writable location so copy to temp directory + if (file_exists($temp.$dbfilename)) { + $db_file_path = $temp; //file already exists use existing file + } + else { //file doese not exist + //copy the file to the temp dir + if (copy($db_file_path.$dbfilename, $temp.$dbfilename)) { + //echo "copy succeeded.\n"; + $db_file_path = $temp; + } + else { + echo "Copy Failed "; + exit; + } + } + */ +} + +function get_string_between($string, $start, $end){ + $string = " ".$string; + $ini = strpos($string,$start); + if ($ini == 0) return ""; + $ini += strlen($start); + $len = strpos($string,$end,$ini) - $ini; + return substr($string,$ini,$len); +} + +//$fullstring = "this is my [tag]dog[/tag]"; +//$parsed = get_string_between($fullstring, "[tag]", "[/tag]"); + +//database connection +try { + //$db = new PDO('sqlite2:example.db'); //sqlite 2 + //$db = new PDO('sqlite::memory:'); //sqlite 3 + if (!function_exists('phpmd5')) { + function phpmd5($string) { + return md5($string); + } + } + if (!function_exists('phpmd5')) { + function phpunix_timestamp($string) { + return strtotime($string); + } + } + if (!function_exists('phpnow')) { + function phpnow() { + return date('r'); + } + } + + if (!function_exists('phpleft')) { + function phpleft($string, $num) { + return substr($string, 0, $num); + } + } + + if (!function_exists('phpright')) { + function phpright($string, $num) { + return substr($string, (strlen($string)-$num), strlen($string)); + } + } + + if (!function_exists('phpsqlitedatatype')) { + function phpsqlitedatatype($string, $field) { + + //--- Begin: Get String Between start and end characters ----- + $start = '('; + $end = ')'; + $ini = stripos($string,$start); + if ($ini == 0) return ""; + $ini += strlen($start); + $len = stripos($string,$end,$ini) - $ini; + $string = substr($string,$ini,$len); + //--- End: Get String Between start and end characters ----- + + $strdatatype = ''; + $stringarray = split (',', $string); + foreach($stringarray as $lnvalue) { + + //$strdatatype .= "-- ".$lnvalue ." ".strlen($lnvalue)." delim ".strrchr($lnvalue, " ")."---
"; + //$delimpos = stripos($lnvalue, " "); + //$strdatatype .= substr($value,$delimpos,strlen($value))." --
"; + + $fieldlistarray = split (" ", $value); + //$strdatatype .= $value ."
"; + //$strdatatype .= $fieldlistarray[0] ."
"; + //echo $fieldarray[0]."
\n"; + if ($fieldarray[0] == $field) { + //$strdatatype = $fieldarray[1]." ".$fieldarray[2]." ".$fieldarray[3]." ".$fieldarray[4]; //strdatatype + } + unset($fieldarray, $string, $field); + } + + //$strdatatype = $string; + return $strdatatype; + } + } //end function + +/* + $db = new PDO('sqlite:'.$db_file_path.$dbfilename); //sqlite 3 + //bool PDO::sqliteCreateFunction ( string function_name, callback callback [, int num_args] ) + $db->sqliteCreateFunction('md5', 'phpmd5', 1); + //$db->sqliteCreateFunction('unix_timestamp', 'phpunix_timestamp', 1); + $db->sqliteCreateFunction('now', 'phpnow', 0); + $db->sqliteCreateFunction('sqlitedatatype', 'phpsqlitedatatype', 2); + $db->sqliteCreateFunction('strleft', 'phpleft', 2); + $db->sqliteCreateFunction('strright', 'phpright', 2); +*/ +} +catch (PDOException $error) { + print "error: " . $error->getMessage() . "
"; + die(); +} + +if(!function_exists('escapejs')){ + function escapejs($strtemp) { + $strtemp = str_replace ("\"", "\\\"", $strtemp); //escape the single quote + //$strtemp = str_replace ("'", "''", $strtemp); //escape the single quote + return $strtemp; + } +} + +if(!function_exists('check_str')){ + function check_str($strtemp) { + //$strtemp = str_replace ("\$", "\\\$", $strtemp); //escape the single quote + //$strtemp = str_replace ("\'", "''", $strtemp); //escape the single quote + $strtemp = str_replace ("'", "''", $strtemp); //escape the single quote + //echo "strtemp $strtemp"; + return $strtemp; + } +} + +?> diff --git a/app/provision_editor/filedelete.php b/app/provision_editor/filedelete.php new file mode 100644 index 0000000000..a45796b4d4 --- /dev/null +++ b/app/provision_editor/filedelete.php @@ -0,0 +1,87 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "config.php"; + +$folder = $_GET["folder"]; +$folder = str_replace ("\\", "/", $folder); +if (substr($folder, -1) != "/") { $folder = $folder.'/'; } +$file = $_GET["file"]; + +//echo $folder.$file; + +if (strlen($folder) > 0 && strlen($file) > 0) { + unlink($folder.$file); + header("Location: fileoptions.php"); +} +else { + //display form + require_once "header.php"; + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Path:
".$folder.$file."
"; + + echo "
"; + + echo ""; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
File Name:
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + + require_once "footer.php"; +} +?> diff --git a/app/provision_editor/filelist.php b/app/provision_editor/filelist.php new file mode 100644 index 0000000000..613ec9524a --- /dev/null +++ b/app/provision_editor/filelist.php @@ -0,0 +1,239 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "app/xml_edit/config.php"; +require_once "app/xml_edit/header.php"; + +function isfile($filename) { + //if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function space($count) { + $r=''; $i=0; + while($i < $count) { + $r .= ' '; + $i++; + } + return $r; +} + +function recur_dir($dir) { + clearstatcache(); + $htmldirlist = ''; + $htmlfilelist = ''; + $dirlist = opendir($dir); + $dir_array = array(); + while (false !== ($file = readdir($dirlist))) { + if ($file != "." AND $file != ".."){ + $newpath = $dir.'/'.$file; + $level = explode('/',$newpath); + if (substr($newpath, -4) == ".svn") { + //ignore .svn dir and subdir + } + elseif (substr($newpath, -3) == ".db") { + //ignore .db files + } + else { + $dir_array[] = $newpath; + } + if ($x > 1000) { break; }; + $x++; + } + } + + asort($dir_array); + foreach ($dir_array as $newpath){ + $level = explode('/',$newpath); + + if (is_dir($newpath)) { + /*$mod_array[] = array( + 'level'=>count($level)-1, + 'path'=>$newpath, + 'name'=>end($level), + 'type'=>'dir', + 'mod_time'=>filemtime($newpath), + 'size'=>''); + $mod_array[] = recur_dir($newpath); + */ + $dirname = end($level); + $htmldirlist .= space(count($level))."
$dirname
\n"; + $htmldirlist .= recur_dir($newpath); + $htmldirlist .= space(count($level))."
\n"; + } + else { + /*$mod_array[] = array( + 'level'=>count($level)-1, + 'path'=>$newpath, + 'name'=>end($level), + 'type'=>'file', + 'mod_time'=>filemtime($newpath), + 'size'=>filesize($newpath)); + */ + $filename = end($level); + $filesize = round(filesize($newpath)/1024, 2); + $htmlfilelist .= space(count($level))."
$filename
\n"; + $htmlfilelist .= space(count($level))."
\n"; + } + } + closedir($dirlist); + return $htmldirlist ."\n". $htmlfilelist; +} + +//begin the content + echo ""; + + echo ""; + + echo "
"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "
Files
\n"; //display:none + + echo recur_dir($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/provision/"); + + echo "
\n"; + + echo "
\n"; + echo "
"; + + echo "

"; + require_once "footer.php"; + + echo ""; + echo ""; + +?> diff --git a/app/provision_editor/filenew.php b/app/provision_editor/filenew.php new file mode 100644 index 0000000000..c6d49568af --- /dev/null +++ b/app/provision_editor/filenew.php @@ -0,0 +1,90 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +$folder = str_replace ("\\", "/", $folder); +if (substr($folder, -1) != "/") { $folder = $folder.'/'; } +$file = $_GET["file"]; + +if (strlen($folder) > 0 && strlen($file) > 0) { + //create new file + $handle = fopen($folder.$file, 'wb') or die("Error!!"); + $content = ""; + fwrite($handle, $content); + fclose($handle); + + header("Location: fileoptions.php"); +} +else { + require_once "header.php"; + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Path:
".$folder.$file."
"; + + echo "
"; + + echo ""; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
File Name:
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + + require_once "footer.php"; + +} + +?> diff --git a/app/provision_editor/fileoptions.php b/app/provision_editor/fileoptions.php new file mode 100644 index 0000000000..208cff3600 --- /dev/null +++ b/app/provision_editor/fileoptions.php @@ -0,0 +1,89 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "config.php"; +require_once "header.php"; + +$file = $_GET["file"]; +$file = str_replace ("\\", "/", $file); +$folder = $_GET["folder"]; +$folder = str_replace ($file, "", $folder); + +$urlpath = str_replace ($_SERVER["DOCUMENT_ROOT"], "", $folder); + +echo "
"; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
"; + +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "
Path:
File:
"; + +echo "
"; + +echo " "; + +echo ""; + +echo "
"; +echo ""; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "





"; +echo "
"; + +echo "
"; +echo "
"; + +require_once "footer.php"; +?> diff --git a/app/provision_editor/fileoptionslist.php b/app/provision_editor/fileoptionslist.php new file mode 100644 index 0000000000..46994251ef --- /dev/null +++ b/app/provision_editor/fileoptionslist.php @@ -0,0 +1,270 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "config.php"; +require_once "header.php"; + +function isfile($filename) { + if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function space($count) { + $r=''; $i=0; + while($i < $count) { + $r .= ' '; + $i++; + } + return $r; +} + +function recur_dir($dir) { + clearstatcache(); + $htmldirlist = ''; + $htmlfilelist = ''; + $dirlist = opendir($dir); + while ($file = readdir ($dirlist)) { + if ($file != '.' && $file != '..') { + $newpath = $dir.'/'.$file; + $level = explode('/',$newpath); + + if (is_dir($newpath)) { + /*$mod_array[] = array( + 'level'=>count($level)-1, + 'path'=>$newpath, + 'name'=>end($level), + 'type'=>'dir', + 'mod_time'=>filemtime($newpath), + 'size'=>''); + $mod_array[] = recur_dir($newpath); + */ + $dirname = end($level); + $htmldirlist .= space(count($level))."
$dirname
\n"; + //$htmldirlist .= space(count($level))."
Tools
\n"; + //$htmldirlist .= space(count($level))."
New Folder
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
New File
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
Options
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + $htmldirlist .= recur_dir($newpath); + $htmldirlist .= space(count($level))."
\n"; + + } + else { + /*$mod_array[] = array( + 'level'=>count($level)-1, + 'path'=>$newpath, + 'name'=>end($level), + 'type'=>'file', + 'mod_time'=>filemtime($newpath), + 'size'=>filesize($newpath)); + */ + $filename = end($level); + $filesize = round(filesize($newpath)/1024, 2); + $newpath = str_replace ($filename, "", $newpath); + $htmlfilelist .= space(count($level))."
$filename
\n"; + $htmlfilelist .= space(count($level))."
\n"; + } + + + } + } + + closedir($dirlist); + return $htmldirlist ."\n". $htmlfilelist; +} + +//show the content + echo "\n"; + + echo "\n"; + + echo "
"; + echo "\n"; + echo "\n"; + echo "
\n"; + //echo "
"; + + echo "\n"; + echo " \n"; + echo "\n"; + echo "
Files
\n"; //display:none + //echo "
Files
\n"; //display:none + + //echo "
Tools
\n"; + //echo "
New Folder
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //echo "
\n"; + //echo "
New File
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //echo "
\n"; + //echo "
\n"; + echo recur_dir($_SESSION['switch']['conf']['dir']); + + echo "
\n"; + + /* + echo "
Files
\n"; + echo "\n"; + echo "
Folder 1
\n"; + echo "\n"; + echo "
demo1.php
\n"; + echo "
\n"; + echo "\n"; + echo "
demo2.php
\n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "
Folder 2
\n"; + echo "\n"; + echo "
demo3.php
\n"; + echo "
\n"; + echo "\n"; + echo "
demo4.php
\n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + */ + + echo "
\n"; + echo ""; + + echo "

"; + require_once "footer.php"; + + echo ""; + echo ""; + +?> diff --git a/app/provision_editor/fileread.php b/app/provision_editor/fileread.php new file mode 100644 index 0000000000..3885abaded --- /dev/null +++ b/app/provision_editor/fileread.php @@ -0,0 +1,48 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +if (permission_exists('xml_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$filename = $_POST["file"]; +$filename = str_replace ("\\", "/", $filename); + +$handle = fopen($filename, "r"); +if ($handle) { + while (!feof($handle)) { + $buffer = fgets($handle, 4096); + echo $buffer; + } + fclose($handle); +} + +?> diff --git a/app/provision_editor/filerename.php b/app/provision_editor/filerename.php new file mode 100644 index 0000000000..9df4307c57 --- /dev/null +++ b/app/provision_editor/filerename.php @@ -0,0 +1,102 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +//$folder = str_replace ("\\", "/", $folder); +//if (substr($folder, -1) != "/") { $folder = $folder.'/'; } +$newfilename = $_GET["newfilename"]; +$filename = $_GET["filename"]; +//echo $folder.$file; + + +if (strlen($folder) > 0 && strlen($newfilename) > 0) { + //echo "new file: ".$newfilename."
"; + //echo "folder: ".$folder."
"; + //echo "orig filename: ".$filename."
";; + rename($folder.$filename, $folder.$newfilename); + header("Location: fileoptions.php"); +} +else { //display form + + require_once "header.php"; + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Path:
".$folder.$filename."

Original file name:
".$filename."
"; + + echo "
"; + + echo ""; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
Rename file to:
"; + echo " "; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + + require_once "footer.php"; + +} + +?> diff --git a/app/provision_editor/filesave.php b/app/provision_editor/filesave.php new file mode 100644 index 0000000000..0d19eaab53 --- /dev/null +++ b/app/provision_editor/filesave.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$filename = $_POST["file"]; //filename with the path +$filename = str_replace ("\\", "/", $filename); +$content = $_POST["content"]; + +$handle = fopen($filename, 'wb') or die("Error!!"); +fwrite($handle, $content); +fclose($handle); + +//set the reload_xml value to true + $_SESSION["reload_xml"] = true; + +echo $content; + +?> diff --git a/app/provision_editor/folderdelete.php b/app/provision_editor/folderdelete.php new file mode 100644 index 0000000000..97c2592ea8 --- /dev/null +++ b/app/provision_editor/folderdelete.php @@ -0,0 +1,46 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +$folder = str_replace ("\\", "/", $folder); + +if (strlen($folder) > 0) { + //delete the folder + rmdir($folder); //, 0700 + header("Location: fileoptions.php"); +} + +?> \ No newline at end of file diff --git a/app/provision_editor/foldernew.php b/app/provision_editor/foldernew.php new file mode 100644 index 0000000000..922d8eb5a2 --- /dev/null +++ b/app/provision_editor/foldernew.php @@ -0,0 +1,86 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "config.php"; + +$folder = $_GET["folder"]; +$folder = str_replace ("\\", "/", $folder); +$foldername = $_GET["foldername"]; + +if (strlen($folder) > 0 && strlen($foldername) > 0) { + //create new folder + mkdir($folder.'/'.$foldername); //, 0700 + header("Location: fileoptions.php"); +} +else { //display form + + require_once "header.php"; + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Path:
".$folder."
"; + + echo "
"; + + echo ""; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
Folder Name:
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + + require_once "footer.php"; +} + +?> diff --git a/app/provision_editor/footer.php b/app/provision_editor/footer.php new file mode 100644 index 0000000000..b11f46e5d4 --- /dev/null +++ b/app/provision_editor/footer.php @@ -0,0 +1,43 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +/* +echo "

"; +echo "
"; + +echo ""; +echo "fusionpbx "; +echo "        "; +echo "http://fusionpbx.com"; +echo "        "; +echo "Author: Mark J. Crane "; + +echo ""; +*/ +echo "
"; +echo ""; +echo ""; + +?> \ No newline at end of file diff --git a/app/provision_editor/header.php b/app/provision_editor/header.php new file mode 100644 index 0000000000..bd10f557d3 --- /dev/null +++ b/app/provision_editor/header.php @@ -0,0 +1,83 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +echo ""; +echo ""; +echo ""; +//echo ""; +echo ""; + + +echo ""; +echo ""; +echo ""; +echo "
"; + +?> \ No newline at end of file diff --git a/app/provision_editor/images/file.gif b/app/provision_editor/images/file.gif new file mode 100644 index 0000000000..a6cf9845fc Binary files /dev/null and b/app/provision_editor/images/file.gif differ diff --git a/app/provision_editor/images/file.png b/app/provision_editor/images/file.png new file mode 100644 index 0000000000..33b5f5f374 Binary files /dev/null and b/app/provision_editor/images/file.png differ diff --git a/app/provision_editor/images/folder.gif b/app/provision_editor/images/folder.gif new file mode 100644 index 0000000000..50ab253cc7 Binary files /dev/null and b/app/provision_editor/images/folder.gif differ diff --git a/app/provision_editor/images/gear.png b/app/provision_editor/images/gear.png new file mode 100644 index 0000000000..1adf1e778f Binary files /dev/null and b/app/provision_editor/images/gear.png differ diff --git a/app/provision_editor/images/leaf.gif b/app/provision_editor/images/leaf.gif new file mode 100644 index 0000000000..50ab253cc7 Binary files /dev/null and b/app/provision_editor/images/leaf.gif differ diff --git a/app/provision_editor/images/minus.gif b/app/provision_editor/images/minus.gif new file mode 100644 index 0000000000..1094ab912b Binary files /dev/null and b/app/provision_editor/images/minus.gif differ diff --git a/app/provision_editor/images/plus.gif b/app/provision_editor/images/plus.gif new file mode 100644 index 0000000000..fdacf8efe5 Binary files /dev/null and b/app/provision_editor/images/plus.gif differ diff --git a/app/provision_editor/images/program.gif b/app/provision_editor/images/program.gif new file mode 100644 index 0000000000..dc3dfa1104 Binary files /dev/null and b/app/provision_editor/images/program.gif differ diff --git a/app/provision_editor/images/thumbnails/Thumbs.db b/app/provision_editor/images/thumbnails/Thumbs.db new file mode 100644 index 0000000000..c4e4684b24 Binary files /dev/null and b/app/provision_editor/images/thumbnails/Thumbs.db differ diff --git a/app/provision_editor/images/thumbnails/cliplibrary.png b/app/provision_editor/images/thumbnails/cliplibrary.png new file mode 100644 index 0000000000..bc70f332fd Binary files /dev/null and b/app/provision_editor/images/thumbnails/cliplibrary.png differ diff --git a/app/provision_editor/images/thumbnails/filemanagement.png b/app/provision_editor/images/thumbnails/filemanagement.png new file mode 100644 index 0000000000..88cb7661b1 Binary files /dev/null and b/app/provision_editor/images/thumbnails/filemanagement.png differ diff --git a/app/provision_editor/images/thumbnails/phpeditor.png b/app/provision_editor/images/thumbnails/phpeditor.png new file mode 100644 index 0000000000..c6f7f369bb Binary files /dev/null and b/app/provision_editor/images/thumbnails/phpeditor.png differ diff --git a/app/provision_editor/index.php b/app/provision_editor/index.php new file mode 100644 index 0000000000..93b207a173 --- /dev/null +++ b/app/provision_editor/index.php @@ -0,0 +1,207 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +require_once "app/xml_edit/config.php"; +echo "\n"; +echo "\n"; +echo " \n"; +echo " "; + + echo "\n"; + + echo ""; + ?> + + + + + + + + + + +
+ + + +\n"; + echo "\n"; + } + else { + echo "\n"; + } +?> + +
+ + \ No newline at end of file diff --git a/app/provision_editor/list.php b/app/provision_editor/list.php new file mode 100644 index 0000000000..87a80f3128 --- /dev/null +++ b/app/provision_editor/list.php @@ -0,0 +1,113 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "header.php"; + +//show the content + echo "
"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + + } //end if results + + echo "
\n"; + echo "
"; + + $sql = ""; + $sql .= "select * from v_clip_library "; + + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + $c = 0; + $row_style["0"] = "background-color: #F5F5DC;"; + $row_style["1"] = "background-color: #FFFFFF;"; + + echo "
\n"; + echo "\n"; + echo ""; + + if ($result_count == 0) { //no results + echo ""; + } + else { //received results + + echo ""; + //echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + echo "\n"; + + foreach($result as $row) { + //print_r( $row ); + echo "\n"; + //echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + + echo "
 
    Id      clip_name      clip_folder        clip_text_start        clip_text_end        clip_desc        clip_order   
".$row[id]."".$row[clip_name]."".$row[clip_folder]."".$row[clip_text_start]."".$row[clip_text_end]."".$row[clip_desc]."".$row[clip_order]."
\n"; + echo "
\n"; + + echo "
\n"; + + echo "
\n"; + echo "   \n"; + echo "   \n"; + echo "
\n"; + echo ""; + + echo "

"; + require_once "footer.php"; + +?> diff --git a/app/provision_editor/readme.txt b/app/provision_editor/readme.txt new file mode 100644 index 0000000000..cafc4144ae --- /dev/null +++ b/app/provision_editor/readme.txt @@ -0,0 +1,7 @@ +Notes + +IFrame +http://www.quirksmode.org/js/iframe.html + +Tree View +http://www.dddekerf.dds.nl/DHTML_Treeview/DHTML_Treeview.htm \ No newline at end of file diff --git a/app/provision_editor/root.php b/app/provision_editor/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/provision_editor/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/recordings/app_config.php b/app/recordings/app_config.php new file mode 100644 index 0000000000..fdd5653a2c --- /dev/null +++ b/app/recordings/app_config.php @@ -0,0 +1,100 @@ + \ No newline at end of file diff --git a/app/recordings/app_defaults.php b/app/recordings/app_defaults.php new file mode 100644 index 0000000000..36abb0f07b --- /dev/null +++ b/app/recordings/app_defaults.php @@ -0,0 +1,30 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//if the recordings directory doesn't exist then create it + if (!is_readable($_SESSION['switch']['recordings']['dir'])) { mkdir($_SESSION['switch']['recordings']['dir'],0777,true); } + +?> \ No newline at end of file diff --git a/app/recordings/root.php b/app/recordings/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/recordings/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/recordings/slim.swf b/app/recordings/slim.swf new file mode 100644 index 0000000000..24b36c9daf Binary files /dev/null and b/app/recordings/slim.swf differ diff --git a/app/recordings/v_recordings.php b/app/recordings/v_recordings.php new file mode 100644 index 0000000000..54c8d653b9 --- /dev/null +++ b/app/recordings/v_recordings.php @@ -0,0 +1,294 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('recordings_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/paging.php"; + +//set the max php execution time + ini_set(max_execution_time,7200); + +//get the http get values and set them as php variables + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//download the recordings + if ($_GET['a'] == "download" && permission_exists('recordings_download')) { + session_cache_limiter('public'); + if ($_GET['type'] = "rec") { + if (file_exists($_SESSION['switch']['recordings']['dir'].'/'.base64_decode($_GET['filename']))) { + $fd = fopen($_SESSION['switch']['recordings']['dir'].'/'.base64_decode($_GET['filename']), "rb"); + if ($_GET['t'] == "bin") { + header("Content-Type: application/force-download"); + header("Content-Type: application/octet-stream"); + header("Content-Type: application/download"); + header("Content-Description: File Transfer"); + header('Content-Disposition: attachment; filename="'.base64_decode($_GET['filename']).'"'); + } + else { + $file_ext = substr(base64_decode($_GET['filename']), -3); + if ($file_ext == "wav") { + header("Content-Type: audio/x-wav"); + } + if ($file_ext == "mp3") { + header("Content-Type: audio/mp3"); + } + } + header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 + header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past + header("Content-Length: " . filesize($_SESSION['switch']['recordings']['dir'].'/'.base64_decode($_GET['filename']))); + fpassthru($fd); + } + } + exit; + } + +//upload the recording + if (($_POST['submit'] == "Upload") && is_uploaded_file($_FILES['ulfile']['tmp_name']) && permission_exists('recordings_upload')) { + if ($_POST['type'] == 'rec') { + move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['switch']['recordings']['dir'].'/'.$_FILES['ulfile']['name']); + $savemsg = "Uploaded file to ".$_SESSION['switch']['recordings']['dir']."/". htmlentities($_FILES['ulfile']['name']); + //system('chmod -R 744 '.$_SESSION['switch']['recordings']['dir'].'*'); + unset($_POST['txtCommand']); + } + } + +//build a list of recordings + $config_recording_list = '|'; + $i = 0; + $sql = ""; + $sql .= "select * from v_recordings "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $config_recording_list .= $row['recording_filename']."|"; + } + unset ($prep_statement); + +//add recordings to the database + if (is_dir($_SESSION['switch']['recordings']['dir'].'/')) { + if ($dh = opendir($_SESSION['switch']['recordings']['dir'].'/')) { + while (($file = readdir($dh)) !== false) { + if (filetype($_SESSION['switch']['recordings']['dir']."/".$file) == "file") { + if (strpos($config_recording_list, "|".$file) === false) { + //echo "The $file was not found
"; + //file not found add it to the database + $a_file = explode("\.", $file); + $recording_uuid = uuid(); + $sql = "insert into v_recordings "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "recording_uuid, "; + $sql .= "recording_filename, "; + $sql .= "recording_name, "; + $sql .= "recording_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$recording_uuid', "; + $sql .= "'$file', "; + $sql .= "'".$a_file[0]."', "; + $sql .= "'auto' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + } + } + closedir($dh); + } + } + +//include the header + require_once "includes/header.php"; + +//begin the content + echo ""; + + echo "
"; + echo "
\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "
\n"; + echo "
"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "

Recordings:
\n"; + echo "
\n"; + echo " To make a recording dial *732 or you can make a\n"; + echo " 16bit 8khz/16khz Mono WAV file then copy it to the\n"; + echo " following directory then refresh the page to play it back.\n"; + echo " Click on the 'Filename' to download it or the 'Recording Name' to\n"; + echo " play the audio.\n"; + echo "

"; + + echo "
\n"; + + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + if ($v_path_show) { + echo "location: \n"; + echo $_SESSION['switch']['recordings']['dir']; + } + echo " \n"; + echo " \n"; + echo " \n"; + echo " File to upload:\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "
"; + + $sql = ""; + $sql .= "select * from v_recordings "; + $sql .= "where domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $num_rows = count($result); + unset ($prep_statement, $result, $sql); + + $rows_per_page = 100; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + $sql = ""; + $sql .= "select * from v_recordings "; + $sql .= "where domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "\n"; + echo "\n"; + echo th_order_by('recording_filename', 'Filename (download)', $order_by, $order); + echo th_order_by('recording_name', 'Recording Name (play)', $order_by, $order); + echo "\n"; + echo th_order_by('recording_description', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + $tmp_filesize = filesize($_SESSION['switch']['recordings']['dir'].'/'.$row['recording_filename']); + $tmp_filesize = byte_convert($tmp_filesize); + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + echo "
Size\n"; + if (permission_exists('recordings_add')) { + echo " $v_link_label_add\n"; + } + echo "
"; + echo " \n"; + echo $row['recording_filename']; + echo " "; + echo " "; + echo " \n"; + echo $row['recording_name']; + echo " "; + echo "\n"; + echo " ".$tmp_filesize; + echo " ".$row['recording_description']."\n"; + if (permission_exists('recordings_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('recordings_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('recordings_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + + echo "
"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + +//include the footer + require_once "includes/footer.php"; + +?> \ No newline at end of file diff --git a/app/recordings/v_recordings_delete.php b/app/recordings/v_recordings_delete.php new file mode 100644 index 0000000000..d0ec21f93b --- /dev/null +++ b/app/recordings/v_recordings_delete.php @@ -0,0 +1,75 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('recordings_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = $_GET["id"]; +} + +if (strlen($id)>0) { + //get filename + $sql = "select * from v_recordings "; + $sql .= "where recording_uuid = '$id' "; + $sql .= "and domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $filename = $row["recording_filename"]; + break; //limit to 1 row + } + unset ($prep_statement); + + //delete recording from the database + $sql = "delete from v_recordings "; + $sql .= "where recording_uuid = '$id' "; + $sql .= "and domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + + //delete the recording + unlink($_SESSION['switch']['recordings']['dir']."/".$filename); +} + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; +?> \ No newline at end of file diff --git a/app/recordings/v_recordings_edit.php b/app/recordings/v_recordings_edit.php new file mode 100644 index 0000000000..9ce07f37c6 --- /dev/null +++ b/app/recordings/v_recordings_edit.php @@ -0,0 +1,271 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('recordings_add') || permission_exists('recordings_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//set the action as an add or an update + if (isset($_REQUEST["id"])) { + $action = "update"; + $recording_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get the form value and set to php variables + if (count($_POST)>0) { + $recording_filename = check_str($_POST["recording_filename"]); + $recording_name = check_str($_POST["recording_name"]); + //$recording_uuid = check_str($_POST["recording_uuid"]); + $recording_description = check_str($_POST["recording_description"]); + + //clean the recording filename and name + $recording_filename = str_replace(" ", "_", $recording_filename); + $recording_filename = str_replace("'", "", $recording_filename); + $recording_name = str_replace(" ", "_", $recording_name); + $recording_name = str_replace("'", "", $recording_name); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $recording_uuid = check_str($_POST["recording_uuid"]); + } + + //check for all required data + //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + if (strlen($recording_filename) == 0) { $msg .= "Please provide: Filename (download)
\n"; } + if (strlen($recording_name) == 0) { $msg .= "Please provide: Recording Name (play)
\n"; } + //if (strlen($recording_uuid) == 0) { $msg .= "Please provide: recording_uuid
\n"; } + //if (strlen($recording_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('recordings_add')) { + $recording_uuid = uuid(); + $sql = "insert into v_recordings "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "recording_uuid, "; + $sql .= "recording_filename, "; + $sql .= "recording_name, "; + $sql .= "recording_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$recording_uuid', "; + $sql .= "'$recording_filename', "; + $sql .= "'$recording_name', "; + $sql .= "'$recording_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update" && permission_exists('recordings_edit')) { + //get the original filename + $sql = ""; + $sql .= "select * from v_recordings "; + $sql .= "where recording_uuid = '$recording_uuid' "; + $sql .= "and domain_uuid = '$domain_uuid' "; + //echo "sql: ".$sql."
\n"; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $recording_filename_orig = $row["recording_filename"]; + break; //limit to 1 row + } + unset ($prep_statement); + + //if file name is not the same then rename the file + if ($recording_filename != $recording_filename_orig) { + //echo "orig: ".$_SESSION['switch']['recordings']['dir'].'/'.$recording_filename_orig."
\n"; + //echo "new: ".$_SESSION['switch']['recordings']['dir'].'/'.$recording_filename."
\n"; + rename($_SESSION['switch']['recordings']['dir'].'/'.$recording_filename_orig, $_SESSION['switch']['recordings']['dir'].'/'.$recording_filename); + } + + //update the database with the new data + $sql = "update v_recordings set "; + $sql .= "domain_uuid = '$domain_uuid', "; + $sql .= "recording_filename = '$recording_filename', "; + $sql .= "recording_name = '$recording_name', "; + //$sql .= "recording_uuid = '$recording_uuid', "; + $sql .= "recording_description = '$recording_description' "; + $sql .= "where domain_uuid = '$domain_uuid'"; + $sql .= "and recording_uuid = '$recording_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $recording_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_recordings "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and recording_uuid = '$recording_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $domain_uuid = $row["domain_uuid"]; + $recording_filename = $row["recording_filename"]; + $recording_name = $row["recording_name"]; + //$recording_uuid = $row["recording_uuid"]; + $recording_description = $row["recording_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + //echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Add RecordingEdit Recording
\n"; + echo " Filename (download):\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Name of the file. example.wav\n"; + echo "
\n"; + echo " Recording Name (play):\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Recording Name. example: recordingx\n"; + echo "
\n"; + //echo " recording_uuid:\n"; + //echo "\n"; + //echo " \n"; + //echo "
\n"; + //echo "\n"; + //echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "You may enter a description here for your reference (not parsed).\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/recordings/v_recordings_play.php b/app/recordings/v_recordings_play.php new file mode 100644 index 0000000000..ccbcccb8c3 --- /dev/null +++ b/app/recordings/v_recordings_play.php @@ -0,0 +1,78 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('recordings_play')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$filename = base64_decode($_GET['filename']); +$type = $_GET['type']; //moh //rec + +?> + + + + + + + + + + + + +
+ file: +
+ "; + echo ""; + + echo "\n"; + + } + if ($file_ext == "mp3") { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + ?> +
+ + + diff --git a/app/registrations/app_config.php b/app/registrations/app_config.php new file mode 100644 index 0000000000..0b088ef4ca --- /dev/null +++ b/app/registrations/app_config.php @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/app/registrations/root.php b/app/registrations/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/registrations/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/registrations/v_status_registrations.php b/app/registrations/v_status_registrations.php new file mode 100644 index 0000000000..bb8114bb57 --- /dev/null +++ b/app/registrations/v_status_registrations.php @@ -0,0 +1,189 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; + +//check permissions + if (permission_exists("registrations_domain") || permission_exists("registrations_all") || if_group("superadmin")) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//request form values and set them as variables + $sip_profile_name = trim($_REQUEST["profile"]); + +//define variables + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + +//create the event socket connection + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + if (!$fp) { + $msg = "
Connection to Event Socket failed.
"; + } + +//show the error message or show the content + if (strlen($msg) > 0) { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Message
$msg
\n"; + echo "
\n"; + } + else { + //get sofia status profile information including registrations + $cmd = "api sofia xmlstatus profile ".$sip_profile_name." reg"; + $xml_response = trim(event_socket_request($fp, $cmd)); + if ($xml_response == "Invalid Profile!") { $xml_response = "Invalid Profile!"; } + $xml_response = str_replace("", "", $xml_response); + $xml_response = str_replace("", "", $xml_response); + try { + $xml = new SimpleXMLElement($xml_response); + } + catch(Exception $e) { + echo $e->getMessage(); + exit; + } + + //build the registration array + if (count($xml->registrations->registration) > 0) { + $registrations = ''; + $x = 0; + foreach ($xml->registrations->registration as $row) { + //get the values from xml and set them to the channel array + $registrations[$x]['user'] = $row->{'user'}; + $user_array = explode('@', $row->{'user'}); + $registrations[$x]['call-id'] = $row->{'call-id'}; + $registrations[$x]['contact'] = $row->{'contact'}; + $registrations[$x]['sip-auth-user'] = $row->{'sip-auth-user'}; + $registrations[$x]['agent'] = $row->{'agent'}; + $registrations[$x]['host'] = $row->{'host'}; + $registrations[$x]['network-ip'] = $row->{'network-ip'}; + $registrations[$x]['network-port'] = $row->{'network-port'}; + $registrations[$x]['sip-auth-realm'] = $row->{'sip-auth-realm'}; + $registrations[$x]['mwi-account'] = $row->{'mwi-account'}; + $registrations[$x]['status'] = $row->{'status'}; + + //remove unrelated domains + if (count($_SESSION["domains"]) > 1 && !permission_exists('registrations_all')) { + if ($registrations[$x]['sip-auth-realm'] != $_SESSION['domain_name']) { + unset($registrations[$x]); + } + } + else { + if ($registrations[$x]['sip-auth-realm'] != $_SESSION['domain_name']) { + unset($registrations[$x]); + } + } + //increment the array id + $x++; + } + } + + //show the header + require_once "includes/header.php"; + + //show the registrations + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo " Registrations: ".count($registrations)."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + if (count($_SESSION["domains"]) > 1) { + echo " \n"; + } + //echo " \n"; + //echo " \n"; + echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo "\n"; + + //order the array + require_once "includes/classes/array_order.php"; + $order = new array_order(); + $registrations = $order->sort($registrations, 'domain', 'user'); + + //display the array + if (count($registrations) > 0) { + foreach ($registrations as $row) { + echo "\n"; + if (count($_SESSION["domains"]) > 1) { + echo "\n"; + } + //\n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } + } + echo "
DomainUserCaller IDUserContactsip-auth-userAgentHostIPPortmwi-accountStatus
 ".$row['sip-auth-realm']."  ".$row['call-id']."  ".$row['user']."  ".$row['contact']."  ".$row['sip-auth-user']."  ".$row['agent']."  ".$row['host']."  ".$row['network-ip']."  ".$row['network-port']."  ".$row['mwi-account']."  ".$row['status']." 
\n"; + + fclose($fp); + unset($xml); + } + +//add some space at the bottom of the page + echo "
\n"; + echo "
\n"; + echo "
\n"; + +//get the footer + require_once "includes/footer.php"; + +?> \ No newline at end of file diff --git a/app/ring_groups/app_config.php b/app/ring_groups/app_config.php new file mode 100644 index 0000000000..ee0c1de965 --- /dev/null +++ b/app/ring_groups/app_config.php @@ -0,0 +1,127 @@ + \ No newline at end of file diff --git a/app/ring_groups/ring_groups.php b/app/ring_groups/ring_groups.php new file mode 100644 index 0000000000..e3e5ffaa5c --- /dev/null +++ b/app/ring_groups/ring_groups.php @@ -0,0 +1,167 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get variables used to control the order + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Ring Groups 
\n"; + echo " A ring group is a set of extensions that can be called with a ring strategy.

\n"; + echo "
\n"; + + //prepare to page the results + $sql = "select count(*) as num_rows from v_ring_groups "; + $sql .= "where domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + + //prepare to page the results + $rows_per_page = 10; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + //get the list + $sql = " select * from v_ring_groups "; + $sql .= " where domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo th_order_by('ring_group_name', 'Name', $order_by, $order); + echo th_order_by('ring_group_extension', 'Extension', $order_by, $order); + //echo th_order_by('ring_group_context', 'Context', $order_by, $order); + //echo th_order_by('ring_group_strategy', 'Strategy', $order_by, $order); + //echo th_order_by('ring_group_timeout_sec', 'Timeout', $order_by, $order); + //echo th_order_by('ring_group_timeout_app', 'Timeout App', $order_by, $order); + //echo th_order_by('ring_group_timeout_data', 'Timeout Data', $order_by, $order); + echo th_order_by('ring_group_enabled', 'Enabled', $order_by, $order); + echo th_order_by('ring_group_description', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo " $v_link_label_add\n"; + echo "
".$row['ring_group_name']." ".$row['ring_group_extension']." ".$row['ring_group_context']." ".$row['ring_group_strategy']." ".$row['ring_group_timeout_sec']." ".$row['ring_group_timeout_app']." ".$row['ring_group_timeout_data']." ".$row['ring_group_enabled']." ".$row['ring_group_description']." \n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/ring_groups/ring_groups_delete.php b/app/ring_groups/ring_groups_delete.php new file mode 100644 index 0000000000..5669bbe6f8 --- /dev/null +++ b/app/ring_groups/ring_groups_delete.php @@ -0,0 +1,88 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the http value and set it as a php variable + if (count($_GET)>0) { + $id = check_str($_GET["id"]); + } + +//delete the user data + if (strlen($id)>0) { + //get the dialplan + $sql = "select dialplan_uuid from v_ring_groups "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and ring_group_uuid = '".$id."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(); + foreach ($result as &$row) { + $dialplan_uuid = $row["dialplan_uuid"]; + } + unset ($prep_statement); + //delete from the ring groups table + $sql = "delete from v_ring_groups "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and ring_group_uuid = '".$id."' "; + $db->exec(check_sql($sql)); + unset($sql); + //delete from the ring group extensions table + $sql = "delete from v_ring_group_extensions "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and ring_group_uuid = '".$id."' "; + $db->exec(check_sql($sql)); + unset($sql); + //delete from the dialplan + $sql = "delete from v_dialplans "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '".$dialplan_uuid."' "; + $db->exec(check_sql($sql)); + unset($sql); + //save the xml + save_dialplan_xml(); + //apply settings reminder + $_SESSION["reload_xml"] = true; + } + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/ring_groups/ring_groups_edit.php b/app/ring_groups/ring_groups_edit.php new file mode 100644 index 0000000000..c208a3b81c --- /dev/null +++ b/app/ring_groups/ring_groups_edit.php @@ -0,0 +1,529 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//delete the user from the v_extension_users + if ($_GET["a"] == "delete" && permission_exists("user_delete")) { + //set the variables + $ring_group_extension_uuid = check_str($_REQUEST["id"]); + $ring_group_uuid = check_str($_REQUEST["ring_group_uuid"]); + //delete the extension from the ring_group + $sql = "delete from v_ring_group_extensions "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and ring_group_extension_uuid = '$ring_group_extension_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + //redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
Delete Complete
"; + require_once "includes/footer.php"; + return; + } + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $ring_group_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $ring_group_name = check_str($_POST["ring_group_name"]); + $ring_group_extension = check_str($_POST["ring_group_extension"]); + $ring_group_context = check_str($_POST["ring_group_context"]); + $ring_group_strategy = check_str($_POST["ring_group_strategy"]); + $ring_group_timeout_sec = check_str($_POST["ring_group_timeout_sec"]); + $ring_group_timeout_action = check_str($_POST["ring_group_timeout_action"]); + $ring_group_enabled = check_str($_POST["ring_group_enabled"]); + $ring_group_description = check_str($_POST["ring_group_description"]); + $dialplan_uuid = check_str($_POST["dialplan_uuid"]); + //$ring_group_timeout_action = "transfer:1001 XML default"; + $ring_group_timeout_array = explode(":", $ring_group_timeout_action); + $ring_group_timeout_app = array_shift($ring_group_timeout_array); + $ring_group_timeout_data = join(':', $ring_group_timeout_array); + $extension_uuid = check_str($_POST["extension_uuid"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $ring_group_uuid = check_str($_POST["ring_group_uuid"]); + } + + //check for all required data + if (strlen($ring_group_name) == 0) { $msg .= "Please provide: Name
\n"; } + if (strlen($ring_group_extension) == 0) { $msg .= "Please provide: Extension
\n"; } + if (strlen($ring_group_strategy) == 0) { $msg .= "Please provide: Strategy
\n"; } + if (strlen($ring_group_timeout_sec) == 0) { $msg .= "Please provide: Timeout
\n"; } + if (strlen($ring_group_timeout_app) == 0) { $msg .= "Please provide: Timeout Action
\n"; } + if (strlen($ring_group_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } + //if (strlen($ring_group_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //set the context for users that are not in the superadmin group + if (!if_group("superadmin")) { + if (count($_SESSION["domains"]) > 1) { + $ring_group_context = $_SESSION['domain_name']; + } + else { + $ring_group_context = "default"; + } + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + //prepare the uuids + $ring_group_uuid = uuid(); + $dialplan_uuid = uuid(); + //add the ring group + $sql = "insert into v_ring_groups "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "ring_group_uuid, "; + $sql .= "ring_group_name, "; + $sql .= "ring_group_extension, "; + $sql .= "ring_group_context, "; + $sql .= "ring_group_strategy, "; + $sql .= "ring_group_timeout_sec, "; + $sql .= "ring_group_timeout_app, "; + $sql .= "ring_group_timeout_data, "; + $sql .= "ring_group_enabled, "; + $sql .= "ring_group_description, "; + $sql .= "dialplan_uuid "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$_SESSION['domain_uuid']."', "; + $sql .= "'".$ring_group_uuid."', "; + $sql .= "'$ring_group_name', "; + $sql .= "'$ring_group_extension', "; + $sql .= "'$ring_group_context', "; + $sql .= "'$ring_group_strategy', "; + $sql .= "'$ring_group_timeout_sec', "; + $sql .= "'$ring_group_timeout_app', "; + $sql .= "'$ring_group_timeout_data', "; + $sql .= "'$ring_group_enabled', "; + $sql .= "'$ring_group_description', "; + $sql .= "'$dialplan_uuid' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_ring_groups set "; + $sql .= "ring_group_name = '$ring_group_name', "; + $sql .= "ring_group_extension = '$ring_group_extension', "; + if (if_group("superadmin")) { + $sql .= "ring_group_context = '$ring_group_context', "; + } + $sql .= "ring_group_strategy = '$ring_group_strategy', "; + $sql .= "ring_group_timeout_sec = '$ring_group_timeout_sec', "; + $sql .= "ring_group_timeout_app = '$ring_group_timeout_app', "; + $sql .= "ring_group_timeout_data = '$ring_group_timeout_data', "; + $sql .= "ring_group_enabled = '$ring_group_enabled', "; + $sql .= "ring_group_description = '$ring_group_description' "; + //$sql .= "dialplan_uuid = '$dialplan_uuid' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and ring_group_uuid = '$ring_group_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + } + + if ($action == "update" || $action == "add") { + //if extension_uuid then add it to ring group extensions + if (strlen($extension_uuid) > 0) { + $ring_group_extension_uuid = uuid(); + $sql = "insert into v_ring_group_extensions "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "ring_group_uuid, "; + $sql .= "ring_group_extension_uuid, "; + $sql .= "extension_uuid "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$_SESSION['domain_uuid']."', "; + $sql .= "'$ring_group_uuid', "; + $sql .= "'$ring_group_extension_uuid', "; + $sql .= "'$extension_uuid' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + + //if it does not exist in the dialplan then add it + $sql = "select count(*) as num_rows from v_dialplans "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '".$dialplan_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] == 0) { + //create the dialplan entry for fax + $dialplan_name = $ring_group_name; + $dialplan_order ='333'; + $dialplan_context = $ring_group_context; + $dialplan_enabled = 'true'; + $dialplan_description = $ring_group_description; + $app_uuid = '1d61fb65-1eec-bc73-a6ee-a6203b4fe6f2'; + dialplan_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_name, $dialplan_order, $dialplan_context, $dialplan_enabled, $dialplan_description, $app_uuid); + + // + $dialplan_detail_tag = 'condition'; //condition, action, antiaction + $dialplan_detail_type = 'destination_number'; + $dialplan_detail_data = '^'.$ring_group_extension.'$'; + $dialplan_detail_order = '000'; + $dialplan_detail_group = '1'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + // + $dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan_detail_type = 'set'; + $dialplan_detail_data = 'ring_group_uuid='.$ring_group_uuid; + $dialplan_detail_order = '010'; + $dialplan_detail_group = '1'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + // + $dialplan_detail_tag = 'action'; //condition, action, antiaction + //$dialplan_detail_type = 'transfer'; + //$dialplan_detail_data = $ring_group_extension . ' LUA ring_group.lua'; + $dialplan_detail_type = 'lua'; + $dialplan_detail_data = 'ring_group.lua'; + $dialplan_detail_order = '020'; + $dialplan_detail_group = '1'; + dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); + + //save the xml + save_dialplan_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + } + } + + //redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + if ($action == "add") { + echo "Add Complete\n"; + } + if ($action == "update") { + echo "Update Complete\n"; + } + echo "
\n"; + require_once "includes/footer.php"; + exit; + } + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $ring_group_uuid = $_GET["id"]; + $sql = "select * from v_ring_groups "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and ring_group_uuid = '$ring_group_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(); + foreach ($result as &$row) { + $ring_group_name = $row["ring_group_name"]; + $ring_group_extension = $row["ring_group_extension"]; + $ring_group_context = $row["ring_group_context"]; + $ring_group_strategy = $row["ring_group_strategy"]; + $ring_group_timeout_sec = $row["ring_group_timeout_sec"]; + $ring_group_timeout_app = $row["ring_group_timeout_app"]; + $ring_group_timeout_data = $row["ring_group_timeout_data"]; + $ring_group_enabled = $row["ring_group_enabled"]; + $ring_group_description = $row["ring_group_description"]; + $dialplan_uuid = $row["dialplan_uuid"]; + } + unset ($prep_statement); + if (strlen($ring_group_timeout_app) > 0) { + $ring_group_timeout_action = $ring_group_timeout_app.":".$ring_group_timeout_data; + } + } + +//set defaults + if (strlen($ring_group_timeout_sec) == 0) { $ring_group_timeout_sec = '30'; } + if (strlen($ring_group_enabled) == 0) { $ring_group_enabled = 'true'; } + if (if_group("superadmin")) { + if (strlen($ring_group_context) == 0) { + if (count($_SESSION["domains"]) > 1) { + $ring_group_context = $_SESSION['domain_name']; + } + else { + $ring_group_context = "default"; + } + } + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if (if_group("superadmin")) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " "; + echo " "; + echo " "; + echo " "; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " "; + echo "
Ring Group AddRing Group Edit
\n"; + echo "A ring group is a set of extensions that can be called with a ring strategy.

\n"; + echo "
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the name.\n"; + echo "
\n"; + echo " Extension:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the extension.\n"; + echo "
\n"; + echo " Context:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the context.\n"; + echo "
\n"; + echo " Strategy:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Select the strategy.\n"; + echo "
Extensions:"; + if ($action == "update") { + echo " \n"; + $sql = "SELECT g.ring_group_extension_uuid, e.extension_uuid, e.extension "; + $sql .= "FROM v_ring_groups as r, v_ring_group_extensions as g, v_extensions as e "; + $sql .= "where g.ring_group_uuid = r.ring_group_uuid "; + $sql .= "and g.domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and g.ring_group_uuid = '".$ring_group_uuid."' "; + $sql .= "and e.extension_uuid = g.extension_uuid "; + $sql .= "order by e.extension asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + foreach($result as $field) { + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + } + echo "
".$field['extension']."\n"; + echo " $v_link_label_delete\n"; + echo "
\n"; + } + echo "
\n"; + $sql = "SELECT * FROM v_extensions "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "order by extension asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + echo " "; + if ($action == "update") { + echo " \n"; + } + unset($sql, $result); + echo "
\n"; + echo " Add the extensions to the ring group.\n"; + echo "
\n"; + echo "
\n"; + echo " Timeout:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the timeout in seconds.\n"; + echo "
\n"; + echo " Destination:\n"; + echo "\n"; + //switch_select_destination(select_type, select_label, select_name, select_value, select_style, action); + switch_select_destination("dialplan", "", "ring_group_timeout_action", $ring_group_timeout_action, "", ""); + echo "
\n"; + echo " Select the timeout destination.\n"; + echo "
\n"; + echo " Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Select enable or disable the ring group.\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the description.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/ring_groups/root.php b/app/ring_groups/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/ring_groups/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/script_edit/app_config.php b/app/script_edit/app_config.php new file mode 100644 index 0000000000..032ef17928 --- /dev/null +++ b/app/script_edit/app_config.php @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/app/script_edit/clipadd.php b/app/script_edit/clipadd.php new file mode 100644 index 0000000000..0b9b326d8a --- /dev/null +++ b/app/script_edit/clipadd.php @@ -0,0 +1,126 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('script_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_POST)>0) { + $clip_name = check_str($_POST["clip_name"]); + $clip_folder = check_str($_POST["clip_folder"]); + $clip_text_start = check_str($_POST["clip_text_start"]); + $clip_text_end = check_str($_POST["clip_text_end"]); + $clip_desc = check_str($_POST["clip_desc"]); + $clip_order = check_str($_POST["clip_order"]); + if (strlen($clip_order) == 0) { $clip_order = 0; } + + $sql = "insert into v_clips "; + $sql .= "("; + $sql .= "clip_uuid, "; + $sql .= "clip_name, "; + $sql .= "clip_folder, "; + $sql .= "clip_text_start, "; + $sql .= "clip_text_end, "; + $sql .= "clip_desc, "; + $sql .= "clip_order "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$clip_name', "; + $sql .= "'$clip_folder', "; + $sql .= "'$clip_text_start', "; + $sql .= "'$clip_text_end', "; + $sql .= "'$clip_desc', "; + $sql .= "'$clip_order' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql,$db); + + require_once "header.php"; + echo "\n"; + echo "Add Complete"; + require_once "footer.php"; + return; +} + +//show the content + require_once "header.php"; + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + + //echo "Clip Library"; + //echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo "
Name:
Folder:
Before Selection:
"; + echo " "; + echo "
After Selection:
"; + echo " "; + echo "
Notes:
"; + echo " "; + echo "
"; + echo "
"; + + echo "
"; + echo "
"; + + require_once "footer.php"; +?> \ No newline at end of file diff --git a/app/script_edit/clipdelete.php b/app/script_edit/clipdelete.php new file mode 100644 index 0000000000..043332a193 --- /dev/null +++ b/app/script_edit/clipdelete.php @@ -0,0 +1,56 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('script_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the uuid from http values + $clip_uuid = check_str($_GET["id"]); + +//delete the clip + if (strlen($_GET["id"])>0) { + $sql = "delete from v_clips "; + $sql .= "where clip_uuid = '".$clip_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql,$db); + } + +//redirect the browser + require_once "header.php"; + echo "\n"; + echo "Delete Complete"; + require_once "footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/script_edit/cliplist.php b/app/script_edit/cliplist.php new file mode 100644 index 0000000000..94750847ad --- /dev/null +++ b/app/script_edit/cliplist.php @@ -0,0 +1,235 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "includes/checkauth.php"; +if (permission_exists('script_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +//require_once "edit/header.php"; + +echo ""; +echo ""; +echo ""; + +function isfile($filename) { + if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function space($count) { + $r=''; $i=0; + while($i < $count) { + $r .= ' '; + $i++; + } + return $r; +} + +echo ""; + +echo ""; + +echo ""; +echo ""; +echo "
"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "
Clip Library
\n"; //display:none + +$sql = "select * from v_clips "; +$sql .= "order by clip_folder "; +$prep_statement = $db->prepare(check_sql($sql)); +$prep_statement->execute(); +$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); +$result_count = count($result); + +if ($result_count > 0) { //no results + $last_folder = ''; + $tag_open = ''; + $x = 0; + $current_depth = 0; + $previous_depth = 0; + foreach($result as $row) { + $current_depth = count(explode ("/", $row['clip_folder'])); + if ($current_depth < $previous_depth) { + $count = ($previous_depth - $current_depth); + $i=0; + while($i < $count){ + echo "
\n"; + $i++; + } + echo "
\n"; + } + + if ($last_folder != $row['clip_folder']) { + $clip_folder_name = str_replace ($previous_folder_name, "", $row['clip_folder']); + $clip_folder_name = str_replace ("/", "", $clip_folder_name); + echo "
 ".$clip_folder_name."  
\n\n"; + $tag_open = 1; + } + + $previous_depth = $current_depth; + $previous_folder_name = $row['clip_folder']; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "".$row['clip_name']."\n"; + echo "
\n"; + echo "\n\n"; + + $last_folder = $row['clip_folder']; + + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + +} //end if results + +echo "\n"; +echo "
\n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo "
"; + +echo "

"; +//require_once "includes/footer.php"; + +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); + +echo ""; +echo ""; + +?> \ No newline at end of file diff --git a/app/script_edit/clipoptions.php b/app/script_edit/clipoptions.php new file mode 100644 index 0000000000..ce27c640dd --- /dev/null +++ b/app/script_edit/clipoptions.php @@ -0,0 +1,71 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('script_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "header.php"; + +echo "
"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Selected Clip:
"; +echo " "; +echo ""; + +echo " "; +//echo " \n"; +//echo " \n"; +//echo " \n"; + +echo " \n"; +echo " \n"; +//echo " \n"; +echo " \n"; +echo " \n"; + +echo " \n"; +echo "
Options











"; + +echo "
"; +echo "
"; + +require_once "footer.php"; +?> \ No newline at end of file diff --git a/app/script_edit/clipoptionslist.php b/app/script_edit/clipoptionslist.php new file mode 100644 index 0000000000..ba406f8114 --- /dev/null +++ b/app/script_edit/clipoptionslist.php @@ -0,0 +1,228 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('php_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +echo ""; +echo ""; + +echo ""; + +function isfile($filename) { + if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function space($count) { + $r=''; $i=0; + while($i < $count) { + $r .= ' '; + $i++; + } + return $r; +} + +//show the content + echo ""; + + echo ""; + +echo ""; +echo ""; + + echo "
"; + echo "\n"; + + echo "\n"; + echo "
\n"; + echo "
Clip Library
\n"; //display:none + + $sql = "select * from v_clips "; + $sql .= "order by clip_folder "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + if ($result_count > 0) { //no results + $last_folder = ''; + $tag_open = ''; + $x = 0; + $current_depth = 0; + $previous_depth = 0; + foreach($result as $row) { + $current_depth = count(explode("/", $row[clip_folder])); + if ($current_depth < $previous_depth) { + $count = ($previous_depth - $current_depth); + $i=0; + while($i < $count){ + echo "
\n"; + $i++; + } + echo "
\n"; + + } + + if ($last_folder != $row['clip_folder']) { + $clip_folder_name = str_replace ($previous_folder_name, "", $row['clip_folder']); + $clip_folder_name = str_replace ("/", "", $clip_folder_name); + echo "
 ".$clip_folder_name."  
\n\n"; + $tag_open = 1; + } + + $previous_depth = $current_depth; + $previous_folder_name = $row['clip_folder']; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "".$row['clip_name']."\n"; + + echo "
\n"; + echo "\n\n"; + + $last_folder = $row['clip_folder']; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
"; + + echo "

"; + + unset ($result_count); + unset ($result); + unset ($key); + unset ($val); + unset ($c); + + echo ""; + echo ""; + +?> \ No newline at end of file diff --git a/app/script_edit/clipsearch.php b/app/script_edit/clipsearch.php new file mode 100644 index 0000000000..69e3b9a487 --- /dev/null +++ b/app/script_edit/clipsearch.php @@ -0,0 +1,180 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/checkauth.php"; +if (permission_exists('script_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_POST)>0) { + $clip_uuid = $_POST["id"]; + $clip_name = $_POST["clip_name"]; + $clip_folder = $_POST["clip_folder"]; + $clip_text_start = $_POST["clip_text_start"]; + $clip_text_end = $_POST["clip_text_end"]; + $clip_desc = $_POST["clip_desc"]; + $clip_order = $_POST["clip_order"]; + + require_once "header.php"; + echo "
"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + + } //end if results + + echo "
\n"; + echo "
"; + + $sql .= "select * from v_clips "; + $sql .= "where "; + if (strlen($clip_uuid) > 0) { $sql .= "and id = '$clip_uuid' "; } + if (strlen($clip_name) > 0) { $sql .= "and clip_name like '%$clip_name%' "; } + if (strlen($clip_folder) > 0) { $sql .= "and clip_folder like '%$clip_folder%' "; } + if (strlen($clip_text_start) > 0) { $sql .= "and clip_text_start like '%$clip_text_start%' "; } + if (strlen($clip_text_end) > 0) { $sql .= "and clip_text_end like '%$clip_text_end%' "; } + if (strlen($clip_desc) > 0) { $sql .= "and clip_desc like '%$clip_desc%' "; } + if (strlen($clip_order) > 0) { $sql .= "and clip_order like '%$clip_order%' "; } + + $sql = trim($sql); + if (substr($sql, -5) == "where"){ $sql = substr($sql, 0, (strlen($sql)-5)); } + $sql = str_replace ("where and", "where", $sql); + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + $c = 0; + $row_style["0"] = "background-color: #F5F5DC;"; + $row_style["1"] = "background-color: #FFFFFF;"; + + echo "
\n"; + echo "\n"; + echo ""; + + if ($result_count == 0) { + //no results + echo ""; + } + else { //received results + echo ""; + //echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + echo "\n"; + + foreach($result as $row) { + //print_r( $row ); + echo "\n"; + //echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach unset($sql, $result, $row_count); + echo "
 
    Id        clip_name Search         clip_folder        clip_text_start        clip_text_end        clip_desc        clip_order   
".$row[id]."".$row[clip_name]."".$row[clip_folder]."".$row[clip_text_start]."".$row[clip_text_end]."".$row[clip_desc]."".$row[clip_order]."
\n"; + echo "
\n"; + + echo "

"; + echo "
\n"; + echo "
"; + echo "

"; + require_once "footer.php"; + + unset ($result_count); + unset ($result); + unset ($key); + unset ($val); + unset ($c); + +} +else { + + //show the content + require_once "header.php"; + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + echo " "; + echo " "; + echo " "; + echo "
Name:
Folder:
Start:
End:
Desc:
clip_order:
"; + echo "
"; + + echo "
"; + echo "
"; + + require_once "footer.php"; + +} //end if not post +?> \ No newline at end of file diff --git a/app/script_edit/clipupdate.php b/app/script_edit/clipupdate.php new file mode 100644 index 0000000000..692eb5f78d --- /dev/null +++ b/app/script_edit/clipupdate.php @@ -0,0 +1,138 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('script_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_POST)>0) { + $clip_uuid = check_str($_POST["id"]); + $clip_name = check_str($_POST["clip_name"]); + $clip_folder = check_str($_POST["clip_folder"]); + $clip_text_start = check_str($_POST["clip_text_start"]); + $clip_text_end = check_str($_POST["clip_text_end"]); + $clip_desc = check_str($_POST["clip_desc"]); + $clip_order = check_str($_POST["clip_order"]); + + //sql update + $sql = "update v_clips set "; + $sql .= "clip_name = '$clip_name', "; + $sql .= "clip_folder = '$clip_folder', "; + $sql .= "clip_text_start = '$clip_text_start', "; + $sql .= "clip_text_end = '$clip_text_end', "; + $sql .= "clip_desc = '$clip_desc', "; + $sql .= "clip_order = '$clip_order' "; + $sql .= "where clip_uuid = '$clip_uuid' "; + $count = $db->exec(check_sql($sql)); + //echo "affected rows: ".$count; + + //redirect the browser + require_once "header.php"; + echo "\n"; + echo "Update Complete"; + require_once "footer.php"; + return; +} +else { + //get the uuid from http values + $clip_uuid = check_str($_GET["id"]); + + //get the clip + $sql = "select * from v_clips "; + $sql .= "where clip_uuid = '$clip_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $clip_name = $row["clip_name"]; + $clip_folder = $row["clip_folder"]; + $clip_text_start = $row["clip_text_start"]; + $clip_text_end = $row["clip_text_end"]; + $clip_desc = $row["clip_desc"]; + $clip_order = $row["clip_order"]; + break; //limit to 1 row + } +} + +//show the content + require_once "header.php"; + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
Name:
Folder:
Before Selection:
"; + echo " "; + echo "
After Selection:
"; + echo " "; + echo "
Notes:
"; + echo " "; + echo "
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + + echo "
"; + echo "
"; + + require_once "footer.php"; +?> \ No newline at end of file diff --git a/app/script_edit/filedelete.php b/app/script_edit/filedelete.php new file mode 100644 index 0000000000..0607661bb7 --- /dev/null +++ b/app/script_edit/filedelete.php @@ -0,0 +1,84 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('script_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +$folder = str_replace ("\\", "/", $folder); +if (substr($folder, -1) != "/") { $folder = $folder.'/'; } +$file = $_GET["file"]; + +if (strlen($folder) > 0 && strlen($file) > 0) { + unlink($folder.$file); + header("Location: fileoptions.php"); +} +else { + //display form + require_once "header.php"; + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Path:
".$folder.$file."
"; + + echo "
"; + + echo ""; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
File Name:
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + + require_once "footer.php"; +} +?> \ No newline at end of file diff --git a/app/script_edit/filelist.php b/app/script_edit/filelist.php new file mode 100644 index 0000000000..e924ea2bc5 --- /dev/null +++ b/app/script_edit/filelist.php @@ -0,0 +1,254 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('script_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "header.php"; + +function isfile($filename) { + //if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function space($count) { + $r=''; $i=0; + while($i < $count) { + $r .= ' '; + $i++; + } + return $r; +} + +function recur_dir($dir) { + clearstatcache(); + $htmldirlist = ''; + $htmlfilelist = ''; + $dirlist = opendir($dir); + $dir_array = array(); + while (false !== ($file = readdir($dirlist))) { + if ($file != "." AND $file != ".."){ + $newpath = $dir.'/'.$file; + $level = explode('/',$newpath); + if (substr($newpath, -4) == ".svn") { + //ignore .svn dir and subdir + } + elseif (substr($newpath, -3) == ".db") { + //ignore .db files + } + else { + $dir_array[] = $newpath; + } + if ($x > 1000) { break; }; + $x++; + } + } + + asort($dir_array); + foreach ($dir_array as $newpath){ + $level = explode('/',$newpath); + + if (is_dir($newpath)) { + /*$mod_array[] = array( + 'level'=>count($level)-1, + 'path'=>$newpath, + 'name'=>end($level), + 'type'=>'dir', + 'mod_time'=>filemtime($newpath), + 'size'=>''); + $mod_array[] = recur_dir($newpath); + */ + $dirname = end($level); + $htmldirlist .= space(count($level))."
$dirname
\n"; + //$htmldirlist .= space(count($level))."
Tools
\n"; + //$htmldirlist .= space(count($level))."
New Folder
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
New File
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
Options
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + $htmldirlist .= recur_dir($newpath); + $htmldirlist .= space(count($level))."
\n"; + } + else { + /*$mod_array[] = array( + 'level'=>count($level)-1, + 'path'=>$newpath, + 'name'=>end($level), + 'type'=>'file', + 'mod_time'=>filemtime($newpath), + 'size'=>filesize($newpath)); + */ + $filename = end($level); + $filesize = round(filesize($newpath)/1024, 2); + $htmlfilelist .= space(count($level))."
$filename
\n"; + $htmlfilelist .= space(count($level))."
\n"; + } + } + closedir($dirlist); + return $htmldirlist ."\n". $htmlfilelist; +} + +echo ""; + + +echo ""; + +echo "
"; +echo "\n"; +echo "\n"; +echo " \n"; + $sql = "select * from v_virtual_table_fields "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and virtual_table_uuid = '$virtual_table_uuid' "; + $sql .= "order by virtual_field_order asc "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + $result_names = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + $result_count = count($result); + foreach($result_names as $row) { + $virtual_field_label = $row["virtual_field_label"]; + $virtual_field_name = $row["virtual_field_name"]; + $virtual_field_type = $row["virtual_field_type"]; + $virtual_field_value = $row["virtual_field_value"]; + $virtual_field_list_hidden = $row["virtual_field_list_hidden"]; + $virtual_field_column = $row["virtual_field_column"]; + $virtual_field_required = $row["virtual_field_required"]; + $virtual_field_order = $row["virtual_field_order"]; + $virtual_field_order_tab = $row["virtual_field_order_tab"]; + $virtual_field_description = $row["virtual_field_description"]; + + $name_array[$virtual_field_name]['virtual_field_label'] = $row["virtual_field_label"]; + $name_array[$virtual_field_name]['virtual_field_type'] = $row["virtual_field_type"]; + $name_array[$virtual_field_name]['virtual_field_list_hidden'] = $row["virtual_field_list_hidden"]; + $name_array[$virtual_field_name]['virtual_field_column'] = $row["virtual_field_column"]; + $name_array[$virtual_field_name]['virtual_field_required'] = $row["virtual_field_required"]; + $name_array[$virtual_field_name]['virtual_field_order'] = $row["virtual_field_order"]; + $name_array[$virtual_field_name]['virtual_field_order_tab'] = $row["virtual_field_order_tab"]; + $name_array[$virtual_field_name]['virtual_field_description'] = $row["virtual_field_description"]; + } + unset($sql, $prep_statement, $row); + $fieldcount = count($name_array); + + $i = 1; + while($i <= $rcount){ + $virtual_field_name = check_str($_POST[$i."field_name"]); + $virtual_data_field_value = check_str($_POST[$i."field_value"]); + if ($i==1) { + $unique_temp_id = md5('7k3j2m'.date('r')); //used to find the first item + $virtual_data_row_uuid = $unique_temp_id; + } + $sql = "select virtual_field_type, virtual_field_name from v_virtual_table_fields "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and virtual_table_uuid = '$virtual_table_uuid' "; + $sql .= "and virtual_field_name = '$virtual_field_name' "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + while($row = $prep_statement->fetch()){ + $virtual_field_type = $row['virtual_field_type']; + } + + if ($virtual_field_type == "upload_file" || $virtual_field_type == "uploadimage") { + //print_r($_FILES); + $upload_temp_dir = $_ENV["TEMP"]."\\"; + ini_set('upload_tmp_dir', $upload_temp_dir); + //$uploaddir = ""; + if ($virtual_field_type == "upload_file") { + $upload_file = $filedir . $_FILES[$i.'field_value']['name']; + } + if ($virtual_field_type == "uploadimage") { + $upload_file = $imagedir . $_FILES[$i.'field_value']['name']; + } + // $_POST[$i."field_name"] + //print_r($_FILES); + //echo "upload_file $upload_file
\n"; + //echo "upload_temp_dir $upload_temp_dir
\n"; + + $virtual_data_field_value = $_FILES[$i.'field_value']['name']; + //echo "name $virtual_data_field_value
\n"; + //echo "virtual_field_name $virtual_field_name
\n"; + //$i."field_value" + //echo "if (move_uploaded_file(\$_FILES[$i.'field_value']['tmp_name'], $upload_file)) "; + //if (strlen($_FILES[$i.'field_value']['name'])>0) { //only do the following if there is a file name + //foreach($_FILES as $file) + //{ + //[$i.'field_value'] + //print_r($file); + if($_FILES[$i.'field_value']['error'] == 0 && $_FILES[$i.'field_value']['size'] > 0) { + if (move_uploaded_file($_FILES[$i.'field_value']['tmp_name'], $upload_file)) { + //echo $_FILES['userfile']['name'] ."
"; + //echo "was successfully uploaded. "; + //echo "

"; + //print "
";
+									//print_r($_FILES);
+									//print "
"; + } + else { + //echo "Upload Error. Here's some debugging info:\n"; + //print "
\n";
+									//print_r($_FILES);
+									//print "
\n"; + //exit; + } + } + //} + //} + } //end if file or image + + if ($action == "add" && permission_exists('virtual_tables_data_add')) { + //get a unique id for the virtual_data_row_uuid + if ($i==1) { + $virtual_data_row_uuid = uuid(); + } + + //insert the field data + $sql = "insert into v_virtual_table_data "; + $sql .= "("; + $sql .= "virtual_table_data_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "virtual_data_row_uuid, "; + if(strlen($virtual_data_parent_row_uuid)>0) { + $sql .= "virtual_data_parent_row_uuid, "; + } + $sql .= "virtual_table_uuid, "; + if (strlen($virtual_table_parent_id) > 0) { + $sql .= "virtual_table_parent_id, "; + } + $sql .= "virtual_field_name, "; + $sql .= "virtual_data_field_value, "; + $sql .= "virtual_data_add_user, "; + $sql .= "virtual_data_add_date "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$domain_uuid', "; + $sql .= "'$virtual_data_row_uuid', "; + if(strlen($virtual_data_parent_row_uuid)>0) { + $sql .= "'$virtual_data_parent_row_uuid', "; + } + $sql .= "'$virtual_table_uuid', "; + if (strlen($virtual_table_parent_id) > 0) { + $sql .= "'$virtual_table_parent_id', "; + } + $sql .= "'$virtual_field_name', "; + switch ($name_array[$virtual_field_name]['virtual_field_type']) { + case "phone": + $tmp_phone = preg_replace('{\D}', '', $virtual_data_field_value); + $sql .= "'$tmp_phone', "; + break; + case "add_user": + $sql .= "'".$_SESSION["username"]."', "; + break; + case "add_date": + $sql .= "now(), "; + break; + case "mod_user": + $sql .= "'".$_SESSION["username"]."', "; + break; + case "mod_date": + $sql .= "now(), "; + break; + default: + $sql .= "'$virtual_data_field_value', "; + } + $sql .= "'".$_SESSION["username"]."', "; + $sql .= "now() "; + $sql .= ")"; + $db->exec(check_sql($sql)); + $lastinsertid = $db->lastInsertId($id); + unset($sql); + } //end action add + + if ($action == "update" && permission_exists('virtual_tables_data_edit')) { + $virtual_data_row_uuid = $_POST["virtual_data_row_uuid"]; + + $sql_update = "update v_virtual_table_data set "; + switch ($name_array[$virtual_field_name]['virtual_field_type']) { + case "phone": + $tmp_phone = preg_replace('{\D}', '', $virtual_data_field_value); + $sql_update .= "virtual_data_field_value = '$tmp_phone' "; + break; + case "add_user": + $sql_update .= "virtual_data_field_value = '".$_SESSION["username"]."' "; + break; + case "add_date": + $sql_update .= "virtual_data_field_value = now() "; + break; + case "mod_user": + $sql_update .= "virtual_data_field_value = '".$_SESSION["username"]."' "; + break; + case "mod_date": + $sql_update .= "virtual_data_field_value = now() "; + break; + default: + $sql_update .= "virtual_data_field_value = '$virtual_data_field_value' "; + } + $sql_update .= "where domain_uuid = '$domain_uuid' "; + $sql_update .= "and virtual_table_uuid = '$virtual_table_uuid' "; + if (strlen($virtual_table_parent_id) > 0) { + $sql_update .= "and virtual_table_parent_id = '$virtual_table_parent_id' "; + } + $sql_update .= "and virtual_data_row_uuid = '$virtual_data_row_uuid' "; + if(strlen($virtual_data_parent_row_uuid)>0) { + $sql_update .= "and virtual_data_parent_row_uuid = '$virtual_data_parent_row_uuid' "; + } + $sql_update .= "and virtual_field_name = '$virtual_field_name' "; + $count = $db->exec(check_sql($sql_update)); + unset ($sql_update); + if ($count > 0) { + //do nothing the update was successfull + } + else { + //no value to update so insert new value + $sql = "insert into v_virtual_table_data "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "virtual_data_row_uuid, "; + if(strlen($virtual_data_parent_row_uuid)>0) { + $sql .= "virtual_data_parent_row_uuid, "; + } + $sql .= "virtual_table_uuid, "; + $sql .= "virtual_table_parent_id, "; + $sql .= "virtual_field_name, "; + $sql .= "virtual_data_field_value, "; + $sql .= "virtual_data_add_user, "; + $sql .= "virtual_data_add_date "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$virtual_data_row_uuid', "; + if(strlen($virtual_data_parent_row_uuid)>0) { + $sql .= "'$virtual_data_parent_row_uuid', "; + } + $sql .= "'$virtual_table_uuid', "; + $sql .= "'$virtual_table_parent_id', "; + $sql .= "'$virtual_field_name', "; + switch ($name_array[$virtual_field_name]['virtual_field_type']) { + case "phone": + $tmp_phone = preg_replace('{\D}', '', $virtual_data_field_value); + $sql .= "'$tmp_phone', "; + break; + case "add_user": + $sql .= "'".$_SESSION["username"]."', "; + break; + case "add_date": + $sql .= "now(), "; + break; + case "mod_user": + $sql .= "'".$_SESSION["username"]."', "; + break; + case "mod_date": + $sql .= "now(), "; + break; + default: + $sql .= "'$virtual_data_field_value', "; + } + $sql .= "'".$_SESSION["username"]."', "; + $sql .= "now() "; + $sql .= ")"; + + $db->exec(check_sql($sql)); + $lastinsertid = $db->lastInsertId($id); + unset($sql); + } + } + $i++; + } + + //show the header + require_once "includes/header.php"; + + //set the meta redirect + if (strlen($virtual_data_parent_row_uuid) == 0) { + echo "\n"; + } + else { + echo "\n"; + } + + //show a message to the user before the redirect + echo "
\n"; + if ($action == "add") { echo "Add Complete\n"; } + if ($action == "update") { echo "Update Complete\n"; } + echo "
\n"; + require_once "includes/footer.php"; + return; + } + +//show the header + require_once "includes/header.php"; + +//pre-populate the form + if ($action == "update") { + //get the field values + $sql = ""; + $sql .= "select * from v_virtual_table_data "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + if (strlen($search_all) == 0) { + $sql .= "and virtual_table_uuid = '$virtual_table_uuid' "; + if (strlen($virtual_data_parent_row_uuid) > 0) { + $sql .= " and virtual_data_parent_row_uuid = '$virtual_data_parent_row_uuid' "; + } + } + else { + $sql .= "and virtual_data_row_uuid in ("; + $sql .= "select virtual_data_row_uuid from v_virtual_table_data \n"; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and virtual_table_uuid = '$virtual_table_uuid' "; + if (strlen($virtual_data_parent_row_uuid) > 0) { + $sql .= " and virtual_data_parent_row_uuid = '$virtual_data_parent_row_uuid' "; + } + else { + //$sql .= "and virtual_data_field_value like '%$search_all%' )\n"; + $tmp_digits = preg_replace('{\D}', '', $search_all); + if (is_numeric($tmp_digits) && strlen($tmp_digits) > 5) { + if (strlen($tmp_digits) == '11' ) { + $sql .= "and virtual_data_field_value like '%".substr($tmp_digits, -10)."%' )\n"; + } + else { + $sql .= "and virtual_data_field_value like '%$tmp_digits%' )\n"; + } + } + else { + $sql .= "and virtual_data_field_value like '%$search_all%' )\n"; + } + } + } + $sql .= "order by virtual_data_row_uuid asc "; + + $row_id = ''; + $row_id_found = false; + $next_row_id_found = false; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + $x=0; + while($row = $prep_statement->fetch()) { + //set the last last row id + if ($x==0) { + if (strlen($virtual_data_row_uuid) == 0) { + $virtual_data_row_uuid = $row['virtual_data_row_uuid']; + } + $first_virtual_data_row_uuid = $row['virtual_data_row_uuid']; + } + //get the data for the specific row id + if ($virtual_data_row_uuid == $row['virtual_data_row_uuid']) { + //set the data and save it to an array + $data_row[$row['virtual_field_name']] = $row['virtual_data_field_value']; + //set the previous row id + if ($previous_row_id != $row['virtual_data_row_uuid']) { + $previous_virtual_data_row_uuid = $previous_row_id; + $row_id_found = true; + } + } + //detect a new row id + if ($previous_row_id != $row['virtual_data_row_uuid']) { + if ($row_id_found) { + if (!$next_row_id_found) { + //make sure it is not the current row id + if ($virtual_data_row_uuid != $row['virtual_data_row_uuid']) { + $next_virtual_data_row_uuid = $row['virtual_data_row_uuid']; + $next_row_id_found = true; + } + } + } + + //set the last last row id + $last_virtual_data_row_uuid = $row['virtual_data_row_uuid']; + + //set the temporary previous row id + $previous_row_id = $row['virtual_data_row_uuid']; + + //set the record number array + $record_number_array[$row['virtual_data_row_uuid']] = $x+1; + + $x++; + } + } + + //save the total number of records + $total_records = $x; + + //set record number + if (strlen($_GET["n"]) == 0) { + $n = 1; + } + else { + $n = $_GET["n"]; + } + unset($sql, $prep_statement, $row); + } + +//use this when the calendar is needed + //echo "\n"; + //echo "\n"; + //echo ""; + +//begin creating the content + echo "
"; + +//get the title and description of the virtual table + echo "
\n"; +//echo "
"; + +echo "\n"; +echo " \n"; +echo "\n"; +echo "
Files
\n"; //display:none +//echo "
Files
\n"; //display:none + +echo recur_dir($_SESSION['switch']['scripts']['dir']); + +echo "
\n"; + +echo "
\n"; +echo ""; + +echo "

"; +require_once "footer.php"; + +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); + +echo ""; +echo ""; + +?> \ No newline at end of file diff --git a/app/script_edit/filenew.php b/app/script_edit/filenew.php new file mode 100644 index 0000000000..3dfd2a69fc --- /dev/null +++ b/app/script_edit/filenew.php @@ -0,0 +1,88 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('script_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +$folder = str_replace ("\\", "/", $folder); +if (substr($folder, -1) != "/") { $folder = $folder.'/'; } +$file = $_GET["file"]; + +if (strlen($folder) > 0 && strlen($file) > 0) { + //create new file + $handle = fopen($folder.$file, 'wb') or die("Error!!"); + $content = ""; + fwrite($handle, $content); + fclose($handle); + header("Location: fileoptions.php"); +} +else { + require_once "header.php"; + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Path:
".$folder.$file."
"; + + echo "
"; + + echo ""; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
File Name:
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + + require_once "footer.php"; +} + +?> \ No newline at end of file diff --git a/app/script_edit/fileoptions.php b/app/script_edit/fileoptions.php new file mode 100644 index 0000000000..78b54ec3a5 --- /dev/null +++ b/app/script_edit/fileoptions.php @@ -0,0 +1,85 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('script_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "header.php"; + +$file = $_GET["file"]; +$file = str_replace ("\\", "/", $file); +$folder = $_GET["folder"]; +$folder = str_replace ($file, "", $folder); +$urlpath = str_replace ($_SERVER["DOCUMENT_ROOT"], "", $folder); + +echo "
"; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
"; + +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "
Path:
File:
"; + +echo "
"; +echo " "; +echo ""; + +echo "
"; +echo ""; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "





"; +echo "
"; + +echo "
"; +echo "
"; + +require_once "footer.php"; +?> \ No newline at end of file diff --git a/app/script_edit/fileoptionslist.php b/app/script_edit/fileoptionslist.php new file mode 100644 index 0000000000..7f4938d8c5 --- /dev/null +++ b/app/script_edit/fileoptionslist.php @@ -0,0 +1,246 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('script_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "header.php"; + +function isfile($filename) { + if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function space($count) { + $r=''; $i=0; + while($i < $count) { + $r .= ' '; + $i++; + } + return $r; +} + +function recur_dir($dir) { + clearstatcache(); + $htmldirlist = ''; + $htmlfilelist = ''; + $dirlist = opendir($dir); + while ($file = readdir ($dirlist)) { + if ($file != '.' && $file != '..') { + $newpath = $dir.'/'.$file; + $level = explode('/',$newpath); + + if (is_dir($newpath)) { + /*$mod_array[] = array( + 'level'=>count($level)-1, + 'path'=>$newpath, + 'name'=>end($level), + 'type'=>'dir', + 'mod_time'=>filemtime($newpath), + 'size'=>''); + $mod_array[] = recur_dir($newpath); + */ + $dirname = end($level); + $htmldirlist .= space(count($level))."
$dirname
\n"; + //$htmldirlist .= space(count($level))."
Tools
\n"; + //$htmldirlist .= space(count($level))."
New Folder
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
New File
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
Options
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + $htmldirlist .= recur_dir($newpath); + $htmldirlist .= space(count($level))."
\n"; + } + else { + /*$mod_array[] = array( + 'level'=>count($level)-1, + 'path'=>$newpath, + 'name'=>end($level), + 'type'=>'file', + 'mod_time'=>filemtime($newpath), + 'size'=>filesize($newpath)); + */ + $filename = end($level); + $filesize = round(filesize($newpath)/1024, 2); + $newpath = str_replace ($filename, "", $newpath); + $htmlfilelist .= space(count($level))."
$filename
\n"; + $htmlfilelist .= space(count($level))."
\n"; + } + } + } + + closedir($dirlist); + return $htmldirlist ."\n". $htmlfilelist; +} + +echo "\n"; + +echo "\n"; + +echo "
"; +echo "\n"; + +echo "\n"; +echo "
\n"; +echo "\n"; +echo " \n"; +echo "\n"; +echo "
Files
\n"; //display:none +//echo "
Files
\n"; //display:none + +//echo "
Tools
\n"; +//echo "
New Folder
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' +//echo "
\n"; +//echo "
New File
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' +//echo "
\n"; +//echo "
\n"; + +echo recur_dir($_SESSION['switch']['scripts']['dir']); + +echo "
\n"; + + +echo "
\n"; +echo ""; + +echo "

"; +require_once "footer.php"; + +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); + +echo ""; +echo ""; + +?> \ No newline at end of file diff --git a/app/script_edit/fileread.php b/app/script_edit/fileread.php new file mode 100644 index 0000000000..907c9ec087 --- /dev/null +++ b/app/script_edit/fileread.php @@ -0,0 +1,49 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('script_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$filename = $_POST["file"]; +$filename = str_replace ("\\", "/", $filename); + +$handle = fopen($filename, "r"); +if ($handle) { + while (!feof($handle)) { + $buffer = fgets($handle, 4096); + echo $buffer; + } + fclose($handle); +} + +?> \ No newline at end of file diff --git a/app/script_edit/filerename.php b/app/script_edit/filerename.php new file mode 100644 index 0000000000..8a6bc58ddf --- /dev/null +++ b/app/script_edit/filerename.php @@ -0,0 +1,102 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('script_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +//$folder = str_replace ("\\", "/", $folder); +//if (substr($folder, -1) != "/") { $folder = $folder.'/'; } +$newfilename = $_GET["newfilename"]; +$filename = $_GET["filename"]; +//echo $folder.$file; + + +if (strlen($folder) > 0 && strlen($newfilename) > 0) { + //echo "new file: ".$newfilename."
"; + //echo "folder: ".$folder."
"; + //echo "orig filename: ".$filename."
";; + rename($folder.$filename, $folder.$newfilename); + header("Location: fileoptions.php"); +} +else { //display form + + require_once "header.php"; + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Path:
".$folder.$filename."

Original file name:
".$filename."
"; + + echo "
"; + + echo ""; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
Rename file to:
"; + echo " "; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + + require_once "footer.php"; + +} + +?> \ No newline at end of file diff --git a/app/script_edit/filesave.php b/app/script_edit/filesave.php new file mode 100644 index 0000000000..4d1c007bd2 --- /dev/null +++ b/app/script_edit/filesave.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('script_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$filename = $_POST["file"]; //filename with the path +$filename = str_replace ("\\", "/", $filename); +$content = $_POST["content"]; + +$handle = fopen($filename, 'wb') or die("Error!!"); +fwrite($handle, $content); +fclose($handle); + +//set the reload_xml value to true + $_SESSION["reload_xml"] = true; + +echo $content; + +?> \ No newline at end of file diff --git a/app/script_edit/folderdelete.php b/app/script_edit/folderdelete.php new file mode 100644 index 0000000000..62c669cddd --- /dev/null +++ b/app/script_edit/folderdelete.php @@ -0,0 +1,46 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('script_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +$folder = str_replace ("\\", "/", $folder); + +if (strlen($folder) > 0) { + //delete the folder + rmdir($folder); //, 0700 + header("Location: fileoptions.php"); +} + +?> \ No newline at end of file diff --git a/app/script_edit/foldernew.php b/app/script_edit/foldernew.php new file mode 100644 index 0000000000..336b9d3633 --- /dev/null +++ b/app/script_edit/foldernew.php @@ -0,0 +1,83 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('script_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +$folder = str_replace ("\\", "/", $folder); +$foldername = $_GET["foldername"]; + +if (strlen($folder) > 0 && strlen($foldername) > 0) { + //create new folder + mkdir($folder.'/'.$foldername); //, 0700 + header("Location: fileoptions.php"); +} +else { //display form + require_once "header.php"; + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Path:
".$folder."
"; + + echo "
"; + + echo ""; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
Folder Name:
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + + require_once "footer.php"; +} +?> \ No newline at end of file diff --git a/app/script_edit/footer.php b/app/script_edit/footer.php new file mode 100644 index 0000000000..b11f46e5d4 --- /dev/null +++ b/app/script_edit/footer.php @@ -0,0 +1,43 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +/* +echo "

"; +echo "
"; + +echo ""; +echo "fusionpbx "; +echo "        "; +echo "http://fusionpbx.com"; +echo "        "; +echo "Author: Mark J. Crane "; + +echo ""; +*/ +echo "
"; +echo ""; +echo ""; + +?> \ No newline at end of file diff --git a/app/script_edit/header.php b/app/script_edit/header.php new file mode 100644 index 0000000000..bd10f557d3 --- /dev/null +++ b/app/script_edit/header.php @@ -0,0 +1,83 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +echo ""; +echo ""; +echo ""; +//echo ""; +echo ""; + + +echo ""; +echo ""; +echo ""; +echo "
"; + +?> \ No newline at end of file diff --git a/app/script_edit/images/Thumbs.db b/app/script_edit/images/Thumbs.db new file mode 100644 index 0000000000..46593a8c2e Binary files /dev/null and b/app/script_edit/images/Thumbs.db differ diff --git a/app/script_edit/images/file.gif b/app/script_edit/images/file.gif new file mode 100644 index 0000000000..a6cf9845fc Binary files /dev/null and b/app/script_edit/images/file.gif differ diff --git a/app/script_edit/images/file.png b/app/script_edit/images/file.png new file mode 100644 index 0000000000..33b5f5f374 Binary files /dev/null and b/app/script_edit/images/file.png differ diff --git a/app/script_edit/images/folder.gif b/app/script_edit/images/folder.gif new file mode 100644 index 0000000000..50ab253cc7 Binary files /dev/null and b/app/script_edit/images/folder.gif differ diff --git a/app/script_edit/images/gear.png b/app/script_edit/images/gear.png new file mode 100644 index 0000000000..1adf1e778f Binary files /dev/null and b/app/script_edit/images/gear.png differ diff --git a/app/script_edit/images/leaf.gif b/app/script_edit/images/leaf.gif new file mode 100644 index 0000000000..50ab253cc7 Binary files /dev/null and b/app/script_edit/images/leaf.gif differ diff --git a/app/script_edit/images/minus.gif b/app/script_edit/images/minus.gif new file mode 100644 index 0000000000..1094ab912b Binary files /dev/null and b/app/script_edit/images/minus.gif differ diff --git a/app/script_edit/images/plus.gif b/app/script_edit/images/plus.gif new file mode 100644 index 0000000000..fdacf8efe5 Binary files /dev/null and b/app/script_edit/images/plus.gif differ diff --git a/app/script_edit/images/program.gif b/app/script_edit/images/program.gif new file mode 100644 index 0000000000..dc3dfa1104 Binary files /dev/null and b/app/script_edit/images/program.gif differ diff --git a/app/script_edit/images/thumbnails/Thumbs.db b/app/script_edit/images/thumbnails/Thumbs.db new file mode 100644 index 0000000000..c4e4684b24 Binary files /dev/null and b/app/script_edit/images/thumbnails/Thumbs.db differ diff --git a/app/script_edit/images/thumbnails/cliplibrary.png b/app/script_edit/images/thumbnails/cliplibrary.png new file mode 100644 index 0000000000..bc70f332fd Binary files /dev/null and b/app/script_edit/images/thumbnails/cliplibrary.png differ diff --git a/app/script_edit/images/thumbnails/filemanagement.png b/app/script_edit/images/thumbnails/filemanagement.png new file mode 100644 index 0000000000..88cb7661b1 Binary files /dev/null and b/app/script_edit/images/thumbnails/filemanagement.png differ diff --git a/app/script_edit/images/thumbnails/phpeditor.png b/app/script_edit/images/thumbnails/phpeditor.png new file mode 100644 index 0000000000..c6f7f369bb Binary files /dev/null and b/app/script_edit/images/thumbnails/phpeditor.png differ diff --git a/app/script_edit/index.php b/app/script_edit/index.php new file mode 100644 index 0000000000..58115d7846 --- /dev/null +++ b/app/script_edit/index.php @@ -0,0 +1,200 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('script_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +echo "\n"; +echo "\n"; +echo " \n"; +echo " "; + + echo "\n"; + + echo ""; + ?> + + + + + + + + +
+ + + + \n"; + echo "\n"; + } + else { + echo "\n"; + } + ?> + +
+ + \ No newline at end of file diff --git a/app/script_edit/list.php b/app/script_edit/list.php new file mode 100644 index 0000000000..5eb76b8cfe --- /dev/null +++ b/app/script_edit/list.php @@ -0,0 +1,107 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/checkauth.php"; +if (permission_exists('script_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "admin/edit/header.php"; +echo "
"; +echo "\n"; +echo "\n"; +echo " \n"; + echo "\n"; +} //end if results +echo "
\n"; +echo "
"; + +$sql = "select * from v_clips "; +$prep_statement = $db->prepare(check_sql($sql)); +$prep_statement->execute(); +$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); +$result_count = count($result); + +$c = 0; +$row_style["0"] = "background-color: #F5F5DC;"; +$row_style["1"] = "background-color: #FFFFFF;"; + +echo "
\n"; +echo "\n"; +echo ""; + +if ($result_count == 0) { //no results + echo ""; +} +else { //received results + echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + echo "\n"; + + foreach($result as $row) { + echo "\n"; + //echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach unset($sql, $result, $row_count); + echo "
 
    clip name      clip_folder        clip_text_start        clip_text_end        clip_desc        clip_order   
".$row['clip_uuid']."".$row['clip_name']."".$row[clip_folder]."".$row[clip_text_start]."".$row[clip_text_end]."".$row[clip_desc]."".$row[clip_order]."
\n"; + echo "
\n"; + + echo "
\n"; + +echo "
\n"; +echo "   \n"; +echo "   \n"; +echo "
\n"; +echo ""; + +echo "

"; +require_once "admin/edit/footer.php"; + +unset ($result_count); +unset ($result); +unset ($key); +unset ($val); +unset ($c); + +?> \ No newline at end of file diff --git a/app/script_edit/readme.txt b/app/script_edit/readme.txt new file mode 100644 index 0000000000..cafc4144ae --- /dev/null +++ b/app/script_edit/readme.txt @@ -0,0 +1,7 @@ +Notes + +IFrame +http://www.quirksmode.org/js/iframe.html + +Tree View +http://www.dddekerf.dds.nl/DHTML_Treeview/DHTML_Treeview.htm \ No newline at end of file diff --git a/app/script_edit/root.php b/app/script_edit/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/script_edit/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/services/app_config.php b/app/services/app_config.php new file mode 100644 index 0000000000..119fe75702 --- /dev/null +++ b/app/services/app_config.php @@ -0,0 +1,101 @@ + \ No newline at end of file diff --git a/app/services/root.php b/app/services/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/services/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/services/v_services.php b/app/services/v_services.php new file mode 100644 index 0000000000..08f2f0cdf2 --- /dev/null +++ b/app/services/v_services.php @@ -0,0 +1,222 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('services_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + +if (strlen($_GET["a"]) > 0) { + $service_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_services "; + $sql .= "where service_uuid = '$service_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $domain_uuid = $row["domain_uuid"]; + $service_name = $row["service_name"]; + $service_type = $row["service_type"]; + $service_data = $row["service_data"]; + $service_cmd_start = $row["service_cmd_start"]; + $service_cmd_stop = $row["service_cmd_stop"]; + $service_description = $row["service_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + + if ($_GET["a"] == "stop") { + $msg = 'Service: '.$service_name. ' stopping. '; + shell_exec($service_cmd_stop); + } + if ($_GET["a"] == "start") { + $msg = 'Service: '.$service_name. ' starting. '; + shell_exec($service_cmd_start); + } + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo $msg."\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; +} + +//check if a process is running + function is_process_running($pid) { + $status = shell_exec( 'ps -p ' . $pid ); + $status_array = explode ("\n", $status); + if (strlen(trim($status_array[1])) > 0) { + return true; + } + else { + return false; + } + } + + echo "
"; + echo "
\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Services 
\n"; + echo "Shows a list of processes, the status of the process and provides control to start and stop the process.

\n"; + echo "
\n"; + + $sql = ""; + $sql .= " select * from v_services "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $num_rows = count($result); + unset ($prep_statement, $result, $sql); + $rows_per_page = 10; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + $sql = ""; + $sql .= " select * from v_services "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo th_order_by('service_name', 'Name', $order_by, $order); + echo th_order_by('service_description', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if ($result_count == 0) { + //no results + } + else { //received results + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
StatusAction\n"; + if (permission_exists('services_add')) { + echo " $v_link_label_add\n"; + } + echo "
".$row[service_name]."".$row[service_description]."\n"; + $pid = file_get_contents($row[service_data]); + if (is_process_running($pid)) { + echo "Running"; + } + else { + echo "Stopped"; + } + echo "\n"; + if (is_process_running($pid)) { + echo " Stop"; + } + else { + echo " Start"; + } + echo "\n"; + if (permission_exists('services_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('services_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('services_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "includes/footer.php"; + +?> \ No newline at end of file diff --git a/app/services/v_services_delete.php b/app/services/v_services_delete.php new file mode 100644 index 0000000000..6ca5d4ff20 --- /dev/null +++ b/app/services/v_services_delete.php @@ -0,0 +1,60 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('services_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); +} + +//delete the data + if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_services "; + $sql .= "where service_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + } + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/services/v_services_edit.php b/app/services/v_services_edit.php new file mode 100644 index 0000000000..ae44238da8 --- /dev/null +++ b/app/services/v_services_edit.php @@ -0,0 +1,294 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('services_add') || permission_exists('services_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $service_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http post and set it to php variables + if (count($_POST)>0) { + $service_name = check_str($_POST["service_name"]); + $service_type = check_str($_POST["service_type"]); + $service_data = check_str($_POST["service_data"]); + $service_cmd_start = check_str($_POST["service_cmd_start"]); + $service_cmd_stop = check_str($_POST["service_cmd_stop"]); + $service_description = check_str($_POST["service_description"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $service_uuid = check_str($_POST["service_uuid"]); + } + + //check for all required data + //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + if (strlen($service_name) == 0) { $msg .= "Please provide: Name
\n"; } + //if (strlen($service_type) == 0) { $msg .= "Please provide: Type
\n"; } + //if (strlen($service_data) == 0) { $msg .= "Please provide: Data
\n"; } + //if (strlen($service_cmd_start) == 0) { $msg .= "Please provide: Start Command
\n"; } + //if (strlen($service_cmd_stop) == 0) { $msg .= "Please provide: Stop Command
\n"; } + //if (strlen($service_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('services_add')) { + $service_uuid = uuid(); + $sql = "insert into v_services "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "service_uuid, "; + $sql .= "service_name, "; + $sql .= "service_type, "; + $sql .= "service_data, "; + $sql .= "service_cmd_start, "; + $sql .= "service_cmd_stop, "; + $sql .= "service_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$service_uuid', "; + $sql .= "'$service_name', "; + $sql .= "'$service_type', "; + $sql .= "'$service_data', "; + $sql .= "'$service_cmd_start', "; + $sql .= "'$service_cmd_stop', "; + $sql .= "'$service_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update" && permission_exists('services_edit')) { + $sql = "update v_services set "; + $sql .= "service_name = '$service_name', "; + $sql .= "service_type = '$service_type', "; + $sql .= "service_data = '$service_data', "; + $sql .= "service_cmd_start = '$service_cmd_start', "; + $sql .= "service_cmd_stop = '$service_cmd_stop', "; + $sql .= "service_description = '$service_description' "; + $sql .= "where domain_uuid = '$domain_uuid'"; + $sql .= "and service_uuid = '$service_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $service_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_services "; + $sql .= "where service_uuid = '$service_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $domain_uuid = $row["domain_uuid"]; + $service_name = $row["service_name"]; + $service_type = $row["service_type"]; + $service_data = $row["service_data"]; + $service_cmd_start = $row["service_cmd_start"]; + $service_cmd_stop = $row["service_cmd_stop"]; + $service_description = $row["service_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//begin the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Service AddService Edit
\n"; + echo "Shows a list of processes and provides ability to start and stop them.

\n"; + echo "
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the service name.\n"; + echo "
\n"; + echo " Type:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Select the service type.\n"; + echo "
\n"; + echo " Data:\n"; + echo "\n"; + echo " \n"; + //echo " \n"; + echo "
\n"; + echo "Enter the service data.\n"; + echo "
\n"; + echo " Start Command:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the command to start the service.\n"; + echo "
\n"; + echo " Stop Command:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the command to stop the service.\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the service description.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//show the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/settings/app_config.php b/app/settings/app_config.php new file mode 100644 index 0000000000..f224a83909 --- /dev/null +++ b/app/settings/app_config.php @@ -0,0 +1,123 @@ + \ No newline at end of file diff --git a/app/settings/root.php b/app/settings/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/settings/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/settings/v_settings_edit.php b/app/settings/v_settings_edit.php new file mode 100644 index 0000000000..311d77950b --- /dev/null +++ b/app/settings/v_settings_edit.php @@ -0,0 +1,523 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('settings_view') || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the number of rows in v_extensions + $sql = ""; + $sql .= " select count(*) as num_rows from v_settings "; + $prep_statement = $db->prepare(check_sql($sql)); + $num_rows = 0; + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = 0; + } + } + unset($prep_statement, $result); + +//set the action + if ($num_rows == 0) { + $action = "add"; + } + else { + $action = "update"; + } + +//get the http values and set them as php variables + if (count($_POST)>0) { + $numbering_plan = check_str($_POST["numbering_plan"]); + $default_gateway = check_str($_POST["default_gateway"]); + $event_socket_ip_address = check_str($_POST["event_socket_ip_address"]); + if (strlen($event_socket_ip_address) == 0) { $event_socket_ip_address = '127.0.0.1'; } + $event_socket_port = check_str($_POST["event_socket_port"]); + $event_socket_password = check_str($_POST["event_socket_password"]); + $xml_rpc_http_port = check_str($_POST["xml_rpc_http_port"]); + $xml_rpc_auth_realm = check_str($_POST["xml_rpc_auth_realm"]); + $xml_rpc_auth_user = check_str($_POST["xml_rpc_auth_user"]); + $xml_rpc_auth_pass = check_str($_POST["xml_rpc_auth_pass"]); + $admin_pin = check_str($_POST["admin_pin"]); + $smtp_host = check_str($_POST["smtp_host"]); + $smtp_secure = check_str($_POST["smtp_secure"]); + $smtp_auth = check_str($_POST["smtp_auth"]); + $smtp_username = check_str($_POST["smtp_username"]); + $smtp_password = check_str($_POST["smtp_password"]); + $smtp_from = check_str($_POST["smtp_from"]); + $smtp_from_name = check_str($_POST["smtp_from_name"]); + $mod_shout_decoder = check_str($_POST["mod_shout_decoder"]); + $mod_shout_volume = check_str($_POST["mod_shout_volume"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + //check for all required data + $msg = ''; + //if (strlen($numbering_plan) == 0) { $msg .= "Please provide: Numbering Plan
\n"; } + //if (strlen($default_gateway) == 0) { $msg .= "Please provide: Default Gateway
\n"; } + if (strlen($event_socket_port) == 0) { $msg .= "Please provide: Event Socket Port
\n"; } + if (strlen($event_socket_password) == 0) { $msg .= "Please provide: Event Socket Password
\n"; } + //if (strlen($xml_rpc_http_port) == 0) { $msg .= "Please provide: XML RPC HTTP Port
\n"; } + //if (strlen($xml_rpc_auth_realm) == 0) { $msg .= "Please provide: XML RPC Auth Realm
\n"; } + //if (strlen($xml_rpc_auth_user) == 0) { $msg .= "Please provide: XML RPC Auth User
\n"; } + //if (strlen($xml_rpc_auth_pass) == 0) { $msg .= "Please provide: XML RPC Auth Password
\n"; } + //if (strlen($admin_pin) == 0) { $msg .= "Please provide: Admin PIN Number
\n"; } + //if (strlen($smtp_host) == 0) { $msg .= "Please provide: SMTP Host
\n"; } + //if (strlen($smtp_secure) == 0) { $msg .= "Please provide: SMTP Secure
\n"; } + //if (strlen($smtp_auth) == 0) { $msg .= "Please provide: SMTP Auth
\n"; } + //if (strlen($smtp_username) == 0) { $msg .= "Please provide: SMTP Username
\n"; } + //if (strlen($smtp_password) == 0) { $msg .= "Please provide: SMTP Password
\n"; } + //if (strlen($smtp_from) == 0) { $msg .= "Please provide: SMTP From
\n"; } + //if (strlen($smtp_from_name) == 0) { $msg .= "Please provide: SMTP From Name
\n"; } + //if (strlen($mod_shout_decoder) == 0) { $msg .= "Please provide: Mod Shout Decoder
\n"; } + //if (strlen($mod_shout_volume) == 0) { $msg .= "Please provide: Mod Shout Volume
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('settings_edit')) { + $sql = "insert into v_settings "; + $sql .= "("; + $sql .= "numbering_plan, "; + $sql .= "event_socket_ip_address, "; + $sql .= "event_socket_port, "; + $sql .= "event_socket_password, "; + $sql .= "xml_rpc_http_port, "; + $sql .= "xml_rpc_auth_realm, "; + $sql .= "xml_rpc_auth_user, "; + $sql .= "xml_rpc_auth_pass, "; + $sql .= "admin_pin, "; + $sql .= "smtp_host, "; + $sql .= "smtp_secure, "; + $sql .= "smtp_auth, "; + $sql .= "smtp_username, "; + $sql .= "smtp_password, "; + $sql .= "smtp_from, "; + $sql .= "smtp_from_name, "; + $sql .= "mod_shout_decoder, "; + $sql .= "mod_shout_volume "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$numbering_plan', "; + $sql .= "'$event_socket_ip_address', "; + $sql .= "'$event_socket_port', "; + $sql .= "'$event_socket_password', "; + $sql .= "'$xml_rpc_http_port', "; + $sql .= "'$xml_rpc_auth_realm', "; + $sql .= "'$xml_rpc_auth_user', "; + $sql .= "'$xml_rpc_auth_pass', "; + $sql .= "'$admin_pin', "; + $sql .= "'$smtp_host', "; + $sql .= "'$smtp_secure', "; + $sql .= "'$smtp_auth', "; + $sql .= "'$smtp_username', "; + $sql .= "'$smtp_password', "; + $sql .= "'$smtp_from', "; + $sql .= "'$smtp_from_name', "; + $sql .= "'$mod_shout_decoder', "; + $sql .= "'$mod_shout_volume' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //synchronize settings + save_setting_xml(); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update" && permission_exists('settings_edit')) { + $sql = "update v_settings set "; + $sql .= "numbering_plan = '$numbering_plan', "; + $sql .= "event_socket_ip_address = '$event_socket_ip_address', "; + $sql .= "event_socket_port = '$event_socket_port', "; + $sql .= "event_socket_password = '$event_socket_password', "; + $sql .= "xml_rpc_http_port = '$xml_rpc_http_port', "; + $sql .= "xml_rpc_auth_realm = '$xml_rpc_auth_realm', "; + $sql .= "xml_rpc_auth_user = '$xml_rpc_auth_user', "; + $sql .= "xml_rpc_auth_pass = '$xml_rpc_auth_pass', "; + $sql .= "admin_pin = '$admin_pin', "; + $sql .= "smtp_host = '$smtp_host', "; + $sql .= "smtp_secure = '$smtp_secure', "; + $sql .= "smtp_auth = '$smtp_auth', "; + $sql .= "smtp_username = '$smtp_username', "; + $sql .= "smtp_password = '$smtp_password', "; + $sql .= "smtp_from = '$smtp_from', "; + $sql .= "smtp_from_name = '$smtp_from_name', "; + $sql .= "mod_shout_decoder = '$mod_shout_decoder', "; + $sql .= "mod_shout_volume = '$mod_shout_volume' "; + $db->exec(check_sql($sql)); + unset($sql); + + //synchronize settings + save_setting_xml(); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") + } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if ($_POST["persistformvar"] != "true") { + $sql = ""; + $sql .= "select * from v_settings "; + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $numbering_plan = $row["numbering_plan"]; + $event_socket_ip_address = $row["event_socket_ip_address"]; + $event_socket_port = $row["event_socket_port"]; + $event_socket_password = $row["event_socket_password"]; + $xml_rpc_http_port = $row["xml_rpc_http_port"]; + $xml_rpc_auth_realm = $row["xml_rpc_auth_realm"]; + $xml_rpc_auth_user = $row["xml_rpc_auth_user"]; + $xml_rpc_auth_pass = $row["xml_rpc_auth_pass"]; + $admin_pin = $row["admin_pin"]; + $smtp_host = $row["smtp_host"]; + $smtp_secure = $row["smtp_secure"]; + $smtp_auth = $row["smtp_auth"]; + $smtp_username = $row["smtp_username"]; + $smtp_password = $row["smtp_password"]; + $smtp_from = $row["smtp_from"]; + $smtp_from_name = $row["smtp_from_name"]; + $mod_shout_decoder = $row["mod_shout_decoder"]; + $mod_shout_volume = $row["mod_shout_volume"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + if (permission_exists('settings_edit')) { + echo " \n"; + echo " \n"; + echo " "; + } + echo "
Setting AddSetting Update
\n"; + echo " Numbering Plan:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the numbering plan. example: US\n"; + echo "
\n"; + echo " Event Socket IP Address:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the event socket IP address. default: 127.0.0.1\n"; + echo "
\n"; + echo " Event Socket Port:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the event socket port. default: 8021\n"; + echo "
\n"; + echo " Event Socket Password:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the event socket password. \n"; + echo "
\n"; + echo " XML RPC HTTP Port:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the XML RPC HTTP Port. default: 8787\n"; + echo "
\n"; + echo " XML RPC Auth Realm:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the XML RPC Auth Realm. default: freeswitch\n"; + echo "
\n"; + echo " XML RPC Auth User:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the XML RPC Auth User. default: xmlrpc\n"; + echo "
\n"; + echo " XML RPC Auth Password:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the XML RPC Auth Password. \n"; + echo "
\n"; + echo " Admin PIN Number:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " SMTP Host:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the SMTP host address. TLS example: smtp.gmail.com:587\n"; + echo "
\n"; + echo " SMTP Secure:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Select the SMTP security. None, TLS, SSL\n"; + echo "
\n"; + echo " SMTP Auth:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Use SMTP Authentication true or false.\n"; + echo "
\n"; + echo " SMTP Username:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the SMTP authentication username.\n"; + echo "
\n"; + echo " SMTP Password:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the SMTP authentication password. \n"; + echo "
\n"; + echo " SMTP From:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the SMTP From email address.\n"; + echo "
\n"; + echo " SMTP From Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the SMTP From Name.\n"; + echo "
\n"; + echo " Mod Shout Decoder:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the Decoder. default: i386\n"; + echo "
\n"; + echo " Mod Shout Volume:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter Mod Shout Volume.\n"; + echo "
\n"; + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//show the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/signup/app_config.php b/app/signup/app_config.php new file mode 100644 index 0000000000..7c3c2db782 --- /dev/null +++ b/app/signup/app_config.php @@ -0,0 +1,22 @@ + diff --git a/app/signup/config.php.dist b/app/signup/config.php.dist new file mode 100644 index 0000000000..4dd534ce04 --- /dev/null +++ b/app/signup/config.php.dist @@ -0,0 +1,8 @@ + diff --git a/app/signup/root.php b/app/signup/root.php new file mode 100644 index 0000000000..c7906e24a5 --- /dev/null +++ b/app/signup/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> diff --git a/app/signup/signup.php b/app/signup/signup.php new file mode 100644 index 0000000000..f7db863a67 --- /dev/null +++ b/app/signup/signup.php @@ -0,0 +1,177 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/recaptchalib.php"; +//require_once "includes/email_address_validator.php"; +include "config.php"; +include "v_fields.php"; + +# the response from reCAPTCHA +$resp = null; +# the error code from reCAPTCHA, if any +$error = null; + +if (count($_POST)>0 && $_POST["persistform"] != "1") { + + $msgerror = ''; + + $required[] = array('username', "Please provid a Username.
\n"); + $required[] = array('user_first_name', "Please provide a first name.
\n"); + $required[] = array('user_last_name', "Please provide a last name.
\n"); + $required[] = array('user_billing_address_1', "Please provide a street address.
\n"); + $required[] = array('user_billing_city', "Please provide a city.
\n"); + $required[] = array('user_billing_state_province', "Please provide a state.
\n"); + $required[] = array('user_billing_country', "Please provide a country.
\n"); + $required[] = array('user_billing_postal_code',"Please provide a postal code.
\n"); + $required[] = array('user_phone_1', "Please provide a phone number.
\n"); + $required[] = array('user_email', "Please provide an email address.
\n"); + + foreach($required as $x) { + if (strlen($_REQUEST[$x[0]]) < 1) { + $msgerror .= $x[1]; + $error_fields[] = $x[0]; + } + } + + //sanitize the http request array + foreach ($_REQUEST as $field => $data){ + $request[$field] = check_str($data); + } + + //username is already used. + if (strlen($request['username']) != 0) { + $sql = "SELECT * FROM v_users "; + $sql .= " where domain_uuid = '$domain_uuid' "; + $sql .= " and username = '" . $request['username'] . "' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + if (count($prep_statement->fetchAll(PDO::FETCH_NAMED)) > 0) { + $msgerror .= "Please choose a different Username.
\n"; + } + } + + // make sure password fields match + if ($request['password'] != $request['confirmpassword']) { + $msgerror .= "Passwords did not match.
\n"; + } + + // email address atleast looks valid + //if (!in_array('user_email', $error_fields)) { + // $validator = new EmailAddressValidator; + // if (!$validator->check_email_address($request['user_email'])) { + // $msgerror .= "Please provide a VALID email address.
\n"; + // } + //} + + if ($_POST["recaptcha_response_field"]) { + $resp = recaptcha_check_answer ($privatekey, + $_SERVER["REMOTE_ADDR"], + $_POST["recaptcha_challenge_field"], + $_POST["recaptcha_response_field"]); + + if (!$resp->is_valid) { + # set the error code so that we can display it + $msgerror .= "Captcha Verification Failed
\n"; + $error = $resp->error; + } + } else { + $msgerror .= "Captcha Verification Failed
\n"; + } + + if (strlen($msgerror) > 0) { + goto showform; + } + + //salt used with the password to create a one way hash + $salt = generate_password('20', '4'); + $user_uuid = uuid(); + $sql = "insert into v_users "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "user_uuid, "; + $sql .= "username, "; + $sql .= "password, "; + $sql .= "salt, "; + $sql .= "user_email, "; + $sql .= "user_add_date, "; + $sql .= "user_add_user "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$user_uuid', "; + $sql .= "'" . $request['username'] . "', "; + $sql .= "'".md5($salt.$request['password'])."', "; + $sql .= "'" . $salt . "', "; + $sql .= "'" . $request['user_email'] . "', "; + $sql .= "now(), "; + $sql .= "'".$_SESSION["username"]."' "; + $sql .= ") "; + if ($db_type == "pgsql") { + + } + $db->exec(check_sql($sql)); + unset($sql); + + //log the success + //$log_type = 'user'; $log_status='add'; $log_add_user=$_SESSION["username"]; $log_desc= "username: ".$username." user added."; + //log_add($db, $log_type, $log_status, $log_desc, $log_add_user, $_SERVER["REMOTE_ADDR"]); + + $group_name = 'user'; + $sql = "insert into v_group_users "; + $sql .= "("; + $sql .= "group_user_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "group_name, "; + $sql .= "user_uuid "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'" . $domain_uuid . "', "; + $sql .= "'" . $group_name . "', "; + $sql .= "'" . $user_uuid . "' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
Add Complete
"; + require_once "includes/footer.php"; + // This should probably be an exit or die() call; + return; +} + +showform: + +require_once "includes/header.php"; + +include "user_template.php"; + +require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/signup/user_template.php b/app/signup/user_template.php new file mode 100644 index 0000000000..e0a8f61132 --- /dev/null +++ b/app/signup/user_template.php @@ -0,0 +1,61 @@ +
+ + 0) { ?> + + + + + +
+ +
+
+ +
+ + + +
+
+ + + +
"); +} +?> + +
+
+ + + + + + + +
+ +
+ + +
+
diff --git a/app/signup/v_fields.php b/app/signup/v_fields.php new file mode 100644 index 0000000000..68ee6a1f6c --- /dev/null +++ b/app/signup/v_fields.php @@ -0,0 +1,30 @@ +\n"); + $forms[1]['fields'][2] = array('password', "Password:", "password", TRUE, "Please provid a Username.
\n"); + $forms[1]['fields'][3] = array('confirmpassword', "Confirm Password:", "password", FALSE, ""); + $forms[1]['fields'][4] = array('user_company_name', "Company Name:", "text", FALSE, ""); + $forms[1]['fields'][5] = array('user_first_name', "First Name:", "text", TRUE, "Please provide a first name.
\n"); + $forms[1]['fields'][6] = array('user_last_name', "Last Name:", "text", TRUE, "Please provide a last name.
\n"); + $forms[1]['fields'][7] = array('user_email', "Email:", "text", TRUE, "Please provide an email address.
\n"); + $forms[1]['fields'][8] = array('user_phone_1', "Phone Number:", "text", TRUE, "Please provide a phone number.
\n"); + $forms[1]['fields'][9] = array('user_phone_1_ext', "Extension:", "text", FALSE, ""); + + $forms[2]['header'] = "Billing Address"; + $forms[2]['fields'][1] = array('user_billing_address_1', "Address 1:", "text", TRUE, "Please provide a street address.
\n"); + $forms[2]['fields'][2] = array('user_billing_address_2', "Address 2:", "text", FALSE, ""); + $forms[2]['fields'][3] = array('user_billing_city', "City:", "text", TRUE, "Please provide a city.
\n"); + $forms[2]['fields'][4] = array('user_billing_state_province', "State/Province:", "text", TRUE, "Please provide a state or province.
\n"); + $forms[2]['fields'][5] = array('user_billing_country', "Country:", "text", TRUE, "Please provide a country.
\n"); + $forms[2]['fields'][6] = array('user_billing_postal_code', "ZIP/Postal Code:", "text", TRUE, "Please provide a postal code.
\n"); + + $forms[3]['header'] = "Shipping Address"; + $forms[3]['fields'][1] = array('user_shipping_address_1', "Address 1:", "text", TRUE, "Please provide a street address.
\n"); + $forms[3]['fields'][2] = array('user_shipping_address_2', "Address 2:", "text", FALSE, ""); + $forms[3]['fields'][3] = array('user_shipping_city', "City:", "text", TRUE, "Please provide a city.
\n"); + $forms[3]['fields'][4] = array('user_shipping_state_province', "State/Province:", "text", TRUE, "Please provide a state or province.
\n"); + $forms[3]['fields'][5] = array('user_shipping_country', "Country:", "text", TRUE, "Please provide a country.
\n"); + $forms[3]['fields'][6] = array('user_shipping_postal_code', "ZIP/Postal Code:", "text", TRUE, "Please provide a postal code.
\n"); + +?> diff --git a/app/sip_profiles/app_config.php b/app/sip_profiles/app_config.php new file mode 100644 index 0000000000..c5200b3774 --- /dev/null +++ b/app/sip_profiles/app_config.php @@ -0,0 +1,84 @@ + \ No newline at end of file diff --git a/app/sip_profiles/app_defaults.php b/app/sip_profiles/app_defaults.php new file mode 100644 index 0000000000..1d781df7eb --- /dev/null +++ b/app/sip_profiles/app_defaults.php @@ -0,0 +1,134 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//if the number of rows is 0 then read the sip profile xml into the database + $sql = "select count(*) as num_rows from v_sip_profiles "; + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] == 0) { + $xml_list = glob($_SESSION['switch']['conf']['dir']."/sip_profiles/*.xml"); + foreach ($xml_list as &$xml_file) { + //load the sip profile xml and save it into an array + $sip_profile_xml = file_get_contents($xml_file); + $xml = simplexml_load_string($sip_profile_xml); + $json = json_encode($xml); + $sip_profile = json_decode($json, true); + $sip_profile_name = $sip_profile['@attributes']['name']; + //echo "sip profile name: ".$sip_profile_name."\n"; + + if ($sip_profile_name != "{v_sip_profile_name}") { + //prepare the description + switch ($sip_profile_name) { + case "internal": + $sip_profile_description = "The Internal profile by default requires registration which is used by the endpoints. "; + $sip_profile_description .= "By default the Internal profile binds to port 5060. "; + break; + case "internal-ipv6": + $sip_profile_description = "The Internal IPV6 profile binds to the IP version 6 address and is similar to the Internal profile.\n"; + break; + case "external": + $sip_profile_description .= "The External profile external provides anonymous calling in the public context. "; + $sip_profile_description .= "By default the External profile binds to port 5080. "; + $sip_profile_description .= "Calls can be sent using a SIP URL \"voip.domain.com:5080\" "; + break; + case "lan": + $sip_profile_description = "The LAN profile is the same as the Internal profile except that it is bound to the LAN IP.\n"; + break; + default: + $sip_profile_description .= ''; + } + + //add the sip profile + $sip_profile_uuid = uuid(); + $sql = "insert into v_sip_profiles"; + $sql .= "("; + $sql .= "sip_profile_uuid, "; + $sql .= "sip_profile_name, "; + $sql .= "sip_profile_description "; + $sql .= ") "; + $sql .= "values "; + $sql .= "( "; + $sql .= "'".check_str($sip_profile_uuid)."', "; + $sql .= "'".check_str($sip_profile_name)."', "; + $sql .= "'".check_str($sip_profile_description)."' "; + $sql .= ")"; + //echo $sql."\n\n"; + $db->exec(check_sql($sql)); + unset($sql); + + //add the sip profile settings + foreach ($sip_profile['settings']['param'] as $row) { + //get the name and value pair + $sip_profile_setting_name = $row['@attributes']['name']; + $sip_profile_setting_value = $row['@attributes']['value']; + //echo "name: $name value: $value\n"; + //add the profile settings into the database + $sip_profile_setting_uuid = uuid(); + $sql = "insert into v_sip_profile_settings "; + $sql .= "("; + $sql .= "sip_profile_setting_uuid, "; + $sql .= "sip_profile_uuid, "; + $sql .= "sip_profile_setting_name, "; + $sql .= "sip_profile_setting_value, "; + $sql .= "sip_profile_setting_enabled "; + $sql .= ") "; + $sql .= "values "; + $sql .= "( "; + $sql .= "'".check_str($sip_profile_setting_uuid)."', "; + $sql .= "'".check_str($sip_profile_uuid)."', "; + $sql .= "'".check_str($sip_profile_setting_name)."', "; + $sql .= "'".check_str($sip_profile_setting_value)."', "; + $sql .= "'true' "; + $sql .= ")"; + //echo $sql."\n\n"; + $db->exec(check_sql($sql)); + } + } + } + } + } + +//if there is more than one domain then disable the force domains sip profile settings + if (count($_SESSION['domains']) > 1) { + //disable force domains + $sql = "update v_sip_profile_settings set "; + $sql .= "sip_profile_setting_enabled = 'false' "; + $sql .= "where sip_profile_setting_name = 'force-register-domain'"; + $sql .= "or sip_profile_setting_name = 'force-subscription-domain'"; + $sql .= "or sip_profile_setting_name = 'force-register-db-domain'"; + $db->exec(check_sql($sql)); + unset($sql); + + //save the sip profile xml + save_sip_profile_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + } + +?> \ No newline at end of file diff --git a/app/sip_profiles/resources/xml/sip_profiles/default.xml b/app/sip_profiles/resources/xml/sip_profiles/default.xml new file mode 100644 index 0000000000..6b29308ec4 --- /dev/null +++ b/app/sip_profiles/resources/xml/sip_profiles/default.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + +{v_sip_profile_settings} + + diff --git a/app/sip_profiles/resources/xml/sip_profiles/external.xml b/app/sip_profiles/resources/xml/sip_profiles/external.xml new file mode 100644 index 0000000000..f48bc7ed0e --- /dev/null +++ b/app/sip_profiles/resources/xml/sip_profiles/external.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + +{v_sip_profile_settings} + + diff --git a/app/sip_profiles/resources/xml/sip_profiles/internal-ipv6.xml b/app/sip_profiles/resources/xml/sip_profiles/internal-ipv6.xml new file mode 100644 index 0000000000..e35b3c515e --- /dev/null +++ b/app/sip_profiles/resources/xml/sip_profiles/internal-ipv6.xml @@ -0,0 +1,6 @@ + + + +{v_sip_profile_settings} + + diff --git a/app/sip_profiles/resources/xml/sip_profiles/internal.xml b/app/sip_profiles/resources/xml/sip_profiles/internal.xml new file mode 100644 index 0000000000..3df6f585b3 --- /dev/null +++ b/app/sip_profiles/resources/xml/sip_profiles/internal.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + +{v_sip_profile_settings} + + diff --git a/app/sip_profiles/root.php b/app/sip_profiles/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/sip_profiles/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/sip_profiles/sip_profile_copy.php b/app/sip_profiles/sip_profile_copy.php new file mode 100644 index 0000000000..f43f252865 --- /dev/null +++ b/app/sip_profiles/sip_profile_copy.php @@ -0,0 +1,128 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "includes/paging.php"; +if (permission_exists('dialplan_add') + || permission_exists('inbound_route_add') + || permission_exists('outbound_route_add') + || permission_exists('time_conditions_add')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//set the http get/post variable(s) to a php variable + if (isset($_REQUEST["id"])) { + $sip_profile_uuid = check_str($_REQUEST["id"]); + } + +//get the sip profile data + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $sql = "select * from v_sip_profiles "; + $sql .= "where sip_profile_uuid = '$sip_profile_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(); + foreach ($result as &$row) { + $sip_profile_name = $row["sip_profile_name"]; + $sip_profile_description = $row["sip_profile_description"]; + } + unset ($prep_statement); + } + + //copy the v_sip_profiles + $sip_profile_uuid_new = uuid(); + $sql = "insert into v_sip_profiles "; + $sql .= "("; + $sql .= "sip_profile_uuid, "; + $sql .= "sip_profile_name, "; + $sql .= "sip_profile_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$sip_profile_uuid_new."', "; + $sql .= "'".$sip_profile_name."-copy', "; + $sql .= "'".$sip_profile_description."' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //get the the sip profile settings + $sql = "select * from v_sip_profile_settings "; + $sql .= "where sip_profile_uuid = '$sip_profile_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(); + foreach ($result as &$row) { + $sip_profile_setting_name = $row["sip_profile_setting_name"]; + $sip_profile_setting_value = $row["sip_profile_setting_value"]; + $sip_profile_setting_enabled = $row["sip_profile_setting_enabled"]; + $sip_profile_setting_description = $row["sip_profile_setting_description"]; + + //add the sip profile setting + $sql = "insert into v_sip_profile_settings "; + $sql .= "("; + $sql .= "sip_profile_setting_uuid, "; + $sql .= "sip_profile_uuid, "; + $sql .= "sip_profile_setting_name, "; + $sql .= "sip_profile_setting_value, "; + $sql .= "sip_profile_setting_enabled, "; + $sql .= "sip_profile_setting_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$sip_profile_uuid_new', "; + $sql .= "'$sip_profile_setting_name', "; + $sql .= "'$sip_profile_setting_value', "; + $sql .= "'$sip_profile_setting_enabled', "; + $sql .= "'$sip_profile_setting_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + unset ($prep_statement); + + //save the sip profile xml + save_sip_profile_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Copy Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/sip_profiles/sip_profile_settings.php b/app/sip_profiles/sip_profile_settings.php new file mode 100644 index 0000000000..07a2d0adee --- /dev/null +++ b/app/sip_profiles/sip_profile_settings.php @@ -0,0 +1,163 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('sip_profile_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get variables used to control the order + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + echo "
Settings 
\n"; + //echo " Settings.

\n"; + //echo "
\n"; + + //prepare to page the results + $sql = "select count(*) as num_rows from v_sip_profile_settings "; + $sql .= "where sip_profile_uuid = '$sip_profile_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + + //prepare to page the results + $rows_per_page = 200; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + //get the sip_profile list + $sql = "select * from v_sip_profile_settings "; + $sql .= "where sip_profile_uuid = '$sip_profile_uuid' "; + if (isset($order_by)) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo th_order_by('sip_profile_setting_name', 'Name', $order_by, $order); + echo th_order_by('sip_profile_setting_value', 'Value', $order_by, $order); + echo th_order_by('sip_profile_setting_enabled', 'Enabled', $order_by, $order); + echo th_order_by('sip_profile_setting_description', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + if ($num_rows > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + if (permission_exists('sip_profile_add')) { + echo " $v_link_label_add\n"; + } + echo "
".$row['sip_profile_setting_name']." ".$row['sip_profile_setting_value']." ".$row['sip_profile_setting_enabled']." ".$row['sip_profile_setting_description']." \n"; + if (permission_exists('sip_profile_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('sip_profile_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('sip_profile_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/sip_profiles/sip_profile_settings_delete.php b/app/sip_profiles/sip_profile_settings_delete.php new file mode 100644 index 0000000000..507e27bfda --- /dev/null +++ b/app/sip_profiles/sip_profile_settings_delete.php @@ -0,0 +1,66 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('sip_profile_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); + $sip_profile_uuid = check_str($_GET["sip_profile_uuid"]); +} + +if (strlen($id)>0) { + //delete the sip profile setting + $sql = "delete from v_sip_profile_settings "; + $sql .= "where sip_profile_setting_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + + //save the sip profile xml + save_sip_profile_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; +} + +//redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/sip_profiles/sip_profile_settings_edit.php b/app/sip_profiles/sip_profile_settings_edit.php new file mode 100644 index 0000000000..be5b79d333 --- /dev/null +++ b/app/sip_profiles/sip_profile_settings_edit.php @@ -0,0 +1,271 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('sip_profile_add') || permission_exists('sip_profile_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $sip_profile_setting_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +if (strlen($_GET["sip_profile_uuid"]) > 0) { + $sip_profile_uuid = check_str($_GET["sip_profile_uuid"]); +} + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $sip_profile_setting_name = check_str($_POST["sip_profile_setting_name"]); + $sip_profile_setting_value = check_str($_POST["sip_profile_setting_value"]); + $sip_profile_setting_enabled = check_str($_POST["sip_profile_setting_enabled"]); + $sip_profile_setting_description = check_str($_POST["sip_profile_setting_description"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $sip_profile_setting_uuid = check_str($_POST["sip_profile_setting_uuid"]); + } + + //check for all required data + //if (strlen($sip_profile_setting_name) == 0) { $msg .= "Please provide: Name
\n"; } + //if (strlen($sip_profile_setting_value) == 0) { $msg .= "Please provide: Value
\n"; } + //if (strlen($sip_profile_setting_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } + //if (strlen($sip_profile_setting_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + //add the sip profile setting + $sql = "insert into v_sip_profile_settings "; + $sql .= "("; + $sql .= "sip_profile_setting_uuid, "; + $sql .= "sip_profile_uuid, "; + $sql .= "sip_profile_setting_name, "; + $sql .= "sip_profile_setting_value, "; + $sql .= "sip_profile_setting_enabled, "; + $sql .= "sip_profile_setting_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$sip_profile_uuid', "; + $sql .= "'$sip_profile_setting_name', "; + $sql .= "'$sip_profile_setting_value', "; + $sql .= "'$sip_profile_setting_enabled', "; + $sql .= "'$sip_profile_setting_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //save the sip profile xml + save_sip_profile_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + + //redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + //update the sip profile setting + $sql = "update v_sip_profile_settings set "; + $sql .= "sip_profile_uuid = '$sip_profile_uuid', "; + $sql .= "sip_profile_setting_name = '$sip_profile_setting_name', "; + $sql .= "sip_profile_setting_value = '$sip_profile_setting_value', "; + $sql .= "sip_profile_setting_enabled = '$sip_profile_setting_enabled', "; + $sql .= "sip_profile_setting_description = '$sip_profile_setting_description' "; + $sql .= "where sip_profile_setting_uuid = '$sip_profile_setting_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + //save the sip profile xml + save_sip_profile_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + + //redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $sip_profile_setting_uuid = $_GET["id"]; + $sql = "select * from v_sip_profile_settings "; + $sql .= "where sip_profile_setting_uuid = '$sip_profile_setting_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(); + foreach ($result as &$row) { + $sip_profile_setting_name = $row["sip_profile_setting_name"]; + $sip_profile_setting_value = $row["sip_profile_setting_value"]; + $sip_profile_setting_enabled = $row["sip_profile_setting_enabled"]; + $sip_profile_setting_description = $row["sip_profile_setting_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Setting
\n"; + //echo "Settings.

\n"; + echo "
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the name.\n"; + echo "
\n"; + echo " Value:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the value.\n"; + echo "
\n"; + echo " Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Choose to enable or disable this.\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the description.\n"; + echo "
\n"; + echo " \n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/sip_profiles/sip_profiles.php b/app/sip_profiles/sip_profiles.php new file mode 100644 index 0000000000..55939be4f8 --- /dev/null +++ b/app/sip_profiles/sip_profiles.php @@ -0,0 +1,159 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('sip_profile_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get variables used to control the order + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Sip Profiles 
\n"; + echo " Manage settings for SIP profiles.

\n"; + echo "
\n"; + + //prepare to page the results + $sql = "select count(*) as num_rows from v_sip_profiles "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + + //prepare to page the results + $rows_per_page = 10; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + //get the list + $sql = "select * from v_sip_profiles "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= "limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo th_order_by('sip_profile_name', 'Name', $order_by, $order); + echo "\n"; + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
Description\n"; + if (permission_exists('sip_profile_add')) { + echo " $v_link_label_add\n"; + } + echo "
".$row['sip_profile_name']." ".$row['sip_profile_description']." \n"; + if (permission_exists('sip_profile_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('sip_profile_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('sip_profile_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/sip_profiles/sip_profiles_delete.php b/app/sip_profiles/sip_profiles_delete.php new file mode 100644 index 0000000000..c1387183bc --- /dev/null +++ b/app/sip_profiles/sip_profiles_delete.php @@ -0,0 +1,77 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('sip_profile_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); +} + +if (strlen($id)>0) { + //delete the sip profile settings + $sql = "delete from v_sip_profile_settings "; + $sql .= "where sip_profile_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + + //delete the sip profile + $sql = "delete from v_sip_profiles "; + $sql .= "where sip_profile_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + + //delete the xml sip profile and directory + unlink($_SESSION['switch']['conf']['dir']."/sip_profiles/".$sip_profile_name.".xml"); + unlink($_SESSION['switch']['conf']['dir']."/sip_profiles/".$sip_profile_name); + + //save the sip profile xml + save_sip_profile_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + +} + +//redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/sip_profiles/sip_profiles_edit.php b/app/sip_profiles/sip_profiles_edit.php new file mode 100644 index 0000000000..438bbd1a2f --- /dev/null +++ b/app/sip_profiles/sip_profiles_edit.php @@ -0,0 +1,206 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('sip_profile_add') || permission_exists('sip_profile_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $sip_profile_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $sip_profile_name = check_str($_POST["sip_profile_name"]); + $sip_profile_description = check_str($_POST["sip_profile_description"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $sip_profile_uuid = check_str($_POST["sip_profile_uuid"]); + } + + //check for all required data + //if (strlen($sip_profile_name) == 0) { $msg .= "Please provide: Name
\n"; } + //if (strlen($sip_profile_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $sql = "insert into v_sip_profiles "; + $sql .= "("; + $sql .= "sip_profile_uuid, "; + $sql .= "sip_profile_name, "; + $sql .= "sip_profile_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$sip_profile_name', "; + $sql .= "'$sip_profile_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_sip_profiles set "; + $sql .= "sip_profile_name = '$sip_profile_name', "; + $sql .= "sip_profile_description = '$sip_profile_description' "; + $sql .= "where sip_profile_uuid = '$sip_profile_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $sip_profile_uuid = $_GET["id"]; + $sql = "select * from v_sip_profiles "; + $sql .= "where sip_profile_uuid = '$sip_profile_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(); + foreach ($result as &$row) { + $sip_profile_name = $row["sip_profile_name"]; + $sip_profile_description = $row["sip_profile_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Sip Profile\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "Manage settings for the SIP profile.

\n"; + echo "
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the SIP Profile name.\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the description.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + if ($action == "update") { + require "sip_profile_settings.php"; + } + + echo "
"; + echo "
"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/sip_status/app_config.php b/app/sip_status/app_config.php new file mode 100644 index 0000000000..7cb6ffe0c2 --- /dev/null +++ b/app/sip_status/app_config.php @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/app/sip_status/cmd.php b/app/sip_status/cmd.php new file mode 100644 index 0000000000..9abe45a5fa --- /dev/null +++ b/app/sip_status/cmd.php @@ -0,0 +1,68 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$cmd = $_GET['cmd']; +$rdr = $_GET['rdr']; + +//create the event socket connection + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + if ($fp) { + //if reloadxml then run reloadacl, reloadxml and rescan the external profile for new gateways + if ($cmd == "api reloadxml") { + //clear the apply settings reminder + $_SESSION["reload_xml"] = false; + + //rescan the external profile to look for new or stopped gateways + $tmp_cmd = 'api sofia profile external rescan'; + $response = event_socket_request($fp, $tmp_cmd); + unset($tmp_cmd); + } + + //run the requested command + $response = event_socket_request($fp, $cmd); + + //close the connection + fclose($fp); + } + +if ($rdr == "false") { + //redirect false + echo $response; +} +else { + header("Location: sip_status.php?savemsg=".urlencode($response)); +} +?> \ No newline at end of file diff --git a/app/sip_status/root.php b/app/sip_status/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/sip_status/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/sip_status/sip_status.php b/app/sip_status/sip_status.php new file mode 100644 index 0000000000..b2f8f1f6d4 --- /dev/null +++ b/app/sip_status/sip_status.php @@ -0,0 +1,260 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; + +if (permission_exists('system_status_sofia_status') + || permission_exists('system_status_sofia_status_profile') + || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//define variables + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + +if ($_GET['a'] == "download") { + if ($_GET['t'] == "cdrcsv") { + $tmp = $_SESSION['switch']['log']['dir'].'/cdr-csv/'; + $filename = 'Master.csv'; + } + if ($_GET['t'] == "backup") { + $tmp = $backup_dir.'/'; + $filename = 'backup.tgz'; + if (!is_dir($backup_dir.'/')) { + exec("mkdir ".$backup_dir."/"); + } + $parent_dir = realpath($_SESSION['switch']['base']['dir']."/.."); + chdir($parent_dir); + shell_exec('tar cvzf freeswitch '.$backup_dir.'/backup.tgz'); + } + session_cache_limiter('public'); + $fd = fopen($tmp.$filename, "rb"); + header("Content-Type: binary/octet-stream"); + header("Content-Length: " . filesize($tmp.$filename)); + header('Content-Disposition: attachment; filename="'.$filename.'"'); + fpassthru($fd); + exit; +} + +require_once "includes/header.php"; + +$msg = $_GET["savemsg"]; +$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); +if (!$fp) { + $msg = "
Connection to Event Socket failed.
"; +} +if (strlen($msg) > 0) { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Message
$msg
\n"; + echo "
\n"; +} + +//sofia status + if ($fp && permission_exists('system_status_sofia_status')) { + $cmd = "api sofia xmlstatus"; + $xml_response = trim(event_socket_request($fp, $cmd)); + try { + $xml = new SimpleXMLElement($xml_response); + } + catch(Exception $e) { + echo $e->getMessage(); + } + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo " sofia status \n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + foreach ($xml->profile as $row) { + //print_r($row); + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } + foreach ($xml->gateway as $row) { + //print_r($row); + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } + foreach ($xml->alias as $row) { + //print_r($row); + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } + echo "
NameTypeDataState
".$row->name."".$row->type."".$row->data."".$row->state."
".$row->name."".$row->type."".$row->data."".$row->state."
".$row->name."".$row->type."".$row->data."".$row->state."
\n"; + unset($xml); + echo "

\n\n"; + } + +//sofia status profile + if (permission_exists('system_status_sofia_status_profile')) { + foreach (ListFiles($_SESSION['switch']['conf']['dir'].'/sip_profiles') as $key=>$sip_profile_file){ + if (substr($sip_profile_file, -4) == ".xml") { + $sip_profile_name = str_replace(".xml", "", $sip_profile_file); + if ($fp) { + $cmd = "api sofia xmlstatus profile ".$sip_profile_name.""; + $xml_response = trim(event_socket_request($fp, $cmd)); + if ($xml_response == "Invalid Profile!") { $xml_response = "Invalid Profile!"; } + $xml_response = str_replace("", "", $xml_response); + $xml_response = str_replace("", "", $xml_response); + try { + $xml = new SimpleXMLElement($xml_response); + } + catch(Exception $e) { + echo $e->getMessage(); + exit; + } + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo " sofia status profile $sip_profile_name \n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + if ($sip_profile_name != "external") { + echo " \n"; + } + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + foreach ($xml->profile_info as $row) { + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + } + echo "
  
name   ".$row->name." 
domain-name   ".$row->{'domain-name'}." 
auto-nat ".$row->{'auto-nat'}." 
db-name ".$row->{'db-name'}." 
pres-hosts ".$row->{'pres-hosts'}." 
dialplan ".$row->dialplan." 
context ".$row->context." 
challenge-realm ".$row->{'challenge-realm'}." 
rtp-ip ".$row->{'rtp-ip'}." 
ext-rtp-ip ".$row->{'ext-rtp-ip'}." 
sip-ip ".$row->{'sip-ip'}." 
ext-sip-ip ".$row->{'ext-sip-ip'}." 
url ".$row->url." 
bind-url ".$row->{'bind-url'}." 
tls-url ".$row->{'tls-url'}." 
tls-bind-url ".$row->{'tls-bind-url'}." 
hold-music ".$row->{'hold-music'}." 
outbound-proxy ".$row->{'outbound-proxy'}." 
inbound-codecs ".$row->{'inbound-codecs'}." 
outbound-codecs ".$row->{'outbound-codecs'}." 
tel-event ".$row->{'tel-event'}." 
dtmf-mode ".$row->{'dtmf-mode'}." 
cng ".$row->cng." 
session-to ".$row->{'session-to'}." 
max-dialog ".$row->{'max-dialog'}." 
nomedia ".$row->nomedia." 
late-neg ".$row->{'late-neg'}." 
proxy-media ".$row->{'proxy-media'}." 
aggressive-nat ".$row->{'aggressive-nat'}." 
stun-enabled ".$row->{'stun-enabled'}." 
stun-auto-disable ".$row->{'stun-auto-disable'}." 
user-agent-filter ".$row->{'user-agent-filter'}." 
max-registrations-per-extension ".$row->{'max-registrations-per-extension'}." 
calls-in ".$row->{'calls-in'}." 
calls-out ".$row->{'calls-out'}." 
failed-calls-in ".$row->{'failed-calls-in'}." 
failed-calls-out ".$row->{'failed-calls-out'}." 
\n"; + unset($xml); + echo "

\n\n"; + } + } + } + } + +//status + if ($fp && permission_exists('sip_status_switch_status')) { + $cmd = "api status"; + $response = event_socket_request($fp, $cmd); + echo "status
\n"; + echo "
";
+		echo trim($response);
+		echo "
\n"; + fclose($fp); + echo "

\n\n"; + } + +//include the footer + require_once "includes/footer.php"; + +?> \ No newline at end of file diff --git a/app/sql_query/app_config.php b/app/sql_query/app_config.php new file mode 100644 index 0000000000..bd9ad6aeb8 --- /dev/null +++ b/app/sql_query/app_config.php @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/app/sql_query/root.php b/app/sql_query/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/sql_query/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/sql_query/v_sql_backup.php b/app/sql_query/v_sql_backup.php new file mode 100644 index 0000000000..dd16c54efa --- /dev/null +++ b/app/sql_query/v_sql_backup.php @@ -0,0 +1,133 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('sql_query_backup')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//pdo database connection + if (strlen($_REQUEST['id']) > 0) { + require_once "v_sql_query_pdo.php"; + } + +//set the headers + header('Content-type: application/octet-binary'); + header('Content-Disposition: attachment; filename=database_backup.sql'); + +//get the list of tables + if ($db_type == "sqlite") { + $sql = "SELECT name FROM sqlite_master "; + $sql .= "WHERE type='table' "; + $sql .= "order by name;"; + } + if ($db_type == "pgsql") { + $sql = "select table_name as name "; + $sql .= "from information_schema.tables "; + $sql .= "where table_schema='public' "; + $sql .= "and table_type='BASE TABLE' "; + $sql .= "order by table_name "; + } + if ($db_type == "mysql") { + $sql = "show tables"; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $table_name = $row[0]; + + //get the table data + $sql = "select * from $table_name"; + if (strlen($sql) > 0) { + $prep_statement_2 = $db->prepare(check_sql($sql)); + if ($prep_statement_2) { + $prep_statement_2->execute(); + $result2 = $prep_statement_2->fetchAll(PDO::FETCH_ASSOC); + } + else { + echo "Error:\n"; + echo "
\n";
+					print_r($db->errorInfo());
+					echo "
\n"; + } + + $x = 0; + foreach ($result2[0] as $key => $value) { + if ($row[$column] != "db") { + $column_array[$x] = $key; + $x++; + } + } + + $column_array_count = count($column_array); + + foreach ($result2 as &$row) { + $sql = "INSERT INTO $table_name ("; + $x = 1; + foreach ($column_array as $column) { + if ($x < $column_array_count) { + if (strlen($row[$column]) > 0) { + $sql .= ''.$column.','; + } + } + else { + if (strlen($row[$column]) > 0) { + $sql .= ''.$column.''; + } + } + $x++; + } + $sql .= ") "; + $sql .= "VALUES( "; + $x = 1; + foreach ($column_array as $column) { + if ($x < $column_array_count) { + if (strlen($row[$column])> 0) { + $sql .= "'".check_str($row[$column])."',"; + } + } + else { + if (strlen($row[$column])> 0) { + $sql .= "'".check_str($row[$column])."'"; + } + } + $x++; + } + $sql .= ");\n"; + echo str_replace(",)", ")", $sql); + } + } + + unset($column_array); + } + +?> diff --git a/app/sql_query/v_sql_db_conversion.php b/app/sql_query/v_sql_db_conversion.php new file mode 100644 index 0000000000..0a9830cbc0 --- /dev/null +++ b/app/sql_query/v_sql_db_conversion.php @@ -0,0 +1,495 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +require_once "includes/lib_schema.php"; + +if (if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; + +//show errors + ini_set('display_errors', '1'); + //error_reporting (E_ALL); // Report everything + error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ); //hide notices and warnings + +//define the db file exists function + function db_field_exists ($tmp_array, $column) { + $result = false; + foreach ($tmp_array as &$row) { + if ($row[0] == $column) { + $result = true; + } + return $result; + } + } + //db_field_exists ($result_dest, $column) + +//destination info + //set the domain_uuid + $dest_domain_uuid = '1'; + + //set the database type + $db_dest_type = 'mysql'; //sqlite, mysql, pgsql, others with a manually created PDO connection + + //sqlite: the dbfilename and db_file_path are automatically assigned however the values can be overidden by setting the values here. + //$dbfilename = 'fusionpbx.db'; //host name/ip address + '.db' is the default database filename + //$db_file_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure'; //the path is determined by a php variable + + //mysql: database connection information + $db_host = '127.0.0.1'; //set the host only if the database is not local + $db_port = '3306'; + $db_name = 'fusionpbx'; + $db_username = 'fusionpbx'; + $db_password = ''; + $db_create_username = 'root'; + $db_create_password = ''; + + //pgsql: database connection information + //$db_host = ''; //set the host only if the database is not local + //$db_port = ''; + //$db_name = ''; + //$db_username = ''; + //$db_password = ''; + //$db_create_username = ''; + //$db_create_password = ''; + + //load data into the database + + //create the sqlite database + if ($db_dest_type == "sqlite") { + //sqlite database will be created when the config.php is loaded and only if the database file does not exist + $filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/sql/sqlite.sql'; + $file_contents = file_get_contents($filename); + unset($filename); + try { + $db_dest = new PDO('sqlite:'.$db_filepath.'/'.$db_filename); //sqlite 3 + //$db_dest = new PDO('sqlite::memory:'); //sqlite 3 + $db_dest->beginTransaction(); + } + catch (PDOException $error) { + print "error: " . $error->getMessage() . "
"; + die(); + } + + //replace \r\n with \n then explode on \n + $file_contents = str_replace("\r\n", "\n", $file_contents); + + //loop line by line through all the lines of sql code + $stringarray = explode("\n", $file_contents); + $x = 0; + foreach($stringarray as $sql) { + try { + if(stristr($sql, 'CREATE TABLE') === FALSE) { + //not found do not execute + } + else { + //execute create table sql strings + $db_dest->query($sql); + } + } + catch (PDOException $error) { + echo "error: " . $error->getMessage() . " sql: $sql
"; + } + $x++; + } + unset ($file_contents, $sql); + $db_dest->commit(); + } + + //create the postgres database + if ($db_dest_type == "pgsql") { + $filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/sql/pgsql.sql'; + $file_contents = file_get_contents($filename); + + //if $db_create_username provided, attempt to create new PG role and database + if (strlen($db_create_username) > 0) { + //create the database connection + try { + if (strlen($db_port) == 0) { $db_port = "5432"; } + if (strlen($db_host) > 0) { + $db_dest = new PDO("pgsql:host={$db_host} port={$db_port} user={$db_create_username} password={$db_create_password} dbname=template1"); + } else { + $db_dest = new PDO("pgsql:host=localhost port={$db_port} user={$db_create_username} password={$db_create_password} dbname=template1"); + } + } catch (PDOException $error) { + print "error: " . $error->getMessage() . "
"; + die(); + } + //create the database, user, grant perms + $db_dest->exec("CREATE DATABASE {$db_name}"); + $db_dest->exec("CREATE USER {$db_username} WITH PASSWORD '{$db_password}'"); + $db_dest->exec("GRANT ALL ON {$db_name} TO {$db_username}"); + //close database connection_aborted + $db_dest = null; + } + + //open database connection with $db_name + try { + if (strlen($db_port) == 0) { $db_port = "5432"; } + if (strlen($db_host) > 0) { + $db_dest = new PDO("pgsql:host={$db_host} port={$db_port} dbname={$db_name} user={$db_username} password={$db_password}"); + } else { + $db_dest = new PDO("pgsql:host=localhost port={$db_port} user={$db_username} password={$db_password} dbname={$db_name}"); + } + } + catch (PDOException $error) { + print "error: " . $error->getMessage() . "
"; + die(); + } + + //replace \r\n with \n then explode on \n + $file_contents = str_replace("\r\n", "\n", $file_contents); + + //loop line by line through all the lines of sql code + $stringarray = explode("\n", $file_contents); + $x = 0; + foreach($stringarray as $sql) { + if (strlen($sql) > 3) { + try { + if(stristr($sql, 'CREATE TABLE') === FALSE) { + //not found do not execute + } + else { + //execute create table sql strings + $db_dest->query($sql); + } + } + catch (PDOException $error) { + echo "error: " . $error->getMessage() . " sql: $sql
"; + die(); + } + } + $x++; + } + unset ($file_contents, $sql); + } + + //create the mysql database + if ($db_dest_type == "mysql") { + $filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/sql/mysql.sql'; + $file_contents = file_get_contents($filename); + + //database connection + try { + if (strlen($db_host) == 0 && strlen($db_port) == 0) { + //if both host and port are empty use the unix socket + if (strlen($db_create_username) == 0) { + $db_dest = new PDO("mysql:host=$db_host;unix_socket=/var/run/mysqld/mysqld.sock;", $db_username, $db_password); + } + else { + $db_dest = new PDO("mysql:host=$db_host;unix_socket=/var/run/mysqld/mysqld.sock;", $db_create_username, $db_create_password); + } + } + else { + if (strlen($db_port) == 0) { + //leave out port if it is empty + if (strlen($db_create_username) == 0) { + $db_dest = new PDO("mysql:host=$db_host;", $db_username, $db_password); + } + else { + $db_dest = new PDO("mysql:host=$db_host;", $db_create_username, $db_create_password); + } + } + else { + if (strlen($db_create_username) == 0) { + $db_dest = new PDO("mysql:host=$db_host;port=$db_port;", $db_username, $db_password); + } + else { + $db_dest = new PDO("mysql:host=$db_host;port=$db_port;", $db_create_username, $db_create_password); + } + } + } + $db_dest->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $db_dest->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); + } + catch (PDOException $error) { + if ($v_debug) { + print "error: " . $error->getMessage() . "
"; + } + } + + //create the table, user and set the permissions only if the db_create_username was provided + if (strlen($db_create_username) > 0) { + //select the mysql database + try { + $db_dest->query("USE mysql;"); + } + catch (PDOException $error) { + if ($v_debug) { + print "error: " . $error->getMessage() . "
"; + } + } + //create user and set the permissions + try { + $tmp_sql = "CREATE USER '".$db_username."'@'%' IDENTIFIED BY '".$db_password."'; "; + $db_dest->query($tmp_sql); + } + catch (PDOException $error) { + if ($v_debug) { + print "error: " . $error->getMessage() . "
"; + } + } + //set account to unlimitted use + try { + $tmp_sql = "GRANT USAGE ON * . * TO '".$db_username."'@'localhost' "; + $tmp_sql .= "IDENTIFIED BY '".$db_password."' "; + $tmp_sql .= "WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0; "; + $db_dest->query($tmp_sql); + } + catch (PDOException $error) { + if ($v_debug) { + print "error: " . $error->getMessage() . "
"; + } + } + //create the database and set the create user with permissions + try { + $tmp_sql = "CREATE DATABASE IF NOT EXISTS ".$db_name."; "; + $db_dest->query($tmp_sql); + } + catch (PDOException $error) { + if ($v_debug) { + print "error: " . $error->getMessage() . "
"; + } + } + //set user permissions + try { + $db_dest->query("GRANT ALL PRIVILEGES ON ".$db_name.".* TO '".$db_username."'@'%'; "); + } + catch (PDOException $error) { + if ($v_debug) { + print "error: " . $error->getMessage() . "
"; + } + } + //make the changes active + try { + $tmp_sql = "FLUSH PRIVILEGES; "; + $db_dest->query($tmp_sql); + } + catch (PDOException $error) { + if ($v_debug) { + print "error: " . $error->getMessage() . "
"; + } + } + } //if (strlen($db_create_username) > 0) + //select the database + try { + $db_dest->query("USE ".$db_name.";"); + } + catch (PDOException $error) { + if ($v_debug) { + print "error: " . $error->getMessage() . "
"; + } + } + + //add the defaults data into the database + //replace \r\n with \n then explode on \n + $file_contents = str_replace("\r\n", "\n", $file_contents); + + //loop line by line through all the lines of sql code + $stringarray = explode("\n", $file_contents); + $x = 0; + foreach($stringarray as $sql) { + if (strlen($sql) > 3) { + try { + if(stristr($sql, 'CREATE TABLE') === FALSE) { + //not found do not execute + } + else { + //execute create table sql strings + $db_dest->query($sql); + } + } + catch (PDOException $error) { + //echo "error on line $x: " . $error->getMessage() . " sql: $sql
"; + //die(); + } + } + $x++; + } + unset ($file_contents, $sql); + } + +//get the list of tables + if ($db_dest_type == "sqlite") { + $sql = "SELECT name FROM sqlite_master "; + $sql .= "WHERE type='table' "; + $sql .= "order by name;"; + } + if ($db_dest_type == "pgsql") { + $sql = "select table_name as name "; + $sql .= "from information_schema.tables "; + $sql .= "where table_schema='public' "; + $sql .= "and table_type='BASE TABLE' "; + $sql .= "order by table_name "; + } + if ($db_dest_type == "mysql") { + $sql = "show tables"; + } + //get the default schema structure + $prep_statement = $db_dest->prepare(check_sql($sql)); + $prep_statement->execute(); + $result_dest = $prep_statement->fetchAll(PDO::FETCH_NAMED); + //clean the content from the table + foreach ($result_dest as &$row) { + $table_name = $row[0]; + $sql = 'delete from '.$table_name; + //$db_dest->query($sql); + } + + //add data into each table + foreach ($result_dest as &$row) { + //get the table name + $table_name = $row[0]; + + //$table_name = 'v_extensions'; + //$db_dest_type = "sqlite"; + + //get the table source data + $destination_column_array=''; + unset($destination_column_array); + if ($db_dest_type == "sqlite") { + $tmp_sql = "PRAGMA table_info($table_name);"; + } + if ($db_dest_type == "pgsql") { + + } + if ($db_dest_type == "mysql") { + $tmp_sql = "show columns from $table_name;"; + } + if (strlen($tmp_sql) > 0) { + $prep_statement_2 = $db_dest->prepare(check_sql($tmp_sql)); + //$prep_statement_2 = $db->prepare(check_sql($tmp_sql)); + if ($prep_statement_2) { + $prep_statement_2->execute(); + $result2 = $prep_statement_2->fetchAll(PDO::FETCH_ASSOC); + } + else { + echo "Error:\n"; + echo "
\n";
+						print_r($db_dest->errorInfo());
+						echo "
\n"; + } + $x = 0; + foreach ($result2 as $row2) { + if ($db_dest_type == "sqlite") { + $destination_column_array[$x] = $row2['name']; + } + if ($db_dest_type == "mysql") { + $destination_column_array[$x] = $row2['Field']; + } + if ($db_dest_type == "pgsql") { + + } + $x++; + } + /* + $x = 0; + foreach ($result2[0] as $key => $value) { + if ($db_dest_type == "sqlite" && $key == "name") { + $destination_column_array[$x] = $key; + } + $x++; + } + */ + $destination_column_array_count = count($destination_column_array); + } + unset($prep_statement_2, $result2); + //echo "
\n";
+				//print_r($destination_column_array);
+				//echo "
\n"; + + //get the table source data + $tmp_sql = "select * from $table_name"; + if (strlen($tmp_sql) > 0) { + $prep_statement_2 = $db->prepare(check_sql($tmp_sql)); + if ($prep_statement_2) { + $prep_statement_2->execute(); + $result2 = $prep_statement_2->fetchAll(PDO::FETCH_ASSOC); + } + else { + echo "Error:\n"; + echo "
\n";
+						print_r($db->errorInfo());
+						echo "
\n"; + } + + $x = 0; + foreach ($result2[0] as $key => $value) { + $column_array[$x] = $key; + $x++; + } + + foreach ($result2 as &$row) { + //build the sql query string + if (substr($table_name, 0, 2) == 'v_') { + $sql = "INSERT INTO $table_name ("; + $x = 1; + foreach ($destination_column_array as $column) { + if ($x < $destination_column_array_count) { + $sql .= "".$column.", "; + } + else { + $sql .= "".$column.""; + } + $x++; + } + $sql .= ") "; + $sql .= "VALUES( "; + $x = 1; + foreach ($destination_column_array as $column) { + if ($x < $destination_column_array_count) { + //if ($column == "domain_uuid") { + // $sql .= "'".$dest_domain_uuid."',"; + //} + //else { + $sql .= "'".check_str($row[$column])."', "; + //} + } + else { + //if ($column == "domain_uuid") { + // $sql .= "'".$dest_domain_uuid."'"; + //} + //else { + $sql .= "'".check_str($row[$column])."'"; + //} + } + $x++; + } + $sql .= ");\n"; + } + //add the sql into the destination database + echo $sql."
\n"; + $db_dest->query($sql); + } + } + } + +?> \ No newline at end of file diff --git a/app/sql_query/v_sql_query.php b/app/sql_query/v_sql_query.php new file mode 100644 index 0000000000..1d0af0ec2a --- /dev/null +++ b/app/sql_query/v_sql_query.php @@ -0,0 +1,171 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('sql_query_execute')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//show the header + require_once "includes/header.php"; + +//pdo voicemail database connection + require_once "v_sql_query_pdo.php"; + +//show the content + //edit area + echo " \n"; + echo " "; + + echo "
"; + echo "\n"; + + echo "\n"; + echo " + +
\n"; + echo "
"; + + echo "
"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo " + + + + + + + + + + + +
SQL Query\n"; + if (strlen($_REQUEST['id']) > 0) { + echo " \n"; + } + else { + echo " \n"; + } + echo " \n"; + echo " \n"; + echo "
\n"; + echo " +
+
+
+ location: ".$_SESSION['switch']['conf']['dir']."/vars.xml\n"; + } + ?> + + + + "; + } + ?> +
+


+


+


+


+


+


+


+


+


+


+
+
+ +
+
+ + \ No newline at end of file diff --git a/app/vars/v_vars_delete.php b/app/vars/v_vars_delete.php new file mode 100644 index 0000000000..126d03ac14 --- /dev/null +++ b/app/vars/v_vars_delete.php @@ -0,0 +1,62 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('variables_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = $_GET["id"]; +} + +//delete the data + if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_vars "; + $sql .= "where var_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + + save_var_xml(); + } + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/vars/v_vars_edit.php b/app/vars/v_vars_edit.php new file mode 100644 index 0000000000..6465cea1d0 --- /dev/null +++ b/app/vars/v_vars_edit.php @@ -0,0 +1,384 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('variables_add') || permission_exists('variables_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//set the action as an add or an update + if (isset($_REQUEST["id"])) { + $action = "update"; + $var_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//set http values as php variables + if (count($_POST)>0) { + $var_name = check_str($_POST["var_name"]); + $var_value = check_str($_POST["var_value"]); + $var_cat = check_str($_POST["var_cat"]); + if (strlen($_POST["var_cat_other"]) > 0) { + $var_cat = check_str($_POST["var_cat_other"]); + } + $var_enabled = check_str($_POST["var_enabled"]); + $var_order = check_str($_POST["var_order"]); + $var_description = $_POST["var_description"]; + $var_description = str_replace("''", "'", $var_description); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $var_uuid = check_str($_POST["var_uuid"]); + } + + //check for all required data + if (strlen($var_name) == 0) { $msg .= "Please provide: Name
\n"; } + if (strlen($var_value) == 0) { $msg .= "Please provide: Value
\n"; } + //if (strlen($var_cat) == 0) { $msg .= "Please provide: Category
\n"; } + if (strlen($var_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } + if (strlen($var_order) == 0) { $msg .= "Please provide: Order
\n"; } + //if (strlen($var_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('variables_add')) { + $var_uuid = uuid(); + $sql = "insert into v_vars "; + $sql .= "("; + $sql .= "var_uuid, "; + $sql .= "var_name, "; + $sql .= "var_value, "; + $sql .= "var_cat, "; + $sql .= "var_enabled, "; + $sql .= "var_order, "; + $sql .= "var_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$var_uuid', "; + $sql .= "'$var_name', "; + $sql .= "'$var_value', "; + $sql .= "'$var_cat', "; + $sql .= "'$var_enabled', "; + $sql .= "'$var_order', "; + $sql .= "'".base64_encode($var_description)."' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //unset the user defined variables + $_SESSION["user_defined_variables"] = ""; + + //synchronize the configuration + save_var_xml(); + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update" && permission_exists('variables_edit')) { + $sql = "update v_vars set "; + $sql .= "var_name = '$var_name', "; + $sql .= "var_value = '$var_value', "; + $sql .= "var_cat = '$var_cat', "; + $sql .= "var_enabled = '$var_enabled', "; + $sql .= "var_order = '$var_order', "; + $sql .= "var_description = '".base64_encode($var_description)."' "; + $sql .= "where var_uuid = '$var_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + + //unset the user defined variables + $_SESSION["user_defined_variables"] = ""; + + //synchronize the configuration + save_var_xml(); + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $var_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_vars "; + $sql .= "where var_uuid = '$var_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $var_name = $row["var_name"]; + $var_value = $row["var_value"]; + $var_cat = $row["var_cat"]; + $var_enabled = $row["var_enabled"]; + $var_order = $row["var_order"]; + $var_description = base64_decode($row["var_description"]); + break; //limit to 1 row + } + unset ($prep_statement); + } + +//include header + require_once "includes/header.php"; + +//show contents + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + + //if variable is a code then show the codec info + if ($var_name == "global_codec_prefs" || $var_name == "outbound_codec_prefs") { + echo "\n"; + echo ""; + echo ""; + } + + echo "
Variable AddVariable Edit
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the variable name here. \n"; + echo "
\n"; + echo " Value:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the variable value here. \n"; + echo "
\n"; + echo " Category:\n"; + echo "\n"; + $table_name = 'v_vars';$field_name = 'var_cat';$sql_where_optional = "";$field_current_value = $var_cat; + echo html_select_other($db, $table_name, $field_name, $sql_where_optional, $field_current_value); + //echo " \n"; + echo "
\n"; + echo "Enter the category here.\n"; + echo "
\n"; + echo " Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Order:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
\n"; + echo "
\n"; + echo "Codec Information:
\n"; + echo "Module must be compiled and loaded.     codecname[@8000h|16000h|32000h[@XXi]]
\n"; + echo "
\n"; + echo "XX is the frame size must be multples allowed for the codec
\n"; + echo "10-120ms is supported on some codecs.
\n"; + echo "We do not support exceeding the MTU of the RTP packet.
\n"; + echo "
\n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " "; + echo " \n"; + echo " \n"; + echo "
iLBC@30iiLBC using mode=30 which will win in all cases.
DVI4@8000h@20iIMA ADPCM 8kHz using 20ms ptime. (multiples of 10)
DVI4@16000h@40iIMA ADPCM 16kHz using 40ms ptime. (multiples of 10)
speex@8000h@20iSpeex 8kHz using 20ms ptime.
speex@16000h@20iSpeex 16kHz using 20ms ptime.
speex@32000h@20iSpeex 32kHz using 20ms ptime.
G7221@16000hG722.1 16kHz (aka Siren 7)
G7221@32000hG722.1C 32kHz (aka Siren 14)
CELT@32000hCELT 32kHz, only 10ms supported
CELT@48000hCELT 48kHz, only 10ms supported
GSM@40iGSM 8kHz using 40ms ptime. (GSM is done in multiples of 20, Default is 20ms)
G722G722 16kHz using default 20ms ptime. (multiples of 10)
PCMUG711 8kHz ulaw using default 20ms ptime. (multiples of 10)
PCMAG711 8kHz alaw using default 20ms ptime. (multiples of 10)
G726-16G726 16kbit adpcm using default 20ms ptime. (multiples of 10)
G726-24G726 24kbit adpcm using default 20ms ptime. (multiples of 10)
G726-32G726 32kbit adpcm using default 20ms ptime. (multiples of 10)
G726-40G726 40kbit adpcm using default 20ms ptime. (multiples of 10)
AAL2-G726-16Same as G726-16 but using AAL2 packing. (multiples of 10)
AAL2-G726-24Same as G726-24 but using AAL2 packing. (multiples of 10)
AAL2-G726-32Same as G726-32 but using AAL2 packing. (multiples of 10)
AAL2-G726-40Same as G726-40 but using AAL2 packing. (multiples of 10)
LPCLPC10 using 90ms ptime (only supports 90ms at this time)
L16L16 isn't recommended for VoIP but you can do it. L16 can exceed the MTU rather quickly.

These are the passthru audio codecs:
G729G729 in passthru mode. (mod_g729)
G723G723.1 in passthru mode. (mod_g723_1)
AMRAMR in passthru mode. (mod_amr)

These are the passthru video codecs: (mod_h26x)
H261H.261 Video
H263H.263 Video
H263-1998H.263-1998 Video
H263-2000H.263-2000 Video
H264H.264 Video
\n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//include header + require_once "includes/footer.php"; +?> diff --git a/app/virtual_tables/app_config.php b/app/virtual_tables/app_config.php new file mode 100644 index 0000000000..8f2fa04c97 --- /dev/null +++ b/app/virtual_tables/app_config.php @@ -0,0 +1,369 @@ + \ No newline at end of file diff --git a/app/virtual_tables/root.php b/app/virtual_tables/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/virtual_tables/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/virtual_tables/v_virtual_table_data_delete.php b/app/virtual_tables/v_virtual_table_data_delete.php new file mode 100644 index 0000000000..bcab3314de --- /dev/null +++ b/app/virtual_tables/v_virtual_table_data_delete.php @@ -0,0 +1,103 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('virtual_tables_data_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + + //declare variable(s) + $virtual_table_parent_id = ''; + + //get the http get and set them as php variables + $virtual_data_row_uuid = check_str($_GET["virtual_data_row_uuid"]); + $virtual_data_parent_row_uuid = check_str($_GET["virtual_data_parent_row_uuid"]); + $virtual_table_uuid = check_str($_GET["virtual_table_uuid"]); + + //show the results and redirect + require_once "includes/header.php"; + + //get the virtual_table_parent_id from the child table + if (strlen($virtual_table_parent_id) == 0) { + $sql = "select * from v_virtual_tables "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and virtual_table_uuid = '$virtual_table_uuid' "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $virtual_table_parent_id = $row["virtual_table_parent_id"]; + } + } + + //delete the child data + $sql = "delete from v_virtual_table_data "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and virtual_data_parent_row_uuid = '$virtual_data_row_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + + //delete the data + $sql = "delete from v_virtual_table_data "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and virtual_data_row_uuid = '$virtual_data_row_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + + //mark the the item as deleted and who deleted it + //$sql = "update v_virtual_table_data set "; + //$sql .= "virtual_data_del_date = now(), "; + //$sql .= "virtual_data_del_user = '".$_SESSION["username"]."' "; + //$sql .= "where domain_uuid = '$domain_uuid' "; + //$sql .= "and virtual_data_row_uuid = '$virtual_data_row_uuid' "; + //$db->exec(check_sql($sql)); + //$lastinsertid = $db->lastInsertId($id); + //unset($sql); + + //set the meta redirect + if (strlen($virtual_data_parent_row_uuid) == 0) { + echo "\n"; + } + else { + echo "\n"; + } + + //show a message to the user before the redirect + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; +} + +?> \ No newline at end of file diff --git a/app/virtual_tables/v_virtual_table_data_edit.php b/app/virtual_tables/v_virtual_table_data_edit.php new file mode 100644 index 0000000000..493ff7bf5a --- /dev/null +++ b/app/virtual_tables/v_virtual_table_data_edit.php @@ -0,0 +1,982 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('virtual_tables_data_add') || permission_exists('virtual_tables_data_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//set http get variables to php variables + $search_all = check_str($_GET["search_all"]); + $virtual_table_uuid = check_str($_GET["virtual_table_uuid"]); + if (strlen($_GET["virtual_data_row_uuid"])>0) { //update + $virtual_data_row_uuid = check_str($_GET["virtual_data_row_uuid"]); + $action = "update"; + } + else { + if (strlen($search_all) > 0) { + $action = "update"; + } + else { + $action = "add"; + } + } + if (strlen($_GET["id"]) > 0) { + $virtual_table_uuid = check_str($_GET["id"]); + } + if (strlen($_GET["virtual_data_parent_row_uuid"])>0) { + $virtual_data_parent_row_uuid = check_str($_GET["virtual_data_parent_row_uuid"]); + } + +//get virtual table information + $sql = ""; + $sql .= "select * from v_virtual_tables "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and virtual_table_uuid = '$virtual_table_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $virtual_table_category = $row["virtual_table_category"]; + $virtual_table_label = $row["virtual_table_label"]; + $virtual_table_name = $row["virtual_table_name"]; + $virtual_table_auth = $row["virtual_table_auth"]; + $virtual_table_captcha = $row["virtual_table_captcha"]; + $virtual_table_parent_id = $row["virtual_table_parent_id"]; + $virtual_table_description = $row["virtual_table_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + +//process the data submitted to by the html form + if (count($_POST)>0) { //add + $virtual_table_uuid = check_str($_POST["virtual_table_uuid"]); + $virtual_table_name = check_str($_POST["virtual_table_name"]); + $rcount = check_str($_POST["rcount"]); + + //get the field information + $db_field_name_array = array(); + $db_value_array = array(); + $db_names .= "
\n"; + echo " \n"; + echo " \n"; + + if (strlen($virtual_data_parent_row_uuid) == 0) { + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + else { + echo " \n"; + } + echo " \n"; + echo "
\n"; + echo " $virtual_table_label \n"; + if ($action == "add") { + echo " Add\n"; + } + else { + echo "Edit\n"; + } + echo " \n"; + echo "      \n"; + if ($action == "update" && permission_exists('virtual_tables_data_edit')) { + echo " \n"; + //echo " \n"; + } + echo "
\n"; + echo " $virtual_table_description\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + + if ($action == "update" && permission_exists('virtual_tables_data_edit')) { + //echo " \n"; + if (strlen($previous_virtual_data_row_uuid) == 0) { + echo " \n"; + } + else { + echo " \n"; + } + echo " \n"; + if (strlen($next_virtual_data_row_uuid) == 0) { + echo " \n"; + } + else { + echo " \n"; + } + //echo " \n"; + } + echo "    "; + echo "    "; + echo "    "; + echo "
\n"; + echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + echo "
\n"; + +//begin the div and table that will hold the html form + echo "
"; + echo "\n"; + +//determine if a file should be uploaded + $sql = "SELECT * FROM v_virtual_table_fields "; + $sql .= "where domain_uuid = '$domain_uuid ' "; + $sql .= "and virtual_table_uuid = '$virtual_table_uuid ' "; + $sql .= "and virtual_field_type = 'uploadimage' "; + $sql .= "or domain_uuid = '$domain_uuid ' "; + $sql .= "and virtual_table_uuid = '$virtual_table_uuid ' "; + $sql .= "and virtual_field_type = 'upload_file' "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + if (count($prep_statement->fetchAll(PDO::FETCH_NAMED)) > 0) { + echo "\n"; + echo "\n"; + } + else { + echo "\n"; + } + +//get the table fields and then display them + $sql = ""; + $sql .= "select * from v_virtual_table_fields "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and virtual_table_uuid = '$virtual_table_uuid' "; + $sql .= "order by virtual_field_column asc, virtual_field_order asc "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + echo "\n"; + echo "\n"; + + if ($result_count == 0) { //no results + echo "\n"; + } + else { //received results + $x=1; + $virtual_field_column_previous = ''; + $column_table_cell_status = ''; + foreach($result as $row) { + //handle more than one column + $virtual_field_column = $row[virtual_field_column]; + //echo "\n"; + if ($virtual_field_column != $virtual_field_column_previous) { + $column_table_cell_status = 'open'; + //do the following except for the first time through the loop + if ($x != 1) { + //close the table + echo "\n"; + echo "\n"; + echo "
 
\n"; + //close the row + echo "\n"; + } + //open a new row + echo "\n"; + //start a table in the new row + echo "\n"; + } + + //display the fields + if ($row['virtual_field_type'] != "hidden"){ + switch ($row['virtual_field_type']) { + case "add_user": + break; + case "add_date": + break; + case "mod_user": + break; + case "mod_date": + break; + default: + echo "\n"; + if ($row['virtual_field_type'] == "label") { + echo "\n"; + } + else { + if ($row['virtual_field_required'] == "yes") { + echo "\n"; + } + } + } + switch ($row['virtual_field_type']) { + case "checkbox": + echo "\n"; + break; + case "text": + echo "\n"; + break; + case "email": + echo "\n"; + break; + case "label": + break; + case "password": + echo "\n"; + break; + case "pin_number": + echo "\n"; + break; + case "hidden": + echo "\n"; + echo "\n"; + break; + case "url": + echo "\n"; + break; + case "date": + echo "\n"; + break; + case "truefalse": + //checkbox + echo "\n"; + break; + case "textarea": + echo "\n"; + break; + case "radiobutton": + echo "\n"; + break; + case "select": + echo "\n"; + break; + case "ipv4": + //max 15 + echo "\n"; + break; + case "ipv6": + //maximum number of characters 39 + echo "\n"; + break; + case "phone": + $tmp_phone = $data_row[$row['virtual_field_name']]; + $tmp_phone = format_phone($tmp_phone); + echo "\n"; + break; + case "money": + echo "\n"; + break; + case "add_user": + //echo "\n"; + break; + case "add_date": + //echo "\n"; + break; + case "mod_user": + //echo "\n"; + break; + case "mod_date": + //echo "\n"; + break; + case "uploadimage": + if (strlen($data_row[$row['virtual_field_name']]) > 0) { + echo "\n"; + } + else { + echo "\n"; + } + break; + case "upload_file": + if (strlen($data_row[$row['virtual_field_name']]) > 0) { + echo "\n"; + } + else { + echo "\n"; + } + + break; + default: + echo "\n"; + } + if ($row['virtual_field_type'] != "hidden"){ + echo "\n"; + } + + //set the current value to the previous value + $virtual_field_column_previous = $virtual_field_column; + + $x++; + + } //end foreach + unset($sql, $result, $row_count); + + if ($column_table_cell_status == 'open') { + $column_table_cell_status = 'closed'; + } + } //end if results + + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$row['virtual_field_label']."\n"; + echo "\n"; + } + else { + echo "\n"; + } + echo "".$row['virtual_field_label'].": \n"; + echo "\n"; + echo "\n"; + if (strlen($data_row[$row['virtual_field_name']])>0) { + echo "\n"; + } + else { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + //echo "\n"; + //echo ""; + //echo ""; + //echo "\n"; + //echo " \n"; + //echo ""; + //echo "
"; + //echo "\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + switch ($row['virtual_field_name']) { + case "true": + echo "\n"; + echo "\n"; + break; + case "false": + echo "\n"; + echo "\n"; + break; + default: + echo "\n"; + echo "\n"; + } + + echo "\n"; + echo "
TrueFalseTrueFalseTrueFalse
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + $sqlselect = "SELECT virtual_data_types_name, virtual_data_types_value "; + $sqlselect .= "FROM v_virtual_table_data_types_name_value "; + $sqlselect .= "where domain_uuid = '".$domain_uuid."' "; + $sqlselect .= "and virtual_table_field_uuid = '".$row[virtual_table_field_uuid]."' "; + $prep_statement_2 = $db->prepare($sqlselect); + $prep_statement_2->execute(); + $result2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED); + $result_count2 = count($result2); + + echo ""; + if ($result_count > 0) { + foreach($result2 as $row2) { + echo ""; + } //end foreach + } //end if results + unset($sqlselect, $result2, $result_count2); + echo "
".$row2["virtual_data_types_name"].""; } else { echo ">"; } + echo "
"; + //echo "\n"; + echo "
\n"; + echo "\n"; + + $sqlselect = "SELECT virtual_data_types_name, virtual_data_types_value "; + $sqlselect .= "FROM v_virtual_table_data_types_name_value "; + $sqlselect .= "where domain_uuid = '".$domain_uuid."' "; + $sqlselect .= "and virtual_table_field_uuid = '".$row[virtual_table_field_uuid]."' "; + $prep_statement_2 = $db->prepare($sqlselect); + $prep_statement_2->execute(); + $result2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED); + $result_count2 = count($result2); + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + echo "\n"; + + echo "
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + echo "
"; + echo "".$data_row[$row['virtual_field_name']].""; + echo ""; + echo "\n"; + //echo "\n"; + echo "
"; + if (file_exists($imagetempdir.$data_row[$row['virtual_field_name']])) { + echo ""; + } + else { + echo ""; + } + echo "
"; + echo "
"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "
"; + echo "".$data_row[$row['virtual_field_name']].""; + echo ""; + echo "\n"; + echo "
"; + echo ""; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + if ($action == "add" && permission_exists('virtual_tables_data_add')) { + echo " \n"; + } + if ($action == "update" && permission_exists('virtual_tables_data_edit')) { + echo " \n"; + echo " \n"; + } + echo "
\n"; + + echo " \n"; + echo " \n"; + echo "\n"; + + if ($action == "update" && permission_exists('virtual_tables_data_edit')) { + //get the child virtual_table_uuid and use it to show the list of data + $sql = "select * from v_virtual_tables "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and virtual_table_parent_id = '$virtual_table_uuid' "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + echo "\n"; + echo " \n"; + echo "
"; + $_GET["id"] = $row["virtual_table_uuid"]; + $virtual_table_label = $row["virtual_table_label"]; + $_GET["virtual_data_parent_row_uuid"] = $virtual_data_row_uuid; + + //show button + //echo "\n"; + + //show list + require_once "v_virtual_table_data_view.php"; + echo " "; + echo " "; + } + } + echo "\n"; + echo "
\n"; + +require_once "includes/footer.php"; +?> diff --git a/app/virtual_tables/v_virtual_table_data_types_name_value.php b/app/virtual_tables/v_virtual_table_data_types_name_value.php new file mode 100644 index 0000000000..b039b61a85 --- /dev/null +++ b/app/virtual_tables/v_virtual_table_data_types_name_value.php @@ -0,0 +1,151 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('virtual_tables_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get the http values + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Virtual Table Data Types Name Value List 
\n"; + echo "Stores the name and value pairs.

\n"; + echo "
\n"; + + //$sql = ""; + //$sql .= " select * from v_virtual_table_data_types_name_value "; + //$sql .= " where domain_uuid = '$domain_uuid' "; + //$sql .= " and virtual_table_field_uuid = '$virtual_table_field_uuid' "; + //if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + //$prep_statement = $db->prepare(check_sql($sql)); + //$prep_statement->execute(); + //$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + //$num_rows = count($result); + //unset ($prep_statement, $result, $sql); + //$rows_per_page = 10; + //$param = ""; + //$page = $_GET['page']; + //if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + //list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + //$offset = $rows_per_page * $page; + + $sql = ""; + $sql .= " select * from v_virtual_table_data_types_name_value "; + $sql .= " where domain_uuid = '$domain_uuid' "; + $sql .= " and virtual_table_field_uuid = '$virtual_table_field_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + //$sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo th_order_by('virtual_data_types_name', 'Name', $order_by, $order); + echo th_order_by('virtual_data_types_value', 'Value', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo " $v_link_label_add\n"; + echo "
".$row[virtual_data_types_name]."".$row[virtual_data_types_value]."\n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + //echo " \n"; + //echo " \n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo "
  $paging_controls\n"; + echo " $v_link_label_add\n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//show the footer + require_once "includes/footer.php"; + +?> diff --git a/app/virtual_tables/v_virtual_table_data_types_name_value_delete.php b/app/virtual_tables/v_virtual_table_data_types_name_value_delete.php new file mode 100644 index 0000000000..58cf226c33 --- /dev/null +++ b/app/virtual_tables/v_virtual_table_data_types_name_value_delete.php @@ -0,0 +1,64 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('virtual_tables_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the http values + if (count($_GET)>0) { + $id = check_str($_GET["id"]); + $virtual_table_uuid = check_str($_GET["virtual_table_uuid"]); + $virtual_table_field_uuid = check_str($_GET["virtual_table_field_uuid"]); + } + +//delete the data + if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_virtual_table_data_types_name_value "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and virtual_table_data_types_name_value_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + } + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/virtual_tables/v_virtual_table_data_types_name_value_edit.php b/app/virtual_tables/v_virtual_table_data_types_name_value_edit.php new file mode 100644 index 0000000000..411b9473f5 --- /dev/null +++ b/app/virtual_tables/v_virtual_table_data_types_name_value_edit.php @@ -0,0 +1,232 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('virtual_tables_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $virtual_table_data_types_name_value_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +if (strlen($_GET["virtual_table_field_uuid"]) > 0) { + $virtual_table_field_uuid = check_str($_GET["virtual_table_field_uuid"]); +} + +//POST to PHP variables + if (count($_POST)>0) { + //$domain_uuid = check_str($_POST["domain_uuid"]); + $virtual_data_types_name = check_str($_POST["virtual_data_types_name"]); + $virtual_data_types_value = check_str($_POST["virtual_data_types_value"]); + $virtual_table_uuid = $_REQUEST["virtual_table_uuid"]; + $virtual_table_field_uuid = $_REQUEST["virtual_table_field_uuid"]; + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $virtual_table_data_types_name_value_uuid = check_str($_POST["virtual_table_data_types_name_value_uuid"]); + } + + //check for all required data + if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + if (strlen($virtual_table_uuid) == 0) { $msg .= "Please provide: virtual_table_uuid
\n"; } + if (strlen($virtual_table_field_uuid) == 0) { $msg .= "Please provide: virtual_table_field_uuid
\n"; } + if (strlen($virtual_data_types_name) == 0) { $msg .= "Please provide: Name
\n"; } + if (strlen($virtual_data_types_value) == 0) { $msg .= "Please provide: Value
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $sql = "insert into v_virtual_table_data_types_name_value "; + $sql .= "("; + $sql .= "virtual_table_data_types_name_value_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "virtual_table_uuid, "; + $sql .= "virtual_table_field_uuid, "; + $sql .= "virtual_data_types_name, "; + $sql .= "virtual_data_types_value "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'".$_SESSION['domain_uuid']."', "; + $sql .= "'$virtual_table_uuid', "; + $sql .= "'$virtual_table_field_uuid', "; + $sql .= "'$virtual_data_types_name', "; + $sql .= "'$virtual_data_types_value' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_virtual_table_data_types_name_value set "; + $sql .= "virtual_data_types_name = '$virtual_data_types_name', "; + $sql .= "virtual_data_types_value = '$virtual_data_types_value' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and virtual_table_uuid = '$virtual_table_uuid' "; + $sql .= "and virtual_table_field_uuid = '$virtual_table_field_uuid' "; + $sql .= "and virtual_table_data_types_name_value_uuid = '$virtual_table_data_types_name_value_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $virtual_table_uuid = $_GET["virtual_table_uuid"]; + $virtual_table_field_uuid = $_GET["virtual_table_field_uuid"]; + $virtual_table_data_types_name_value_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_virtual_table_data_types_name_value "; + $sql .= "where domain_uuid = '$domain_uuid' "; + //$sql .= "and virtual_table_uuid = '$virtual_table_uuid' "; + $sql .= "and virtual_table_field_uuid = '$virtual_table_field_uuid' "; + $sql .= "and virtual_table_data_types_name_value_uuid = '$virtual_table_data_types_name_value_uuid' "; + + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $virtual_data_types_name = $row["virtual_data_types_name"]; + $virtual_data_types_value = $row["virtual_data_types_value"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Virtual Table Data Types Name Value AddVirtual Table Data Types Name Value Edit
\n"; + echo "Stores the name and value pairs.

\n"; + echo "
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the name.\n"; + echo "
\n"; + echo " Value:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the value.\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +require_once "includes/footer.php"; +?> diff --git a/app/virtual_tables/v_virtual_table_data_view.php b/app/virtual_tables/v_virtual_table_data_view.php new file mode 100644 index 0000000000..ac68a3a5c8 --- /dev/null +++ b/app/virtual_tables/v_virtual_table_data_view.php @@ -0,0 +1,399 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('virtual_tables_data_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (strlen($_GET["id"]) > 0) { + $virtual_table_uuid = check_str($_GET["id"]); + if (strlen($_GET["virtual_data_parent_row_uuid"])>0) { + $virtual_data_parent_row_uuid = $_GET["virtual_data_parent_row_uuid"]; + } + $search_all = check_str($_GET["search_all"]); +} + +//used for changing the order + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//used to alternate colors when paging + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + +//show the header + require_once "includes/header.php"; + +//get the information about the virtual table by using the id + $sql = ""; + $sql .= "select * from v_virtual_tables "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and virtual_table_uuid = '$virtual_table_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + foreach ($result as &$row) { + $virtual_table_category = $row["virtual_table_category"]; + $virtual_table_label = $row["virtual_table_label"]; + $virtual_table_name = $row["virtual_table_name"]; + $virtual_table_auth = $row["virtual_table_auth"]; + $virtual_table_captcha = $row["virtual_table_captcha"]; + $virtual_table_parent_uuid = $row["virtual_table_parent_uuid"]; + $virtual_table_description = $row["virtual_table_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + +//get the field information + $db_field_name_array = array(); + $db_value_array = array(); + $db_names .= "\n"; + $sql = "select * from v_virtual_table_fields "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and virtual_table_uuid = '$virtual_table_uuid' "; + $sql .= "order by virtual_field_order asc "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + $result_names = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + $result_count = count($result); + foreach($result_names as $row) { + $virtual_field_label = $row["virtual_field_label"]; + $virtual_field_name = $row["virtual_field_name"]; + $virtual_field_type = $row["virtual_field_type"]; + $virtual_field_value = $row["virtual_field_value"]; + $virtual_field_list_hidden = $row["virtual_field_list_hidden"]; + $virtual_field_column = $row["virtual_field_column"]; + $virtual_field_required = $row["virtual_field_required"]; + $virtual_field_order = $row["virtual_field_order"]; + $virtual_field_order_tab = $row["virtual_field_order_tab"]; + $virtual_field_description = $row["virtual_field_description"]; + + $name_array[$virtual_field_name]['virtual_field_label'] = $row["virtual_field_label"]; + $name_array[$virtual_field_name]['virtual_field_type'] = $row["virtual_field_type"]; + $name_array[$virtual_field_name]['virtual_field_list_hidden'] = $row["virtual_field_list_hidden"]; + $name_array[$virtual_field_name]['virtual_field_column'] = $row["virtual_field_column"]; + $name_array[$virtual_field_name]['virtual_field_required'] = $row["virtual_field_required"]; + $name_array[$virtual_field_name]['virtual_field_order'] = $row["virtual_field_order"]; + $name_array[$virtual_field_name]['virtual_field_order_tab'] = $row["virtual_field_order_tab"]; + $name_array[$virtual_field_name]['virtual_field_description'] = $row["virtual_field_description"]; + } + unset($sql, $prep_statement, $row); + $fieldcount = count($name_array); + +//get the data + $sql = ""; + $sql .= "select * from v_virtual_table_data "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + if (strlen($search_all) == 0) { + $sql .= "and virtual_table_uuid = '$virtual_table_uuid' "; + if (strlen($virtual_data_parent_row_uuid) > 0) { + $sql .= " and virtual_data_parent_row_uuid = '$virtual_data_parent_row_uuid' "; + } + } + else { + $sql .= "and virtual_data_row_uuid in ("; + $sql .= "select virtual_data_row_uuid from v_virtual_table_data \n"; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and virtual_table_uuid = '$virtual_table_uuid' "; + if (strlen($virtual_data_parent_row_uuid) == 0) { + $tmp_digits = preg_replace('{\D}', '', $search_all); + if (is_numeric($tmp_digits) && strlen($tmp_digits) > 5) { + if (strlen($tmp_digits) == '11' ) { + $sql .= "and virtual_data_field_value like '%".substr($tmp_digits, -10)."%' \n"; + } + else { + $sql .= "and virtual_data_field_value like '%$tmp_digits%' \n"; + } + } + else { + $sql .= "and virtual_data_field_value like '%$search_all%' \n"; + } + } + else { + $sql .= "and virtual_data_parent_row_uuid = '$virtual_data_parent_row_uuid' "; + } + $sql .= ")\n"; + } + $sql .= "limit 20000\n"; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + $result_values = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + foreach($result_values as $row) { + //set a php variable + $virtual_field_name = $row[virtual_field_name]; + $virtual_data_row_uuid = $row[virtual_data_row_uuid]; + + //restructure the data by setting it the value_array + $value_array[$virtual_data_row_uuid][$virtual_field_name] = $row[virtual_data_field_value]; + $value_array[$virtual_data_row_uuid]['virtual_table_uuid'] = $row[virtual_table_uuid]; + $value_array[$virtual_data_row_uuid]['virtual_data_row_uuid'] = $row[virtual_data_row_uuid]; + $value_array[$virtual_data_row_uuid]['virtual_table_parent_uuid'] = $row[virtual_table_parent_uuid]; + $value_array[$virtual_data_row_uuid]['virtual_data_parent_row_uuid'] = $row[virtual_data_parent_row_uuid]; + } + $num_rows = count($value_array); + +//create the connection to the memory dbase_add_record + try { + $db_memory = new PDO('sqlite::memory:'); //sqlite 3 + } + catch (PDOException $error) { + print "error: " . $error->getMessage() . "
"; + die(); + } + +//create a memory database and add the fields to the table + $sql = "CREATE TABLE memory_table "; + $sql .= "("; + $sql .= "'id' INTEGER PRIMARY KEY, "; + $sql .= "'virtual_table_uuid' TEXT, "; + $sql .= "'virtual_data_row_uuid' TEXT, "; + $sql .= "'virtual_table_parent_uuid' TEXT, "; + $sql .= "'virtual_data_parent_row_uuid' TEXT, "; + foreach($result_names as $row) { + if ($row["virtual_field_type"] != "label") { + if ($row["virtual_field_name"] != "domain_uuid") { + //$row["virtual_field_label"]; + //$row["virtual_field_name"] + //$row["virtual_field_type"]; + if ($row["virtual_field_name"] == "number") { + $sql .= "'".$row["virtual_field_name"]."' NUMERIC, "; + } + else { + $sql .= "'".$row["virtual_field_name"]."' TEXT, "; + } + } + } + } + $sql .= "'domain_uuid' TEXT "; + $sql .= ");"; + //echo "$sql

\n"; + $prep_statement = $db_memory->prepare($sql); + $prep_statement->execute(); + unset ($prep_statement, $sql); + +//list the values from the array + $x = 0; + foreach($value_array as $array) { + //insert the data into the memory table + $sql = "insert into memory_table "; + $sql .= "("; + $sql .= "'virtual_table_uuid', "; + $sql .= "'virtual_data_row_uuid', "; + $sql .= "'virtual_table_parent_uuid', "; + $sql .= "'virtual_data_parent_row_uuid', "; + //foreach($array as $key => $value) { + // $sql .= "'$key', "; + foreach($result_names as $row) { + $virtual_field_name = $row["virtual_field_name"]; + $sql .= "'$virtual_field_name', "; + } + $sql .= "'domain_uuid' "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$array['virtual_table_uuid']."', "; + $sql .= "'".$array['virtual_data_row_uuid']."', "; + $sql .= "'".$array['virtual_table_parent_uuid']."', "; + $sql .= "'".$array['virtual_data_parent_row_uuid']."', "; + //foreach($array as $key => $value) { + // $sql .= "'$value', "; + foreach($result_names as $row) { + $virtual_field_name = $row["virtual_field_name"]; + $sql .= "'".check_str($array[$virtual_field_name])."', "; + } + $sql .= "'$domain_uuid' "; + $sql .= ");"; + //echo "$sql

\n"; + $db_memory->exec(check_sql($sql)); + unset($sql); + unset($array); + //unset the row of data + unset($value_array[$x]); + //increment the value + $x++; + } + +//set the title and description of the virtual table + echo "
\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
$virtual_table_label
\n"; + echo " $virtual_table_description\n"; + echo "
\n"; + if (strlen($virtual_data_parent_row_uuid) == 0) { + $search_all = str_replace("''", "'", $search_all); + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + } + echo "
\n"; + echo "
"; + +//prepare for paging the results + require_once "includes/paging.php"; + $rows_per_page = 100; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + if (strlen($virtual_table_parent_uuid) > 0) { + $param = "&id=$virtual_table_parent_uuid&virtual_data_row_uuid=$virtual_data_row_uuid"; + } + else { + $param = "&id=$virtual_table_uuid&virtual_data_row_uuid=$virtual_data_row_uuid"; + } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + +//list the data in the database + $sql = "select * from memory_table \n"; + $sql .= "where domain_uuid = '$domain_uuid' \n"; + $sql .= "limit $rows_per_page offset $offset \n"; + //$sql .= "order by virtual_field_order asc \n"; + //echo "
\n";
+	//echo $sql;
+	//echo "
\n"; + $prep_statement = $db_memory->prepare($sql); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + +//begin the list + echo "\n"; + echo "\n"; + foreach($result_names as $row) { + if ($row['virtual_field_list_hidden'] != "hide") { + echo "\n"; + } + } + echo "\n"; + echo "\n"; + + $db_values = ''; + $x = 0; + foreach ($result as &$row) { + echo "\n"; + foreach($result_names as $row2) { + $virtual_field_name = $row2[virtual_field_name]; + + //get the values from the array and set as php variables + $virtual_field_label = $name_array[$virtual_field_name]['virtual_field_label']; + $virtual_field_type = $name_array[$virtual_field_name]['virtual_field_type']; + $virtual_field_list_hidden = $name_array[$virtual_field_name]['virtual_field_list_hidden']; + $virtual_field_column = $name_array[$virtual_field_name]['virtual_field_column']; + $virtual_field_required = $name_array[$virtual_field_name]['virtual_field_required']; + $virtual_field_order = $name_array[$virtual_field_name]['virtual_field_order']; + $virtual_field_order_tab = $name_array[$virtual_field_name]['virtual_field_order_tab']; + $virtual_field_description = $name_array[$virtual_field_name]['virtual_field_description']; + + if ($virtual_field_list_hidden != "hide") { + switch ($virtual_field_type) { + case "textarea": + $tmp_value = str_replace("\n", "
\n", $row[$virtual_field_name]); + echo "\n"; + unset($tmp_value); + break; + case "email": + echo "\n"; + break; + case "phone": + $tmp_phone = $row[$virtual_field_name]; + $tmp_phone = format_phone($tmp_phone); + echo "\n"; + break; + case "url": + $url = $row[$virtual_field_name]; + if (substr($url,0,4) != "http") { + $url = 'http://'.$url; + } + echo "\n"; + break; + default: + echo "\n"; + break; + } + } + } + + echo "\n"; + + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } + +//show the paging tools and final add button + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
  ".$row['virtual_field_label']."  \n"; + if (permission_exists('virtual_tables_data_add')) { + echo " $v_link_label_add\n"; + } + echo "
".$tmp_value." ".$row[$virtual_field_name]." ".$tmp_phone." ".$row[$virtual_field_name]." ".$row[$virtual_field_name]." \n"; + if (permission_exists('virtual_tables_data_edit')) { + if (strlen($virtual_data_parent_row_uuid) == 0) { + echo " $v_link_label_edit\n"; + } + else { + echo " $v_link_label_edit\n"; + } + } + if (permission_exists('virtual_tables_data_delete')) { + echo" $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('virtual_tables_data_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
\n"; + echo "

\n"; + echo "
"; + +//show the header + echo "

"; + require_once "includes/footer.php"; + +?> diff --git a/app/virtual_tables/v_virtual_table_fields.php b/app/virtual_tables/v_virtual_table_fields.php new file mode 100644 index 0000000000..ef7a8745ec --- /dev/null +++ b/app/virtual_tables/v_virtual_table_fields.php @@ -0,0 +1,158 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('virtual_tables_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Virtual Table Field List 
\n"; + echo "Lists the fields in the virtual database.

\n"; + echo "
\n"; + + if (strlen($order_by) == 0) { + $order_by = 'virtual_field_order'; + $order = 'asc'; + } + + $sql = ""; + $sql .= " select * from v_virtual_table_fields "; + $sql .= " where domain_uuid = '$domain_uuid' "; + $sql .= " and virtual_table_uuid = '$virtual_table_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo th_order_by('virtual_field_label', 'Label', $order_by, $order); + echo th_order_by('virtual_field_name', 'Name', $order_by, $order); + echo th_order_by('virtual_field_type', 'Type', $order_by, $order); + echo th_order_by('virtual_field_column', 'Column', $order_by, $order); + echo th_order_by('virtual_field_required', 'Required', $order_by, $order); + echo th_order_by('virtual_field_order', 'Field Order', $order_by, $order); + echo th_order_by('virtual_field_order_tab', 'Tab Order', $order_by, $order); + echo th_order_by('virtual_field_description', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count == 0) { + //no results + } + else { //received results + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + if (permission_exists('virtual_tables_view')) { + echo " $v_link_label_add\n"; + } + echo "
".$row['virtual_field_label']."".$row['virtual_field_name']." ".$row['virtual_field_type']."".$row['virtual_field_column']."".$row['virtual_field_required']."".$row['virtual_field_order']."".$row['virtual_field_order_tab']."".$row['virtual_field_description']." \n"; + if (permission_exists('virtual_tables_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('virtual_tables_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
  \n"; + if (permission_exists('virtual_tables_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "includes/footer.php"; + +?> diff --git a/app/virtual_tables/v_virtual_table_fields_delete.php b/app/virtual_tables/v_virtual_table_fields_delete.php new file mode 100644 index 0000000000..c94cbb6e1f --- /dev/null +++ b/app/virtual_tables/v_virtual_table_fields_delete.php @@ -0,0 +1,63 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('virtual_tables_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the http values + if (count($_GET)>0) { + $id = check_str($_GET["id"]); + $virtual_table_uuid = check_str($_GET["virtual_table_uuid"]); + } + +//delete the data + if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_virtual_table_fields "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and virtual_table_field_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + } + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> diff --git a/app/virtual_tables/v_virtual_table_fields_edit.php b/app/virtual_tables/v_virtual_table_fields_edit.php new file mode 100644 index 0000000000..b3bacd6fab --- /dev/null +++ b/app/virtual_tables/v_virtual_table_fields_edit.php @@ -0,0 +1,545 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('virtual_tables_add') || permission_exists('virtual_tables_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//set the action as an add or update +if (isset($_REQUEST["id"])) { + $action = "update"; + $virtual_table_field_uuid = check_str($_REQUEST["id"]); +} +else { + $action = "add"; +} + +//get the http variables + if (strlen($_GET["virtual_table_uuid"]) > 0) { + $virtual_table_uuid = check_str($_GET["virtual_table_uuid"]); + } + +//get the http post variables +if (count($_POST)>0) { + $virtual_field_label = check_str($_POST["virtual_field_label"]); + $virtual_field_name = check_str($_POST["virtual_field_name"]); + $virtual_field_type = check_str($_POST["virtual_field_type"]); + $virtual_field_value = check_str($_POST["virtual_field_value"]); + $virtual_field_list_hidden = check_str($_POST["virtual_field_list_hidden"]); + $virtual_field_column = check_str($_POST["virtual_field_column"]); + $virtual_field_required = check_str($_POST["virtual_field_required"]); + $virtual_field_order = check_str($_POST["virtual_field_order"]); + $virtual_field_order_tab = check_str($_POST["virtual_field_order_tab"]); + $virtual_field_description = check_str($_POST["virtual_field_description"]); +} + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $virtual_table_field_uuid = check_str($_POST["virtual_table_field_uuid"]); + } + + //check for all required data + if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + //if (strlen($virtual_field_label) == 0) { $msg .= "Please provide: Label
\n"; } + if (strlen($virtual_field_name) == 0 && $virtual_field_type != "label") { $msg .= "Please provide: Name
\n"; } + if (strlen($virtual_field_type) == 0) { $msg .= "Please provide: Type
\n"; } + //if (strlen($virtual_field_value) == 0) { $msg .= "Please provide: Value
\n"; } + if (strlen($virtual_field_list_hidden) == 0) { $msg .= "Please provide: List Visibility
\n"; } + if (strlen($virtual_field_column) == 0) { $msg .= "Please provide: Column
\n"; } + if (strlen($virtual_field_required) == 0) { $msg .= "Please provide: Required
\n"; } + if (strlen($virtual_field_order) == 0) { $msg .= "Please provide: Field Order
\n"; } + if (strlen($virtual_field_order_tab) == 0) { $msg .= "Please provide: Tab Order
\n"; } + //if (strlen($virtual_field_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('virtual_tables_add')) { + $virtual_table_field_uuid = uuid(); + $sql = "insert into v_virtual_table_fields "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "virtual_table_uuid, "; + $sql .= "virtual_table_field_uuid, "; + $sql .= "virtual_field_label, "; + $sql .= "virtual_field_name, "; + $sql .= "virtual_field_type, "; + $sql .= "virtual_field_value, "; + $sql .= "virtual_field_list_hidden, "; + $sql .= "virtual_field_column, "; + $sql .= "virtual_field_required, "; + $sql .= "virtual_field_order, "; + $sql .= "virtual_field_order_tab, "; + $sql .= "virtual_field_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$virtual_table_uuid', "; + $sql .= "'$virtual_table_field_uuid', "; + $sql .= "'$virtual_field_label', "; + $sql .= "'$virtual_field_name', "; + $sql .= "'$virtual_field_type', "; + $sql .= "'$virtual_field_value', "; + $sql .= "'$virtual_field_list_hidden', "; + $sql .= "'$virtual_field_column', "; + $sql .= "'$virtual_field_required', "; + $sql .= "'$virtual_field_order', "; + $sql .= "'$virtual_field_order_tab', "; + $sql .= "'$virtual_field_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update" && permission_exists('virtual_tables_edit')) { + $sql = "update v_virtual_table_fields set "; + $sql .= "virtual_field_label = '$virtual_field_label', "; + $sql .= "virtual_field_name = '$virtual_field_name', "; + $sql .= "virtual_field_type = '$virtual_field_type', "; + $sql .= "virtual_field_value = '$virtual_field_value', "; + $sql .= "virtual_field_list_hidden = '$virtual_field_list_hidden', "; + $sql .= "virtual_field_column = '$virtual_field_column', "; + $sql .= "virtual_field_required = '$virtual_field_required', "; + $sql .= "virtual_field_order = '$virtual_field_order', "; + $sql .= "virtual_field_order_tab = '$virtual_field_order_tab', "; + $sql .= "virtual_field_description = '$virtual_field_description' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and virtual_table_uuid = '$virtual_table_uuid'"; + $sql .= "and virtual_table_field_uuid = '$virtual_table_field_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $virtual_table_uuid = $_GET["virtual_table_uuid"]; + $virtual_table_field_uuid = $_GET["id"]; + + $sql = ""; + $sql .= "select * from v_virtual_table_fields "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and virtual_table_uuid = '$virtual_table_uuid' "; + $sql .= "and virtual_table_field_uuid = '$virtual_table_field_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $virtual_field_label = $row["virtual_field_label"]; + $virtual_field_name = $row["virtual_field_name"]; + $virtual_field_type = $row["virtual_field_type"]; + $virtual_field_value = $row["virtual_field_value"]; + $virtual_field_list_hidden = $row["virtual_field_list_hidden"]; + $virtual_field_column = $row["virtual_field_column"]; + $virtual_field_required = $row["virtual_field_required"]; + $virtual_field_order = $row["virtual_field_order"]; + $virtual_field_order_tab = $row["virtual_field_order_tab"]; + $virtual_field_description = $row["virtual_field_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//begin the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Virtual Table Field AddVirtual Table Field Edit
\n"; + echo "Lists the fields in the virtual database.

\n"; + echo "
\n"; + echo " Label:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the field label.\n"; + echo "
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter field name.\n"; + echo "
\n"; + echo " Type:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Select the field type.\n"; + echo "
\n"; + echo " Value:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the default value.\n"; + echo "
\n"; + echo " List Visibility:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Choose whether the field is hidden from the list.\n"; + echo "
\n"; + echo " Column:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Determines which column to show the field in.\n"; + echo "
\n"; + echo " Required:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Choose whether the field is required.\n"; + echo "
\n"; + echo " Field Order:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the order of the field.\n"; + echo "
\n"; + echo " Tab Order:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the HTML Tab Order.\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the description.\n"; + echo "
\n"; + echo " \n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + if ($action == "update") { + if ($virtual_field_type == "select") { + require "v_virtual_table_data_types_name_value.php"; + } + } + + echo "
"; + echo "
"; + +//show the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/virtual_tables/v_virtual_tables.php b/app/virtual_tables/v_virtual_tables.php new file mode 100644 index 0000000000..d12bca7c84 --- /dev/null +++ b/app/virtual_tables/v_virtual_tables.php @@ -0,0 +1,161 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('virtual_tables_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get the http get variables + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Virtual Tables 
\n"; + echo "Provides the ability to quickly define information to store and dynamically makes tools available to view, add, edit, delete, and search.\n"; + echo "

\n"; + echo "
\n"; + + $sql = " select * from v_virtual_tables "; + $sql .= " where domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $num_rows = count($result); + unset ($prep_statement, $result, $sql); + $rows_per_page = 100; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + $sql = " select * from v_virtual_tables "; + $sql .= " where domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo th_order_by('virtual_table_label', 'Label', $order_by, $order); + echo th_order_by('virtual_table_name', 'Table Name', $order_by, $order); + echo th_order_by('virtual_table_auth', 'Authentication', $order_by, $order); + echo th_order_by('virtual_table_description', 'Description', $order_by, $order); + //echo "\n"; + echo "\n"; + echo "\n"; + + if ($result_count == 0) { + //no results + } + else { //received results + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
View\n"; + if (permission_exists('virtual_tables_add')) { + echo " $v_link_label_add\n"; + } + echo "
".$row['virtual_table_label']." ".$row['virtual_table_name']."".$row['virtual_table_auth']."".$row['virtual_table_description']." \n"; + if (permission_exists('virtual_tables_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('virtual_tables_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('virtual_tables_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//show the footer + require_once "includes/footer.php"; + +?> diff --git a/app/virtual_tables/v_virtual_tables_delete.php b/app/virtual_tables/v_virtual_tables_delete.php new file mode 100644 index 0000000000..1f1992c01f --- /dev/null +++ b/app/virtual_tables/v_virtual_tables_delete.php @@ -0,0 +1,65 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('virtual_tables_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the http get variable + if (count($_GET)>0) { + $id = check_str($_GET["id"]); + } + +//show the header + require_once "includes/header.php"; + +if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_virtual_tables "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and virtual_table_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); +} + +//redirect the user + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + +//show the footer + require_once "includes/footer.php"; + return; + +?> diff --git a/app/virtual_tables/v_virtual_tables_edit.php b/app/virtual_tables/v_virtual_tables_edit.php new file mode 100644 index 0000000000..bdb18acc47 --- /dev/null +++ b/app/virtual_tables/v_virtual_tables_edit.php @@ -0,0 +1,355 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('virtual_tables_add') || permission_exists('virtual_tables_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $virtual_table_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get the http post variables + if (count($_POST)>0) { + $virtual_table_category = check_str($_POST["virtual_table_category"]); + $virtual_table_label = check_str($_POST["virtual_table_label"]); + $virtual_table_name = check_str($_POST["virtual_table_name"]); + $virtual_table_auth = check_str($_POST["virtual_table_auth"]); + $virtual_table_captcha = check_str($_POST["virtual_table_captcha"]); + $virtual_table_parent_id = check_str($_POST["virtual_table_parent_id"]); + $virtual_table_description = check_str($_POST["virtual_table_description"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $virtual_table_uuid = check_str($_POST["virtual_table_uuid"]); + } + + //check for all required data + if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + //if (strlen($virtual_table_category) == 0) { $msg .= "Please provide: Table Category
\n"; } + //if (strlen($virtual_table_label) == 0) { $msg .= "Please provide: Label
\n"; } + if (strlen($virtual_table_name) == 0) { $msg .= "Please provide: Table Name
\n"; } + //if (strlen($virtual_table_auth) == 0) { $msg .= "Please provide: Authentication
\n"; } + //if (strlen($virtual_table_captcha) == 0) { $msg .= "Please provide: Captcha
\n"; } + //if (strlen($virtual_table_parent_id) == 0) { $msg .= "Please provide: Parent Table
\n"; } + //if (strlen($virtual_table_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $virtual_table_uuid = uuid(); + $sql = "insert into v_virtual_tables "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "virtual_table_uuid, "; + $sql .= "virtual_table_category, "; + $sql .= "virtual_table_label, "; + $sql .= "virtual_table_name, "; + $sql .= "virtual_table_auth, "; + $sql .= "virtual_table_captcha, "; + $sql .= "virtual_table_parent_id, "; + $sql .= "virtual_table_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$virtual_table_uuid', "; + $sql .= "'$virtual_table_category', "; + $sql .= "'$virtual_table_label', "; + $sql .= "'$virtual_table_name', "; + $sql .= "'$virtual_table_auth', "; + $sql .= "'$virtual_table_captcha', "; + $sql .= "'$virtual_table_parent_id', "; + $sql .= "'$virtual_table_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_virtual_tables set "; + $sql .= "domain_uuid = '$domain_uuid', "; + $sql .= "virtual_table_category = '$virtual_table_category', "; + $sql .= "virtual_table_label = '$virtual_table_label', "; + $sql .= "virtual_table_name = '$virtual_table_name', "; + $sql .= "virtual_table_auth = '$virtual_table_auth', "; + $sql .= "virtual_table_captcha = '$virtual_table_captcha', "; + $sql .= "virtual_table_parent_id = '$virtual_table_parent_id', "; + $sql .= "virtual_table_description = '$virtual_table_description' "; + $sql .= "where virtual_table_uuid = '$virtual_table_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $virtual_table_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_virtual_tables "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and virtual_table_uuid = '$virtual_table_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $virtual_table_category = $row["virtual_table_category"]; + $virtual_table_label = $row["virtual_table_label"]; + $virtual_table_name = $row["virtual_table_name"]; + $virtual_table_auth = $row["virtual_table_auth"]; + $virtual_table_captcha = $row["virtual_table_captcha"]; + $virtual_table_parent_id = $row["virtual_table_parent_id"]; + $virtual_table_description = $row["virtual_table_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Virtual Table AddVirtual Table Edit\n"; + if (strlen($row[virtual_table_uuid]) > 0) { + echo "   \n"; + echo "   \n"; + } + include "export/index.php"; + echo " \n"; + echo "
\n"; + echo "Provides the ability to quickly define information to store and dynamically makes tools available to view, add, edit, delete, and search.

\n"; + echo "
\n"; + echo " Table Category:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the category.\n"; + echo "
\n"; + echo " Label:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the label.\n"; + echo "
\n"; + echo " Table Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the table name.\n"; + echo "
\n"; + echo " Authentication:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Choose whether to require authentication.\n"; + echo "
\n"; + echo " Captcha:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Choose whether to require captcha.\n"; + echo "
\n"; + echo " Parent Table:\n"; + echo "\n"; + + echo " \n"; + + echo "
\n"; + echo "Select a parent table.\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter a description.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + if ($action == "update") { + require "v_virtual_table_fields.php"; + } + + echo "
"; + echo "
"; + +//show the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/virtual_tables/v_virtual_tables_import.php b/app/virtual_tables/v_virtual_tables_import.php new file mode 100644 index 0000000000..5fc202560c --- /dev/null +++ b/app/virtual_tables/v_virtual_tables_import.php @@ -0,0 +1,373 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('virtual_tables_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_POST)>0) { + $virtual_table_uuid = trim($_REQUEST["id"]); + $data = trim($_POST["data"]); + $data_delimiter = trim($_POST["data_delimiter"]); + $data_enclosure = trim($_POST["data_enclosure"]); +} + +//define the php class + class v_virtual_table_fields { + var $domain_uuid; + var $virtual_table_uuid; + var $virtual_field_label; + var $virtual_field_name; + var $virtual_field_type; + var $virtual_field_value; + var $virtual_field_list_hidden; + var $virtual_field_column; + var $virtual_field_required; + var $virtual_field_order; + var $virtual_field_order_tab; + var $virtual_field_description; + + function db_field_exists() { + global $db; + $sql = "select * from v_virtual_table_fields "; + $sql .= "where domain_uuid = '$this->domain_uuid' "; + $sql .= "and virtual_table_uuid ='$this->virtual_table_uuid' "; + $sql .= "and virtual_field_name = '$this->virtual_field_name' "; + $row = $db->query($sql)->fetch(PDO::FETCH_ASSOC); + if (is_array($row)) { + return true; + } + else { + return false; + } + } + + function db_insert() { + global $db; + $sql = "insert into v_virtual_table_fields "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "virtual_table_uuid, "; + $sql .= "virtual_field_label, "; + $sql .= "virtual_field_name, "; + $sql .= "virtual_field_type, "; + $sql .= "virtual_field_value, "; + $sql .= "virtual_field_list_hidden, "; + $sql .= "virtual_field_column, "; + $sql .= "virtual_field_required, "; + $sql .= "virtual_field_order, "; + $sql .= "virtual_field_order_tab, "; + $sql .= "virtual_field_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$this->domain_uuid', "; + $sql .= "'$this->virtual_table_uuid', "; + $sql .= "'$this->virtual_field_label', "; + $sql .= "'$this->virtual_field_name', "; + $sql .= "'$this->virtual_field_type', "; + $sql .= "'$this->virtual_field_value', "; + $sql .= "'$this->virtual_field_list_hidden', "; + $sql .= "'$this->virtual_field_column', "; + $sql .= "'$this->virtual_field_required', "; + $sql .= "'$this->virtual_field_order', "; + $sql .= "'$this->virtual_field_order_tab', "; + $sql .= "'$this->virtual_field_description' "; + $sql .= ")"; + if (!$this->db_field_exists()) { + $db->exec(check_sql($sql)); + } + unset($sql); + } + } + + class v_virtual_table_data { + var $domain_uuid; + var $virtual_table_uuid; + var $virtual_data_row_id; + var $virtual_field_name; + var $virtual_data_field_value; + var $last_insert_id; + var $virtual_table_data_uuid; + + function db_unique_id() { + global $db; + $sql = "insert into v_virtual_table_data_row_id "; + $sql .= "("; + $sql .= "domain_uuid "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$this->domain_uuid' "; + $sql .= ")"; + $db->exec($sql); + unset($sql); + return $db->lastInsertId($id); + } + + function db_insert() { + global $db; + $sql = "insert into v_virtual_table_data "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "virtual_data_row_id, "; + $sql .= "virtual_table_uuid, "; + $sql .= "virtual_field_name, "; + $sql .= "virtual_data_field_value, "; + $sql .= "virtual_data_add_user, "; + $sql .= "virtual_data_add_date "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$this->domain_uuid', "; + $sql .= "'$this->virtual_data_row_id', "; + $sql .= "'$this->virtual_table_uuid', "; + $sql .= "'$this->virtual_field_name', "; + $sql .= "'$this->virtual_data_field_value', "; + $sql .= "'".$_SESSION["username"]."', "; + $sql .= "now() "; + $sql .= ")"; + $db->exec($sql); + $this->last_insert_id = $db->lastInsertId($id); + unset($sql); + } + + function db_update() { + global $db; + $sql = "update v_virtual_table_data set "; + $sql .= "virtual_data_row_id = '$this->virtual_data_row_id', "; + $sql .= "virtual_field_name = '$this->virtual_field_name', "; + $sql .= "virtual_data_field_value = '$this->virtual_data_field_value', "; + $sql .= "virtual_data_add_user = '".$_SESSION["username"]."', "; + $sql .= "virtual_data_add_date = now() "; + $sql .= "where domain_uuid = '$this->domain_uuid' "; + $sql .= "and virtual_table_data_uuid = '$this->virtual_table_data_uuid' "; + $db->exec($sql); + $this->last_insert_id = $db->lastInsertId($id); + unset($sql); + } + } + +//built in str_getcsv requires PHP 5.3 or higher, this function can be used to reproduct the functionality but requirs PHP 5.1.0 or higher + if(!function_exists('str_getcsv')) { + function str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") { + $fp = fopen("php://memory", 'r+'); + fputs($fp, $input); + rewind($fp); + $data = fgetcsv($fp, null, $delimiter, $enclosure); // $escape only got added in 5.3.0 + fclose($fp); + return $data; + } + } + + //POST to PHP variables + if (count($_POST)>0) { + + //show the header + require_once "includes/header.php"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " "; + echo "
Import Results\n"; + echo " \n"; + echo "

\n"; + echo "
\n"; + + //import data + if (strlen($data) > 0) { + $line_array = explode("\n",$data); + $name_array = explode(",",$line_array[0]); + $x = 0; + $db->beginTransaction(); + foreach($name_array as $key => $val) { + $virtual_field_label = trim($val); + $virtual_field_name = trim($val); + $virtual_field_name = str_replace(" ", "_", $virtual_field_name); + $virtual_field_name = str_replace("-", "_", $virtual_field_name); + $virtual_field_name = strtolower($virtual_field_name); + + $fields = new v_virtual_table_fields; + $fields->domain_uuid = $domain_uuid; + $fields->virtual_table_uuid = $virtual_table_uuid; + $fields->virtual_field_label = $virtual_field_label; + $fields->virtual_field_name = $virtual_field_name; + $fields->virtual_field_type = 'text'; + $fields->virtual_field_value = ''; + $fields->virtual_field_list_hidden = 'show'; + $fields->virtual_field_column = '1'; + $fields->virtual_field_required = 'yes'; + $fields->virtual_field_order = $x; + $fields->virtual_field_order_tab = $x; + $fields->virtual_field_description = $virtual_field_label; + $fields->db_insert(); + unset($fields); + $x++; + } + + foreach($line_array as $key => $line) { + if ($key > 0) { + $value_array = str_getcsv($line, $data_delimiter, $data_enclosure); + $x=0; + foreach($value_array as $key => $val) { + + $virtual_field_label = trim($name_array[$x]); + $virtual_field_name = trim($name_array[$x]); + $virtual_field_name = str_replace(" ", "_", $virtual_field_name); + $virtual_field_name = str_replace("-", "_", $virtual_field_name); + $virtual_field_name = strtolower($virtual_field_name); + + $virtual_field_value = $val; + + $data = new v_virtual_table_data; + $data->domain_uuid = $domain_uuid; + $data->virtual_table_uuid = $virtual_table_uuid; + if ($x == 0) { + $virtual_data_row_id = $data->db_unique_id(); +// echo "id: ".$virtual_data_row_id."
\n"; + } + $data->virtual_data_row_id = $virtual_data_row_id; + $data->virtual_field_name = $virtual_field_name; + $data->virtual_data_field_value = $virtual_field_value; + $data->db_insert(); + unset($data); + + echo "$virtual_field_name: $virtual_field_value
\n"; + $x++; + } + echo "
\n"; + } + } + $db->commit(); + } //if (strlen($data) > 0) + + echo "
"; + echo "
\n"; + + //show the footer + require_once "includes/footer.php"; + + exit; + } + + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Import\n"; + //echo " \n"; + echo "

\n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + + echo " \n"; + echo " \n"; + echo " "; + echo "
\n"; + echo " Data:\n"; + echo "\n"; + echo " \n"; + //echo "
\n"; + //echo "\n"; + //echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//show the footer + require_once "includes/footer.php"; + +?> diff --git a/app/voicemail_msgs/v_voicemail_msgs_play.php b/app/voicemail_msgs/v_voicemail_msgs_play.php new file mode 100644 index 0000000000..7370713f3a --- /dev/null +++ b/app/voicemail_msgs/v_voicemail_msgs_play.php @@ -0,0 +1,112 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('voicemail_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the http get values + $uuid = $_GET['uuid']; + $file_ext = $_GET['ext']; + $type = $_GET['type']; //vm + $desc = $_GET['desc']; + $id = $_GET['id']; + +//get the domain from the domains array + $domain_name = $_SESSION['domains'][$domain_uuid]['domain_name']; + +//create the event socket connection + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + if (!$fp) { + $msg = "
Connection to Event Socket failed.
"; + } + +//show the error message or show the content + if (strlen($msg) > 0) { + require_once "includes/header.php"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Message
$msg
\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } + +?> + + + + + + + + + + + + +
+ voicemail: +
+ \n"; + } + //object html tag to add flash player that can play the mp3 file + if ($file_ext == "mp3") { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + ?> +
+ + \ No newline at end of file diff --git a/app/voicemail_status/app_config.php b/app/voicemail_status/app_config.php new file mode 100644 index 0000000000..2eed674a7d --- /dev/null +++ b/app/voicemail_status/app_config.php @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/app/voicemail_status/root.php b/app/voicemail_status/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/voicemail_status/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/voicemail_status/v_voicemail.php b/app/voicemail_status/v_voicemail.php new file mode 100644 index 0000000000..3761a2c488 --- /dev/null +++ b/app/voicemail_status/v_voicemail.php @@ -0,0 +1,198 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('voicemail_status_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + +//show the content + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; +echo ""; +echo "
\n"; + echo "
"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Voicemail
\n"; + echo " Show details about the voicemail settings including the voicemail count, and voicemail to email address.\n"; + echo "
\n"; + echo "
"; + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo th_order_by('extension', 'Extension', $order_by, $order); + echo th_order_by('vm_mailto', 'Voicemail Mail To', $order_by, $order); + echo "\n"; + echo th_order_by('enabled', 'Enabled', $order_by, $order); + echo th_order_by('description', 'Description', $order_by, $order); + echo "\n"; + + $sql = ""; + $sql .= "select * from v_extensions "; + $sql .= "where domain_uuid = '$domain_uuid' "; + if (!(if_group("admin") || if_group("superadmin"))) { + if (count($_SESSION['user']['extension']) > 0) { + $sql .= "and ("; + $x = 0; + foreach($_SESSION['user']['extension'] as $row) { + if ($x > 0) { $sql .= "or "; } + $sql .= "extension = '".$row['user']."' "; + $x++; + } + $sql .= ")"; + } + else { + //hide any results when a user has not been assigned an extension + $sql .= "and extension = 'disabled' "; + } + } + if (strlen($order_by)> 0) { + $sql .= "order by $order_by $order "; + } + else { + $sql .= "order by extension asc "; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $num_rows = count($result); + unset ($prep_statement, $result, $sql); + + $rows_per_page = 100; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + $sql = ""; + $sql .= "select * from v_extensions "; + $sql .= "where domain_uuid = '$domain_uuid' "; + if (!(if_group("admin") || if_group("superadmin"))) { + if (count($_SESSION['user']['extension']) > 0) { + $sql .= "and ("; + $x = 0; + foreach($_SESSION['user']['extension'] as $row) { + if ($x > 0) { $sql .= "or "; } + $sql .= "extension = '".$row['user']."' "; + $x++; + } + $sql .= ")"; + } + else { + //hide any results when a user has not been assigned an extension + $sql .= "and extension = 'disabled' "; + } + } + if (strlen($order_by)> 0) { + $sql .= "order by $order_by $order "; + } + else { + $sql .= "order by extension asc "; + } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + //pdo voicemail database connection +// include "includes/lib_pdo_vm.php"; + + if ($result_count > 0) { + foreach($result as $row) { +// echo "
\n";
+//		print_r($row);
+//		echo "
\n"; + $sql = ""; + $sql .= "select count(*) as count from voicemail_msgs "; + $sql .= "where domain = '".$_SESSION['domains'][$domain_uuid]['domain_name']."' "; + $sql .= "and username = '".$row['extension']."' "; +// $prep_statement = $db->prepare(check_sql($sql)); +// $prep_statement->execute(); +// $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); +// foreach ($result as &$row2) { +// $count = $row2["count"]; +// break; //limit to 1 row +// } +// unset ($prep_statement); + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + + unset($count); + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + +echo "
Messages
".$row['extension']."".$row['vm_mailto']." ".$count." ".($row['vm_enabled']?"true":"false")."".$row['description']." \n"; + if (permission_exists('voicemail_status_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
"; +echo "
"; +echo "

"; +echo "

"; + +echo "
"; +echo "
"; +echo "

"; + +//show the footer + require "includes/require.php"; + require_once "includes/footer.php"; +?> diff --git a/app/voicemail_status/v_voicemail_prefs_delete.php b/app/voicemail_status/v_voicemail_prefs_delete.php new file mode 100644 index 0000000000..79078a4516 --- /dev/null +++ b/app/voicemail_status/v_voicemail_prefs_delete.php @@ -0,0 +1,66 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('voicemail_status_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = $_GET["id"]; +} + +//pdo voicemail database connection + include "includes/lib_pdo_vm.php"; + +//delete the data + if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from voicemail_prefs "; + $sql .= "where domain = '".$_SESSION['domains'][$domain_uuid]['domain_name']."' "; + $sql .= "and username = '$domain_uuid' "; + $count = $db->exec(check_sql($sql)); + unset($sql); + } + +//redirect the user + require "includes/require.php"; + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Voicemail Preferences set to default\n"; + echo "
\n"; + require "includes/require.php"; + require_once "includes/footer.php"; + return; + +?> + diff --git a/app/xml_cdr/app_config.php b/app/xml_cdr/app_config.php new file mode 100644 index 0000000000..27607155da --- /dev/null +++ b/app/xml_cdr/app_config.php @@ -0,0 +1,275 @@ + \ No newline at end of file diff --git a/app/xml_cdr/app_defaults.php b/app/xml_cdr/app_defaults.php new file mode 100644 index 0000000000..6140274772 --- /dev/null +++ b/app/xml_cdr/app_defaults.php @@ -0,0 +1,39 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//make sure that prefix-a-leg is set to true in the xml_cdr.conf.xml file + $file_contents = file_get_contents($_SESSION['switch']['conf']['dir']."/autoload_configs/xml_cdr.conf.xml"); + $file_contents_new = str_replace("param name=\"prefix-a-leg\" value=\"false\"/", "param name=\"prefix-a-leg\" value=\"true\"/", $file_contents); + if ($file_contents != $file_contents_new) { + $fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/xml_cdr.conf.xml","w"); + fwrite($fout, $file_contents_new); + fclose($fout); + if ($display_type == "text") { + echo " xml_cdr.conf.xml: updated\n"; + } + } + +?> \ No newline at end of file diff --git a/app/xml_cdr/root.php b/app/xml_cdr/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/xml_cdr/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/xml_cdr/v_xml_cdr_import.php b/app/xml_cdr/v_xml_cdr_import.php new file mode 100644 index 0000000000..45af23d93a --- /dev/null +++ b/app/xml_cdr/v_xml_cdr_import.php @@ -0,0 +1,359 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//check the permission + if(defined('STDIN')) { + $document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]); + preg_match("/^(.*)\/mod\/.*$/", $document_root, $matches); + $document_root = $matches[1]; + set_include_path($document_root); + $_SERVER["DOCUMENT_ROOT"] = $document_root; + require_once "includes/require.php"; + $display_type = 'text'; //html, text + } + else { + include "root.php"; + require_once "includes/require.php"; + } + +//set debug + $debug = false; //true //false + if($debug){ + $time5 = microtime(true); + $insert_time=$insert_count=0; + } + +//increase limits + set_time_limit(3600); + ini_set('memory_limit', '256M'); + +//set pdo attribute that enables exception handling + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + +function process_xml_cdr($db, $leg, $xml_string) { + //set global variable + global $debug; + + //parse the xml to get the call detail record info + try { + $xml = simplexml_load_string($xml_string); + } + catch(Exception $e) { + echo $e->getMessage(); + } + + //prepare the database object + require_once "includes/classes/database.php"; + $database = new database; + $database->table = "v_xml_cdr"; + + //misc + $uuid = check_str(urldecode($xml->variables->uuid)); + $database->fields['uuid'] = $uuid; + $database->fields['accountcode'] = check_str(urldecode($xml->variables->accountcode)); + $database->fields['default_language'] = check_str(urldecode($xml->variables->default_language)); + $database->fields['bridge_uuid'] = check_str(urldecode($xml->variables->bridge_uuid)); + $database->fields['digits_dialed'] = check_str(urldecode($xml->variables->digits_dialed)); + $database->fields['sip_hangup_disposition'] = check_str(urldecode($xml->variables->sip_hangup_disposition)); + //time + $database->fields['start_epoch'] = check_str(urldecode($xml->variables->start_epoch)); + $start_stamp = check_str(urldecode($xml->variables->start_stamp)); + $database->fields['start_stamp'] = $start_stamp; + $database->fields['answer_stamp'] = check_str(urldecode($xml->variables->answer_stamp)); + $database->fields['answer_epoch'] = check_str(urldecode($xml->variables->answer_epoch)); + $database->fields['end_epoch'] = check_str(urldecode($xml->variables->end_epoch)); + $database->fields['end_stamp'] = check_str(urldecode($xml->variables->end_stamp)); + $database->fields['duration'] = check_str(urldecode($xml->variables->duration)); + $database->fields['mduration'] = check_str(urldecode($xml->variables->mduration)); + $database->fields['billsec'] = check_str(urldecode($xml->variables->billsec)); + $database->fields['billmsec'] = check_str(urldecode($xml->variables->billmsec)); + //codecs + $database->fields['read_codec'] = check_str(urldecode($xml->variables->read_codec)); + $database->fields['read_rate'] = check_str(urldecode($xml->variables->read_rate)); + $database->fields['write_codec'] = check_str(urldecode($xml->variables->write_codec)); + $database->fields['write_rate'] = check_str(urldecode($xml->variables->write_rate)); + $database->fields['remote_media_ip'] = check_str(urldecode($xml->variables->remote_media_ip)); + $database->fields['hangup_cause'] = check_str(urldecode($xml->variables->hangup_cause)); + $database->fields['hangup_cause_q850'] = check_str(urldecode($xml->variables->hangup_cause_q850)); + //call center + $database->fields['cc_side'] = check_str(urldecode($xml->variables->cc_side)); + $database->fields['cc_member_uuid'] = check_str(urldecode($xml->variables->cc_member_uuid)); + $database->fields['cc_queue_joined_epoch'] = check_str(urldecode($xml->variables->cc_queue_joined_epoch)); + $database->fields['cc_queue'] = check_str(urldecode($xml->variables->cc_queue)); + $database->fields['cc_member_session_uuid'] = check_str(urldecode($xml->variables->cc_member_session_uuid)); + $database->fields['cc_agent'] = check_str(urldecode($xml->variables->cc_agent)); + $database->fields['cc_agent_type'] = check_str(urldecode($xml->variables->cc_agent_type)); + $database->fields['waitsec'] = check_str(urldecode($xml->variables->waitsec)); + //app info + $database->fields['last_app'] = check_str(urldecode($xml->variables->last_app)); + $database->fields['last_arg'] = check_str(urldecode($xml->variables->last_arg)); + //conference + $database->fields['conference_name'] = check_str(urldecode($xml->variables->conference_name)); + $database->fields['conference_uuid'] = check_str(urldecode($xml->variables->conference_uuid)); + $database->fields['conference_member_id'] = check_str(urldecode($xml->variables->conference_member_id)); + + //get the values from the callflow. + $x = 0; + foreach ($xml->callflow as $row) { + if ($x == 0) { + $context = check_str(urldecode($row->caller_profile->context)); + $database->fields['destination_number'] = check_str(urldecode($row->caller_profile->destination_number)); + $database->fields['context'] = $context; + $database->fields['network_addr'] = check_str(urldecode($row->caller_profile->network_addr)); + } + $database->fields['caller_id_name'] = check_str(urldecode($row->caller_profile->caller_id_name)); + $database->fields['caller_id_number'] = check_str(urldecode($row->caller_profile->caller_id_number)); + $x++; + } + unset($x); + + //store the call leg + $database->fields['leg'] = $leg; + + //store the call direction. + $database->fields['direction'] = check_str(urldecode($xml->variables->call_direction)); + + //store post dial delay, in milliseconds. + $database->fields['pdd_ms'] = check_str(urldecode($xml->variables->progress_mediamsec) + urldecode($xml->variables->progressmsec)); + + //get break down the date to year, month and day + $tmp_time = strtotime($start_stamp); + $tmp_year = date("Y", $tmp_time); + $tmp_month = date("M", $tmp_time); + $tmp_day = date("d", $tmp_time); + + //find the domain_uuid by using the domain_name + $domain_name = check_str(urldecode($xml->variables->domain_name)); + $sql = "select domain_uuid from v_domains "; + if (strlen($domain_name) == 0 && $context != 'public' && $context != 'default') { + $sql .= "where domain_name = '".$context."' "; + } + else { + $sql .= "where domain_name = '".$domain_name."' "; + } + $row = $db->query($sql)->fetch(); + $domain_uuid = $row['domain_uuid']; + if (strlen($domain_uuid) == 0) { + $sql = "select domain_name, domain_uuid from v_domains "; + $row = $db->query($sql)->fetch(); + $domain_uuid = $row['domain_uuid']; + if (strlen($domain_name) == 0) { $domain_name = $row['domain_name']; } + } + $database->domain_uuid = $domain_uuid; + $database->fields['domain_uuid'] = $domain_uuid; + $database->fields['domain_name'] = $domain_name; + + //check whether a recording exists + $recording_relative_path = '/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day; + if (file_exists($_SESSION['switch']['recordings']['dir'].$recording_relative_path.'/'.$uuid.'.wav')) { + $recording_file = $recording_relative_path.'/'.$uuid.'.wav'; + } + elseif (file_exists($_SESSION['switch']['recordings']['dir'].$recording_relative_path.'/'.$uuid.'.mp3')) { + $recording_file = $recording_relative_path.'/'.$uuid.'.mp3'; + } + if(isset($recording_file) && !empty($recording_file)) { + $database->fields['recording_file'] = $recording_file; + } + + //determine where the xml cdr will be archived + $sql = "select * from v_vars "; + $sql .= "where var_name = 'xml_cdr_archive' "; + $row = $db->query($sql)->fetch(); + $var_value = trim($row["var_value"]); + switch ($var_value) { + case "dir": + $xml_cdr_archive = 'dir'; + break; + case "db": + $xml_cdr_archive = 'db'; + break; + case "none": + $xml_cdr_archive = 'none'; + break; + default: + $xml_cdr_archive = 'dir'; + break; + } + + //if xml_cdr_archive is set to db then insert it. + if ($xml_cdr_archive == "db") { + $database->fields['xml_cdr'] = check_str($xml_string); + } + + //insert xml_cdr into the db + $database->add(); + if ($debug) { + echo $database->sql."\n"; + } + + //insert the values + if (strlen($uuid) > 0) { + if ($debug) { + $time5_insert = microtime(true); + //echo $sql."
\n"; + } + try { + $error = "false"; + //$db->exec(check_sql($sql)); + } + catch(PDOException $e) { + $tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/failed/'; + if(!file_exists($tmp_dir)) { + mkdir($tmp_dir, 0777, true); + } + $tmp_file = $uuid.'.xml'; + $fh = fopen($tmp_dir.'/'.$tmp_file, 'w'); + fwrite($fh, $xml_string); + fclose($fh); + if ($debug) { + echo $e->getMessage(); + } + $error = "true"; + } + //if xml_cdr_archive is set to dir, then store it. + if ($xml_cdr_archive == "dir" && $error != "true") { + if (strlen($uuid) > 0) { + $tmp_time = strtotime($start_stamp); + $tmp_year = date("Y", $tmp_time); + $tmp_month = date("M", $tmp_time); + $tmp_day = date("d", $tmp_time); + $tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day; + if(!file_exists($tmp_dir)) { + mkdir($tmp_dir, 0777, true); + } + $tmp_file = $uuid.'.xml'; + $fh = fopen($tmp_dir.'/'.$tmp_file, 'w'); + fwrite($fh, $xml_string); + fclose($fh); + } + } + unset($error); + + if ($debug) { + GLOBAL $insert_time,$insert_count; + $insert_time+=microtime(true)-$time5_insert;//add this current query. + $insert_count++; + } + } + unset($sql); +} + +//get cdr details from the http post + if (strlen($_POST["cdr"]) > 0) { + + //authentication for xml cdr http post + if (strlen($_SESSION["xml_cdr_username"]) == 0) { + //get the contents of xml_cdr.conf.xml + $conf_xml_string = file_get_contents($_SESSION['switch']['conf']['dir'].'/autoload_configs/xml_cdr.conf.xml'); + + //parse the xml to get the call detail record info + try { + $conf_xml = simplexml_load_string($conf_xml_string); + } + catch(Exception $e) { + echo $e->getMessage(); + } + foreach ($conf_xml->settings->param as $row) { + if ($row->attributes()->name == "cred") { + $auth_array = explode(":", $row->attributes()->value); + $_SESSION["xml_cdr_username"] = $auth_array[0]; + $_SESSION["xml_cdr_password"] = $auth_array[1]; + //echo "username: ".$_SESSION["xml_cdr_username"]."
\n"; + //echo "password: ".$_SESSION["xml_cdr_password"]."
\n"; + } + } + } + + //check for the correct username and password + if ($_SESSION["xml_cdr_username"] == $_SERVER["PHP_AUTH_USER"] && $_SESSION["xml_cdr_password"] == $_SERVER["PHP_AUTH_PW"]) { + //echo "access granted
\n"; + } + else { + echo "access denied
\n"; + return; + } + //loop through all attribues + //foreach($xml->settings->param[1]->attributes() as $a => $b) { + // echo $a,'="',$b,"\"
\n"; + //} + + //get the http post variable + $xml_string = trim($_POST["cdr"]); + + //get the leg of the call + if (substr($_REQUEST['uuid'], 0, 2) == "a_") { + $leg = "a"; + } + else { + $leg = "b"; + } + + //parse the xml and insert the data into the db + process_xml_cdr($db, $leg, $xml_string); + } + +//check the filesystem for xml cdr records that were missed + $xml_cdr_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr'; + $dir_handle = opendir($xml_cdr_dir); + $x = 0; + while($file=readdir($dir_handle)) { + if ($file != '.' && $file != '..') { + if ( !is_dir($xml_cdr_dir . '/' . $file) ) { + //get the leg of the call + if (substr($file, 0, 2) == "a_") { + $leg = "a"; + } + else { + $leg = "b"; + } + + //get the xml cdr string + $xml_string = file_get_contents($xml_cdr_dir.'/'.$file); + + //parse the xml and insert the data into the db + process_xml_cdr($db, $leg, $xml_string); + + //delete the file after it has been imported + unlink($xml_cdr_dir.'/'.$file); + + $x++; + } + } + } + closedir($dir_handle); + +//debug true + if ($debug) { + $content = ob_get_contents(); //get the output from the buffer + ob_end_clean(); //clean the buffer + $time = "\n\n$insert_count inserts in: ".number_format($insert_time,5). " seconds.\n"; + $time .= "Other processing time: ".number_format((microtime(true)-$time5-$insert_time),5). " seconds.\n"; + $fp = fopen(sys_get_temp_dir().'/xml_cdr_post.log', 'w'); + fwrite($fp, $content.$time); + fclose($fp); + } + +?> \ No newline at end of file diff --git a/app/xml_cdr/xml_cdr.php b/app/xml_cdr/xml_cdr.php new file mode 100644 index 0000000000..c2ee2c1255 --- /dev/null +++ b/app/xml_cdr/xml_cdr.php @@ -0,0 +1,427 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_cdr_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//import xml_cdr files + require_once "v_xml_cdr_import.php"; + +//additional includes + require_once "includes/header.php"; + require_once "includes/paging.php"; + +//xml cdr include + require_once "xml_cdr_inc.php"; + +//page title and description + echo "
"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Call Detail Records\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo " \n"; + echo "\n"; + echo "
\n"; + echo " \n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "
\n"; + + echo "Call Detail Records (CDRs) are detailed information on the calls. \n"; + echo "The information contains source, destination, duration, and other useful call details. \n"; + echo "Use the fields to filter the information for the specific call records that are desired. \n"; + echo "Then view the calls in the list or download them as comma seperated file by using the 'csv' button. \n"; + //To do an advanced search of the call detail records click on the following advanced button. + + echo "
\n"; + echo "
\n"; + + echo "
\n"; + + //search the call detail records + if (if_group("admin") || if_group("superadmin")) { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo ""; + echo "
\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo "
Direction:\n"; + echo " \n"; + echo "
CID Name:
\n"; + + echo "
\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Source:
Destination:
\n"; + + echo "
\n"; + + echo "\n"; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + + echo " "; + echo "
Context:
Answer:
End:
Start:
Status:\n"; + echo " \n"; + echo "
Duration:
Bill:
UUID:
Bridge UUID:
Account Code:
Read Codec:
Write Codec:
Remote Media IP:
Network Address:
"; + + echo "
\n"; + //echo " \n"; + echo "\n"; + echo "  \n"; + echo " \n"; + echo "
"; + echo "
"; + } + +//show the results + echo "\n"; + echo "\n"; + //echo th_order_by('direction', 'Direction', $order_by, $order); + //echo th_order_by('default_language', 'Language', $order_by, $order); + //echo th_order_by('context', 'Context', $order_by, $order); + //echo th_order_by('leg', 'Leg', $order_by, $order); + echo th_order_by('caller_id_name', 'Name', $order_by, $order); + echo th_order_by('caller_id_number', 'Number', $order_by, $order); + echo th_order_by('destination_number', 'Destination', $order_by, $order); + echo th_order_by('start_stamp', 'Start', $order_by, $order); + //echo th_order_by('end_stamp', 'End', $order_by, $order); + echo th_order_by('duration', 'Length', $order_by, $order); + if (if_group("admin") || if_group("superadmin")) { + echo th_order_by('pdd_ms', 'PDD', $order_by, $order); + } + echo th_order_by('hangup_cause', 'Status', $order_by, $order); + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + $tmp_year = date("Y", strtotime($row['start_stamp'])); + $tmp_month = date("M", strtotime($row['start_stamp'])); + $tmp_day = date("d", strtotime($row['start_stamp'])); + + if (defined('TIME_24HR') && TIME_24HR == 1) { + $tmp_start_epoch = date("j M Y H:i:s", $row['start_epoch']); + } else { + $tmp_start_epoch = date("j M Y h:i:sa", $row['start_epoch']); + } + + $hangup_cause = $row['hangup_cause']; + $hangup_cause = str_replace("_", " ", $hangup_cause); + $hangup_cause = strtolower($hangup_cause); + $hangup_cause = ucwords($hangup_cause); + + echo "\n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + if (is_numeric($row['destination_number'])) { + echo " \n"; + } + else { + echo " \n"; + } + echo " \n"; + //echo " \n"; + + //If they cancelled, show the ring time, not the bill time. + $seconds = ($row['hangup_cause']=="ORIGINATOR_CANCEL") ? $row['duration'] : $row['billsec']; + + echo " \n"; + if (if_group("admin") || if_group("superadmin")) { + echo " \n"; + echo " \n"; + } + else { + echo " \n"; + } + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
".$row['direction']."".$row['default_language']."".$row['context']."".$row['leg'].""; + + $tmp_dir = $_SESSION['switch']['recordings']['dir'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day; + $tmp_name = ''; + if(!empty($row['recording_file']) && file_exists($row['recording_file'])){ + $tmp_name=$row['recording_file']; + } + elseif (file_exists($tmp_dir.'/'.$row['uuid'].'.wav')) { + $tmp_name = $row['uuid'].".wav"; + } + elseif (file_exists($tmp_dir.'/'.$row['uuid'].'_1.wav')) { + $tmp_name = $row['uuid']."_1.wav"; + } + elseif (file_exists($tmp_dir.'/'.$row['uuid'].'.mp3')) { + $tmp_name = $row['uuid'].".mp3"; + } + elseif (file_exists($tmp_dir.'/'.$row['uuid'].'_1.mp3')) { + $tmp_name = $row['uuid']."_1.mp3"; + } + if (strlen($tmp_name) > 0 && file_exists($_SESSION['switch']['recordings']['dir'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) { + echo " \n"; + echo $row['caller_id_name'].' '; + echo " "; + } + else { + echo $row['caller_id_name'].' '; + } + echo " "; + if (strlen($tmp_name) > 0 && file_exists($_SESSION['switch']['recordings']['dir'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) { + echo " \n"; + if (is_numeric($row['caller_id_number'])) { + echo format_phone($row['caller_id_number']).' '; + } + else { + echo $row['caller_id_number'].' '; + } + echo " "; + } + else { + if (is_numeric($row['caller_id_number'])) { + echo format_phone($row['caller_id_number']).' '; + } + else { + echo $row['caller_id_number'].' '; + } + } + echo " ".format_phone($row['destination_number'])."".$row['destination_number']."".$tmp_start_epoch."".$row['end_stamp']."".gmdate("G:i:s", $seconds)."".number_format($row['pdd_ms']/1000,2)."s".$hangup_cause."".$hangup_cause."
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls 
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + +//show the footer + require_once "includes/footer.php"; +?> diff --git a/app/xml_cdr/xml_cdr_csv.php b/app/xml_cdr/xml_cdr_csv.php new file mode 100644 index 0000000000..adf95cbb99 --- /dev/null +++ b/app/xml_cdr/xml_cdr_csv.php @@ -0,0 +1,82 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_cdr_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//additional includes + require_once "xml_cdr_inc.php"; + +//set the http headers + header('Content-type: application/octet-binary'); + header('Content-Disposition: attachment; filename=cdr.csv'); + +//set the csv headers + $z = 0; + foreach($result[0] as $key => $val) { + if ($key != "xml_cdr") { + if ($z == 0) { + echo '"'.$key.'"'; + } + else { + echo ',"'.$key.'"'; + } + } + $z++; + } + echo "\n"; + +//show the csv data + $x=0; + while(true) { + $z = 0; + foreach($result[0] as $key => $val) { + if ($key != "xml_cdr") { + if ($z == 0) { + echo '"'.$result[$x][$key].'"'; + } + else { + echo ',"'.$result[$x][$key].'"'; + } + } + $z++; + } + echo "\n"; + ++$x; + if ($x > ($result_count-1)) { + break; + } + //$row++; + } + +?> \ No newline at end of file diff --git a/app/xml_cdr/xml_cdr_details.php b/app/xml_cdr/xml_cdr_details.php new file mode 100644 index 0000000000..59906e0e2e --- /dev/null +++ b/app/xml_cdr/xml_cdr_details.php @@ -0,0 +1,508 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_cdr_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//get the http values and set them to a variable + if (strlen($_REQUEST["uuid"]) > 0) { + $uuid = trim($_REQUEST["uuid"]); + } + +//get the xml cdr string from the database + $sql = "select * from v_xml_cdr "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and uuid = '$uuid' "; + $row = $db->query($sql)->fetch(); + $start_stamp = trim($row["start_stamp"]); + $xml_string = trim($row["xml_cdr"]); + //print_r($row); + +//get cdr from the file system + if (strlen($xml_string) == 0) { + $tmp_time = strtotime($start_stamp); + $tmp_year = date("Y", $tmp_time); + $tmp_month = date("M", $tmp_time); + $tmp_day = date("d", $tmp_time); + $tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day; + $tmp_file = $uuid.'.xml'; + $xml_string = file_get_contents($tmp_dir.'/'.$tmp_file); + } + +//parse the xml to get the call detail record info + try { + $xml = simplexml_load_string($xml_string); + } + catch(Exception $e) { + echo $e->getMessage(); + } + +//get the header + require_once "includes/header.php"; + +//page title and description + echo "
"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Call Details\n"; + echo " \n"; + echo "
\n"; + echo "A detailed view of the call and all information regarding it. \n"; + echo "The information contains caller id name and number, channel data, \n"; + echo "call variables, call flow, timing information, and other useful call details. \n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + +//detail summary + //get the variables from the xml + $uuid = check_str(urldecode($xml->variables->uuid)); + $direction = check_str(urldecode($xml->channel_data->direction)); + $language = check_str(urldecode($xml->variables->language)); + $xml_string = check_str($xml_string); + $start_epoch = check_str(urldecode($xml->variables->start_epoch)); + $start_stamp = check_str(urldecode($xml->variables->start_stamp)); + $start_uepoch = check_str(urldecode($xml->variables->start_uepoch)); + $answer_stamp = check_str(urldecode($xml->variables->answer_stamp)); + $answer_epoch = check_str(urldecode($xml->variables->answer_epoch)); + $answer_uepoch = check_str(urldecode($xml->variables->answer_uepoch)); + $end_epoch = check_str(urldecode($xml->variables->end_epoch)); + $end_uepoch = check_str(urldecode($xml->variables->end_uepoch)); + $end_stamp = check_str(urldecode($xml->variables->end_stamp)); + $duration = check_str(urldecode($xml->variables->duration)); + $mduration = check_str(urldecode($xml->variables->mduration)); + $billsec = check_str(urldecode($xml->variables->billsec)); + $billmsec = check_str(urldecode($xml->variables->billmsec)); + $bridge_uuid = check_str(urldecode($xml->variables->bridge_uuid)); + $read_codec = check_str(urldecode($xml->variables->read_codec)); + $write_codec = check_str(urldecode($xml->variables->write_codec)); + $remote_media_ip = check_str(urldecode($xml->variables->remote_media_ip)); + $hangup_cause = check_str(urldecode($xml->variables->hangup_cause)); + $hangup_cause_q850 = check_str(urldecode($xml->variables->hangup_cause_q850)); + $x = 0; + foreach ($xml->callflow as $row) { + if ($x == 0) { + $destination_number = check_str(urldecode($row->caller_profile->destination_number)); + $context = check_str(urldecode($row->caller_profile->context)); + $network_addr = check_str(urldecode($row->caller_profile->network_addr)); + } + $caller_id_name = check_str(urldecode($row->caller_profile->caller_id_name)); + $caller_id_number = check_str(urldecode($row->caller_profile->caller_id_number)); + $x++; + } + unset($x); + + $tmp_year = date("Y", strtotime($start_stamp)); + $tmp_month = date("M", strtotime($start_stamp)); + $tmp_day = date("d", strtotime($start_stamp)); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Summary 
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
DirectionLanguageContextName (play)Number (download)DestinationStartEndLengthStatus
".$direction."".$language."".$context.""; + if (file_exists($_SESSION['switch']['recordings']['dir'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$uuid.'.wav')) { + //echo " \n"; + //echo " "; + + echo " \n"; + //$tmp_file_array = explode("\.",$file); + echo $caller_id_name.' '; + echo " "; + + } + else { + echo $caller_id_name.' '; + } + echo " "; + if (file_exists($_SESSION['switch']['recordings']['dir'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$uuid.'.wav')) { + echo " \n"; + echo $caller_id_number.' '; + echo " "; + } + else { + echo $caller_id_number.' '; + } + echo " ".$destination_number."".$start_stamp."".$end_stamp."".$duration."".$hangup_cause."
"; + echo "
"; + +//breaking space + echo "

\n"; + +//channel data loop + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Channel Data 
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + foreach($xml->channel_data->children() as $child) { + $key = $child->getName(); + $value = urldecode($child); + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } + echo "
NameValue
".$key." ".wordwrap($value,75,"
\n", TRUE)." 
"; + echo "
"; + +//breaking space + echo "

\n"; + +//variable loop + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "\n"; + echo "
Variables 
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + foreach($xml->variables->children() as $child) { + $key = $child->getName(); + $value = urldecode($child); + echo "\n"; + echo " \n"; + if ($key == "bridge_uuid" || $key == "signal_bond") { + echo " \n"; + } + else { + echo " \n"; + } + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } + echo "
NameValue
".$key."\n"; + echo " ".$value." \n"; + $tmp_dir = $_SESSION['switch']['recordings']['dir'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day; + $tmp_name = ''; + if (file_exists($tmp_dir.'/'.$value.'.wav')) { + $tmp_name = $value.".wav"; + } + elseif (file_exists($tmp_dir.'/'.$value.'_1.wav')) { + $tmp_name = $value."_1.wav"; + } + elseif (file_exists($tmp_dir.'/'.$value.'.mp3')) { + $tmp_name = $value.".mp3"; + } + elseif (file_exists($tmp_dir.'/'.$value.'_1.mp3')) { + $tmp_name = $value."_1.mp3"; + } + if (strlen($tmp_name) > 0 && file_exists($_SESSION['switch']['recordings']['dir'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) { + echo " \n"; + echo " play"; + echo "  "; + } + if (strlen($tmp_name) > 0 && file_exists($_SESSION['switch']['recordings']['dir'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day.'/'.$tmp_name)) { + echo " \n"; + echo " download"; + echo " "; + } + echo "".wordwrap($value,75,"
\n", TRUE)." 
"; + echo "
"; + +//breaking space + echo "

\n"; + +//app_log + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Application Log 
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + foreach ($xml->app_log->application as $row) { + $app_name = $row->attributes()->app_name; + $app_data = $row->attributes()->app_data; + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } + echo "
NameData
".$app_name." ".wordwrap($app_data,75,"
\n", TRUE)." 
"; + echo "
"; + +//breaking space + echo "

\n"; + +//callflow + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + foreach ($xml->callflow as $row) { + + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "
\n"; + + //attributes + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Call Flow: Attributes 
\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + foreach($row->attributes() as $key => $value) { + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + if ($c==0) { $c=1; } else { $c=0; } + } + echo " \n"; + echo " \n"; + echo " \n"; + echo "
NameValue
".$key." ".wordwrap($value,75,"
\n", TRUE)." 


\n"; + + //extension->attributes + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Call Flow: Extension: Attributes 
\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + foreach($row->extension->attributes() as $key => $value) { + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + if ($c==0) { $c=1; } else { $c=0; } + } + echo " \n"; + echo " \n"; + echo " \n"; + echo "
NameValue
".$key." ".wordwrap($value,75,"
\n", TRUE)." 


\n"; + + //extension->application + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Call Flow: Extension: Application 
\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + foreach ($row->extension->application as $tmp_row) { + $app_name = $tmp_row->attributes()->app_name; + $app_data = $tmp_row->attributes()->app_data; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + if ($c==0) { $c=1; } else { $c=0; } + } + echo " \n"; + echo " \n"; + echo " \n"; + echo "
NameData
".$app_name." ".wordwrap($app_data,75,"
\n", TRUE)." 


\n"; + + //caller_profile + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Call Flow: Caller Profile 
\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + foreach($row->caller_profile->children() as $child) { + $key = $child->getName(); + echo " \n"; + if ($key != "originatee") { + $value = urldecode($child); + echo " \n"; + echo " \n"; + } + else { + echo " \n"; + echo " \n"; + } + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } + echo " \n"; + echo " \n"; + echo " \n"; + echo "
NameValue
".$key." ".wordwrap($value,75,"
\n", TRUE)." 
".$key."\n"; + echo " \n"; + foreach($child->originatee_caller_profile->children() as $tmp_child) { + //print_r($tmp_child); + $key = $tmp_child->getName(); + $value = urldecode($tmp_child); + echo " \n"; + echo " \n"; + if ($key != "uuid") { + echo " \n"; + } + else { + echo " \n"; + } + echo " \n"; + } + echo "
".$key." ".wordwrap($value,75,"
\n", TRUE)." 
".$value." 
\n"; + echo "


\n"; + + //times + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + foreach($row->times->children() as $child) { + $key = $child->getName(); + $value = urldecode($child); + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + if ($c==0) { $c=1; } else { $c=0; } + } + + echo " \n"; + echo " \n"; + echo " \n"; + + echo "
Call Flow: Times 
NameValue
".$key." ".wordwrap($value,75,"
\n", TRUE)." 


"; + echo "

\n"; + } + + echo "
"; + +//testing + //echo "
\n";
+	//echo htmlentities($xml_string);
+	//print_r($xml);
+	//echo "
\n"; + +//get the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/xml_cdr/xml_cdr_import_update.php b/app/xml_cdr/xml_cdr_import_update.php new file mode 100644 index 0000000000..4a0aa19c39 --- /dev/null +++ b/app/xml_cdr/xml_cdr_import_update.php @@ -0,0 +1,159 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//check the permission + if(defined('STDIN')) { + $document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]); + preg_match("/^(.*)\/mod\/.*$/", $document_root, $matches); + $document_root = $matches[1]; + set_include_path($document_root); + require_once "includes/require.php"; + $_SERVER["DOCUMENT_ROOT"] = $document_root; + $display_type = 'text'; //html, text + } + else { + echo "access denied"; + exit; + } + +//determine where the xml cdr will be archived + $sql = "select * from v_vars "; + $sql .= "where domain_uuid = '1' "; + $sql .= "and var_name = 'xml_cdr_archive' "; + $row = $db->query($sql)->fetch(); + $var_value = trim($row["var_value"]); + switch ($var_value) { + case "dir": + $xml_cdr_archive = 'dir'; + break; + case "db": + $xml_cdr_archive = 'db'; + break; + case "none": + $xml_cdr_archive = 'none'; + break; + default: + $xml_cdr_archive = 'dir'; + break; + } + +//get the list of installed apps from the core and mod directories + if ($xml_cdr_archive == "db") { + //get the xml cdr list + $sql = ""; + $sql .= "select xml_cdr, uuid from v_xml_cdr "; + $sql .= "where waitsec is null "; + //$sql .= "limit 5000 "; + //start the transaction + $db->beginTransaction(); + //loop through the results + $x = 0; + foreach ($db->query($sql,PDO::FETCH_ASSOC) as $row) { + //get the values from the db + $uuid = $row['uuid']; + $xml_string = $row['xml_cdr']; + //save each set of records and begin a new transaction + if ($x > 5000) { + //save the transaction + $db->commit(); + //start the transaction + $db->beginTransaction(); + //reset the count + $x = 0; + } + //parse the xml to get the call detail record info + try { + $xml = simplexml_load_string($xml_string); + } + catch(Exception $e) { + echo $e->getMessage(); + } + //get the values from the xml and set at variables + $uuid = urldecode($xml->variables->uuid); + $waitsec = urldecode($xml->variables->waitsec); + //update the database + if (strlen($waitsec) > 0) { + $sql = ""; + $sql .= "update v_xml_cdr "; + $sql .= "set waitsec = '$waitsec' "; + $sql .= "where uuid = '$uuid' "; + echo $sql."\n"; + $db->exec($sql); + $x++; + } + } + //save the transaction + $db->commit(); + //echo finished + echo "completed\n"; + } + if ($xml_cdr_archive == "dir") { + $xml_cdr_list = glob($_SESSION['switch']['log']['dir']."/xml_cdr/archive/*/*/*/*.xml"); + echo "count: ".count($xml_cdr_list)."\n"; + //print_r($xml_cdr_list); + $x = 0; + //start the transaction + $db->beginTransaction(); + //loop through the xml cdr records + foreach ($xml_cdr_list as $xml_cdr) { + //save each set of records and begin a new transaction + if ($x > 5000) { + //save the transaction + $db->commit(); + //start the transaction + $db->beginTransaction(); + //reset the count + $x = 0; + } + //get the xml cdr string + $xml_string = file_get_contents($xml_cdr); + //parse the xml to get the call detail record info + try { + $xml = simplexml_load_string($xml_string); + } + catch(Exception $e) { + echo $e->getMessage(); + } + //get the values from the xml and set at variables + $uuid = urldecode($xml->variables->uuid); + $waitsec = urldecode($xml->variables->waitsec); + //update the database + //if ($num_rows == "0" && strlen($waitsec) > 0) { + if (strlen($waitsec) > 0) { + $sql = ""; + $sql .= "update v_xml_cdr "; + $sql .= "set waitsec = '$waitsec' "; + $sql .= "where uuid = '$uuid' "; + echo $sql."\n"; + $db->exec($sql); + $x++; + } + } + //save the transaction + $db->commit(); + //echo finished + echo "completed\n"; + } \ No newline at end of file diff --git a/app/xml_cdr/xml_cdr_inc.php b/app/xml_cdr/xml_cdr_inc.php new file mode 100644 index 0000000000..99f1431d66 --- /dev/null +++ b/app/xml_cdr/xml_cdr_inc.php @@ -0,0 +1,203 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_cdr_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//import xml_cdr files + require_once "v_xml_cdr_import.php"; + +//additional includes + require_once "includes/paging.php"; + +//set 24hr or 12hr clock + define('TIME_24HR', 1); + +//get post or get variables from http + if (count($_REQUEST)>0) { + $order_by = $_REQUEST["order_by"]; + $order = $_REQUEST["order"]; + $cdr_id = $_REQUEST["cdr_id"]; + $direction = $_REQUEST["direction"]; + $caller_id_name = $_REQUEST["caller_id_name"]; + $caller_id_number = $_REQUEST["caller_id_number"]; + $destination_number = $_REQUEST["destination_number"]; + $context = $_REQUEST["context"]; + $start_stamp = $_REQUEST["start_stamp"]; + $answer_stamp = $_REQUEST["answer_stamp"]; + $end_stamp = $_REQUEST["end_stamp"]; + $duration = $_REQUEST["duration"]; + $billsec = $_REQUEST["billsec"]; + $hangup_cause = $_REQUEST["hangup_cause"]; + $uuid = $_REQUEST["uuid"]; + $bleg_uuid = $_REQUEST["bleg_uuid"]; + $accountcode = $_REQUEST["accountcode"]; + $read_codec = $_REQUEST["read_codec"]; + $write_codec = $_REQUEST["write_codec"]; + $remote_media_ip = $_REQUEST["remote_media_ip"]; + $network_addr = $_REQUEST["network_addr"]; + } + +//build the sql where string + if (strlen($cdr_id) > 0) { $sql_where .= "and cdr_id like '%$cdr_id%' "; } + if (strlen($direction) > 0) { $sql_where .= "and direction like '%$direction%' "; } + if (strlen($caller_id_name) > 0) { $sql_where .= "and caller_id_name like '%$caller_id_name%' "; } + if (strlen($caller_id_number) > 0 && strlen($destination_number) > 0) { + $sql_where .= "and ("; + $sql_where .= "caller_id_number = '$caller_id_number' "; + $sql_where .= "or destination_number = '$destination_number'"; + $sql_where .= ") "; + } + else { + if (strlen($caller_id_number) > 0) { $sql_where .= "and caller_id_number like '%$caller_id_number%' "; } + if (strlen($destination_number) > 0) { $sql_where .= "and destination_number like '%$destination_number%' "; } + } + if (strlen($context) > 0) { $sql_where .= "and context like '%$context%' "; } + if ($db_type == "sqlite") { + if (strlen($start_stamp) > 0) { $sql_where .= "and start_stamp like '%$start_stamp%' "; } + if (strlen($end_stamp) > 0) { $sql_where .= "and end_stamp like '%$end_stamp%' "; } + } + if ($db_type == "pgsql" || $db_type == "mysql") { + if (strlen($start_stamp) > 0 && strlen($end_stamp) == 0) { $sql_where .= "and start_stamp between '$start_stamp 00:00:00' and '$start_stamp 23:59:59' "; } + if (strlen($start_stamp) > 0 && strlen($end_stamp) > 0) { $sql_where .= "and start_stamp between '$start_stamp 00:00:00' and '$end_stamp 23:59:59' "; } + } + if (strlen($answer_stamp) > 0) { $sql_where .= "and answer_stamp like '%$answer_stamp%' "; } + if (strlen($duration) > 0) { $sql_where .= "and duration like '%$duration%' "; } + if (strlen($billsec) > 0) { $sql_where .= "and billsec like '%$billsec%' "; } + if (strlen($hangup_cause) > 0) { $sql_where .= "and hangup_cause like '%$hangup_cause%' "; } + if (strlen($uuid) > 0) { $sql_where .= "and uuid = '$uuid' "; } + if (strlen($bleg_uuid) > 0) { $sql_where .= "and bleg_uuid = '$bleg_uuid' "; } + if (strlen($accountcode) > 0) { $sql_where .= "and accountcode = '$accountcode' "; } + if (strlen($read_codec) > 0) { $sql_where .= "and read_codec like '%$read_codec%' "; } + if (strlen($write_codec) > 0) { $sql_where .= "and write_codec like '%$write_codec%' "; } + if (strlen($remote_media_ip) > 0) { $sql_where .= "and remote_media_ip like '%$remote_media_ip%' "; } + if (strlen($network_addr) > 0) { $sql_where .= "and network_addr like '%$network_addr%' "; } + + //example sql + // select caller_id_number, destination_number from v_xml_cdr where domain_uuid = '' + // and (caller_id_number = '1001' or destination_number = '1001' or destination_number = '*991001') + if (!if_group("admin") && !if_group("superadmin")) { + $sql_where = "where domain_uuid = '$domain_uuid' "; + $sql_where .= "and ( "; + if (count($_SESSION['user']['extension']) > 0) { + $x = 0; + foreach($_SESSION['user']['extension'] as $row) { + if ($x==0) { + if ($row['user'] > 0) { $sql_where .= "caller_id_number = '".$row['user']."' \n"; } //source + } + else { + if ($row['user'] > 0) { $sql_where .= "or caller_id_number = '".$row['user']."' \n"; } //source + } + if ($row['user'] > 0) { $sql_where .= "or destination_number = '".$row['user']."' \n"; } //destination + if ($row['user'] > 0) { $sql_where .= "or destination_number = '*99".$row['user']."' \n"; } //destination + $x++; + } + } + else { + $sql_where .= "destination_number = 'no extension assigned' \n"; //destination + } + $sql_where .= ") "; + } + else { + //superadmin or admin + $sql_where = "where domain_uuid = '$domain_uuid' ".$sql_where; + } + //$sql_where = str_replace ("where or", "where", $sql_where); + //$sql_where = str_replace ("where and", " and", $sql_where); + +//set the param variable which is used with paging + $param = ""; + $param .= "&caller_id_name=$caller_id_name"; + $param .= "&start_stamp=$start_stamp"; + $param .= "&hangup_cause=$hangup_cause"; + $param .= "&caller_id_number=$caller_id_number"; + $param .= "&destination_number=$destination_number"; + $param .= "&context=$context"; + $param .= "&answer_stamp=$answer_stamp"; + $param .= "&end_stamp=$end_stamp"; + $param .= "&duration=$duration"; + $param .= "&billsec=$billsec"; + $param .= "&uuid=$uuid"; + $param .= "&bridge_uuid=$bridge_uuid"; + $param .= "&accountcode=$accountcode"; + $param .= "&read_codec=$read_codec"; + $param .= "&write_codec=$write_codec"; + $param .= "&remote_media_ip=$remote_media_ip"; + $param .= "&network_addr=$network_addr"; + +//create the sql query to get the xml cdr records + if (strlen($order_by) == 0) { $order_by = "start_epoch"; } + if (strlen($order) == 0) { $order = "desc"; } + +//set the default + $num_rows = '0'; + +//get the number of rows in the v_xml_cdr + $sql = "select count(*) as num_rows from v_xml_cdr "; + $sql .= $sql_where; + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + unset($prep_statement, $result); + +//prepare to page the results + $rows_per_page = 150; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + +//get the results from the db + $sql = "select * from v_xml_cdr "; + $sql .= $sql_where; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + +?> \ No newline at end of file diff --git a/app/xml_cdr/xml_cdr_search.php b/app/xml_cdr/xml_cdr_search.php new file mode 100644 index 0000000000..22358e6316 --- /dev/null +++ b/app/xml_cdr/xml_cdr_search.php @@ -0,0 +1,157 @@ + + Copyright (C) 2008-2012 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_cdr_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_POST)>0) { + $cdr_id = $_POST["cdr_id"]; + $caller_id_name = $_POST["caller_id_name"]; + $caller_id_number = $_POST["caller_id_number"]; + $destination_number = $_POST["destination_number"]; + $context = $_POST["context"]; + $start_stamp = $_POST["start_stamp"]; + $answer_stamp = $_POST["answer_stamp"]; + $end_stamp = $_POST["end_stamp"]; + $duration = $_POST["duration"]; + $billsec = $_POST["billsec"]; + $hangup_cause = $_POST["hangup_cause"]; + $uuid = $_POST["uuid"]; + $bleg_uuid = $_POST["bleg_uuid"]; + $accountcode = $_POST["accountcode"]; + $read_codec = $_POST["read_codec"]; + $write_codec = $_POST["write_codec"]; + $remote_media_ip = $_POST["remote_media_ip"]; + $network_addr = $_POST["network_addr"]; +} +else { + + require_once "includes/header.php"; + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Advanced Search

Source Name:
Source Number:
Destination Number:
Context:
Start:
Answer:
End:
Duration:
Bill Sec:
Status:
UUID:
Bridge UUID:
Account Code:
Read Codec:
Write Codec:
Remote Media IP:
Network Address:
"; + echo "
"; + + echo "
"; + echo "
"; + + require_once "includes/footer.php"; + +} //end if not post +?> diff --git a/app/xml_cdr/xml_cdr_statistics.php b/app/xml_cdr/xml_cdr_statistics.php new file mode 100644 index 0000000000..dfcb141c81 --- /dev/null +++ b/app/xml_cdr/xml_cdr_statistics.php @@ -0,0 +1,219 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_cdr_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//additional includes + require_once "xml_cdr_statistics_inc.php"; + require_once "includes/header.php"; + +//page title and description + echo "
"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "
Call Detail Record Statistics\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " Call Detail Records Statics summarize the call information. \n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + +//set the style + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + ?> + + + + + + + + +
+
+
+

+
+ + \n"; + echo "\n"; + echo " Hours\n"; + echo " Date\n"; + echo " Time\n"; + echo " Volume\n"; + echo " Minutes\n"; + echo " Calls Per Min\n"; + echo " Missed\n"; + echo " ASR\n"; + echo " ALOC\n"; + echo "\n"; + + $i = 0; + foreach ($stats as $row) { + echo "\n"; + if ($i < 24) { + echo " ".($i+1)."\n"; + } + elseif ($i == 24) { + echo "

\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo "

\n"; + echo " \n"; + echo "\n"; + echo "\n"; + echo " Days\n"; + echo " Date\n"; + echo " Time\n"; + echo " Volume\n"; + echo " Minutes\n"; + echo " Calls Per Min\n"; + echo " Missed\n"; + echo " ASR\n"; + echo " ALOC\n"; + echo "\n"; + echo "\n"; + echo " 1\n"; + } + elseif ($i == 25) { + echo "\n"; + echo " 7\n"; + } + elseif ($i == 26) { + echo " 30\n"; + } + if ($i < 24) { + echo " ".date('j M', $row['start_epoch'])."\n"; + echo " ".date('H:i', $row['start_epoch'])." - ".date('H:i', $row['stop_epoch'])." \n"; + } + else { + echo " ".date('j M', $row['start_epoch'])." \n"; + echo " ".date('H:i', $row['start_epoch'])." - ".date('j M H:i', $row['stop_epoch'])." \n"; + } + echo " ".$row['volume']." \n"; + echo " ".(round($row['minutes'],2))." \n"; + echo " ".(round($row['avg_min'],2))." \n"; + echo " ".$row['missed']." \n"; + echo " ".(round($row['asr'],2))." \n"; + echo " ".(round($row['aloc'],2))." \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + $i++; + } + echo "\n"; + +//show the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/xml_cdr/xml_cdr_statistics_csv.php b/app/xml_cdr/xml_cdr_statistics_csv.php new file mode 100644 index 0000000000..5275f431a4 --- /dev/null +++ b/app/xml_cdr/xml_cdr_statistics_csv.php @@ -0,0 +1,73 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_cdr_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//include the xml cdr statistics backend + require_once "xml_cdr_statistics_inc.php"; + +//set the http header + header('Content-type: application/octet-binary'); + header('Content-Disposition: attachment; filename=cdr-statistics.csv'); + +//show the column names on the first line + $z = 0; + foreach($stats[1] as $key => $val) { + if ($z == 0) { + echo '"'.$key.'"'; + } + else { + echo ',"'.$key.'"'; + } + $z++; + } + echo "\n"; + +//add the values to the csv + $x = 0; + foreach($stats as $row) { + $z = 0; + foreach($row as $key => $val) { + if ($z == 0) { + echo '"'.$stats[$x][$key].'"'; + } + else { + echo ',"'.$stats[$x][$key].'"'; + } + $z++; + } + echo "\n"; + $x++; + } +?> \ No newline at end of file diff --git a/app/xml_cdr/xml_cdr_statistics_inc.php b/app/xml_cdr/xml_cdr_statistics_inc.php new file mode 100644 index 0000000000..75bf5bedeb --- /dev/null +++ b/app/xml_cdr/xml_cdr_statistics_inc.php @@ -0,0 +1,246 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_cdr_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//show all call detail records to admin and superadmin. for everyone else show only the call details for extensions assigned to them + if (!if_group("admin") && !if_group("superadmin")) { + // select caller_id_number, destination_number from v_xml_cdr where domain_uuid = '' + // and (caller_id_number = '1001' or destination_number = '1001' or destination_number = '*991001') + $sql_where = "where domain_uuid = '$domain_uuid' and ( "; + if (count($_SESSION['user']['extension']) > 0) { + $x = 0; + foreach($_SESSION['user']['extension'] as $row) { + if ($x==0) { + if ($row['user'] > 0) { $sql_where .= "caller_id_number = '".$row['user']."' \n"; } //source + } + else { + if ($row['user'] > 0) { $sql_where .= "or caller_id_number = '".$row['user']."' \n"; } //source + } + if ($row['user'] > 0) { $sql_where .= "or destination_number = '".$row['user']."' \n"; } //destination + if ($row['user'] > 0) { $sql_where .= "or destination_number = '*99".$row['user']."' \n"; } //destination + $x++; + } + } + $sql_where .= ") "; + } + else { + //superadmin or admin + $sql_where = "where domain_uuid = '$domain_uuid' "; + } + +//create the sql query to get the xml cdr records + if (strlen($order_by) == 0) { $order_by = "start_epoch"; } + if (strlen($order) == 0) { $order = "desc"; } + +//calculate the seconds in different time frames + $seconds_hour = 3600; + $seconds_day = $seconds_hour * 24; + $seconds_week = $seconds_day * 7; + $seconds_month = $seconds_day * 30; + +//get the call volume between a start end end time in seconds + function get_call_volume_between($start, $end, $where) { + global $db; + if (strlen($where) == 0) { + $where = "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + } + $sql = " select count(*) as count from v_xml_cdr "; + $sql .= $where; + $sql .= "and start_epoch BETWEEN ".$start." AND ".$end." "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + unset ($prep_statement, $sql); + if (count($result) > 0) { + foreach($result as $row) { + return $row['count']; + } + } + else { + return false; + } + unset($prep_statement, $result, $sql); + } + +//get the call time in seconds between the start and end time in seconds + function get_call_seconds_between($start, $end, $where) { + global $db; + if (strlen($where) == 0) { + $where = "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + } + $sql = " select sum(billsec) as seconds from v_xml_cdr "; + $sql .= $where; + $sql .= "and start_epoch BETWEEN ".$start." AND ".$end." "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + unset ($prep_statement, $sql); + if (count($result) > 0) { + foreach($result as $row) { + $result = $row['seconds']; + if (strlen($result) == 0) { + return 0; + } + else { + return $row['seconds']; + } + } + } + else { + return false; + } + unset($prep_statement, $result, $sql); + } + //$call_seconds_1st_hour = get_call_seconds_between(3600, 0); + //if (strlen($call_seconds_1st_hour) == 0) { $call_seconds_1st_hour = 0; } + +//round down to the nearest hour + $time = time() - time() % 3600; + +//call info hour by hour + for ($i = 0; $i <= 23; $i++) { + $stats[$i]['start_epoch'] = $time - 3600*$i; + $stats[$i]['stop_epoch'] = $stats[$i]['start_epoch'] + 3600; + $stats[$i]['volume'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], ''); + $stats[$i]['seconds'] = get_call_seconds_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], ''); + $stats[$i]['minutes'] = $stats[$i]['seconds'] / 60; + $stats[$i]['avg_sec'] = $stats[$i]['seconds'] / $stats[$i]['volume']; + $stats[$i]['avg_min'] = ($stats[$i]['volume'] - $stats[$i]['missed']) / 60; + + //answer / seizure ratio + $where = "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $where .= "and billsec = '0' "; + $where .= "and direction = 'inbound' "; + $stats[$i]['missed'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where); + $stats[$i]['asr'] = (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100); + + //average length of call + $stats[$i]['aloc'] = $stats[$i]['minutes'] / ($stats[$i]['volume'] - $stats[$i]['missed']); + } + +//call info for a day + $i = 24; + $stats[$i]['start_epoch'] = time() - $seconds_day; + $stats[$i]['stop_epoch'] = time(); + $stats[$i]['volume'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], ''); + $stats[$i]['seconds'] = get_call_seconds_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], ''); + $stats[$i]['minutes'] = $stats[$i]['seconds'] / 60; + $stats[$i]['avg_sec'] = $stats[$i]['seconds'] / $stats[$i]['volume']; + $stats[$i]['avg_min'] = ($stats[$i]['volume'] - $stats[$i]['missed']) / (60*24); + $where = "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $where .= "and billsec = '0' "; + $where .= "and direction = 'inbound' "; + $stats[$i]['missed'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where); + $stats[$i]['asr'] = (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100); + $stats[$i]['aloc'] = $stats[$i]['minutes'] / ($stats[$i]['volume'] - $stats[$i]['missed']); + $i++; + +//call info for a week + $stats[$i]['start_epoch'] = time() - $seconds_week; + $stats[$i]['stop_epoch'] = time(); + $stats[$i]['volume'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], ''); + $stats[$i]['seconds'] = get_call_seconds_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], ''); + $stats[$i]['minutes'] = $stats[$i]['seconds'] / 60; + $stats[$i]['avg_sec'] = $stats[$i]['seconds'] / $stats[$i]['volume']; + $stats[$i]['avg_min'] = ($stats[$i]['volume'] - $stats[$i]['missed']) / (60*24*7); + $where = "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $where .= "and billsec = '0' "; + $where .= "and direction = 'inbound' "; + $stats[$i]['missed'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where); + $stats[$i]['asr'] = (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100); + $stats[$i]['aloc'] = $stats[$i]['minutes'] / ($stats[$i]['volume'] - $stats[$i]['missed']); + $i++; + +//call info for a month + $stats[$i]['start_epoch'] = time() - $seconds_month; + $stats[$i]['stop_epoch'] = time(); + $stats[$i]['volume'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], ''); + $stats[$i]['seconds'] = get_call_seconds_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], ''); + $stats[$i]['minutes'] = $stats[$i]['seconds'] / 60; + $stats[$i]['avg_sec'] = $stats[$i]['seconds'] / $stats[$i]['volume']; + $stats[$i]['avg_min'] = ($stats[$i]['volume'] - $stats[$i]['missed']) / (60*24*30); + $where = "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $where .= "and billsec = '0' "; + $where .= "and direction = 'inbound' "; + $stats[$i]['missed'] = get_call_volume_between($stats[$i]['start_epoch'], $stats[$i]['stop_epoch'], $where); + $stats[$i]['asr'] = (($stats[$i]['volume'] - $stats[$i]['missed']) / ($stats[$i]['volume']) * 100); + $stats[$i]['aloc'] = $stats[$i]['minutes'] / ($stats[$i]['volume'] - $stats[$i]['missed']); + $i++; + +//show the graph + $x = 0; + foreach ($stats as $row) { + $graph['volume'][$x][] = date('H', $row['start_epoch']); + $graph['volume'][$x][] = $row['volume']/1; + if ($x == 23) { break; } + $x++; + } + $x = 0; + foreach ($stats as $row) { + $graph['minutes'][$x][] = date('H', $row['start_epoch']); + $graph['minutes'][$x][] = round($row['minutes'],2); + if ($x == 23) { break; } + $x++; + } + $x = 0; + foreach ($stats as $row) { + $graph['call_per_min'][$x][] = date('H', $row['start_epoch']); + $graph['call_per_min'][$x][] = round($row['avg_min'],2); + if ($x == 23) { break; } + $x++; + } + $x = 0; + foreach ($stats as $row) { + $graph['missed'][$x][] = date('H', $row['start_epoch']); + $graph['missed'][$x][] = $row['missed']/1; + if ($x == 23) { break; } + $x++; + } + $x = 0; + foreach ($stats as $row) { + $graph['asr'][$x][] = date('H', $row['start_epoch']); + $graph['asr'][$x][] = round($row['asr'],2)/100; + if ($x == 23) { break; } + $x++; + } + $x = 0; + foreach ($stats as $row) { + $graph['aloc'][$x][] = date('H', $row['start_epoch']); + $graph['aloc'][$x][] = round($row['aloc'],2); + if ($x == 23) { break; } + $x++; + } + +?> \ No newline at end of file diff --git a/app/xml_edit/app_config.php b/app/xml_edit/app_config.php new file mode 100644 index 0000000000..a0c0eee327 --- /dev/null +++ b/app/xml_edit/app_config.php @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/app/xml_edit/clip.db b/app/xml_edit/clip.db new file mode 100644 index 0000000000..5f15c2fb9e Binary files /dev/null and b/app/xml_edit/clip.db differ diff --git a/app/xml_edit/clipadd.php b/app/xml_edit/clipadd.php new file mode 100644 index 0000000000..fed2365c17 --- /dev/null +++ b/app/xml_edit/clipadd.php @@ -0,0 +1,123 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "config.php"; + +if (count($_POST)>0) { + $clip_name = check_str($_POST["clip_name"]); + $clip_folder = check_str($_POST["clip_folder"]); + $clip_text_start = check_str($_POST["clip_text_start"]); + $clip_text_end = check_str($_POST["clip_text_end"]); + $clip_desc = check_str($_POST["clip_desc"]); + $clip_order = check_str($_POST["clip_order"]); + + $sql = "insert into v_clip_library "; + $sql .= "("; + $sql .= "clip_name, "; + $sql .= "clip_folder, "; + $sql .= "clip_text_start, "; + $sql .= "clip_text_end, "; + $sql .= "clip_desc, "; + $sql .= "clip_order "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$clip_name', "; + $sql .= "'$clip_folder', "; + $sql .= "'$clip_text_start', "; + $sql .= "'$clip_text_end', "; + $sql .= "'$clip_desc', "; + $sql .= "'$clip_order' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql,$db); + + require_once "header.php"; + echo "\n"; + echo "Add Complete"; + require_once "footer.php"; + return; +} + + require_once "header.php"; + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
Name:
Folder:
Before Selection:
"; + echo " "; + echo "
After Selection:
"; + echo " "; + echo "
Notes:
"; + echo " "; + echo "
"; + echo "
"; + + echo "
"; + echo "
"; + +require_once "footer.php"; +?> \ No newline at end of file diff --git a/app/xml_edit/clipdelete.php b/app/xml_edit/clipdelete.php new file mode 100644 index 0000000000..bdc059d619 --- /dev/null +++ b/app/xml_edit/clipdelete.php @@ -0,0 +1,54 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "config.php"; + +$id = $_GET["id"]; +if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_clip_library "; + $sql .= "where id = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql,$db); +} + +require_once "header.php"; +echo "\n"; +echo "Delete Complete"; +require_once "footer.php"; +return; + +?> diff --git a/app/xml_edit/cliplist.php b/app/xml_edit/cliplist.php new file mode 100644 index 0000000000..3f19d4c222 --- /dev/null +++ b/app/xml_edit/cliplist.php @@ -0,0 +1,224 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "config.php"; + +echo ""; +echo ""; +echo ""; + +function isfile($filename) { + if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function space($count) { + $r=''; $i=0; + while($i < $count) { + $r .= ' '; + $i++; + } + return $r; +} + +//show the content + echo ""; + + echo ""; + +echo ""; +echo ""; + + echo "
"; + echo "\n"; + + echo "\n"; + echo "
\n"; + echo "
Clip Library
\n"; //display:none + + $sql = ""; + $sql .= "select * from v_clip_library "; + $sql .= "order by clip_folder "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + if ($result_count > 0) { + $last_folder = ''; + $tag_open = ''; + $x = 0; + $current_depth = 0; + $previous_depth = 0; + foreach($result as $row) { + $current_depth = count(explode ("/", $row[clip_folder])); + if ($current_depth < $previous_depth) { + $count = ($previous_depth - $current_depth); + $i=0; + while($i < $count){ + echo "
\n"; + $i++; + } + echo "
\n"; + } + + if ($last_folder != $row[clip_folder]) { + $clip_folder_name = str_replace ($previous_folder_name, "", $row[clip_folder]); + $clip_folder_name = str_replace ("/", "", $clip_folder_name); + echo "
 ".$clip_folder_name."  
\n\n"; + $tag_open = 1; + } + + $previous_depth = $current_depth; + $previous_folder_name = $row[clip_folder]; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "".$row[clip_name]."\n"; + echo "
\n"; + echo "\n\n"; + + $last_folder = $row[clip_folder]; + + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + + } //end if results + + echo "\n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
"; + echo "

"; + + echo ""; + echo ""; + +?> \ No newline at end of file diff --git a/app/xml_edit/clipoptions.php b/app/xml_edit/clipoptions.php new file mode 100644 index 0000000000..fec1ac5e80 --- /dev/null +++ b/app/xml_edit/clipoptions.php @@ -0,0 +1,73 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "config.php"; +require_once "header.php"; + +echo "
"; +echo "\n"; +echo ""; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
Selected Clip:
"; + +echo " "; + +echo ""; + +echo " "; +//echo " \n"; +//echo " \n"; +//echo " \n"; + +echo " \n"; +echo " \n"; +//echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "
Options











"; + +echo "
"; +echo "
"; + +require_once "footer.php"; +?> diff --git a/app/xml_edit/clipoptionslist.php b/app/xml_edit/clipoptionslist.php new file mode 100644 index 0000000000..e6c7ff579a --- /dev/null +++ b/app/xml_edit/clipoptionslist.php @@ -0,0 +1,247 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "config.php"; + +echo ""; +echo ""; + +echo ""; + +function isfile($filename) { + if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function space($count) { + $r=''; $i=0; + while($i < $count) { + $r .= ' '; + $i++; + } + return $r; +} + +//show the content + echo ""; + + echo ""; + +echo ""; +echo ""; + + echo "
"; + echo "\n"; + + echo "\n"; + echo "
\n"; + echo "
Clip Library
\n"; //display:none + + $sql = ""; + $sql .= "select * from v_clip_library "; + $sql .= "order by clip_folder "; + //$sql .= "and clip_name asc "; + + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + if ($result_count == 0) { + //no results + } + else { //received results + $last_folder = ''; + $tag_open = ''; + $x = 0; + $current_depth = 0; + $previous_depth = 0; + foreach($result as $row) { + $current_depth = count(explode("/", $row[clip_folder])); + if ($current_depth < $previous_depth) { + $count = ($previous_depth - $current_depth); + $i=0; + while($i < $count){ + echo "
\n"; + $i++; + } + echo "
\n"; + + } + + if ($last_folder != $row[clip_folder]) { + $clip_folder_name = str_replace ($previous_folder_name, "", $row[clip_folder]); + $clip_folder_name = str_replace ("/", "", $clip_folder_name); + echo "
 ".$clip_folder_name."  
\n\n"; + $tag_open = 1; + } + + $previous_depth = $current_depth; + $previous_folder_name = $row[clip_folder]; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "".$row[clip_name]."\n"; + echo "
\n"; + echo "\n\n"; + + $last_folder = $row[clip_folder]; + + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + + } //end if results + + echo "\n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
"; + + echo "

"; + echo ""; + echo ""; + +?> diff --git a/app/xml_edit/clipsearch.php b/app/xml_edit/clipsearch.php new file mode 100644 index 0000000000..c405fca466 --- /dev/null +++ b/app/xml_edit/clipsearch.php @@ -0,0 +1,187 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "config.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_POST)>0) { + $id = $_POST["id"]; + $clip_name = $_POST["clip_name"]; + $clip_folder = $_POST["clip_folder"]; + $clip_text_start = $_POST["clip_text_start"]; + $clip_text_end = $_POST["clip_text_end"]; + $clip_desc = $_POST["clip_desc"]; + $clip_order = $_POST["clip_order"]; + + require_once "header.php"; + echo "
"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + + } //end if results + + echo "
\n"; + echo "
"; + + $sql = ""; + $sql .= "select * from v_clip_library "; + $sql .= "where "; + if (strlen($id) > 0) { $sql .= "and id like '%$id%' "; } + if (strlen($clip_name) > 0) { $sql .= "and clip_name like '%$clip_name%' "; } + if (strlen($clip_folder) > 0) { $sql .= "and clip_folder like '%$clip_folder%' "; } + if (strlen($clip_text_start) > 0) { $sql .= "and clip_text_start like '%$clip_text_start%' "; } + if (strlen($clip_text_end) > 0) { $sql .= "and clip_text_end like '%$clip_text_end%' "; } + if (strlen($clip_desc) > 0) { $sql .= "and clip_desc like '%$clip_desc%' "; } + if (strlen($clip_order) > 0) { $sql .= "and clip_order like '%$clip_order%' "; } + + + $sql = trim($sql); + if (substr($sql, -5) == "where"){ $sql = substr($sql, 0, (strlen($sql)-5)); } + $sql = str_replace ("where and", "where", $sql); + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + $c = 0; + $row_style["0"] = "background-color: #F5F5DC;"; + $row_style["1"] = "background-color: #FFFFFF;"; + + echo "
\n"; + echo "\n"; + echo ""; + + if ($result_count == 0) { //no results + echo ""; + } + else { //received results + + echo ""; + //echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + echo "\n"; + + foreach($result as $row) { + //print_r( $row ); + echo "\n"; + //echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach unset($sql, $result, $row_count); + + echo "
 
    Id        clip_name Search         clip_folder        clip_text_start        clip_text_end        clip_desc        clip_order   
".$row[id]."".$row[clip_name]."".$row[clip_folder]."".$row[clip_text_start]."".$row[clip_text_end]."".$row[clip_desc]."".$row[clip_order]."
\n"; + echo "
\n"; + + + echo "

"; + echo "
\n"; + echo "
"; + + echo "

"; + require_once "footer.php"; + + unset ($result_count); + unset ($result); + unset ($key); + unset ($val); + unset ($c); + +} +else { + + require_once "header.php"; + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + echo " "; + echo " "; + echo " "; + echo "
Name:
Folder:
Start:
End:
Desc:
clip_order:
"; + echo "
"; + + echo "
"; + echo "
"; + + require_once "footer.php"; + +} //end if not post +?> diff --git a/app/xml_edit/clipupdate.php b/app/xml_edit/clipupdate.php new file mode 100644 index 0000000000..674d4cc7d1 --- /dev/null +++ b/app/xml_edit/clipupdate.php @@ -0,0 +1,142 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "config.php"; + +if (count($_POST)>0) { + $id = check_str($_POST["id"]); + $clip_name = check_str($_POST["clip_name"]); + $clip_folder = check_str($_POST["clip_folder"]); + $clip_text_start = check_str($_POST["clip_text_start"]); + $clip_text_end = check_str($_POST["clip_text_end"]); + $clip_desc = check_str($_POST["clip_desc"]); + $clip_order = check_str($_POST["clip_order"]); + + //sql update + $sql = "update v_clip_library set "; + $sql .= "clip_name = '$clip_name', "; + $sql .= "clip_folder = '$clip_folder', "; + $sql .= "clip_text_start = '$clip_text_start', "; + $sql .= "clip_text_end = '$clip_text_end', "; + $sql .= "clip_desc = '$clip_desc', "; + $sql .= "clip_order = '$clip_order' "; + $sql .= "where id = '$id' "; + $count = $db->exec(check_sql($sql)); + //echo "Affected Rows: ".$count; + + + //edit: make sure the meta redirect url is correct + require_once "header.php"; + echo "\n"; + echo "Update Complete"; + require_once "footer.php"; + return; +} +else { + //get data from the db + $id = $_GET["id"]; + + $sql = ""; + $sql .= "select * from v_clip_library "; + $sql .= "where id = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $clip_name = $row["clip_name"]; + $clip_folder = $row["clip_folder"]; + $clip_text_start = $row["clip_text_start"]; + $clip_text_end = $row["clip_text_end"]; + $clip_desc = $row["clip_desc"]; + $clip_order = $row["clip_order"]; + break; //limit to 1 row + } + echo ""; + echo "
";} + + require_once "header.php"; + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
Name:
Folder:
Before Selection:
"; + echo " "; + echo "
After Selection:
"; + echo " "; + echo "
Notes:
"; + echo " "; + echo "
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + + echo "
"; + echo "
"; + + require_once "footer.php"; +?> diff --git a/app/xml_edit/config.php b/app/xml_edit/config.php new file mode 100644 index 0000000000..9806b236e7 --- /dev/null +++ b/app/xml_edit/config.php @@ -0,0 +1,176 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +include "root.php"; + +error_reporting (E_ALL ^ E_NOTICE); + +$applicationname = 'Edit'; +$bodyoptions = ""; + +$dbfilename = "clip.db"; +$db_file_path = PROJECT_PATH."/xml_edit/"; + +//$temp = $_ENV["TEMP"]."\\"; +if (is_writable($db_file_path.$dbfilename)) { //is writable + //use database in current location + echo "yes"; +} +else { //not writable + /* + //running from a non writable location so copy to temp directory + if (file_exists($temp.$dbfilename)) { + $db_file_path = $temp; //file already exists use existing file + } + else { //file doese not exist + //copy the file to the temp dir + if (copy($db_file_path.$dbfilename, $temp.$dbfilename)) { + //echo "copy succeeded.\n"; + $db_file_path = $temp; + } + else { + echo "Copy Failed "; + exit; + } + } + */ +} + +function get_string_between($string, $start, $end){ + $string = " ".$string; + $ini = strpos($string,$start); + if ($ini == 0) return ""; + $ini += strlen($start); + $len = strpos($string,$end,$ini) - $ini; + return substr($string,$ini,$len); +} + +//$fullstring = "this is my [tag]dog[/tag]"; +//$parsed = get_string_between($fullstring, "[tag]", "[/tag]"); + +//database connection +try { + //$db = new PDO('sqlite2:example.db'); //sqlite 2 + //$db = new PDO('sqlite::memory:'); //sqlite 3 + if (!function_exists('phpmd5')) { + function phpmd5($string) { + return md5($string); + } + } + if (!function_exists('phpmd5')) { + function phpunix_timestamp($string) { + return strtotime($string); + } + } + if (!function_exists('phpnow')) { + function phpnow() { + return date('r'); + } + } + + if (!function_exists('phpleft')) { + function phpleft($string, $num) { + return substr($string, 0, $num); + } + } + + if (!function_exists('phpright')) { + function phpright($string, $num) { + return substr($string, (strlen($string)-$num), strlen($string)); + } + } + + if (!function_exists('phpsqlitedatatype')) { + function phpsqlitedatatype($string, $field) { + + //--- Begin: Get String Between start and end characters ----- + $start = '('; + $end = ')'; + $ini = stripos($string,$start); + if ($ini == 0) return ""; + $ini += strlen($start); + $len = stripos($string,$end,$ini) - $ini; + $string = substr($string,$ini,$len); + //--- End: Get String Between start and end characters ----- + + $strdatatype = ''; + $stringarray = split (',', $string); + foreach($stringarray as $lnvalue) { + + //$strdatatype .= "-- ".$lnvalue ." ".strlen($lnvalue)." delim ".strrchr($lnvalue, " ")."---
"; + //$delimpos = stripos($lnvalue, " "); + //$strdatatype .= substr($value,$delimpos,strlen($value))." --
"; + + $fieldlistarray = split (" ", $value); + //$strdatatype .= $value ."
"; + //$strdatatype .= $fieldlistarray[0] ."
"; + //echo $fieldarray[0]."
\n"; + if ($fieldarray[0] == $field) { + //$strdatatype = $fieldarray[1]." ".$fieldarray[2]." ".$fieldarray[3]." ".$fieldarray[4]; //strdatatype + } + unset($fieldarray, $string, $field); + } + + //$strdatatype = $string; + return $strdatatype; + } + } //end function + +/* + $db = new PDO('sqlite:'.$db_file_path.$dbfilename); //sqlite 3 + //bool PDO::sqliteCreateFunction ( string function_name, callback callback [, int num_args] ) + $db->sqliteCreateFunction('md5', 'phpmd5', 1); + //$db->sqliteCreateFunction('unix_timestamp', 'phpunix_timestamp', 1); + $db->sqliteCreateFunction('now', 'phpnow', 0); + $db->sqliteCreateFunction('sqlitedatatype', 'phpsqlitedatatype', 2); + $db->sqliteCreateFunction('strleft', 'phpleft', 2); + $db->sqliteCreateFunction('strright', 'phpright', 2); +*/ +} +catch (PDOException $error) { + print "error: " . $error->getMessage() . "
"; + die(); +} + +if(!function_exists('escapejs')){ + function escapejs($strtemp) { + $strtemp = str_replace ("\"", "\\\"", $strtemp); //escape the single quote + //$strtemp = str_replace ("'", "''", $strtemp); //escape the single quote + return $strtemp; + } +} + +if(!function_exists('check_str')){ + function check_str($strtemp) { + //$strtemp = str_replace ("\$", "\\\$", $strtemp); //escape the single quote + //$strtemp = str_replace ("\'", "''", $strtemp); //escape the single quote + $strtemp = str_replace ("'", "''", $strtemp); //escape the single quote + //echo "strtemp $strtemp"; + return $strtemp; + } +} + +?> diff --git a/app/xml_edit/filedelete.php b/app/xml_edit/filedelete.php new file mode 100644 index 0000000000..a45796b4d4 --- /dev/null +++ b/app/xml_edit/filedelete.php @@ -0,0 +1,87 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "config.php"; + +$folder = $_GET["folder"]; +$folder = str_replace ("\\", "/", $folder); +if (substr($folder, -1) != "/") { $folder = $folder.'/'; } +$file = $_GET["file"]; + +//echo $folder.$file; + +if (strlen($folder) > 0 && strlen($file) > 0) { + unlink($folder.$file); + header("Location: fileoptions.php"); +} +else { + //display form + require_once "header.php"; + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Path:
".$folder.$file."
"; + + echo "
"; + + echo ""; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
File Name:
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + + require_once "footer.php"; +} +?> diff --git a/app/xml_edit/filelist.php b/app/xml_edit/filelist.php new file mode 100644 index 0000000000..79290797e4 --- /dev/null +++ b/app/xml_edit/filelist.php @@ -0,0 +1,281 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "app/xml_edit/config.php"; +require_once "app/xml_edit/header.php"; + +function isfile($filename) { + //if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function space($count) { + $r=''; $i=0; + while($i < $count) { + $r .= ' '; + $i++; + } + return $r; +} + +function recur_dir($dir) { + clearstatcache(); + $htmldirlist = ''; + $htmlfilelist = ''; + $dirlist = opendir($dir); + $dir_array = array(); + while (false !== ($file = readdir($dirlist))) { + if ($file != "." AND $file != ".."){ + $newpath = $dir.'/'.$file; + $level = explode('/',$newpath); + if (substr($newpath, -4) == ".svn") { + //ignore .svn dir and subdir + } + elseif (substr($newpath, -3) == ".db") { + //ignore .db files + } + else { + $dir_array[] = $newpath; + } + if ($x > 1000) { break; }; + $x++; + } + } + + asort($dir_array); + foreach ($dir_array as $newpath){ + $level = explode('/',$newpath); + + if (is_dir($newpath)) { + /*$mod_array[] = array( + 'level'=>count($level)-1, + 'path'=>$newpath, + 'name'=>end($level), + 'type'=>'dir', + 'mod_time'=>filemtime($newpath), + 'size'=>''); + $mod_array[] = recur_dir($newpath); + */ + $dirname = end($level); + $htmldirlist .= space(count($level))."
$dirname
\n"; + //$htmldirlist .= space(count($level))."
Tools
\n"; + //$htmldirlist .= space(count($level))."
New Folder
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
New File
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
Options
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + $htmldirlist .= recur_dir($newpath); + $htmldirlist .= space(count($level))."
\n"; + } + else { + /*$mod_array[] = array( + 'level'=>count($level)-1, + 'path'=>$newpath, + 'name'=>end($level), + 'type'=>'file', + 'mod_time'=>filemtime($newpath), + 'size'=>filesize($newpath)); + */ + $filename = end($level); + $filesize = round(filesize($newpath)/1024, 2); + $htmlfilelist .= space(count($level))."
$filename
\n"; + $htmlfilelist .= space(count($level))."
\n"; + } + } + closedir($dirlist); + return $htmldirlist ."\n". $htmlfilelist; +} + +//begin the content + echo ""; + + echo ""; + + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + //echo ""; + echo ""; + echo ""; + //echo ""; + //echo ""; + if ($menu_item_protected == "true") { + echo ""; + } + else { + echo ""; + } + echo ""; + + //echo ""; + + echo " \n"; + echo ""; + + //update the menu order + if ($row2[menu_item_order] != $tmp_menu_item_order) { + $sql = "update v_menu_items set "; + $sql .= "menu_item_title = '".$row2[menu_item_title]."', "; + $sql .= "menu_item_order = '".$tmp_menu_item_order."' "; + $sql .= "where menu_uuid = '".$menu_uuid."' "; + $sql .= "and menu_item_uuid = '".$row2[menu_item_uuid]."' "; + $count = $db->exec(check_sql($sql)); + } + $tmp_menu_item_order++; + + //check for additional sub menus + if (strlen($menu_item_uuid)> 0) { + $c = build_db_child_menu_list($db, $menu_item_level, $menu_item_uuid, $c); + } + + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result2, $row2); + } + return $c; + //end check for children +} + +require_once "includes/header.php"; +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; + + echo "
"; + echo "
\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "
Files
\n"; //display:none + //echo "
Files
\n"; //display:none + + //echo "
Tools
\n"; + //echo "
New Folder
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //echo "
\n"; + //echo "
New File
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //echo "
\n"; + //echo "
\n"; + + echo recur_dir($_SESSION['switch']['conf']['dir']); + + echo "
\n"; + + /* + echo "
Files
\n"; + echo "\n"; + echo "
Folder 1
\n"; + echo "\n"; + echo "
demo1.php
\n"; + echo "
\n"; + echo "\n"; + echo "
demo2.php
\n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "
Folder 2
\n"; + echo "\n"; + echo "
demo3.php
\n"; + echo "
\n"; + echo "\n"; + echo "
demo4.php
\n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + */ + + echo "
\n"; + echo ""; + + echo "

"; + require_once "footer.php"; + + echo ""; + echo ""; + +?> diff --git a/app/xml_edit/filenew.php b/app/xml_edit/filenew.php new file mode 100644 index 0000000000..c6d49568af --- /dev/null +++ b/app/xml_edit/filenew.php @@ -0,0 +1,90 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +$folder = str_replace ("\\", "/", $folder); +if (substr($folder, -1) != "/") { $folder = $folder.'/'; } +$file = $_GET["file"]; + +if (strlen($folder) > 0 && strlen($file) > 0) { + //create new file + $handle = fopen($folder.$file, 'wb') or die("Error!!"); + $content = ""; + fwrite($handle, $content); + fclose($handle); + + header("Location: fileoptions.php"); +} +else { + require_once "header.php"; + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Path:
".$folder.$file."
"; + + echo "
"; + + echo ""; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
File Name:
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + + require_once "footer.php"; + +} + +?> diff --git a/app/xml_edit/fileoptions.php b/app/xml_edit/fileoptions.php new file mode 100644 index 0000000000..208cff3600 --- /dev/null +++ b/app/xml_edit/fileoptions.php @@ -0,0 +1,89 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "config.php"; +require_once "header.php"; + +$file = $_GET["file"]; +$file = str_replace ("\\", "/", $file); +$folder = $_GET["folder"]; +$folder = str_replace ($file, "", $folder); + +$urlpath = str_replace ($_SERVER["DOCUMENT_ROOT"], "", $folder); + +echo "
"; +echo "\n"; +echo ""; +echo "\n"; +echo "\n"; + +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
"; + +echo ""; +echo ""; +echo "\n"; +echo "\n"; +echo ""; +echo "
Path:
File:
"; + +echo "
"; + +echo " "; + +echo ""; + +echo "
"; +echo ""; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo " \n"; +echo "





"; +echo "
"; + +echo "
"; +echo "
"; + +require_once "footer.php"; +?> diff --git a/app/xml_edit/fileoptionslist.php b/app/xml_edit/fileoptionslist.php new file mode 100644 index 0000000000..46994251ef --- /dev/null +++ b/app/xml_edit/fileoptionslist.php @@ -0,0 +1,270 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "config.php"; +require_once "header.php"; + +function isfile($filename) { + if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function space($count) { + $r=''; $i=0; + while($i < $count) { + $r .= ' '; + $i++; + } + return $r; +} + +function recur_dir($dir) { + clearstatcache(); + $htmldirlist = ''; + $htmlfilelist = ''; + $dirlist = opendir($dir); + while ($file = readdir ($dirlist)) { + if ($file != '.' && $file != '..') { + $newpath = $dir.'/'.$file; + $level = explode('/',$newpath); + + if (is_dir($newpath)) { + /*$mod_array[] = array( + 'level'=>count($level)-1, + 'path'=>$newpath, + 'name'=>end($level), + 'type'=>'dir', + 'mod_time'=>filemtime($newpath), + 'size'=>''); + $mod_array[] = recur_dir($newpath); + */ + $dirname = end($level); + $htmldirlist .= space(count($level))."
$dirname
\n"; + //$htmldirlist .= space(count($level))."
Tools
\n"; + //$htmldirlist .= space(count($level))."
New Folder
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
New File
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
\n"; + //$htmldirlist .= space(count($level))."
Options
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //$htmldirlist .= space(count($level))."
\n"; + $htmldirlist .= recur_dir($newpath); + $htmldirlist .= space(count($level))."
\n"; + + } + else { + /*$mod_array[] = array( + 'level'=>count($level)-1, + 'path'=>$newpath, + 'name'=>end($level), + 'type'=>'file', + 'mod_time'=>filemtime($newpath), + 'size'=>filesize($newpath)); + */ + $filename = end($level); + $filesize = round(filesize($newpath)/1024, 2); + $newpath = str_replace ($filename, "", $newpath); + $htmlfilelist .= space(count($level))."
$filename
\n"; + $htmlfilelist .= space(count($level))."
\n"; + } + + + } + } + + closedir($dirlist); + return $htmldirlist ."\n". $htmlfilelist; +} + +//show the content + echo "\n"; + + echo "\n"; + + echo "
"; + echo "\n"; + echo "\n"; + echo "
\n"; + //echo "
"; + + echo "\n"; + echo " \n"; + echo "\n"; + echo "
Files
\n"; //display:none + //echo "
Files
\n"; //display:none + + //echo "
Tools
\n"; + //echo "
New Folder
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //echo "
\n"; + //echo "
New File
\n"; //parent.document.getElementById('file').value='".urlencode($newpath)."' + //echo "
\n"; + //echo "
\n"; + echo recur_dir($_SESSION['switch']['conf']['dir']); + + echo "
\n"; + + /* + echo "
Files
\n"; + echo "\n"; + echo "
Folder 1
\n"; + echo "\n"; + echo "
demo1.php
\n"; + echo "
\n"; + echo "\n"; + echo "
demo2.php
\n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "
Folder 2
\n"; + echo "\n"; + echo "
demo3.php
\n"; + echo "
\n"; + echo "\n"; + echo "
demo4.php
\n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo "
\n"; + */ + + echo "
\n"; + echo ""; + + echo "

"; + require_once "footer.php"; + + echo ""; + echo ""; + +?> diff --git a/app/xml_edit/fileread.php b/app/xml_edit/fileread.php new file mode 100644 index 0000000000..3885abaded --- /dev/null +++ b/app/xml_edit/fileread.php @@ -0,0 +1,48 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +if (permission_exists('xml_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$filename = $_POST["file"]; +$filename = str_replace ("\\", "/", $filename); + +$handle = fopen($filename, "r"); +if ($handle) { + while (!feof($handle)) { + $buffer = fgets($handle, 4096); + echo $buffer; + } + fclose($handle); +} + +?> diff --git a/app/xml_edit/filerename.php b/app/xml_edit/filerename.php new file mode 100644 index 0000000000..9df4307c57 --- /dev/null +++ b/app/xml_edit/filerename.php @@ -0,0 +1,102 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +//$folder = str_replace ("\\", "/", $folder); +//if (substr($folder, -1) != "/") { $folder = $folder.'/'; } +$newfilename = $_GET["newfilename"]; +$filename = $_GET["filename"]; +//echo $folder.$file; + + +if (strlen($folder) > 0 && strlen($newfilename) > 0) { + //echo "new file: ".$newfilename."
"; + //echo "folder: ".$folder."
"; + //echo "orig filename: ".$filename."
";; + rename($folder.$filename, $folder.$newfilename); + header("Location: fileoptions.php"); +} +else { //display form + + require_once "header.php"; + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Path:
".$folder.$filename."

Original file name:
".$filename."
"; + + echo "
"; + + echo ""; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
Rename file to:
"; + echo " "; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + + require_once "footer.php"; + +} + +?> diff --git a/app/xml_edit/filesave.php b/app/xml_edit/filesave.php new file mode 100644 index 0000000000..0d19eaab53 --- /dev/null +++ b/app/xml_edit/filesave.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$filename = $_POST["file"]; //filename with the path +$filename = str_replace ("\\", "/", $filename); +$content = $_POST["content"]; + +$handle = fopen($filename, 'wb') or die("Error!!"); +fwrite($handle, $content); +fclose($handle); + +//set the reload_xml value to true + $_SESSION["reload_xml"] = true; + +echo $content; + +?> diff --git a/app/xml_edit/folderdelete.php b/app/xml_edit/folderdelete.php new file mode 100644 index 0000000000..97c2592ea8 --- /dev/null +++ b/app/xml_edit/folderdelete.php @@ -0,0 +1,46 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$folder = $_GET["folder"]; +$folder = str_replace ("\\", "/", $folder); + +if (strlen($folder) > 0) { + //delete the folder + rmdir($folder); //, 0700 + header("Location: fileoptions.php"); +} + +?> \ No newline at end of file diff --git a/app/xml_edit/foldernew.php b/app/xml_edit/foldernew.php new file mode 100644 index 0000000000..922d8eb5a2 --- /dev/null +++ b/app/xml_edit/foldernew.php @@ -0,0 +1,86 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_save')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "config.php"; + +$folder = $_GET["folder"]; +$folder = str_replace ("\\", "/", $folder); +$foldername = $_GET["foldername"]; + +if (strlen($folder) > 0 && strlen($foldername) > 0) { + //create new folder + mkdir($folder.'/'.$foldername); //, 0700 + header("Location: fileoptions.php"); +} +else { //display form + + require_once "header.php"; + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Path:
".$folder."
"; + + echo "
"; + + echo ""; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo "
Folder Name:
"; + echo " "; + echo " "; + echo "
"; + echo "
"; + echo "
"; + + require_once "footer.php"; +} + +?> diff --git a/app/xml_edit/footer.php b/app/xml_edit/footer.php new file mode 100644 index 0000000000..b11f46e5d4 --- /dev/null +++ b/app/xml_edit/footer.php @@ -0,0 +1,43 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +/* +echo "

"; +echo "
"; + +echo ""; +echo "fusionpbx "; +echo "        "; +echo "http://fusionpbx.com"; +echo "        "; +echo "Author: Mark J. Crane "; + +echo ""; +*/ +echo "
"; +echo ""; +echo ""; + +?> \ No newline at end of file diff --git a/app/xml_edit/header.php b/app/xml_edit/header.php new file mode 100644 index 0000000000..bd10f557d3 --- /dev/null +++ b/app/xml_edit/header.php @@ -0,0 +1,83 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +echo ""; +echo ""; +echo ""; +//echo ""; +echo ""; + + +echo ""; +echo ""; +echo ""; +echo "
"; + +?> \ No newline at end of file diff --git a/app/xml_edit/images/Thumbs.db b/app/xml_edit/images/Thumbs.db new file mode 100644 index 0000000000..46593a8c2e Binary files /dev/null and b/app/xml_edit/images/Thumbs.db differ diff --git a/app/xml_edit/images/file.gif b/app/xml_edit/images/file.gif new file mode 100644 index 0000000000..a6cf9845fc Binary files /dev/null and b/app/xml_edit/images/file.gif differ diff --git a/app/xml_edit/images/file.png b/app/xml_edit/images/file.png new file mode 100644 index 0000000000..33b5f5f374 Binary files /dev/null and b/app/xml_edit/images/file.png differ diff --git a/app/xml_edit/images/folder.gif b/app/xml_edit/images/folder.gif new file mode 100644 index 0000000000..50ab253cc7 Binary files /dev/null and b/app/xml_edit/images/folder.gif differ diff --git a/app/xml_edit/images/gear.png b/app/xml_edit/images/gear.png new file mode 100644 index 0000000000..1adf1e778f Binary files /dev/null and b/app/xml_edit/images/gear.png differ diff --git a/app/xml_edit/images/leaf.gif b/app/xml_edit/images/leaf.gif new file mode 100644 index 0000000000..50ab253cc7 Binary files /dev/null and b/app/xml_edit/images/leaf.gif differ diff --git a/app/xml_edit/images/minus.gif b/app/xml_edit/images/minus.gif new file mode 100644 index 0000000000..1094ab912b Binary files /dev/null and b/app/xml_edit/images/minus.gif differ diff --git a/app/xml_edit/images/plus.gif b/app/xml_edit/images/plus.gif new file mode 100644 index 0000000000..fdacf8efe5 Binary files /dev/null and b/app/xml_edit/images/plus.gif differ diff --git a/app/xml_edit/images/program.gif b/app/xml_edit/images/program.gif new file mode 100644 index 0000000000..dc3dfa1104 Binary files /dev/null and b/app/xml_edit/images/program.gif differ diff --git a/app/xml_edit/images/thumbnails/Thumbs.db b/app/xml_edit/images/thumbnails/Thumbs.db new file mode 100644 index 0000000000..c4e4684b24 Binary files /dev/null and b/app/xml_edit/images/thumbnails/Thumbs.db differ diff --git a/app/xml_edit/images/thumbnails/cliplibrary.png b/app/xml_edit/images/thumbnails/cliplibrary.png new file mode 100644 index 0000000000..bc70f332fd Binary files /dev/null and b/app/xml_edit/images/thumbnails/cliplibrary.png differ diff --git a/app/xml_edit/images/thumbnails/filemanagement.png b/app/xml_edit/images/thumbnails/filemanagement.png new file mode 100644 index 0000000000..88cb7661b1 Binary files /dev/null and b/app/xml_edit/images/thumbnails/filemanagement.png differ diff --git a/app/xml_edit/images/thumbnails/phpeditor.png b/app/xml_edit/images/thumbnails/phpeditor.png new file mode 100644 index 0000000000..c6f7f369bb Binary files /dev/null and b/app/xml_edit/images/thumbnails/phpeditor.png differ diff --git a/app/xml_edit/index.php b/app/xml_edit/index.php new file mode 100644 index 0000000000..83235c975b --- /dev/null +++ b/app/xml_edit/index.php @@ -0,0 +1,201 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +require_once "app/xml_edit/config.php"; +echo "\n"; +echo "\n"; +echo " \n"; +echo " "; + + echo "\n"; + + echo ""; + ?> + + + + + + + + + +
+ + + \n"; + echo "\n"; + } + else { + echo "\n"; + } + ?> + +
+ + + \ No newline at end of file diff --git a/app/xml_edit/list.php b/app/xml_edit/list.php new file mode 100644 index 0000000000..87a80f3128 --- /dev/null +++ b/app/xml_edit/list.php @@ -0,0 +1,113 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xml_editor_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "header.php"; + +//show the content + echo "
"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + + } //end if results + + echo "
\n"; + echo "
"; + + $sql = ""; + $sql .= "select * from v_clip_library "; + + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + $c = 0; + $row_style["0"] = "background-color: #F5F5DC;"; + $row_style["1"] = "background-color: #FFFFFF;"; + + echo "
\n"; + echo "\n"; + echo ""; + + if ($result_count == 0) { //no results + echo ""; + } + else { //received results + + echo ""; + //echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + echo "\n"; + + foreach($result as $row) { + //print_r( $row ); + echo "\n"; + //echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + //echo ""; + echo ""; + + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + + echo "
 
    Id      clip_name      clip_folder        clip_text_start        clip_text_end        clip_desc        clip_order   
".$row[id]."".$row[clip_name]."".$row[clip_folder]."".$row[clip_text_start]."".$row[clip_text_end]."".$row[clip_desc]."".$row[clip_order]."
\n"; + echo "
\n"; + + echo "
\n"; + + echo "
\n"; + echo "   \n"; + echo "   \n"; + echo "
\n"; + echo ""; + + echo "

"; + require_once "footer.php"; + +?> diff --git a/app/xml_edit/readme.txt b/app/xml_edit/readme.txt new file mode 100644 index 0000000000..cafc4144ae --- /dev/null +++ b/app/xml_edit/readme.txt @@ -0,0 +1,7 @@ +Notes + +IFrame +http://www.quirksmode.org/js/iframe.html + +Tree View +http://www.dddekerf.dds.nl/DHTML_Treeview/DHTML_Treeview.htm \ No newline at end of file diff --git a/app/xml_edit/root.php b/app/xml_edit/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/xml_edit/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/app/xmpp/README b/app/xmpp/README new file mode 100644 index 0000000000..c8629b0513 --- /dev/null +++ b/app/xmpp/README @@ -0,0 +1,3 @@ +This Module brought to you by the Letters Ken Rice + +See the Wiki for more information. diff --git a/app/xmpp/app_config.php b/app/xmpp/app_config.php new file mode 100644 index 0000000000..f87d8c434a --- /dev/null +++ b/app/xmpp/app_config.php @@ -0,0 +1,142 @@ + \ No newline at end of file diff --git a/app/xmpp/client_template.php b/app/xmpp/client_template.php new file mode 100644 index 0000000000..1e5427938a --- /dev/null +++ b/app/xmpp/client_template.php @@ -0,0 +1,53 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Ken Rice + Mark J Crane +*/ +function make_xmpp_xml($input) { + $xml_out .= "\n"; + $xml_out .= " \n"; + $xml_out .= sprintf(" \n", $input['profile_name']); + $xml_out .= sprintf(" \n", $input['profile_username']); + $xml_out .= sprintf(" \n", $input['profile_password']); + $xml_out .= sprintf(" \n", $input['dialplan']); + $xml_out .= sprintf(" \n", $input['context']); + $xml_out .= " \n"; + $xml_out .= sprintf(" \n", $input['rtp_ip']); + $xml_out .= sprintf(" \n", $input['ext_rtp_ip']); + $xml_out .= sprintf(" \n", $input['auto_login']); + $xml_out .= sprintf(" \n", $input['sasl_type']); + $xml_out .= sprintf(" \n", $input['xmpp_server']); + $xml_out .= sprintf(" \n", $input['tls_enable']); + $xml_out .= sprintf(" \n", $input['use_rtp_timer']); + $xml_out .= sprintf(" \n", $input['default_exten']); + $xml_out .= sprintf(" \n", $input['vad']); + $xml_out .= sprintf(" \n", $input['candidate_acl']); + $xml_out .= sprintf(" \n", $input['local_network_acl']); + $xml_out .= " \n"; + $xml_out .= "\n"; + + return $xml_out; +} + +?> \ No newline at end of file diff --git a/app/xmpp/db_create.php b/app/xmpp/db_create.php new file mode 100644 index 0000000000..d2bb5f24ff --- /dev/null +++ b/app/xmpp/db_create.php @@ -0,0 +1,51 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Ken Rice + Mark J Crane +*/ +function sql_tables($db_type) { + $x = 0; + + include "app_config.php"; + $sql = ""; + + foreach ($apps[$x]['db'] as $new_db) { + $sql .= "CREATE TABLE " . $new_db['table'] . " (\n"; + $fcount = 0; + foreach ($new_db['fields'] as $field) { + if ($fcount > 0 ) { $sql .= ",\n"; } + $sql .= $field['name'] . " "; + if (is_array($field['type'])) { + $sql .= $field['type'][$db_type]; + } else { + $sql .= $field['type']; + } + $fcount++; + } + $sql .= ");\n\n"; + } + + return $sql; +} +?> diff --git a/app/xmpp/errors.php b/app/xmpp/errors.php new file mode 100644 index 0000000000..95bc3d96c2 --- /dev/null +++ b/app/xmpp/errors.php @@ -0,0 +1,31 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Ken Rice + Mark J Crane +*/ +echo "
\n"; +echo "
\n"; +echo $error . "\n"; +echo "
\n"; +?> diff --git a/app/xmpp/profile_edit.php b/app/xmpp/profile_edit.php new file mode 100644 index 0000000000..c3057ee3d9 --- /dev/null +++ b/app/xmpp/profile_edit.php @@ -0,0 +1,286 @@ + + +
+ + + + +
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
+ Profile Edit
+
+ + + +
+ Defines a connections to a Jabber, GTalk, or other XMPP Provider server.
+
+
+
+ Profile Name: + + +
+ Enter the profile name here. +
+ Username: + + +
+ Enter the XMPP username here. +
+ Password: + + +
+ Enter the password here. +
+ Auto-Login: + + +
+ Choose whether to automatically login. +
+ XMPP Server: + + +
+ Enter alternate XMPP server if the server is not the same as the one in the Username
+ Example GoogleTalk is: xmpp-server1.l.google.com +
+ Default Extension: + + +
+ Default extension (if one cannot be determined) +
+
+ + + + + +
Show Advanced + +
+
+ +
+ Enabled: + + +
+
+ Profile Description: + + '> +
+ Enter the description of the Profile here. +
+ '> + +
+ + +
+
diff --git a/app/xmpp/profile_list.php b/app/xmpp/profile_list.php new file mode 100644 index 0000000000..b576cf9afe --- /dev/null +++ b/app/xmpp/profile_list.php @@ -0,0 +1,61 @@ +
+ + + + + +
XMPP Manager
+ Utilizes the Jingle protocol. Jingle is an extension to the Jabber/XMPP protocol. +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
ProfileContextStatusEnabledDescription + + + +
      + + ' alt='edit'> + + + ' onclick="return confirm('Do you really want to delete this?')" + alt='delete'> + +
+ + + +
+
diff --git a/app/xmpp/root.php b/app/xmpp/root.php new file mode 100644 index 0000000000..3d662fd043 --- /dev/null +++ b/app/xmpp/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> diff --git a/app/xmpp/update_complete.php b/app/xmpp/update_complete.php new file mode 100644 index 0000000000..525d591aa4 --- /dev/null +++ b/app/xmpp/update_complete.php @@ -0,0 +1,11 @@ + +
+ +
diff --git a/app/xmpp/v_profile_delete.php b/app/xmpp/v_profile_delete.php new file mode 100644 index 0000000000..5de0fc7d33 --- /dev/null +++ b/app/xmpp/v_profile_delete.php @@ -0,0 +1,95 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Ken Rice + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xmpp_delete')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +require_once "includes/header.php"; + +$domain_name = $_SESSION['domains'][$domain_uuid]['domain_name']; + +$profile_id = $_REQUEST['id']; + +$sql = ""; +$sql .= "select * from v_xmpp "; +$sql .= "where domain_uuid = '$domain_uuid' "; +$sql .= "and xmpp_profile_uuid = '$profile_id' "; +$prep_statement = $db->prepare(check_sql($sql)); +$prep_statement->execute(); + +$x = 0; +$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); +foreach ($result as &$row) { + $profiles_array[$x] = $row; + $x++; +} + +$profile = $profiles_array[0]; +unset ($prep_statement); + +$sql = ""; +$sql .= "delete from v_xmpp "; +$sql .= "where domain_uuid = '$domain_uuid' "; +$sql .= "and xmpp_profile_uuid = '$profile_id' "; +$db->exec(check_sql($sql)); + +$filename = $_SESSION['switch']['conf']['dir'] . "/jingle_profiles/" . "v_" . $domain_name . "_" . + preg_replace("/[^A-Za-z0-9]/", "", $profile['profile_name']) . "_" . $profile_id . ".xml"; + +unlink($filename); + +$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); +if ($fp) { + //reload the XML Configs + $tmp_cmd = 'api reloadxml'; + $response = event_socket_request($fp, $tmp_cmd); + unset($tmp_cmd); + + //tell mod_dingaling to reload is config + $tmp_cmd = 'api dingaling reload'; + $response = event_socket_request($fp, $tmp_cmd); + unset($tmp_cmd); + + //close the connection + fclose($fp); +} + +include "update_complete.php"; + +end: +//show the footer +require_once "includes/footer.php"; + +?> diff --git a/app/xmpp/v_profile_edit.php b/app/xmpp/v_profile_edit.php new file mode 100644 index 0000000000..1b4a478fcc --- /dev/null +++ b/app/xmpp/v_profile_edit.php @@ -0,0 +1,245 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Ken Rice + Mark J Crane +*/ + +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; + +if (permission_exists('xmpp_add') || permission_exists('xmpp_edit')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +require_once "includes/header.php"; + +$domain_name = $_SESSION['domains'][$_SESSION['domain_uuid']]['domain_name']; + +//add or update the database +if (isset($_REQUEST["id"])) { + $action = "update"; + $profile_id = check_str($_REQUEST["id"]); +} else { + $action = "add"; +} + +if ($action == "update") { + $sql = ""; + $sql .= "select * from v_xmpp "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and xmpp_profile_uuid = '$profile_id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + + $x = 0; + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $profiles_array[$x] = $row; + $x++; + } + + $profile = $profiles_array[0]; + unset ($prep_statement); + $profile['profile_username'] = $profile['username']; + $profile['profile_password'] = $profile['password']; +} else { + $profile['dialplan'] = "XML"; + $profile['context'] = $_SESSION['domain_name']; + $profile['rtp_ip'] = '$${local_ip_v4}'; + $profile['ext_rtp_ip'] = '$${external_rtp_ip}'; + $profile['auto_login'] = "true"; + $profile['sasl_type'] = "md5"; + $profile['tls_enable'] = "true"; + $profile['usr_rtp_timer'] = "true"; + $profile['vad'] = "none"; + $profile['candidate_acl'] = "wan.auto"; + $profile['local_network_acl'] = "localnet.auto"; +} + +if ((!isset($_REQUEST['submit'])) || ($_REQUEST['submit'] != 'Save')) { + // If we arent saving a Profile Display the form. + include "profile_edit.php"; + goto end; +} + +foreach ($_REQUEST as $field => $data){ + $request[$field] = check_str($data); +} + +// check the data +$error = ""; +if (strlen($request['profile_name']) < 1) $error .= "Profile name is a Required Field
\n"; +if (strlen($request['profile_username']) < 1) $error .= "Username is a Required Field
\n"; +if (strlen($request['profile_password']) < 1) $error .= "Password is a Required Field
\n"; +if (strlen($request['default_exten']) < 1) $error .= "Default Extension is a Required Field
\n"; +if (strlen($error) > 0) { + include "errors.php"; + $profile = $request; + include "profile_edit.php"; + goto end; +} + +// Save New Entry +if ($action == "add" && permission_exists('xmpp_add')) { + $xmpp_profile_uuid = uuid(); + $sql = ""; + $sql .= "insert into v_xmpp ("; + $sql .= "domain_uuid, "; + $sql .= "xmpp_profile_uuid, "; + $sql .= "profile_name, "; + $sql .= "username, "; + $sql .= "password, "; + $sql .= "dialplan, "; + $sql .= "context, "; + $sql .= "rtp_ip, "; + $sql .= "ext_rtp_ip, "; + $sql .= "auto_login, "; + $sql .= "sasl_type, "; + $sql .= "xmpp_server, "; + $sql .= "tls_enable, "; + $sql .= "usr_rtp_timer, "; + $sql .= "default_exten, "; + $sql .= "vad, "; + $sql .= "avatar, "; + $sql .= "candidate_acl, "; + $sql .= "local_network_acl, "; + $sql .= "description, "; + $sql .= "enabled "; + $sql .= ") values ("; + $sql .= "'" . $_SESSION['domain_uuid'] . "', "; + $sql .= "'" . $xmpp_profile_uuid . "', "; + $sql .= "'" . $request['profile_name'] . "', "; + $sql .= "'" . $request['profile_username'] . "', "; + $sql .= "'" . $request['profile_password'] . "', "; + $sql .= "'" . $request['dialplan'] . "', "; + if (if_group("superadmin") && $request['context']) { + $sql .= "'" . $request['context'] . "', "; + } + else { + $sql .= "'" . $_SESSION['context'] . "', "; + } + $sql .= "'" . $request['rtp_ip'] . "', "; + $sql .= "'" . $request['ext_rtp_ip'] . "', "; + $sql .= "'" . $request['auto_login'] . "', "; + $sql .= "'" . $request['sasl_type'] . "', "; + $sql .= "'" . $request['xmpp_server'] . "', "; + $sql .= "'" . $request['tls_enable'] . "', "; + $sql .= "'" . $request['usr_rtp_timer'] . "', "; + $sql .= "'" . $request['default_exten'] . "', "; + $sql .= "'" . $request['vad'] . "', "; + $sql .= "'" . $request['avatar'] . "', "; + $sql .= "'" . $request['candidate_acl'] . "', "; + $sql .= "'" . $request['local_network_acl'] . "', "; + $sql .= "'" . $request['description'] . "', "; + $sql .= "'" . $request['enabled'] . "' "; + $sql .= ") "; + $db->exec(check_sql($sql)); + + goto writeout; +} +elseif ($action == "update" && permission_exists('xmpp_edit')) { + $sql = ""; + $sql .= "UPDATE v_xmpp SET "; + $sql .= "profile_name = '" . $request['profile_name'] . "', "; + $sql .= "username = '" . $request['profile_username'] . "', "; + $sql .= "password = '" . $request['profile_password'] . "', "; + $sql .= "dialplan = '" . $request['dialplan'] . "', "; + if (if_group("superadmin") && $request['context']) { + $sql .= "context = '" . $request['context'] . "', "; + } + else { + $sql .= "context = '" . $_SESSION["context"] . "', "; + } + $sql .= "rtp_ip = '" . $request['rtp_ip'] . "', "; + $sql .= "ext_rtp_ip = '" . $request['ext_rtp_ip'] . "', "; + $sql .= "auto_login = '" . $request['auto_login'] . "', "; + $sql .= "sasl_type = '" . $request['sasl_type'] . "', "; + $sql .= "xmpp_server = '" . $request['xmpp_server'] . "', "; + $sql .= "tls_enable = '" . $request['tls_enable'] . "', "; + $sql .= "usr_rtp_timer = '" . $request['usr_rtp_timer'] . "', "; + $sql .= "default_exten = '" . $request['default_exten'] . "', "; + $sql .= "vad = '" . $request['vad'] . "', "; + $sql .= "avatar = '" . $request['avatar'] . "', "; + $sql .= "candidate_acl = '" . $request['candidate_acl'] . "', "; + $sql .= "local_network_acl = '" . $request['local_network_acl'] . "', "; + $sql .= "description = '" . $request['description'] . "', "; + $sql .= "enabled = '" . $request['enabled'] . "' "; + $sql .= "where xmpp_profile_uuid = '" . $request['id'] . "' "; + $db->exec(check_sql($sql)); + $xmpp_profile_uuid = $request['id']; + + goto writeout; +} + +writeout: + +//prepare the xmpp files to be written. delete all jingle files that are prefixed with v_ and have a file extension of .xml +$jingle_list = glob($_SESSION['switch']['conf']['dir'] . "/jingle_profiles/*v_*.xml"); +foreach($jingle_list as $name => $value) { + unlink($value); +} + + +if ($request['enabled'] == "true") { + //prepare the xml + include "client_template.php"; + $xml = make_xmpp_xml($request); + + //write the xml + $filename = $_SESSION['switch']['conf']['dir'] . "/jingle_profiles/" . "v_" . $_SESSION['domain_name'] . "_" . preg_replace("/[^A-Za-z0-9]/", "", $request['profile_name']) . "_" . $xmpp_profile_uuid . ".xml"; + $fh = fopen($filename,"w") or die("Unable to open the file"); + fwrite($fh, $xml); + unset($file_name); + fclose($fh); +} + +$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); +if ($fp) { + //reload the XML Configs + $tmp_cmd = 'api reloadxml'; + $response = event_socket_request($fp, $tmp_cmd); + unset($tmp_cmd); + + //Tell mod_dingaling to reload is config + $tmp_cmd = 'api dingaling reload'; + $response = event_socket_request($fp, $tmp_cmd); + unset($tmp_cmd); + + //close the connection + fclose($fp); +} + +include "update_complete.php"; + +end: +//show the footer +require_once "includes/footer.php"; + +?> \ No newline at end of file diff --git a/app/xmpp/v_xmpp.php b/app/xmpp/v_xmpp.php new file mode 100644 index 0000000000..6f384fde3e --- /dev/null +++ b/app/xmpp/v_xmpp.php @@ -0,0 +1,95 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Ken Rice + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('xmpp_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//connect to event socket +$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + +if ($fp) { + if (strlen($_GET["a"]) > 0) { + if ($_GET["a"] == "reload") { + $cmd = 'api dingaling reload'; + $response = trim(event_socket_request($fp, $cmd)); + $msg = 'Reload:
'.$response.'
'; + } + } + + if (!function_exists('switch_dingaling_status')) { + function switch_dingaling_status($profile_username, $result_type = 'xml') { + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + $cmd = 'api dingaling status'; + $response = trim(event_socket_request($fp, $cmd)); + $response = explode("\n", $response); + + $x = 0; + foreach ($response as $row) { + if ($x > 1) { + $dingaling = explode("|", $row); + if ($profile_username == trim($dingaling[0])) { + return trim($dingaling[1]); + } + } + $x++; + } + } + } +} + +//get a list of assigned extensions for this user +$sql = ""; +$sql .= "select * from v_xmpp "; +$sql .= "where domain_uuid = '$domain_uuid' "; +$prep_statement = $db->prepare(check_sql($sql)); +$prep_statement->execute(); +$x = 0; +$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); +foreach ($result as &$row) { + $profiles_array[$x] = $row; + $profiles_array[$x]['status'] = switch_dingaling_status($row['username'].'/talk'); + $x++; +} +unset ($prep_statement); + +//include the view +include "profile_list.php"; + +//include the footer +require_once "includes/footer.php"; + +?> \ No newline at end of file diff --git a/core/apps/app_config.php b/core/apps/app_config.php new file mode 100644 index 0000000000..6a0c15ce04 --- /dev/null +++ b/core/apps/app_config.php @@ -0,0 +1,46 @@ + \ No newline at end of file diff --git a/core/apps/apps.php b/core/apps/apps.php new file mode 100644 index 0000000000..53cd7137d7 --- /dev/null +++ b/core/apps/apps.php @@ -0,0 +1,118 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get variables used to control the order + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//get the list of installed apps from the core and mod directories + $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php"); + $x=0; + foreach ($config_list as $config_path) { + include($config_path); + $x++; + } + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
App Manager 
\n"; + echo " Manage the applications that are installed.

\n"; + echo "
\n"; + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + //echo "\n"; + echo "\n"; + + foreach($apps as $row) { + if ($row['uuid'] != "d8704214-75a0-e52f-1336-f0780e29fef8") { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + } + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + + echo "
NameCategorySubcategoryVersionDescription\n"; + //echo " $v_link_label_add\n"; + //echo "
".$row['name']." ".$row['category']." ".$row['subcategory']." ".$row['version']." ".$row['description']['en']." \n"; + echo "  $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/core/apps/apps_delete.php b/core/apps/apps_delete.php new file mode 100644 index 0000000000..b70ddce40d --- /dev/null +++ b/core/apps/apps_delete.php @@ -0,0 +1,95 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET) > 0) { + $id = check_str($_GET["id"]); +} + +if (strlen($id)>0) { + + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $app_uuid = $_GET["id"]; + //get the list of installed apps from the core and mod directories + $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php"); + $x=0; + foreach ($config_list as $config_path) { + include($config_path); + $x++; + } + //find the app using the $app_uuid + foreach ($apps as &$row) { + if ($row["uuid"] == $app_uuid) { + $name = $row['name']; + if ($row["uuid"] == $app_uuid && $row['category'] != "Core") { + //delete the app from the menu + foreach ($row['menu'] as &$menu) { + //delete menu groups and permissions from the database + $sql = "delete from v_menu_item_groups "; + $sql .= "where menu_item_uuid = '".$menu['uuid']."' "; + $db->query($sql); + + $sql = "delete from v_menu_items "; + $sql .= "where menu_item_uuid = '".$menu['uuid']."' "; + $db->query($sql); + + //delete the app from the file system + if (strlen($menu['path']) > 0) { + system('rm -rf '.dirname($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.$menu['path'])); + } + } + + //delete the group permissions for the app + foreach ($row['permissions'] as &$permission) { + $sql = "delete from v_group_permissions "; + $sql .= "where permission_name = '".$permission['name']."' "; + $db->query($sql); + } + } + } + } + } +} + +//redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/core/apps/apps_edit.php b/core/apps/apps_edit.php new file mode 100644 index 0000000000..78fecf64a7 --- /dev/null +++ b/core/apps/apps_edit.php @@ -0,0 +1,215 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $app_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $app_enabled = check_str($_POST["app_enabled"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $app_uuid = check_str($_POST["app_uuid"]); + } + + //check for all required data + //if (strlen($app_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $sql = "insert into v_apps "; + $sql .= "("; + $sql .= "app_uuid "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."' "; + $sql .= ")"; + //$db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_apps set "; + $sql .= "app_uuid = '$app_uuid' "; + $sql .= "where app_uuid = '$app_uuid'"; + //$db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//show the header + require_once "includes/header.php"; + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $app_uuid = $_GET["id"]; + //get the list of installed apps from the core and mod directories + $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php"); + $x=0; + foreach ($config_list as $config_path) { + include($config_path); + $x++; + } + foreach ($apps as &$row) { + if ($row["uuid"] == $app_uuid) { + $name = $row['name']; + $category = $row['category']; + $subcategory = $row['subcategory']; + $version = $row['version']; + $description = $row['description']['en']; + } + } + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " "; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " "; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " "; + + echo " \n"; + echo " \n"; + echo " \n"; + echo " "; + + echo " \n"; + echo " \n"; + echo " "; + echo "
$name
\n"; + echo "Manage the applications that are installed.

\n"; + echo "
\n"; + echo " Category:\n"; + echo " \n"; + echo " $category  \n"; + echo "
\n"; + echo " Subcategory:\n"; + echo " \n"; + echo " $subcategory  \n"; + echo "
\n"; + echo " Version:\n"; + echo " \n"; + echo " $version  \n"; + echo "
\n"; + echo " Description:\n"; + echo " \n"; + echo " $description  \n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/core/apps/root.php b/core/apps/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/core/apps/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/core/backup/backup.php b/core/backup/backup.php new file mode 100644 index 0000000000..541e9b35be --- /dev/null +++ b/core/backup/backup.php @@ -0,0 +1,45 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; + +if (if_group("superadmin")) { + + $fh = fopen($db_file_path.'/'.$dbfilename, 'r+b'); + $contents = fread($fh, filesize($db_file_path.'/'.$dbfilename)); + + header("Content-disposition: attachment; filename=$dbfilename"); + header("Content-Type: application/force-download"); + header("Content-Transfer-Encoding: binary"); + header("Content-Length: ".strlen($contents)); + header("Pragma: no-cache"); + header("Expires: 0"); + + echo $contents; +} + +?> diff --git a/core/backup/backupandrestore.php b/core/backup/backupandrestore.php new file mode 100644 index 0000000000..d9e8f4e320 --- /dev/null +++ b/core/backup/backupandrestore.php @@ -0,0 +1,87 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; + +if (if_group("superadmin")) { + + echo "\n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + echo "
Backup
\n"; + echo " download \n"; + echo " \n"; + echo "
\n"; + echo "To backup your application click on the download link and then choose \n"; + echo "a safe location on your computer to save the file. You may want to \n"; + echo "save the backup to more than one computer to prevent the backup from being lost. \n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo "\n"; + + echo "
\n"; + echo "
"; + echo "

"; + + /* + echo "Restore Application
\n"; + echo "
\n"; + //Browse to Backup File + echo "Click on 'Browse' then locate and select the application backup file named '.bak'. \n"; + echo "Then click on 'Restore.' \n"; + echo "

"; + + echo "
"; + echo "
"; + echo " "; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " "; + echo " "; + echo " "; + echo "
"; + echo " \n"; + echo " \n"; + echo "
"; + echo "
\n"; + echo "
\n"; + echo "
"; + + echo "
"; + */ + + } + +?> diff --git a/core/backup/root.php b/core/backup/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/core/backup/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/core/databases/app_config.php b/core/databases/app_config.php new file mode 100644 index 0000000000..71da3e3035 --- /dev/null +++ b/core/databases/app_config.php @@ -0,0 +1,97 @@ + \ No newline at end of file diff --git a/core/databases/database_delete.php b/core/databases/database_delete.php new file mode 100644 index 0000000000..d1c14d54ea --- /dev/null +++ b/core/databases/database_delete.php @@ -0,0 +1,58 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); +} + +if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_databases "; + $sql .= "where database_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); +} + +require_once "includes/header.php"; +echo "\n"; +echo "
\n"; +echo "Delete Complete\n"; +echo "
\n"; +require_once "includes/footer.php"; +return; + +?> \ No newline at end of file diff --git a/core/databases/database_edit.php b/core/databases/database_edit.php new file mode 100644 index 0000000000..6499ef7844 --- /dev/null +++ b/core/databases/database_edit.php @@ -0,0 +1,346 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $database_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//clear the values + $database_type = ''; + $database_host = ''; + $database_port = ''; + $database_name = ''; + $database_username = ''; + $database_password = ''; + $database_path = ''; + $database_description = ''; + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $database_type = check_str($_POST["database_type"]); + $database_host = check_str($_POST["database_host"]); + $database_port = check_str($_POST["database_port"]); + $database_name = check_str($_POST["database_name"]); + $database_username = check_str($_POST["database_username"]); + $database_password = check_str($_POST["database_password"]); + $database_path = check_str($_POST["database_path"]); + $database_description = check_str($_POST["database_description"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $database_uuid = check_str($_POST["database_uuid"]); + } + + //check for all required data + //if (strlen($database_type) == 0) { $msg .= "Please provide: Type
\n"; } + //if (strlen($database_host) == 0) { $msg .= "Please provide: Host
\n"; } + //if (strlen($database_port) == 0) { $msg .= "Please provide: Port
\n"; } + //if (strlen($database_name) == 0) { $msg .= "Please provide: Name
\n"; } + //if (strlen($database_username) == 0) { $msg .= "Please provide: Username
\n"; } + //if (strlen($database_password) == 0) { $msg .= "Please provide: Password
\n"; } + //if (strlen($database_path) == 0) { $msg .= "Please provide: Path
\n"; } + //if (strlen($database_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $database_uuid = uuid(); + $sql = "insert into v_databases "; + $sql .= "("; + //$sql .= "domain_uuid, "; + $sql .= "database_uuid, "; + $sql .= "database_type, "; + $sql .= "database_host, "; + $sql .= "database_port, "; + $sql .= "database_name, "; + $sql .= "database_username, "; + $sql .= "database_password, "; + $sql .= "database_path, "; + $sql .= "database_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + //$sql .= "'$domain_uuid', "; + $sql .= "'$database_uuid', "; + $sql .= "'$database_type', "; + $sql .= "'$database_host', "; + $sql .= "'$database_port', "; + $sql .= "'$database_name', "; + $sql .= "'$database_username', "; + $sql .= "'$database_password', "; + $sql .= "'$database_path', "; + $sql .= "'$database_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_databases set "; + $sql .= "database_type = '$database_type', "; + $sql .= "database_host = '$database_host', "; + $sql .= "database_port = '$database_port', "; + $sql .= "database_name = '$database_name', "; + $sql .= "database_username = '$database_username', "; + $sql .= "database_password = '$database_password', "; + $sql .= "database_path = '$database_path', "; + $sql .= "database_description = '$database_description' "; + $sql .= "where database_uuid = '$database_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $database_uuid = $_GET["id"]; + $sql = "select * from v_databases "; + $sql .= "where database_uuid = '$database_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $database_type = $row["database_type"]; + $database_host = $row["database_host"]; + $database_port = $row["database_port"]; + $database_name = $row["database_name"]; + $database_username = $row["database_username"]; + $database_password = $row["database_password"]; + $database_path = $row["database_path"]; + $database_description = $row["database_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Database AddDatabase Edit
\n"; + echo "Database connection information.

\n"; + echo "
\n"; + echo " Type:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Select the database type.\n"; + echo "
\n"; + echo " Host:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the host name.\n"; + echo "
\n"; + echo " Port:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the port number.\n"; + echo "
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the database name.\n"; + echo "
\n"; + echo " Username:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the database username.\n"; + echo "
\n"; + echo " Password:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the database password.\n"; + echo "
\n"; + echo " Path:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the database file path.\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the description.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/core/databases/databases.php b/core/databases/databases.php new file mode 100644 index 0000000000..2f21ab9988 --- /dev/null +++ b/core/databases/databases.php @@ -0,0 +1,162 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get variables used to control the order + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Databases 
\n"; + echo " Database information.

\n"; + echo "
\n"; + + //prepare to page the results + $sql = " select count(*) as num_rows from v_databases "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + + //prepare to page the results + $rows_per_page = 150; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + //get the list + $sql = " select * from v_databases "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo th_order_by('database_type', 'Type', $order_by, $order); + echo th_order_by('database_host', 'Host', $order_by, $order); + //echo th_order_by('database_port', 'Port', $order_by, $order); + echo th_order_by('database_name', 'Name', $order_by, $order); + //echo th_order_by('database_username', 'Username', $order_by, $order); + //echo th_order_by('database_path', 'Path', $order_by, $order); + echo th_order_by('database_description', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo " $v_link_label_add\n"; + echo "
".$row['database_type']." ".$row['database_host']." ".$row['database_port']." ".$row['database_name']." ".$row['database_username']." ".$row['database_path']." ".$row['database_description']." \n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/core/databases/root.php b/core/databases/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/core/databases/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/core/default_settings/app_config.php b/core/default_settings/app_config.php new file mode 100644 index 0000000000..dc3e5a76fd --- /dev/null +++ b/core/default_settings/app_config.php @@ -0,0 +1,65 @@ + \ No newline at end of file diff --git a/core/default_settings/app_defaults.php b/core/default_settings/app_defaults.php new file mode 100644 index 0000000000..a05620f994 --- /dev/null +++ b/core/default_settings/app_defaults.php @@ -0,0 +1,29 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2010 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + + + +?> \ No newline at end of file diff --git a/core/default_settings/default_settings.php b/core/default_settings/default_settings.php new file mode 100644 index 0000000000..d934cd8165 --- /dev/null +++ b/core/default_settings/default_settings.php @@ -0,0 +1,190 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get variables used to control the order + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Default Settings 
\n"; + echo " Settings used for all domains.

\n"; + echo "
\n"; + + //prepare to page the results + $sql = ""; + $sql .= " select count(*) as num_rows from v_default_settings "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + + //prepare to page the results + $rows_per_page = 100; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + //get the domain list + $sql = ""; + $sql .= " select * from v_default_settings "; + if (strlen($order_by) == 0) { + $sql .= "order by default_setting_category, default_setting_subcategory asc "; + } + else { + $sql .= "order by $order_by $order "; + } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + if ($result_count > 0) { + $previous_category = ''; + foreach($result as $row) { + if ($previous_category != $row['default_setting_category']) { + echo "\n"; + echo "\n"; + echo th_order_by('default_setting_subcategory', 'Category', $order_by, $order); + echo th_order_by('default_setting_name', 'Name', $order_by, $order); + echo th_order_by('default_setting_value', 'Value', $order_by, $order); + echo th_order_by('default_setting_enabled', 'Enabled', $order_by, $order); + echo th_order_by('default_setting_description', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + } + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + $previous_category = $row['default_setting_category']; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo "
\n"; + echo " ".ucfirst($row['default_setting_category'])." 
\n"; + echo " $v_link_label_add\n"; + echo "
".$row['default_setting_subcategory']." ".$row['default_setting_name']." \n"; + + $category = $row['default_setting_category']; + $subcategory = $row['default_setting_subcategory']; + $name = $row['default_setting_name']; + if ($category == "domain" && $subcategory == "menu" && $name == "uuid" ) { + $sql = ""; + $sql .= "select * from v_menus "; + $sql .= "where menu_uuid = '".$row['default_setting_value']."' "; + $sub_prep_statement = $db->prepare(check_sql($sql)); + $sub_prep_statement->execute(); + $sub_result = $sub_prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($sub_result as &$sub_row) { + echo $sub_row["menu_language"]." - ".$sub_row["menu_name"]."\n"; + } + } else { + echo $row['default_setting_value']; + } + echo "  \n"; + echo " ".$row['default_setting_enabled']." ".$row['default_setting_description']." \n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/core/default_settings/default_settings_delete.php b/core/default_settings/default_settings_delete.php new file mode 100644 index 0000000000..0d66603d95 --- /dev/null +++ b/core/default_settings/default_settings_delete.php @@ -0,0 +1,58 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); +} + +if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_default_settings "; + $sql .= "where default_setting_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); +} + +require_once "includes/header.php"; +echo "\n"; +echo "
\n"; +echo "Delete Complete\n"; +echo "
\n"; +require_once "includes/footer.php"; +return; + +?> \ No newline at end of file diff --git a/core/default_settings/default_settings_edit.php b/core/default_settings/default_settings_edit.php new file mode 100644 index 0000000000..9423013a49 --- /dev/null +++ b/core/default_settings/default_settings_edit.php @@ -0,0 +1,372 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $default_setting_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $default_setting_category = check_str($_POST["default_setting_category"]); + $default_setting_subcategory = check_str($_POST["default_setting_subcategory"]); + $default_setting_name = check_str($_POST["default_setting_name"]); + $default_setting_value = check_str($_POST["default_setting_value"]); + $default_setting_enabled = check_str($_POST["default_setting_enabled"]); + $default_setting_description = check_str($_POST["default_setting_description"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $default_setting_uuid = check_str($_POST["default_setting_uuid"]); + } + + //check for all required data + //if (strlen($default_setting_category) == 0) { $msg .= "Please provide: Category
\n"; } + //if (strlen($default_setting_subcategory) == 0) { $msg .= "Please provide: Subcategory
\n"; } + //if (strlen($default_setting_name) == 0) { $msg .= "Please provide: Name
\n"; } + //if (strlen($default_setting_value) == 0) { $msg .= "Please provide: Value
\n"; } + //if (strlen($default_setting_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } + //if (strlen($default_setting_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $sql = "insert into v_default_settings "; + $sql .= "("; + $sql .= "default_setting_uuid, "; + $sql .= "default_setting_category, "; + $sql .= "default_setting_subcategory, "; + $sql .= "default_setting_name, "; + $sql .= "default_setting_value, "; + $sql .= "default_setting_enabled, "; + $sql .= "default_setting_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$default_setting_category', "; + $sql .= "'$default_setting_subcategory', "; + $sql .= "'$default_setting_name', "; + $sql .= "'$default_setting_value', "; + $sql .= "'$default_setting_enabled', "; + $sql .= "'$default_setting_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_default_settings set "; + $sql .= "default_setting_category = '$default_setting_category', "; + $sql .= "default_setting_subcategory = '$default_setting_subcategory', "; + $sql .= "default_setting_name = '$default_setting_name', "; + $sql .= "default_setting_value = '$default_setting_value', "; + $sql .= "default_setting_enabled = '$default_setting_enabled', "; + $sql .= "default_setting_description = '$default_setting_description' "; + $sql .= "where default_setting_uuid = '$default_setting_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $default_setting_uuid = $_GET["id"]; + $sql = "select * from v_default_settings "; + $sql .= "where default_setting_uuid = '$default_setting_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $default_setting_category = $row["default_setting_category"]; + $default_setting_subcategory = $row["default_setting_subcategory"]; + $default_setting_name = $row["default_setting_name"]; + $default_setting_value = $row["default_setting_value"]; + $default_setting_enabled = $row["default_setting_enabled"]; + $default_setting_description = $row["default_setting_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " "; + echo "
Default Setting AddDefault Setting Edit
\n"; + echo "Settings used for all domains.

\n"; + echo "
\n"; + echo " Category:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the category.\n"; + echo "
\n"; + echo " Subcategory:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the category.\n"; + echo "
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the name.\n"; + echo "
\n"; + echo " Value:\n"; + echo "\n"; + $category = $row['default_setting_category']; + $subcategory = $row['default_setting_subcategory']; + $name = $row['default_setting_name']; + if ($category == "domain" && $subcategory == "menu" && $name == "uuid" ) { + echo " \n"; + } elseif ($category == "domain" && $subcategory == "template" && $name == "name" ) { + echo " \n"; + } elseif ($category == "domain" && $subcategory == "time_zone" && $name == "name" ) { + echo " \n"; + } else { + echo " \n"; + } + echo "
\n"; + echo "Enter the value.\n"; + echo "
\n"; + echo " Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Choose to enable or disable the value.\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the description.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/core/default_settings/root.php b/core/default_settings/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/core/default_settings/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/core/domains/app_config.php b/core/domains/app_config.php new file mode 100644 index 0000000000..addaeb44c2 --- /dev/null +++ b/core/domains/app_config.php @@ -0,0 +1,115 @@ + \ No newline at end of file diff --git a/core/domains/app_defaults.php b/core/domains/app_defaults.php new file mode 100644 index 0000000000..bddc363f9c --- /dev/null +++ b/core/domains/app_defaults.php @@ -0,0 +1,37 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2010 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//remove external from the end of the gateway path + if (substr($v_gateways_dir, -8) == "external") { + //$v_gateways_dir = substr($v_gateways_dir, 0, (strlen($v_gateways_dir)-9)); + //$sql = "update v_domain_settings set "; + //$sql .= "v_gateways_dir = '$v_gateways_dir' "; + //$sql .= "where domain_uuid = '$domain_uuid'"; + //$db->exec($sql); + //unset($sql); + } + +?> \ No newline at end of file diff --git a/core/domains/domain_settings.php b/core/domains/domain_settings.php new file mode 100644 index 0000000000..4249062dd6 --- /dev/null +++ b/core/domains/domain_settings.php @@ -0,0 +1,189 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get variables used to control the order + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + //echo "\n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo "
Domain Settings 
\n"; + //echo " Settings used for each domain.

\n"; + //echo "
\n"; + + //prepare to page the results + $sql = " select count(*) as num_rows from v_domain_settings "; + $sql .= " where domain_uuid = '$domain_uuid' "; + $sql .= " and domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + + //prepare to page the results + $rows_per_page = 100; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + //get the domain list + $sql = ""; + $sql .= " select * from v_domain_settings "; + $sql .= " where domain_uuid = '$domain_uuid' "; + $sql .= " and domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + if ($result_count > 0) { + $previous_category = ''; + foreach($result as $row) { + if ($previous_category != $row['domain_setting_category']) { + echo "\n"; + echo "\n"; + echo th_order_by('domain_setting_subcategory', 'Category', $order_by, $order); + echo th_order_by('domain_setting_name', 'Name', $order_by, $order); + echo th_order_by('domain_setting_value', 'Value', $order_by, $order); + echo th_order_by('domain_setting_enabled', 'Enabled', $order_by, $order); + echo th_order_by('domain_setting_description', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + } + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + $previous_category = $row['domain_setting_category']; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo " ".ucfirst($row['domain_setting_category'])." 
\n"; + echo " $v_link_label_add\n"; + echo "
".$row['domain_setting_subcategory']." ".$row['domain_setting_name']." \n"; + + $category = $row['domain_setting_category']; + $subcategory = $row['domain_setting_subcategory']; + $name = $row['domain_setting_name']; + if ($category == "domain" && $subcategory == "menu" && $name == "uuid" ) { + $sql = ""; + $sql .= "select * from v_menus "; + $sql .= "where menu_uuid = '".$row['domain_setting_value']."' "; + $sub_prep_statement = $db->prepare(check_sql($sql)); + $sub_prep_statement->execute(); + $sub_result = $sub_prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($sub_result as &$sub_row) { + echo $sub_row["menu_language"]." - ".$sub_row["menu_name"]."\n"; + } + } else { + echo $row['domain_setting_value']; + } + echo "  \n"; + echo " ".$row['domain_setting_enabled']." ".$row['domain_setting_description']." \n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/core/domains/domain_settings_delete.php b/core/domains/domain_settings_delete.php new file mode 100644 index 0000000000..eeee263f8d --- /dev/null +++ b/core/domains/domain_settings_delete.php @@ -0,0 +1,60 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); + $domain_uuid = check_str($_GET["domain_uuid"]); +} + +if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_domain_settings "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and domain_setting_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); +} + +require_once "includes/header.php"; +echo "\n"; +echo "
\n"; +echo "Delete Complete\n"; +echo "
\n"; +require_once "includes/footer.php"; +return; + +?> \ No newline at end of file diff --git a/core/domains/domain_settings_edit.php b/core/domains/domain_settings_edit.php new file mode 100644 index 0000000000..990d15cb19 --- /dev/null +++ b/core/domains/domain_settings_edit.php @@ -0,0 +1,369 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $domain_setting_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +if (strlen($_GET["domain_uuid"]) > 0) { + $domain_uuid = check_str($_GET["domain_uuid"]); +} + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $domain_setting_category = check_str($_POST["domain_setting_category"]); + $domain_setting_subcategory = check_str($_POST["domain_setting_subcategory"]); + $domain_setting_name = check_str($_POST["domain_setting_name"]); + $domain_setting_value = check_str($_POST["domain_setting_value"]); + $domain_setting_enabled = check_str($_POST["domain_setting_enabled"]); + $domain_setting_description = check_str($_POST["domain_setting_description"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $domain_setting_uuid = check_str($_POST["domain_setting_uuid"]); + } + + //check for all required data + //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + //if (strlen($domain_setting_category) == 0) { $msg .= "Please provide: Category
\n"; } + //if (strlen($domain_setting_subcategory) == 0) { $msg .= "Please provide: Subcategory
\n"; } + //if (strlen($domain_setting_name) == 0) { $msg .= "Please provide: Name
\n"; } + //if (strlen($domain_setting_value) == 0) { $msg .= "Please provide: Value
\n"; } + //if (strlen($domain_setting_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } + //if (strlen($domain_setting_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $sql = "insert into v_domain_settings "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "domain_setting_uuid, "; + $sql .= "domain_setting_category, "; + $sql .= "domain_setting_subcategory, "; + $sql .= "domain_setting_name, "; + $sql .= "domain_setting_value, "; + $sql .= "domain_setting_enabled, "; + $sql .= "domain_setting_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'".uuid()."', "; + $sql .= "'$domain_setting_category', "; + $sql .= "'$domain_setting_subcategory', "; + $sql .= "'$domain_setting_name', "; + $sql .= "'$domain_setting_value', "; + $sql .= "'$domain_setting_enabled', "; + $sql .= "'$domain_setting_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_domain_settings set "; + $sql .= "domain_setting_category = '$domain_setting_category', "; + $sql .= "domain_setting_subcategory = '$domain_setting_subcategory', "; + $sql .= "domain_setting_name = '$domain_setting_name', "; + $sql .= "domain_setting_value = '$domain_setting_value', "; + $sql .= "domain_setting_enabled = '$domain_setting_enabled', "; + $sql .= "domain_setting_description = '$domain_setting_description' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and domain_setting_uuid = '$domain_setting_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $domain_setting_uuid = $_GET["id"]; + $sql = "select * from v_domain_settings "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and domain_setting_uuid = '$domain_setting_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $domain_setting_category = $row["domain_setting_category"]; + $domain_setting_subcategory = $row["domain_setting_subcategory"]; + $domain_setting_name = $row["domain_setting_name"]; + $domain_setting_value = $row["domain_setting_value"]; + $domain_setting_enabled = $row["domain_setting_enabled"]; + $domain_setting_description = $row["domain_setting_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " "; + echo "
Domain Setting AddDomain Setting Edit
\n"; + echo "Settings used for each domain.

\n"; + echo "
\n"; + echo " Category:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the category.\n"; + echo "
\n"; + echo " Subcategory:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the category.\n"; + echo "
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the name.\n"; + echo "
\n"; + echo " Value:\n"; + echo "\n"; + $category = $row['domain_setting_category']; + $subcategory = $row['domain_setting_subcategory']; + $name = $row['domain_setting_name']; + if ($category == "domain" && $subcategory == "menu" && $name == "uuid" ) { + echo " \n"; + } elseif ($category == "domain" && $subcategory == "template" && $name == "name" ) { + echo " \n"; + } elseif ($category == "domain" && $subcategory == "time" && $name == "zone" ) { + echo " \n"; + break; + } else { + echo " \n"; + } + echo "
\n"; + echo "Enter the value.\n"; + echo "
\n"; + echo " Enabled:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Choose to enable or disable the value.\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the description.\n"; + echo "
\n"; + echo " \n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/core/domains/domains.php b/core/domains/domains.php new file mode 100644 index 0000000000..37326b5be0 --- /dev/null +++ b/core/domains/domains.php @@ -0,0 +1,197 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//change the tenant + if (strlen($_GET["domain_uuid"]) > 0 && $_GET["domain_change"] == "true") { + //get the domain_uuid + $sql = "select * from v_domains "; + $sql .= "order by domain_name asc "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach($result as $row) { + if (count($result) == 0) { + $_SESSION["domain_uuid"] = $row["domain_uuid"]; + $_SESSION["domain_name"] = $row['domain_name']; + } + else { + if ($row['domain_name'] == $domain_array[0] || $row['domain_name'] == 'www.'.$domain_array[0]) { + $_SESSION["domain_uuid"] = $row["domain_uuid"]; + $_SESSION["domain_name"] = $row['domain_name']; + } + $_SESSION['domains'][$row['domain_uuid']]['domain_uuid'] = $row['domain_uuid']; + $_SESSION['domains'][$row['domain_uuid']]['domain_name'] = $row['domain_name']; + } + } + unset($result, $prep_statement); + + //update the domain session variables + $domain_uuid = check_str($_GET["domain_uuid"]); + $_SESSION['domain_uuid'] = $domain_uuid; + $_SESSION["domain_name"] = $_SESSION['domains'][$domain_uuid]['domain_name']; + $_SESSION['domain']['template']['name'] = $_SESSION['domains'][$domain_uuid]['template_name']; + //clear the menu session so that it is regenerated for the selected domain + $_SESSION["menu"] = ''; + //clear the extension array so that it is regenerated for the selected domain + unset($_SESSION['extension_array']); + //set the context + if (count($_SESSION["domains"]) > 1) { + $_SESSION["context"] = $_SESSION["domain_name"]; + } + else { + $_SESSION["context"] = 'default'; + } + } + +//includes + require_once "includes/header.php"; + require_once "includes/paging.php"; + +//get variables used to control the order + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Domains 
\n"; + echo " Control the list of domains to manage.

\n"; + echo "
\n"; + + //prepare to page the results + $sql = "select count(*) as num_rows from v_domains "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + + //prepare to page the results + $rows_per_page = 100; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + //get the list + $sql = "select * from v_domains "; + $sql .= "order by domain_name asc "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo th_order_by('domain_name', 'Domain', $order_by, $order); + echo th_order_by('domain_description', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo " $v_link_label_add\n"; + echo "
".$row['domain_name']." ".$row['domain_description']." \n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/core/domains/domains_delete.php b/core/domains/domains_delete.php new file mode 100644 index 0000000000..16cecb8a35 --- /dev/null +++ b/core/domains/domains_delete.php @@ -0,0 +1,195 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); +} + +if (strlen($id) > 0) { + //get the domain using the id + $sql = "select * from v_domains "; + $sql .= "where domain_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $domain_name = $row["domain_name"]; + } + unset ($prep_statement); + + //get the domain settings + $sql = "select * from v_domain_settings "; + $sql .= "where domain_uuid = '".$id."' "; + $sql .= "and domain_setting_enabled = 'true' "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach($result as $row) { + $name = $row['domain_setting_name']; + $category = $row['domain_setting_category']; + $subcategory = $row['domain_setting_subcategory']; + if (strlen($subcategory) == 0) { + //$$category[$name] = $row['domain_setting_value']; + $_SESSION[$category][$name] = $row['domain_setting_value']; + } + else { + //$$category[$subcategory][$name] = $row['domain_setting_value']; + $_SESSION[$category][$subcategory][$name] = $row['domain_setting_value']; + } + } + + //get the $apps array from the installed apps from the core and mod directories + $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php"); + $x=0; + foreach ($config_list as &$config_path) { + include($config_path); + $x++; + } + + //delete the domain data from all tables in the database + $db->beginTransaction(); + foreach ($apps as &$app) { + foreach ($app['db'] as $row) { + $table_name = $row['table']; + foreach ($row['fields'] as $field) { + if ($field['name'] == "domain_uuid") { + $sql = "delete from $table_name where domain_uuid = '$id' "; + $db->query($sql); + } + } + } + } + $db->commit(); + + if (strlen($domain_name) > 0) { + //set the needle + if (count($_SESSION["domains"]) > 1) { + $v_needle = 'v_'.$domain_name.'_'; + } + else { + $v_needle = 'v_'; + } + + //delete the dialplan + unlink($_SESSION['switch']['dialplan']['dir'].'/'.$domain_name.'.xml'); + if (strlen($_SESSION['switch']['dialplan']['dir']) > 0) { + system('rm -rf '.$_SESSION['switch']['dialplan']['dir'].'/'.$domain_name); + } + + //delete the dialplan public + unlink($_SESSION['switch']['dialplan']['dir'].'/public/'.$domain_name.'.xml'); + if (strlen($_SESSION['switch']['dialplan']['dir']) > 0) { + system('rm -rf '.$_SESSION['switch']['dialplan']['dir'].'/public/'.$domain_name); + } + + //delete the extension + unlink($_SESSION['switch']['extensions']['dir'].'/'.$domain_name.'.xml'); + if (strlen($_SESSION['switch']['extensions']['dir']) > 0) { + system('rm -rf '.$_SESSION['switch']['extensions']['dir'].'/'.$domain_name); + } + + //delete fax + if (strlen($_SESSION['switch']['storage']['dir']) > 0) { + system('rm -rf '.$_SESSION['switch']['storage']['dir'].'/fax/'.$domain_name); + } + + //delete the gateways + if($dh = opendir($_SESSION['switch']['gateways']['dir'])) { + $files = Array(); + while($file = readdir($dh)) { + if($file != "." && $file != ".." && $file[0] != '.') { + if(is_dir($dir . "/" . $file)) { + //this is a directory do nothing + } else { + //check if file extension is xml + if (strpos($file, $v_needle) !== false && substr($file,-4) == '.xml') { + unlink($_SESSION['switch']['gateways']['dir']."/".$file); + } + } + } + } + closedir($dh); + } + + //delete the ivr menu + if($dh = opendir($_SESSION['switch']['conf']['dir']."/ivr_menus/")) { + $files = Array(); + while($file = readdir($dh)) { + if($file != "." && $file != ".." && $file[0] != '.') { + if(is_dir($dir . "/" . $file)) { + //this is a directory + } else { + if (strpos($file, $v_needle) !== false && substr($file,-4) == '.xml') { + unlink($_SESSION['switch']['conf']['dir']."/ivr_menus/".$file); + } + } + } + } + closedir($dh); + } + + //delete the recordings + if (strlen($_SESSION['switch'][recordings]['dir']) > 0) { + system('rm -rf '.$_SESSION['switch']['recordings']['dir'].'/'.$domain_name); + } + + //delete voicemail + if (strlen($_SESSION['switch']['voicemail']['dir']) > 0) { + system('rm -rf '.$_SESSION['switch']['voicemail']['dir'].'/'.$domain_name); + } + } + + //apply settings reminder + $_SESSION["reload_xml"] = true; + + //clear the domains session array to update it + unset($_SESSION["domains"]); + unset($_SESSION["domain_uuid"]); + unset($_SESSION["domain_name"]); + unset($_SESSION['domain']); + unset($_SESSION['switch']); +} + +//redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/core/domains/domains_edit.php b/core/domains/domains_edit.php new file mode 100644 index 0000000000..caa2e34c9a --- /dev/null +++ b/core/domains/domains_edit.php @@ -0,0 +1,216 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $domain_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $domain_name = check_str($_POST["domain_name"]); + $domain_description = check_str($_POST["domain_description"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $domain_uuid = check_str($_POST["domain_uuid"]); + } + + //check for all required data + //if (strlen($domain_name) == 0) { $msg .= "Please provide: Domain
\n"; } + //if (strlen($domain_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $sql = "insert into v_domains "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "domain_name, "; + $sql .= "domain_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$domain_name', "; + $sql .= "'$domain_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + + if ($action == "update") { + $sql = "update v_domains set "; + $sql .= "domain_name = '$domain_name', "; + $sql .= "domain_description = '$domain_description' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + } + + //upgrade the domains + require_once "core/upgrade/upgrade_domains.php"; + + //clear the domains session array to update it + unset($_SESSION["domains"]); + unset($_SESSION["domain_uuid"]); + unset($_SESSION["domain_name"]); + unset($_SESSION['domain']); + unset($_SESSION['switch']); + + //redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + if ($action == "update") { + echo "Update Complete\n"; + } + if ($action == "add") { + echo "Add Complete\n"; + } + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $domain_uuid = $_GET["id"]; + $sql = "select * from v_domains "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $domain_name = $row["domain_name"]; + $domain_description = $row["domain_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Domain AddDomain Edit
\n"; + echo "Control the list of domains to manage.

\n"; + echo "
\n"; + echo " Domain:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the domain name.\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the description.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + if ($action == "update") { + require "domain_settings.php"; + } + + echo "
"; + echo "
"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/core/domains/root.php b/core/domains/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/core/domains/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/core/menu/app_config.php b/core/menu/app_config.php new file mode 100644 index 0000000000..e56d01953f --- /dev/null +++ b/core/menu/app_config.php @@ -0,0 +1,232 @@ + \ No newline at end of file diff --git a/core/menu/app_defaults.php b/core/menu/app_defaults.php new file mode 100644 index 0000000000..57a9ad23ec --- /dev/null +++ b/core/menu/app_defaults.php @@ -0,0 +1,118 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//if there are no items in the menu then add the default menu + $sql = "SELECT count(*) as count FROM v_menus "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $sub_result = $prep_statement->fetch(PDO::FETCH_ASSOC); + unset ($prep_statement); + if ($sub_result['count'] > 0) { + if ($display_type == "text") { + echo " Menu: no change\n"; + } + } + else { + //create the uuid + $menu_uuid = 'b4750c3f-2a86-b00d-b7d0-345c14eca286'; + //set the defaults + $menu_name = 'default'; + $menu_language = 'en'; + $menu_description = ''; + //add the menu + $sql = "insert into v_menus "; + $sql .= "("; + $sql .= "menu_uuid, "; + $sql .= "menu_name, "; + $sql .= "menu_language, "; + $sql .= "menu_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$menu_uuid."', "; + $sql .= "'$menu_name', "; + $sql .= "'$menu_language', "; + $sql .= "'$menu_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + //add the menu items + require_once "includes/classes/menu.php"; + $menu = new menu; + $menu->db = $db; + $menu->menu_uuid = $menu_uuid; + $menu->restore(); + unset($menu); + if ($display_type == "text") { + echo " Menu: added\n"; + } + } + unset($prep_statement, $sub_result); + +//if there are no groups listed in v_menu_item_groups then add the default groups + $sql = "SELECT * FROM v_menus "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + foreach($result as $field) { + //get the menu_uuid + $menu_uuid = $field['menu_uuid']; + //check each menu to see if there are items in the menu assigned to it + $sql = ""; + $sql .= "select count(*) as count from v_menu_item_groups "; + $sql .= "where menu_uuid = '$menu_uuid' "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + $sub_result = $prep_statement->fetch(PDO::FETCH_ASSOC); + unset ($prep_statement); + if ($sub_result['count'] == 0) { + //no menu item groups found add the defaults + foreach($apps as $app) { + foreach ($app['menu'] as $sub_row) { + foreach ($sub_row['groups'] as $group) { + //add the record + $sql = "insert into v_menu_item_groups "; + $sql .= "("; + $sql .= "menu_uuid, "; + $sql .= "menu_item_uuid, "; + $sql .= "group_name "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$menu_uuid', "; + $sql .= "'".$sub_row['uuid']."', "; + $sql .= "'".$group."' "; + $sql .= ")"; + $db->exec($sql); + unset($sql); + } + } + } + } + } + +?> \ No newline at end of file diff --git a/core/menu/menu.php b/core/menu/menu.php new file mode 100644 index 0000000000..dad8cbfb57 --- /dev/null +++ b/core/menu/menu.php @@ -0,0 +1,152 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get variables used to control the order + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Menu Manager 
\n"; + echo " Used to customize one or more menus.

\n"; + echo "
\n"; + + //prepare to page the results + $sql = " select count(*) as num_rows from v_menus "; + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + + //prepare to page the results + $rows_per_page = 150; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + //get the list + $sql = " select * from v_menus "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo th_order_by('menu_name', 'Name', $order_by, $order); + echo th_order_by('menu_language', 'Language', $order_by, $order); + echo th_order_by('menu_description', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo " $v_link_label_add\n"; + echo "
".$row['menu_name']." ".$row['menu_language']." ".$row['menu_description']." \n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/core/menu/menu_delete.php b/core/menu/menu_delete.php new file mode 100644 index 0000000000..2612db755a --- /dev/null +++ b/core/menu/menu_delete.php @@ -0,0 +1,83 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); + $menu_uuid = check_str($_GET["menu_uuid"]); +} + +if (strlen($id)>0) { + //start the database transaction + $db->beginTransaction(); + + //delete the menu + $sql = ""; + $sql .= "delete from v_menus "; + $sql .= "where menu_uuid = '$menu_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + + //delete the items in the menu + $sql = ""; + $sql .= "delete from v_menu_items "; + $sql .= "where menu_uuid = '$menu_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + + //delete the menu permissions + $sql = ""; + $sql .= "delete from v_menu_item_groups "; + $sql .= "where menu_uuid = '$menu_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + + //save the changes to the database + $db->commit(); +} + +//redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/core/menu/menu_edit.php b/core/menu/menu_edit.php new file mode 100644 index 0000000000..02608984fc --- /dev/null +++ b/core/menu/menu_edit.php @@ -0,0 +1,245 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $menu_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $menu_uuid = check_str($_POST["menu_uuid"]); + $menu_name = check_str($_POST["menu_name"]); + $menu_language = check_str($_POST["menu_language"]); + $menu_description = check_str($_POST["menu_description"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $menu_uuid = check_str($_POST["menu_uuid"]); + } + + //check for all required data + //if (strlen($menu_uuid) == 0) { $msg .= "Please provide: Menu UUID
\n"; } + //if (strlen($menu_name) == 0) { $msg .= "Please provide: Name
\n"; } + //if (strlen($menu_language) == 0) { $msg .= "Please provide: Language
\n"; } + //if (strlen($menu_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + //create a new unique id + $menu_uuid = uuid(); + + //start a new menu + $sql = "insert into v_menus "; + $sql .= "("; + $sql .= "menu_uuid, "; + $sql .= "menu_name, "; + $sql .= "menu_language, "; + $sql .= "menu_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$menu_uuid."', "; + $sql .= "'$menu_name', "; + $sql .= "'$menu_language', "; + $sql .= "'$menu_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //add the default items in the menu + require_once "includes/classes/menu.php"; + $menu = new menu; + $menu->db = $db; + $menu->menu_uuid = $menu_uuid; + $menu->restore(); + + //redirect the user back to the main menu + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + //update the menu + $sql = "update v_menus set "; + $sql .= "menu_name = '$menu_name', "; + $sql .= "menu_language = '$menu_language', "; + $sql .= "menu_description = '$menu_description' "; + $sql .= "where menu_uuid = '$menu_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + //redirect the user back to the main menu + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $menu_uuid = $_GET["id"]; + $sql = "select * from v_menus "; + $sql .= "where menu_uuid = '$menu_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $menu_uuid = $row["menu_uuid"]; + $menu_name = $row["menu_name"]; + $menu_language = $row["menu_language"]; + $menu_description = $row["menu_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Menu AddMenu Edit\n"; + if (permission_exists('menu_restore')) { + echo " "; + } + echo "
\n"; + echo "Used to customize one or more menus.

\n"; + echo "
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the name of the menu.\n"; + echo "
\n"; + echo " Language:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the language.\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the description.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//show the menu items + require_once "core/menu/menu_item_list.php"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/core/menu/menu_item_delete.php b/core/menu/menu_item_delete.php new file mode 100644 index 0000000000..dfc84964cc --- /dev/null +++ b/core/menu/menu_item_delete.php @@ -0,0 +1,62 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('menu_delete')) { + //access granted +} +else { + echo "access denied"; + return; +} + +if (count($_GET)>0) { + //clear the menu session so it will rebuild with the update + $_SESSION["menu"] = ""; + + //get the menu uuid + $menu_uuid = check_str($_GET["id"]); + $menu_item_id = check_str($_GET["menu_item_id"]); + + //delete the item in the menu + $sql = "delete from v_menu_items "; + $sql .= "where menu_item_id = '$menu_item_id' "; + $sql .= "and menu_uuid = '$menu_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
"; + echo "Delete Completed"; + echo "
"; + require_once "includes/footer.php"; + return; +} + +?> \ No newline at end of file diff --git a/core/menu/menu_item_edit.php b/core/menu/menu_item_edit.php new file mode 100644 index 0000000000..40e92d4a4f --- /dev/null +++ b/core/menu/menu_item_edit.php @@ -0,0 +1,464 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('menu_add') || permission_exists('menu_edit') || permission_exists('menu_delete')) { + //access granted +} +else { + echo "access denied"; + return; +} + +//include the header + require_once "includes/header.php"; + +//get the menu_uuid + $menu_uuid = check_str($_REQUEST["id"]); + $menu_item_uuid = check_str($_REQUEST['menu_item_uuid']); + $group_name = check_str($_REQUEST['group_name']); + +//delete the group from the user + if ($_REQUEST["a"] == "delete" && permission_exists("menu_delete")) { + //delete the group from the users + $sql = "delete from v_menu_item_groups "; + $sql .= "where menu_uuid = '".$menu_uuid."' "; + $sql .= "and menu_item_uuid = '".$menu_item_uuid."' "; + $sql .= "and group_name = '".$group_name."' "; + $db->exec(check_sql($sql)); + //redirect the browser + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Delete Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } + +//add a group to the menu + if ($_REQUEST["a"] != "delete" && strlen($group_name) > 0 && permission_exists('menu_add')) { + //add the group to the menu + if (strlen($menu_item_uuid) > 0) { + $sql_insert = "insert into v_menu_item_groups "; + $sql_insert .= "("; + $sql_insert .= "menu_uuid, "; + $sql_insert .= "menu_item_uuid, "; + $sql_insert .= "group_name "; + $sql_insert .= ")"; + $sql_insert .= "values "; + $sql_insert .= "("; + $sql_insert .= "'".$menu_uuid."', "; + $sql_insert .= "'".$menu_item_uuid."', "; + $sql_insert .= "'".$group_name."' "; + $sql_insert .= ")"; + $db->exec($sql_insert); + } + } + +//action add or update + if (isset($_REQUEST["menu_item_uuid"])) { + if (strlen($_REQUEST["menu_item_uuid"]) > 0) { + $action = "update"; + $menu_item_uuid = check_str($_REQUEST["menu_item_uuid"]); + } + else { + $action = "add"; + } + } + else { + $action = "add"; + } + +//clear the menu session so it will rebuild with the update + $_SESSION["menu"] = ""; + +//get the HTTP POST variables and set them as PHP variables + if (count($_POST)>0) { + $menu_uuid = check_str($_POST["menu_uuid"]); + $menu_item_uuid = check_str($_POST["menu_item_uuid"]); + $menu_item_title = check_str($_POST["menu_item_title"]); + $menu_item_link = check_str($_POST["menu_item_link"]); + $menu_item_category = check_str($_POST["menu_item_category"]); + $menu_item_description = check_str($_POST["menu_item_description"]); + $menu_item_protected = check_str($_POST["menu_item_protected"]); + //$menu_item_uuid = check_str($_POST["menu_item_uuid"]); + $menu_item_parent_uuid = check_str($_POST["menu_item_parent_uuid"]); + $menu_item_order = check_str($_POST["menu_item_order"]); + } + +//when a HTTP POST is available then process it + if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + if ($action == "update") { + $menu_item_uuid = check_str($_POST["menu_item_uuid"]); + } + + //check for all required data + $msg = ''; + if (strlen($menu_item_title) == 0) { $msg .= "Please provide: title
\n"; } + if (strlen($menu_item_category) == 0) { $msg .= "Please provide: category
\n"; } + //if (strlen($menu_item_link) == 0) { $msg .= "Please provide: menu_item_link
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('menu_add')) { + $sql = "SELECT menu_item_order FROM v_menu_items "; + $sql .= "where menu_uuid = '$menu_uuid' "; + $sql .= "and menu_item_parent_uuid = '$menu_item_parent_uuid' "; + $sql .= "order by menu_item_order desc "; + $sql .= "limit 1 "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $highest_menu_item_order = $row[menu_item_order]; + } + unset($prep_statement); + + $sql = "insert into v_menu_items "; + $sql .= "("; + $sql .= "menu_uuid, "; + $sql .= "menu_item_title, "; + $sql .= "menu_item_link, "; + $sql .= "menu_item_category, "; + $sql .= "menu_item_description, "; + $sql .= "menu_item_protected, "; + $sql .= "menu_item_uuid, "; + $sql .= "menu_item_parent_uuid, "; + $sql .= "menu_item_order, "; + $sql .= "menu_item_add_user, "; + $sql .= "menu_item_add_date "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$menu_uuid', "; + $sql .= "'$menu_item_title', "; + $sql .= "'$menu_item_link', "; + $sql .= "'$menu_item_category', "; + $sql .= "'$menu_item_description', "; + $sql .= "'$menu_item_protected', "; + $sql .= "'".uuid()."', "; + if (strlen($menu_item_parent_uuid) == 0) { + $sql .= "null, "; + } + else { + $sql .= "'$menu_item_parent_uuid', "; + } + $sql .= "'".($highest_menu_item_order+1)."', "; + $sql .= "'".$_SESSION["username"]."', "; + $sql .= "now() "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + if ($action == "update" && permission_exists('menu_edit')) { + $sql = "update v_menu_items set "; + $sql .= "menu_item_title = '$menu_item_title', "; + $sql .= "menu_item_link = '$menu_item_link', "; + $sql .= "menu_item_category = '$menu_item_category', "; + $sql .= "menu_item_description = '$menu_item_description', "; + $sql .= "menu_item_protected = '$menu_item_protected', "; + if (strlen($menu_item_parent_uuid) == 0) { + $sql .= "menu_item_parent_uuid = null, "; + } + else { + $sql .= "menu_item_parent_uuid = '$menu_item_parent_uuid', "; + } + $sql .= "menu_item_order = '$menu_item_order', "; + $sql .= "menu_item_mod_user = '".$_SESSION["username"]."', "; + $sql .= "menu_item_mod_date = now() "; + $sql .= "where menu_uuid = '$menu_uuid' "; + $sql .= "and menu_item_uuid = '$menu_item_uuid' "; + $count = $db->exec(check_sql($sql)); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Edit Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } + } //if ($_POST["persistformvar"] != "true") + } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $menu_item_uuid = $_GET["menu_item_uuid"]; + + $sql = "select * from v_menu_items "; + $sql .= "where menu_uuid = '$menu_uuid' "; + $sql .= "and menu_item_uuid = '$menu_item_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $menu_item_uuid = $row["menu_item_uuid"]; + $menu_item_title = $row["menu_item_title"]; + $menu_item_link = $row["menu_item_link"]; + $menu_item_category = $row["menu_item_category"]; + $menu_item_description = $row["menu_item_description"]; + $menu_item_protected = $row["menu_item_protected"]; + $menu_item_parent_uuid = $row["menu_item_parent_uuid"]; + $menu_item_order = $row["menu_item_order"]; + $menu_item_add_user = $row["menu_item_add_user"]; + $menu_item_add_date = $row["menu_item_add_date"]; + //$menu_item_del_user = $row["menu_item_del_user"]; + //$menu_item_del_date = $row["menu_item_del_date"]; + $menu_item_mod_user = $row["menu_item_mod_user"]; + $menu_item_mod_date = $row["menu_item_mod_date"]; + break; //limit to 1 row + } + } + +//show the content + require_once "includes/header.php"; + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
"; + echo ""; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo " "; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + if ($action == "update") { + echo " "; + echo " "; + echo " "; + echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + //echo " "; + } + + echo " "; + echo " "; + echo " "; + echo " "; + + if (permission_exists('menu_add') || permission_exists('menu_edit')) { + echo " \n"; + echo " "; + echo " "; + } + echo "
Menu Item Edit

Title:
Link:
Category:"; + echo " "; + echo "
Parent Menu:"; + $sql = "SELECT * FROM v_menu_items "; + $sql .= "where menu_uuid = '$menu_uuid' "; + $sql .= "order by menu_item_title asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + echo ""; + unset($sql, $result); + echo "
Groups:"; + + echo "\n"; + $sql = "SELECT * FROM v_menu_item_groups "; + $sql .= "where menu_uuid=:menu_uuid "; + $sql .= "and menu_item_uuid=:menu_item_uuid "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->bindParam(':menu_uuid', $menu_uuid); + $prep_statement->bindParam(':menu_item_uuid', $menu_item_uuid); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + foreach($result as $field) { + if (strlen($field['group_name']) > 0) { + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + } + } + echo "
".$field['group_name']."\n"; + if (permission_exists('group_member_delete') || if_group("superadmin")) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + + echo "
\n"; + $sql = "SELECT * FROM v_groups "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + echo ""; + echo "\n"; + unset($sql, $result); + echo "
\n"; + echo " Protected:\n"; + echo "\n"; + echo "
\n"; + echo "Protect this item in the menu so that is is not removed by 'Restore Default.'
\n"; + echo "\n"; + echo "
Menu Order:
Added By:$menu_item_add_user  
Add Date:$menu_item_add_date  
menu_item_del_user:
menu_item_del_date:
Modified By:$menu_item_mod_user  
Modified Date:$menu_item_mod_date  
Description:
\n"; + echo " "; + echo " "; + echo " \n"; + echo " "; + echo " "; + echo "
"; + echo " "; + if ($action == "update") { + echo " "; + } + echo " "; + echo " "; + echo " \n"; + echo "
"; + echo "
"; + echo "
"; + + echo "
"; + echo "
"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/core/menu/menu_item_list.php b/core/menu/menu_item_list.php new file mode 100644 index 0000000000..06f13ef936 --- /dev/null +++ b/core/menu/menu_item_list.php @@ -0,0 +1,371 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('menu_add') || permission_exists('menu_edit')) { + //access granted +} +else { + echo "access denied"; + return; +} + +$tmp_menu_item_order = 0; + +function build_db_child_menu_list ($db, $menu_item_level, $menu_item_uuid, $c) { + global $menu_uuid, $tmp_menu_item_order, $v_link_label_edit, $v_link_label_delete; + + //check for sub menus + $menu_item_level = $menu_item_level+1; + $sql = "select * from v_menu_items "; + $sql .= "where menu_uuid = '".$menu_uuid."' "; + $sql .= "and menu_item_parent_uuid = '".$menu_item_uuid."' "; + $sql .= "order by menu_item_order, menu_item_title asc "; + $prep_statement_2 = $db->prepare($sql); + $prep_statement_2->execute(); + $result2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED); + + $row_style["0"] = "row_style1"; + $row_style["1"] = "row_style1"; + + if (count($result2) > 0) { + if ($c == 0) { $c2 = 1; } else { $c2 = 0; } + foreach($result2 as $row2) { + //set the db values as php variables + $menu_item_uuid = $row2['menu_item_uuid']; + $menu_item_category = $row2['menu_item_category']; + $menu_item_protected = $row2['menu_item_protected']; + $menu_item_parent_uuid = $row2['menu_item_parent_uuid']; + $menu_item_order = $row2['menu_item_order']; + $menu_item_language = $row2['menu_item_language']; + $menu_item_title = $row2[menu_item_title]; + $menu_item_link = $row2[menu_item_link]; + //get the groups that have been assigned to the menu + $sql = ""; + $sql .= "select group_name from v_menu_item_groups "; + $sql .= "where menu_uuid = '$menu_uuid' "; + $sql .= "and menu_item_uuid = '".$menu_item_uuid."' "; + $sub_prep_statement = $db->prepare(check_sql($sql)); + $sub_prep_statement->execute(); + $sub_result = $sub_prep_statement->fetchAll(PDO::FETCH_NAMED); + $group_list = ""; + $x = 0; + foreach ($sub_result as &$sub_row) { + if ($x == 0) { + $group_list = $sub_row["group_name"]; + } + else { + $group_list .= ", ".$sub_row["group_name"]; + } + $x++; + } + unset ($sub_prep_statement); + //display the main body of the list + switch ($menu_item_category) { + case "internal": + $menu_item_title = "$menu_item_title"; + break; + case "external": + if (substr($menu_item_link, 0,1) == "/") { + $menu_item_link = PROJECT_PATH . $menu_item_link; + } + $menu_item_title = "$menu_item_title"; + break; + case "email": + $menu_item_title = "$menu_item_title"; + break; + } + + //display the content of the list + echo "\n"; + echo "
"; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
"; + $i=0; + while($i < $menu_item_level){ + echo "         "; + $i++; + } + echo " ".$menu_item_title." "; + + echo "
"; + echo "
 ".$menu_item_link."  ".$group_list."  ".$menu_item_category." ".$row[menu_item_description]." ".$row[menu_item_order]."   yes    no  "; + echo "  "; + //echo " ".$row2[menu_item_order]." "; + echo ""; + //if (permission_exists('menu_edit')) { + // echo " "; + // echo " "; + //} + //echo "\n"; + if (permission_exists('menu_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('menu_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + echo "
\n"; + + echo ""; + //echo ""; + echo "\n"; + echo "\n"; + echo "
Menu Manager\n"; + //if (permission_exists('menu_restore')) { + // echo " "; + //} + echo "
"; + + $sql = "select * from v_menu_items "; + $sql .= "where menu_uuid = '".$menu_uuid."' "; + $sql .= "and menu_item_parent_uuid is null "; + if (strlen($order_by)> 0) { + $sql .= "order by $order_by $order "; + } + else { + $sql .= "order by menu_item_order asc "; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style0"; + + echo "
\n"; + echo "\n"; + + if ($result_count == 0) { + //no results + echo ""; + } + else { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + //echo ""; + echo ""; + echo "\n"; + echo ""; + + foreach($result as $row) { + //set the db values as php variables + $menu_item_uuid = $row['menu_item_uuid']; + $menu_item_category = $row['menu_item_category']; + $menu_item_title = $row['menu_item_title']; + $menu_item_link = $row['menu_item_link']; + $menu_item_protected = $row['menu_item_protected']; + + //get the groups that have been assigned to the menu + $sql = ""; + $sql .= "select group_name from v_menu_item_groups "; + $sql .= "where menu_uuid = '$menu_uuid' "; + $sql .= "and menu_item_uuid = '$menu_item_uuid' "; + $sub_prep_statement = $db->prepare(check_sql($sql)); + $sub_prep_statement->execute(); + $sub_result = $sub_prep_statement->fetchAll(PDO::FETCH_NAMED); + $group_list = ""; + $x = 0; + foreach ($sub_result as &$sub_row) { + if ($x == 0) { + $group_list = $sub_row["group_name"]; + } + else { + $group_list .= ", ".$sub_row["group_name"]; + } + $x++; + } + unset ($sub_prep_statement); + + //add the type link based on the typd of the menu + switch ($menu_item_category) { + case "internal": + $menu_item_title = "$menu_item_title"; + break; + case "external": + if (substr($menu_item_link, 0,1) == "/") { + $menu_item_link = PROJECT_PATH . $menu_item_link; + } + $menu_item_title = "$menu_item_title"; + break; + case "email": + $menu_item_title = "$menu_item_title"; + break; + } + + //display the content of the list + echo "\n"; + echo ""; + echo ""; + //echo ""; + echo ""; + //echo ""; + //echo ""; + //echo ""; + + if ($menu_item_protected == "true") { + echo ""; + } + else { + echo ""; + } + + echo ""; + + //echo ""; + + echo " \n"; + echo ""; + + //update the menu order + if ($row[menu_item_order] != $tmp_menu_item_order) { + $sql = "update v_menu_items set "; + $sql .= "menu_item_title = '".$row['menu_item_title']."', "; + $sql .= "menu_item_order = '".$tmp_menu_item_order."' "; + $sql .= "where menu_uuid = '".$menu_uuid."' "; + $sql .= "and menu_item_uuid = '".$row[menu_item_uuid]."' "; + //$db->exec(check_sql($sql)); + } + $tmp_menu_item_order++; + + //check for sub menus + $menu_item_level = 0; + if (strlen($row['menu_item_uuid']) > 0) { + $c = build_db_child_menu_list($db, $menu_item_level, $row['menu_item_uuid'], $c); + } + + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
 
  Title     Groups     Category     Protected     Order  Order   \n"; + if (permission_exists('menu_add')) { + echo " $v_link_label_add\n"; + } + echo "
  ".$menu_item_title."   ".$group_list."  ".$menu_item_link."  ".$menu_item_category." ".$row[menu_item_description]." ".$row['menu_item_parent_uuid']."  ".$row['menu_item_order']."   yes    no  "; + echo " ".$row[menu_item_order]." "; + echo ""; + //if (permission_exists('menu_edit')) { + // echo " "; + // echo " "; + //} + //echo "\n"; + if (permission_exists('menu_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('menu_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
  \n"; + if (permission_exists('menu_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + + echo "
\n"; + echo "
\n"; + echo "

"; + + echo "
\n"; + echo "
"; + + echo "

"; + require_once "includes/footer.php"; + +?> \ No newline at end of file diff --git a/core/menu/menu_item_move_down.php b/core/menu/menu_item_move_down.php new file mode 100644 index 0000000000..22cb10f07e --- /dev/null +++ b/core/menu/menu_item_move_down.php @@ -0,0 +1,88 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('menu_edit')) { + //access granted +} +else { + echo "access denied"; + return; +} + +//move down more than one level at a time +//update v_menu_items set menu_item_order = (menu_item_order+1) where menu_item_order > 2 or menu_item_order = 2 + +if (count($_GET)>0) { + $menu_item_id = check_str($_GET["menu_item_id"]); + $menu_item_order = check_str($_GET["menu_item_order"]); + $menu_parent_guid = check_str($_GET["menu_parent_guid"]); + + $sql = "SELECT menu_item_order FROM v_menu_items "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "order by menu_item_order desc "; + $sql .= "limit 1 "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $highestmenu_item_order = $row[menu_item_order]; + } + unset($prep_statement); + + if ($menu_item_order != $highestmenu_item_order) { + //clear the menu session so it will rebuild with the update + $_SESSION["menu"] = ""; + + //move the current item's order number up + $sql = "update v_menu_items set "; + $sql .= "menu_item_order = (menu_item_order-1) "; //move down + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and menu_item_order = ".($menu_item_order+1)." "; + $db->exec(check_sql($sql)); + unset($sql); + + //move the selected item's order number down + $sql = "update v_menu_items set "; + $sql .= "menu_item_order = (menu_item_order+1) "; //move up + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and menu_item_id = '$menu_item_id' "; + $db->exec(check_sql($sql)); + unset($sql); + } + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
"; + echo "Item Moved Down"; + echo "
"; + require_once "includes/footer.php"; + return; +} + +?> \ No newline at end of file diff --git a/core/menu/menu_item_move_up.php b/core/menu/menu_item_move_up.php new file mode 100644 index 0000000000..b645f38209 --- /dev/null +++ b/core/menu/menu_item_move_up.php @@ -0,0 +1,75 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('menu_edit')) { + //access granted +} +else { + echo "access denied"; + return; +} + +//move down more than one level at a time +//update v_menu_items set menu_order = (menu_order+1) where menu_order > 2 or menu_order = 2 + +if (count($_GET)>0) { + $menu_item_id = check_str($_GET["menu_item_id"]); + $menu_order = check_str($_GET["menu_order"]); + + if ($menu_order != 1) { + //clear the menu session so it will rebuild with the update + $_SESSION["menu"] = ""; + + //move the current item's order number down + $sql = "update v_menu_items set "; + $sql .= "menu_order = (menu_order+1) "; //move down + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and menu_order = ".($menu_order-1)." "; + $db->exec(check_sql($sql)); + unset($sql); + + //move the selected item's order number up + $sql = "update v_menu_items set "; + $sql .= "menu_order = (menu_order-1) "; //move up + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and menu_item_id = '$menu_item_id' "; + $db->exec(check_sql($sql)); + unset($sql); + } + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
"; + echo "Item Moved Up"; + echo "
"; + require_once "includes/footer.php"; + return; +} + +?> \ No newline at end of file diff --git a/core/menu/menu_restore_default.php b/core/menu/menu_restore_default.php new file mode 100644 index 0000000000..0f9f529614 --- /dev/null +++ b/core/menu/menu_restore_default.php @@ -0,0 +1,63 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('menu_restore')) { + //access granted +} +else { + echo "access denied"; + return; +} + +//get the http value and set as a php variable + $menu_uuid = check_str($_REQUEST["menu_uuid"]); + +//menu restore default + require_once "includes/classes/menu.php"; + $menu = new menu; + $menu->db = $db; + $menu->menu_uuid = $menu_uuid; + $menu->delete(); + $menu->restore(); + +//unset the menu session variable + $_SESSION["menu"] = ""; + +//unset the default template + $_SESSION["template_content"] = ''; + +//show a message to the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Restore Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> diff --git a/core/menu/root.php b/core/menu/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/core/menu/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/core/servers/app_config.php b/core/servers/app_config.php new file mode 100644 index 0000000000..769adfeec2 --- /dev/null +++ b/core/servers/app_config.php @@ -0,0 +1,98 @@ + \ No newline at end of file diff --git a/core/servers/root.php b/core/servers/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/core/servers/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/core/servers/v_server_settings.php b/core/servers/v_server_settings.php new file mode 100644 index 0000000000..d78f4db2f8 --- /dev/null +++ b/core/servers/v_server_settings.php @@ -0,0 +1,161 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get variables used to control the order + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Server Setting List 
\n"; + echo " Server settings are assigned to Domains.

\n"; + echo "
\n"; + + //prepare to page the results + $sql = ""; + $sql .= " select count(*) as num_rows from v_server_settings "; + $sql .= " where domain_uuid = '$domain_uuid' "; + $sql .= " and server_uuid = '$server_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + + //prepare to page the results + $rows_per_page = 100; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + //get the server list + $sql = ""; + $sql .= " select * from v_server_settings "; + $sql .= " where domain_uuid = '$domain_uuid' "; + $sql .= " and server_uuid = '$server_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo th_order_by('server_setting_category', 'Category', $order_by, $order); + echo th_order_by('server_setting_name', 'Name', $order_by, $order); + echo th_order_by('server_setting_value', 'Value', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo " $v_link_label_add\n"; + echo "
".$row['server_setting_category']." ".$row['server_setting_name']." ".$row['server_setting_value']." \n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/core/servers/v_server_settings_delete.php b/core/servers/v_server_settings_delete.php new file mode 100644 index 0000000000..7396ff13b0 --- /dev/null +++ b/core/servers/v_server_settings_delete.php @@ -0,0 +1,60 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); + $server_uuid = check_str($_GET["server_uuid"]); +} + +if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_server_settings "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and server_setting_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); +} + +require_once "includes/header.php"; +echo "\n"; +echo "
\n"; +echo "Delete Complete\n"; +echo "
\n"; +require_once "includes/footer.php"; +return; + +?> \ No newline at end of file diff --git a/core/servers/v_server_settings_edit.php b/core/servers/v_server_settings_edit.php new file mode 100644 index 0000000000..c89903b331 --- /dev/null +++ b/core/servers/v_server_settings_edit.php @@ -0,0 +1,244 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $server_setting_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +if (strlen($_GET["server_uuid"]) > 0) { + $server_uuid = check_str($_GET["server_uuid"]); +} + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $server_uuid = check_str($_POST["server_uuid"]); + $server_setting_category = check_str($_POST["server_setting_category"]); + $server_setting_value = check_str($_POST["server_setting_value"]); + $server_setting_name = check_str($_POST["server_setting_name"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $server_setting_uuid = check_str($_POST["server_setting_uuid"]); + } + + //check for all required data + //if (strlen($server_uuid) == 0) { $msg .= "Please provide: server_uuid
\n"; } + //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } + //if (strlen($server_setting_category) == 0) { $msg .= "Please provide: Category
\n"; } + //if (strlen($server_setting_value) == 0) { $msg .= "Please provide: Value
\n"; } + //if (strlen($server_setting_name) == 0) { $msg .= "Please provide: Name
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $sql = "insert into v_server_settings "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "server_uuid, "; + $sql .= "server_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "server_setting_category, "; + $sql .= "server_setting_value, "; + $sql .= "server_setting_name "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$server_uuid', "; + $sql .= "'$server_uuid', "; + $sql .= "'$domain_uuid', "; + $sql .= "'$server_setting_category', "; + $sql .= "'$server_setting_value', "; + $sql .= "'$server_setting_name' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_server_settings set "; + $sql .= "server_uuid = '$server_uuid', "; + $sql .= "server_uuid = '$server_uuid', "; + $sql .= "domain_uuid = '$domain_uuid', "; + $sql .= "server_setting_category = '$server_setting_category', "; + $sql .= "server_setting_value = '$server_setting_value', "; + $sql .= "server_setting_name = '$server_setting_name' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and server_setting_uuid = '$server_setting_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $server_setting_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_server_settings "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and server_setting_uuid = '$server_setting_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $server_uuid = $row["server_uuid"]; + $server_setting_category = $row["server_setting_category"]; + $server_setting_value = $row["server_setting_value"]; + $server_setting_name = $row["server_setting_name"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " "; + echo "
Server Setting AddServer Setting Edit
\n"; + echo "Server settings are assigned to Domains.

\n"; + echo "
\n"; + echo " Category:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the category.\n"; + echo "
\n"; + echo " Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the name.\n"; + echo "
\n"; + echo " Value:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the value.\n"; + echo "
\n"; + echo " \n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/core/servers/v_servers.php b/core/servers/v_servers.php new file mode 100644 index 0000000000..d968c18fdc --- /dev/null +++ b/core/servers/v_servers.php @@ -0,0 +1,158 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get variables used to control the order + $order_by = $_GET["order_by"]; + $order = $_GET["order"]; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Servers 
\n"; + echo " Servers Settings

\n"; + echo "
\n"; + + //prepare to page the results + $sql = ""; + $sql .= " select count(*) as num_rows from v_servers "; + $sql .= " where domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + + //prepare to page the results + $rows_per_page = 10; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + //get the list + $sql = ""; + $sql .= " select * from v_servers "; + $sql .= " where domain_uuid = '$domain_uuid' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo "\n"; + + echo "\n"; + echo th_order_by('server_name', 'Server Name', $order_by, $order); + echo th_order_by('server_description', 'Description', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + //print_r( $row ); + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + echo " $v_link_label_add\n"; + echo "
".$row['server_name']." ".$row['server_description']." \n"; + echo " $v_link_label_edit\n"; + echo " $v_link_label_delete\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + echo " $v_link_label_add\n"; + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/core/servers/v_servers_delete.php b/core/servers/v_servers_delete.php new file mode 100644 index 0000000000..8a6b69ee1f --- /dev/null +++ b/core/servers/v_servers_delete.php @@ -0,0 +1,59 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +if (count($_GET)>0) { + $id = check_str($_GET["id"]); +} + +if (strlen($id)>0) { + $sql = ""; + $sql .= "delete from v_servers "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and server_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); +} + +require_once "includes/header.php"; +echo "\n"; +echo "
\n"; +echo "Delete Complete\n"; +echo "
\n"; +require_once "includes/footer.php"; +return; + +?> \ No newline at end of file diff --git a/core/servers/v_servers_edit.php b/core/servers/v_servers_edit.php new file mode 100644 index 0000000000..85fd3db499 --- /dev/null +++ b/core/servers/v_servers_edit.php @@ -0,0 +1,212 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $server_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $server_name = check_str($_POST["server_name"]); + $server_description = check_str($_POST["server_description"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $server_uuid = check_str($_POST["server_uuid"]); + } + + //check for all required data + //if (strlen($server_name) == 0) { $msg .= "Please provide: Server Name
\n"; } + //if (strlen($server_description) == 0) { $msg .= "Please provide: Description
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "includes/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add") { + $sql = "insert into v_servers "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "server_name, "; + $sql .= "server_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$server_name', "; + $sql .= "'$server_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Add Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "add") + + if ($action == "update") { + $sql = "update v_servers set "; + $sql .= "server_name = '$server_name', "; + $sql .= "server_description = '$server_description' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and server_uuid = '$server_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Update Complete\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET)>0 && $_POST["persistformvar"] != "true") { + $server_uuid = $_GET["id"]; + $sql = ""; + $sql .= "select * from v_servers "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and server_uuid = '$server_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $server_name = $row["server_name"]; + $server_description = $row["server_description"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + echo "
\n"; + echo "
\n"; + echo "\n"; + echo "\n"; + if ($action == "add") { + echo "\n"; + } + if ($action == "update") { + echo "\n"; + } + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
Server AddServer Edit
\n"; + echo "Servers Settings

\n"; + echo "
\n"; + echo " Server Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the name.\n"; + echo "
\n"; + echo " Description:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the description.\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo ""; + + if ($action == "update") { + require "v_server_settings.php"; + } + + echo "
"; + echo "
"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/core/upgrade/app_config.php b/core/upgrade/app_config.php new file mode 100644 index 0000000000..0e83ad3d90 --- /dev/null +++ b/core/upgrade/app_config.php @@ -0,0 +1,71 @@ + \ No newline at end of file diff --git a/core/upgrade/app_defaults.php b/core/upgrade/app_defaults.php new file mode 100644 index 0000000000..04559932e8 --- /dev/null +++ b/core/upgrade/app_defaults.php @@ -0,0 +1,132 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +if (strlen($_SESSION['switch']['scripts']['dir']) > 0) { + + //if the resource scripts resource directory does not exist then create it + if (!is_dir($_SESSION['switch']['scripts']['dir']."/resources")) { mkdir($_SESSION['switch']['scripts']['dir']."/resources",0755,true); } + + //get odbc information + $sql = "select count(*) as num_rows from v_databases "; + $sql .= "where database_type = 'odbc' "; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $odbc_num_rows = $row['num_rows']; + + $sql = "select * from v_databases "; + $sql .= "where database_type = 'odbc' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $dsn_name = $row["database_name"]; + $dsn_username = $row["database_username"]; + $dsn_password = $row["database_password"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + else { + $odbc_num_rows = '0'; + } + } + + //config.lua + $fout = fopen($_SESSION['switch']['scripts']['dir']."/resources/config.lua","w"); + $tmp = "\n"; + $tmp .= "--switch directories\n"; + if (strlen($_SESSION['switch']['sounds']['dir']) > 0) { + $tmp .= " sounds_dir = \"".$_SESSION['switch']['sounds']['dir']."\";\n"; + } + if (strlen($_SESSION['switch']['recordings']['dir']) > 0) { + $tmp .= " recordings_dir = \"".$_SESSION['switch']['recordings']['dir']."\";\n"; + } + $tmp .= "\n"; + $tmp .= "--database connection info\n"; + if (strlen($db_type) > 0) { + $tmp .= " db_type = \"".$db_type."\";\n"; + } + if (strlen($db_name) > 0) { + $tmp .= " db_name = \"".$db_name."\";\n"; + } + if (strlen($db_path) > 0) { + $tmp .= " db_path = \"".$db_path."\";\n"; + } + if (strlen($dsn_name) > 0) { + $tmp .= " dsn_name = \"".$dsn_name."\";\n"; + } + if (strlen($dsn_username) > 0) { + $tmp .= " dsn_username = \"".$dsn_username."\";\n"; + } + if (strlen($dsn_password) > 0) { + $tmp .= " dsn_password = \"".$dsn_password."\";\n"; + } + $tmp .= "\n"; + $tmp .= "--additional info\n"; + $tmp .= " tmp_dir = \"".$tmp_dir."\";\n"; + fwrite($fout, $tmp); + unset($tmp); + fclose($fout); + + //config.js + $fout = fopen($_SESSION['switch']['scripts']['dir']."/resources/config.js","w"); + $tmp = "\n"; + $tmp .= "//switch directories\n"; + $tmp .= " var admin_pin = \"".$row["admin_pin"]."\";\n"; + $tmp .= " var sounds_dir = \"".$_SESSION['switch']['sounds']['dir']."\";\n"; + $tmp .= " var recordings_dir = \"".$_SESSION['switch']['recordings']['dir']."\";\n"; + $tmp .= "\n"; + $tmp = "//database connection info\n"; + if (strlen($db_type) > 0) { + $tmp .= " var db_type = \"".$db_type."\";\n"; + } + if (strlen($db_name) > 0) { + $tmp .= " var db_name = \"".$db_name."\";\n"; + } + if (strlen($db_path) > 0) { + $tmp .= " var db_path = \"".$db_path."\";\n"; + } + if (strlen($dsn_name) > 0) { + $tmp .= " var dsn_name = \"".$dsn_name."\";\n"; + } + if (strlen($dsn_username) > 0) { + $tmp .= " var dsn_username = \"".$dsn_username."\";\n"; + } + if (strlen($dsn_password) > 0) { + $tmp .= " var dsn_password = \"".$dsn_password."\";\n"; + } + $tmp .= "\n"; + $tmp .= "//additional info\n"; + $tmp .= " var tmp_dir = \"".$tmp_dir."\";\n"; + fwrite($fout, $tmp); + unset($tmp); + fclose($fout); +} +?> \ No newline at end of file diff --git a/core/upgrade/root.php b/core/upgrade/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/core/upgrade/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/core/upgrade/upgrade.php b/core/upgrade/upgrade.php new file mode 100644 index 0000000000..8e447677ff --- /dev/null +++ b/core/upgrade/upgrade.php @@ -0,0 +1,101 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//check the permission + if(defined('STDIN')) { + $document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]); + preg_match("/^(.*)\/core\/.*$/", $document_root, $matches); + $document_root = $matches[1]; + set_include_path($document_root); + require_once "includes/require.php"; + $_SERVER["DOCUMENT_ROOT"] = $document_root; + $display_type = 'text'; //html, text + } + else { + include "root.php"; + require_once "includes/require.php"; + require_once "includes/checkauth.php"; + if (permission_exists('upgrade_schema') || permission_exists('upgrade_svn') || if_group("superadmin")) { + //echo "access granted"; + } + else { + echo "access denied"; + exit; + } + } + +//set the default + if (!isset($display_results)) { + $display_results = false; + } + +//include the header + if ($display_results) { + require_once "includes/header.php"; + } + +if ($display_type == 'text') { + echo "\n"; + echo "Upgrade\n"; + echo "-----------------------------------------\n"; + echo "\n"; + echo "Database\n"; +} + +//upgrade the database schema + require_once "core/upgrade/upgrade_schema.php"; + +//show the content + if ($display_type == 'html') { + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Message
Upgrade Completed
\n"; + echo "
\n"; + + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + } + +if ($display_type == 'text') { + echo "\n"; +} + +//include the footer + if ($display_results) { + require_once "includes/footer.php"; + } +?> \ No newline at end of file diff --git a/core/upgrade/upgrade_domains.php b/core/upgrade/upgrade_domains.php new file mode 100644 index 0000000000..9897d28ec5 --- /dev/null +++ b/core/upgrade/upgrade_domains.php @@ -0,0 +1,188 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//check the permission + if(defined('STDIN')) { + $document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]); + preg_match("/^(.*)\/core\/.*$/", $document_root, $matches); + $document_root = $matches[1]; + set_include_path($document_root); + require_once "includes/require.php"; + $_SERVER["DOCUMENT_ROOT"] = $document_root; + $display_type = 'text'; //html, text + } + else { + include "root.php"; + require_once "includes/require.php"; + require_once "includes/checkauth.php"; + if (permission_exists('upgrade_schema') || permission_exists('upgrade_svn') || if_group("superadmin")) { + //echo "access granted"; + } + else { + echo "access denied"; + exit; + } + } + +//copy the files and directories from includes/install + require_once "includes/classes/install.php"; + $install = new install; + $install->domain_uuid = $domain_uuid; + $install->domain_name = $domain; + $install->switch_conf_dir = $_SESSION['switch']['conf']['dir']; + $install->switch_scripts_dir = $_SESSION['switch']['scripts']['dir']; + $install->switch_sounds_dir = $_SESSION['switch']['sounds']['dir']; + $install->copy(); + //print_r($install->result); + +//get the list of installed apps from the core and mod directories + $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php"); + $x=0; + foreach ($config_list as &$config_path) { + include($config_path); + $x++; + } + +//get the domain_uuid + $sql = "select * from v_domains "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach($result as $row) { + if (count($result) == 0) { + $_SESSION["domain_uuid"] = $row["domain_uuid"]; + $_SESSION["domain_name"] = $row['domain_name']; + } + else { + if ($row['domain_name'] == $domain_array[0] || $row['domain_name'] == 'www.'.$domain_array[0]) { + $_SESSION["domain_uuid"] = $row["domain_uuid"]; + $_SESSION["domain_name"] = $row['domain_name']; + } + $_SESSION['domains'][$row['domain_uuid']]['domain_uuid'] = $row['domain_uuid']; + $_SESSION['domains'][$row['domain_uuid']]['domain_name'] = $row['domain_name']; + } + } + unset($result, $prep_statement); + +//get the default settings + $sql = "select * from v_default_settings "; + $sql .= "where default_setting_enabled = 'true' "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + $result_default_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED); + +//get the default recordings directory + foreach($result_default_settings as $row) { + $name = $row['default_setting_name']; + $category = $row['default_setting_category']; + $subcategory = $row['default_setting_subcategory']; + if ($category == 'switch' && $subcategory == 'recordings' && $name == 'dir') { + $switch_recordings_dir = $row['default_setting_value']; + } + } + +//loop through all domains + $sql = "select * from v_domains "; + $v_prep_statement = $db->prepare(check_sql($sql)); + $v_prep_statement->execute(); + $main_result = $v_prep_statement->fetchAll(PDO::FETCH_ASSOC); + $domain_count = count($main_result); + foreach ($main_result as &$row) { + //get the values from database and set them as php variables + $domain_uuid = $row["domain_uuid"]; + $domain_name = $row["domain_name"]; + + //get the context + if ($domain_count == 1) { + $context = "default"; + } + else { + $context = $domain_name; + } + + //show the domain when display_type is set to text + if ($display_type == "text") { + echo "\n"; + echo $domain_name; + echo "\n"; + } + + //get the default settings - this needs to be done to reset the session values back to the defaults for each domain in the loop + foreach($result_defaults_settings as $row) { + $name = $row['default_setting_name']; + $category = $row['default_setting_category']; + $subcategory = $row['default_setting_subcategory']; + if (strlen($subcategory) == 0) { + $_SESSION[$category][$name] = $row['default_setting_value']; + } + else { + $_SESSION[$category][$subcategory][$name] = $row['default_setting_value']; + } + } + + //get the domains settings + $sql = "select * from v_domain_settings "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and domain_setting_enabled = 'true' "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach($result as $row) { + $name = $row['domain_setting_name']; + $category = $row['domain_setting_category']; + $subcategory = $row['domain_setting_subcategory']; + if (strlen($subcategory) == 0) { + //$$category[$name] = $row['domain_setting_value']; + $_SESSION[$category][$name] = $row['domain_setting_value']; + } + else { + //$$category[$subcategory][$name] = $row['domain_setting_value']; + $_SESSION[$category][$subcategory][$name] = $row['domain_setting_value']; + } + } + + //set the recordings directory + if (strlen($switch_recordings_dir) > 1 && count($_SESSION["domains"]) > 1) { + $_SESSION['switch']['recordings']['dir'] = $switch_recordings_dir."/".$domain_name; + } + + //get the list of installed apps from the core and mod directories and execute the php code in app_defaults.php + $default_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_defaults.php"); + foreach ($default_list as &$default_path) { + include($default_path); + } + // synchronize the dialplan + if (function_exists('save_dialplan_xml')) { + save_dialplan_xml(); + } + } + unset ($v_prep_statement); + +//clear the session variables + unset($_SESSION['domain']); + unset($_SESSION['switch']); + +?> \ No newline at end of file diff --git a/core/upgrade/upgrade_schema.php b/core/upgrade/upgrade_schema.php new file mode 100644 index 0000000000..c330294ab7 --- /dev/null +++ b/core/upgrade/upgrade_schema.php @@ -0,0 +1,71 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//check the permission + if(defined('STDIN')) { + $document_root = str_replace("\\", "/", $_SERVER["PHP_SELF"]); + preg_match("/^(.*)\/core\/.*$/", $document_root, $matches); + $document_root = $matches[1]; + set_include_path($document_root); + require_once "includes/require.php"; + $_SERVER["DOCUMENT_ROOT"] = $document_root; + $display_type = 'text'; //html, text + } + else { + include "root.php"; + require_once "includes/require.php"; + require_once "includes/checkauth.php"; + if (permission_exists('upgrade_schema') || if_group("superadmin")) { + //echo "access granted"; + } + else { + echo "access denied"; + exit; + } + require_once "includes/header.php"; + $display_type = 'html'; //html, text + } + +//set the default + if (!isset($display_results)) { + $display_results = true; + } + +//load the default database into memory and compare it with the active database + require_once "includes/lib_schema.php"; + db_upgrade_schema ($db, $db_type, $db_name, $display_results); + unset($apps); + +//upgrade the domains + require_once "core/upgrade/upgrade_domains.php"; + +if ($display_results && $display_type == "html") { + echo "
\n"; + echo "
\n"; + require_once "includes/footer.php"; +} + +?> \ No newline at end of file diff --git a/core/upgrade/upgrade_svn.php b/core/upgrade/upgrade_svn.php new file mode 100644 index 0000000000..bde426585a --- /dev/null +++ b/core/upgrade/upgrade_svn.php @@ -0,0 +1,296 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +/* + $mtime = microtime(); + $mtime = explode(" ",$mtime); + $mtime = $mtime[1] + $mtime[0]; + $start_time = $mtime; +*/ + +include "root.php"; +require_once "includes/require.php"; +require_once "includes/phpsvnclient/phpsvnclient.php"; + +if (!isset($display_results)) { + $display_results = true; +} + +if (strlen($_SERVER['HTTP_USER_AGENT']) > 0) { + require_once "includes/checkauth.php"; + if (permission_exists('upgrade_svn') || if_group("superadmin")) { + //echo "access granted"; + } + else { + echo "access denied"; + exit; + } +} +else { + $display_results = false; //true false + //$display_type = 'csv'; //html, csv +} + +ini_set('display_errors', '0'); +ini_set(max_execution_time,3600); +clearstatcache(); + +if ($display_results) { + require_once "includes/header.php"; +} + +$svn_url = 'http://fusionpbx.googlecode.com/svn/'; +$svn_path = '/trunk/fusionpbx/'; + +//set path_array + $sql = ""; + $sql .= "select * from v_src "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $path = trim($row["path"]); + $path_array[$path][type] = $row["type"]; + $path_array[$path][last_mod] = $row["last_mod"]; + } + unset ($prep_statement); + +$svn = new phpsvnclient($svn_url); +//$svn_version = $svn->getVersion(); +$svn_directory_tree = $svn->getDirectoryTree($svn_path); + +if ($display_results) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; +} + +//$db->beginTransaction(); +foreach ($svn_directory_tree as &$row) { + $md5_match = false; + $xml_type = $row[type]; + $xml_relative_path = trim(str_replace(trim($svn_path,'/'),"",$row[path])); + $xml_last_mod = $row[last_mod]; + $new_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH . $xml_relative_path; + + if (file_exists($new_path)) { + $exists = true; + } + else { + $exists = false; + } + + if ( $xml_type == 'file' ) { + $xml_file_path = trim($row[path]); //we need this to download the file from svn + $md5_xml = $row[md5]; + if ($exists) { + $md5_file = md5_file($new_path); + if ($md5_xml == $md5_file){ + $md5_match = true; + } + } + else { + $md5_match = false;//??? + $md5_file = ''; + } + } + else { + $md5_xml = '';//directory has no md5 + } + + if (strlen($xml_relative_path) > 0) { + if ($display_results) { + if ($xml_type == 'file' && !$md5_match) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + //echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + //file_get_contents($svn_url.$svn_path.$xml_relative_path);\n"; + echo "\n"; + echo "\n"; + } + } + //update the database + if (strlen($sql) > 0) { + $db->exec(check_sql($sql)); + //echo "$sql
\n"; + } + unset($sql); + } +} +//$db->commit(); +//clearstatcache(); +if ($display_results) { + echo "
TypeLast ModifiedPathStatus/SizeMD5 fileMD5 xmlAction
$xml_type$xml_last_mod$xml_relative_path$exists$xml_size$md5_file$md5_xml$md5_match \n"; + } + } + + //update the v_scr data + if ($xml_type=='file' && strlen($path_array[$xml_relative_path]['type']) == 0) { + //insert a new record into the src table + $sql =""; + $sql .= "insert into v_src "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "type, "; + $sql .= "last_mod, "; + $sql .= "path "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$xml_type', "; + $sql .= "'$xml_last_mod', "; + $sql .= "'$xml_relative_path' "; + $sql .= ")"; + //echo "$sql
\n"; + } + else { + if ($xml_type=='file' && !$md5_match) {//update changed files + //update the src table + $sql =""; + $sql .= "update v_src set "; + $sql .= "type = '$xml_type', "; + $sql .= "last_mod = '$xml_last_mod' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and path = '$xml_relative_path' "; + } + } + //if the path exists and is a file + if ($exists && $xml_type == 'file') { + //the md5 of the xml file and the local file do not match + if ($md5_match) { + if ($display_results) { + //echo "current "; //the file is up to date + } + } + else { +/* if ($xml_file_path == '/core/upgrade/upgrade_svn.php' ) { + if ($display_results) { + echo "white list"; //the file is up to date + } + continue; + } +*/ //get the remote file contents + $file_content = $svn->getFile($xml_file_path); + + //the md5 of the local file and the remote content match + if (md5_file($new_path) == md5($file_content)) { + if ($display_results) { + //echo "current 2 "; //the file is up to date + } + } + else { + //make sure the string matches the file md5 that was recorded. + if (strlen($file_content) > 0) { + $tmp_fh = fopen($new_path, 'w'); + fwrite($tmp_fh, $file_content); + fclose($tmp_fh); + } + + //display the results + if ($display_results) { + echo " "; + if (is_writable($new_path)) { + echo "updated "; + } + else { + echo "not writable "; + } + echo ""; + } + } + } + //unset the variable + unset($file_content); + } + else { + + //if the path does not exist create it and then add it to the database + //echo "file is missing |"; + if ($xml_type == 'directory' && !$exists) { + //make sure the directory exists + mkdir (dirname($new_path), 0755, true); + } + if ($xml_type == 'file') { + //make sure the directory exists + if (!is_dir(dirname($new_path))){ + mkdir (dirname($new_path), 0755, true); + } + + //get the remote file contents + $file_content = $svn->getFile($xml_file_path); + + //make sure we got some data. + if (strlen($file_content) > 0) { + $tmp_fh = fopen($new_path, 'w'); + fwrite($tmp_fh, $file_content); + fclose($tmp_fh); + } + + if ($display_results) { + echo " "; + if (is_writable($new_path)) { + echo "added/restored"; + } + else { + echo "not writable "; + } + echo ""; + //echo "
\n"; + } + //unset the variable + unset($file_content); + } + } + + if ($display_results) { + if ($xml_type == 'file' && !$md5_match) { + echo " "; + echo "
\n"; + require_once "includes/footer.php"; +} +/* + $mtime = microtime(); + $mtime = explode(" ",$mtime); + $mtime = $mtime[1] + $mtime[0]; + $end_time = $mtime; + $total_time = ($end_time - $start_time); + echo "This page was created in ".$total_time." seconds"; +*/ +?> \ No newline at end of file diff --git a/core/users/app_config.php b/core/users/app_config.php new file mode 100644 index 0000000000..f72aa9d339 --- /dev/null +++ b/core/users/app_config.php @@ -0,0 +1,356 @@ + \ No newline at end of file diff --git a/core/users/app_defaults.php b/core/users/app_defaults.php new file mode 100644 index 0000000000..46ca4e85ab --- /dev/null +++ b/core/users/app_defaults.php @@ -0,0 +1,169 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//if the are no groups add the default groups + $sql = "SELECT * FROM v_groups "; + $sql .= "WHERE domain_uuid = '$domain_uuid' "; + $sub_result = $db->query($sql)->fetch(); + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $sub_result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + if (count($sub_result) == 0) { + $x = 0; + $tmp[$x]['group_name'] = 'superadmin'; + $tmp[$x]['group_description'] = 'Super Administrator Group'; + $x++; + $tmp[$x]['group_name'] = 'admin'; + $tmp[$x]['group_description'] = 'Administrator Group'; + $x++; + $tmp[$x]['group_name'] = 'user'; + $tmp[$x]['group_description'] = 'User Group'; + $x++; + $tmp[$x]['group_name'] = 'public'; + $tmp[$x]['group_description'] = 'Public Group'; + $x++; + $tmp[$x]['group_name'] = 'agent'; + $tmp[$x]['group_description'] = 'Call Center Agent Group'; + foreach($tmp as $row) { + if (strlen($row['group_name']) > 0) { + $sql = "insert into v_groups "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "group_uuid, "; + $sql .= "group_name, "; + $sql .= "group_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'".uuid()."', "; + $sql .= "'".$row['group_name']."', "; + $sql .= "'".$row['group_description']."' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + } + } + } + unset($prep_statement, $sub_result); + +//if there are no permissions listed in v_group_permissions then set the default permissions + $sql = "select count(*) as count from v_group_permissions "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + $sub_result = $prep_statement->fetch(PDO::FETCH_ASSOC); + unset ($prep_statement); + if ($sub_result['count'] > 0) { + if ($display_type == "text") { + echo " Group Permissions: no change\n"; + } + } + else { + if ($display_type == "text") { + echo " Group Permissions: added\n"; + } + //no permissions found add the defaults + $db->beginTransaction(); + foreach($apps as $app) { + foreach ($app['permissions'] as $sub_row) { + foreach ($sub_row['groups'] as $group) { + //add the record + $sql = "insert into v_group_permissions "; + $sql .= "("; + $sql .= "group_permission_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "permission_name, "; + $sql .= "group_name "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$domain_uuid', "; + $sql .= "'".$sub_row['name']."', "; + $sql .= "'".$group."' "; + $sql .= ")"; + $db->exec($sql); + unset($sql); + } + } + } + $db->commit(); + } + +//find rows that have a null user_uuid and set the correct user_uuid + $sql = "select * from v_group_users "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and user_uuid is null; "; + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach($result as $row) { + if (strlen($row['username']) > 0) { + //get the user_uuid + $sql = "select user_uuid from v_users "; + $sql .= "where username = '".$row['username']."' "; + $prep_statement_sub = $db->prepare($sql); + $prep_statement_sub->execute(); + $sub_result = $prep_statement_sub->fetch(PDO::FETCH_ASSOC); + unset ($prep_statement_sub); + $user_uuid = $sub_result['user_uuid']; + //set the user uuid + $sql = "update v_group_users set "; + $sql .= "user_uuid = '".$user_uuid."' "; + $sql .= "where username = '".$row['username']."'; "; + $db->exec($sql); + unset($sql); + } + else { + //get the number of users + $sql = "select count(*) as num_rows from v_users "; + $prep_statement_sub = $db->prepare($sql); + $prep_statement_sub->execute(); + $sub_result = $prep_statement_sub->fetch(PDO::FETCH_ASSOC); + unset ($prep_statement_sub); + $num_rows = $sub_result['num_rows']; + if ($num_rows == 1) { + //get the user_uuid + $sql = "select user_uuid from v_users "; + $prep_statement_sub = $db->prepare($sql); + $prep_statement_sub->execute(); + $sub_result = $prep_statement_sub->fetch(PDO::FETCH_ASSOC); + unset ($prep_statement_sub); + $user_uuid = $sub_result['user_uuid']; + //set the user uuid + $sql = "update v_group_users set "; + $sql .= "user_uuid = '".$user_uuid."' "; + $db->exec($sql); + unset($sql); + } + } + } + } +?> \ No newline at end of file diff --git a/core/users/group_permissions.php b/core/users/group_permissions.php new file mode 100644 index 0000000000..2dbfd0bab2 --- /dev/null +++ b/core/users/group_permissions.php @@ -0,0 +1,275 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('group_permissions') || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} +require_once "includes/header.php"; +require_once "includes/paging.php"; + +//get the list of installed apps from the core and mod directories + $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php"); + $x=0; + foreach ($config_list as &$config_path) { + include($config_path); + $x++; + } + +//if there are no permissions listed in v_group_permissions then set the default permissions + $sql = ""; + $sql .= "select count(*) as count from v_group_permissions "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $group_permission_count = $row["count"]; + break; //limit to 1 row + } + unset ($prep_statement); + if ($group_permission_count == 0) { + //no permissions found add the defaults + foreach($apps as $app) { + foreach ($app['permissions'] as $row) { + foreach ($row['groups'] as $group) { + //add the record + $sql = "insert into v_group_permissions "; + $sql .= "("; + $sql .= "group_permission_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "permission_name, "; + $sql .= "group_name "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$domain_uuid', "; + $sql .= "'".$row['name']."', "; + $sql .= "'".$group."' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + } + } + } + +//get the http values and set them as php variables + $group_name = $_REQUEST['group_name']; + +//get the permissions assigned to this group + $sql = ""; + $sql .= " select * from v_group_permissions "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and group_name = '$group_name' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $permission_name = $row["permission_name"]; + $permissions_db[$permission_name] = "true"; + } +//show the db checklist + //echo "
";
+	//print_r($permissions_db);
+	//echo "
"; + +//list all the permissions in the database + foreach($apps as $app) { + foreach ($app['permissions'] as $row) { + if ($permissions_db[$row['name']] == "true") { + $permissions_db_checklist[$row['name']] = "true"; + } + else { + $permissions_db_checklist[$row['name']] = "false"; + } + } + } +//show the db checklist + //echo "
";
+	//print_r($permissions_db_checklist);
+	//echo "
"; + +//process the http post + if (count($_POST)>0) { + foreach($_POST['permissions_form'] as $permission) { + $permissions_form[$permission] = "true"; + } + + //list all the permissions + foreach($apps as $app) { + foreach ($app['permissions'] as $row) { + if ($permissions_form[$row['name']] == "true") { + $permissions_form_checklist[$row['name']] = "true"; + } + else { + $permissions_form_checklist[$row['name']] = "false"; + } + } + } + //show the form db checklist + //echo "
";
+			//print_r($permissions_form_checklist);
+			//echo "
"; + + //list all the permissions + foreach($apps as $app) { + foreach ($app['permissions'] as $row) { + $permission = $row['name']; + if ($permissions_db_checklist[$permission] == "true" && $permissions_form_checklist[$permission] == "true") { + //matched do nothing + } + if ($permissions_db_checklist[$permission] == "false" && $permissions_form_checklist[$permission] == "false") { + //matched do nothing + } + if ($permissions_db_checklist[$permission] == "true" && $permissions_form_checklist[$permission] == "false") { + //delete the record + $sql = "delete from v_group_permissions "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and group_name = '$group_name' "; + $sql .= "and permission_name = '$permission' "; + $db->exec(check_sql($sql)); + unset($sql); + //set the permission to false in the permissions_db_checklist + $permissions_db_checklist[$permission] = "false"; + } + if ($permissions_db_checklist[$permission] == "false" && $permissions_form_checklist[$permission] == "true") { + //add the record + $sql = "insert into v_group_permissions "; + $sql .= "("; + $sql .= "group_permission_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "permission_name, "; + $sql .= "group_name "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$domain_uuid', "; + $sql .= "'$permission', "; + $sql .= "'$group_name' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + //set the permission to true in the permissions_db_checklist + $permissions_db_checklist[$permission] = "true"; + } + } + } + } + +//show the content + echo "
\n"; + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
Group Permission List for $group_name\n"; + echo " "; + echo "
\n"; + echo " Assign permissions to groups.

\n"; + echo "
\n"; + + echo "
\n"; + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + + //list all the permissions + foreach($apps as $app) { + $app_name = $app['name']; + $description = $app['description']['en']; + + echo "".$app_name."
\n"; + echo "".$description."

"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + foreach ($app['permissions'] as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } + + echo "\n"; + echo " \n"; + echo "\n"; + echo "
PermissionsDescription
\n"; + if ($permissions_db_checklist[$row['name']] == "true") { + echo " \n"; + } + else { + echo " \n"; + } + echo "   ".$row['name']."\n"; + echo " \n"; + echo "   ".$row['description']."\n"; + echo "
\n"; + echo " \n"; + echo "
"; + echo "
\n"; + } //end foreach + unset($sql, $result, $row_count); + + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "\n"; + + echo "

"; + +//show the footer + require_once "includes/footer.php"; + +?> diff --git a/core/users/groupadd.php b/core/users/groupadd.php new file mode 100644 index 0000000000..8d7ffbe054 --- /dev/null +++ b/core/users/groupadd.php @@ -0,0 +1,134 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('group_add')) { + //access allowed +} +else { + echo "access denied"; + return; +} + +//get the http values and set them as variables + $path = check_str($_GET["path"]); + $msg = check_str($_GET["msg"]); + $group_name = check_str($_POST["group_name"]); + $group_description = check_str($_POST["group_description"]); + +if (strlen($group_name) > 0) { + $sql_insert = "insert into v_groups "; + $sql_insert .= "("; + $sql_insert .= "domain_uuid, "; + $sql_insert .= "group_uuid, "; + $sql_insert .= "group_name, "; + $sql_insert .= "group_description "; + $sql_insert .= ")"; + $sql_insert .= "values "; + $sql_insert .= "("; + $sql_insert .= "'$domain_uuid', "; + $sql_insert .= "'".uuid()."', "; + $sql_insert .= "'$group_name', "; + $sql_insert .= "'$group_description' "; + $sql_insert .= ")"; + if (!$db->exec($sql_insert)) { + //echo $db->errorCode() . "
"; + $info = $db->errorInfo(); + print_r($info); + // $info[0] == $db->errorCode() unified error code + // $info[1] is the driver specific error code + // $info[2] is the driver specific error string + } + + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
\n"; + echo "Group Added\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; +} + +//include the header + include "includes/header.php"; + +//show the content + echo "

"; + echo "
"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " Please choose a group name. "; + echo " \n"; + echo " "; + echo "
\n"; + echo "
"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "Group Name:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Description:\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo ""; + echo "
"; + + echo "

"; + echo "

"; + +//include the footer + include "includes/footer.php"; + +?> diff --git a/core/users/groupdelete.php b/core/users/groupdelete.php new file mode 100644 index 0000000000..b0c6c40568 --- /dev/null +++ b/core/users/groupdelete.php @@ -0,0 +1,56 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('group_delete') || if_group("superadmin")) { + //access allowed +} +else { + echo "access denied"; + return; +} + +//get the http value and set as a variable + $id = check_str($_GET["id"]); + +//delete the group + $sqldelete = "delete from v_groups "; + $sqldelete .= "where domain_uuid = '$domain_uuid' "; + $sqldelete .= "and group_uuid = '$id' "; + if (!$db->exec($sqldelete)) { + //echo $db->errorCode() . "
"; + $info = $db->errorInfo(); + print_r($info); + // $info[0] == $db->errorCode() unified error code + // $info[1] is the driver specific error code + // $info[2] is the driver specific error string + } + +//redirect the user + header("Location: grouplist.php"); + +?> diff --git a/core/users/grouplist.php b/core/users/grouplist.php new file mode 100644 index 0000000000..1978710cc0 --- /dev/null +++ b/core/users/grouplist.php @@ -0,0 +1,137 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; + +//check the permissions + require_once "includes/checkauth.php"; + if (if_group("admin") || if_group("superadmin")) { + //access allowed + } + else { + echo "access denied"; + return; + } + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
\n"; + echo ""; + echo ""; + echo ""; + echo "
"; + + echo ""; + echo ""; + echo "\n"; + echo "
Group List"; + if (permission_exists('user_view')) { + echo " "; + } + echo "
"; + + $sql = "SELECT * FROM v_groups "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + $strlist = "\n"; + $strlist .= "\n"; + $strlist .= " \n"; + $strlist .= " \n"; + $strlist .= " \n"; + + $strlist .= " \n"; + $strlist .= "\n"; + + $count = 0; + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $group_name = $row["group_name"]; + $group_uuid = $row["group_uuid"]; + $group_description = $row["group_description"]; + if (strlen($group_name) == 0) { $group_name = " "; } + if (strlen($group_description) == 0) { $group_description = " "; } + $group_description = wordwrap($group_description, 50, "
\n"); + + if (!if_group("superadmin") && $group_name == "superadmin") { + //hide the superadmin group from non superadmin's + } + else { + $strlist .= ""; + $strlist .= "\n"; + $strlist .= "\n"; + + $strlist .= "\n"; + + $strlist .= "\n"; + $strlist .= "\n"; + } + if ($c==0) { $c=1; } else { $c=0; } + $count++; + } + + $strlist .= "\n"; + $strlist .= "\n"; + $strlist .= "\n"; + + $strlist .= "
  Group Name     Group Description    \n"; + if (permission_exists('group_add')) { + $strlist .= " $v_link_label_add\n"; + } + $strlist .= "
  $group_name     $group_description   \n"; + if (permission_exists('group_add') || if_group("superadmin")) { + $strlist .= " Permissions  "; + } + if (permission_exists('group_member_view') || if_group("superadmin")) { + $strlist .= " Members "; + } + $strlist .= "\n"; + $strlist .= "$v_link_label_delete\n"; + + $strlist .= "
\n"; + if (permission_exists('group_add')) { + $strlist .= " $v_link_label_add\n"; + } + $strlist .= "
\n"; + if ($count > 0) { + echo $strlist; + } + + echo "
"; + echo "
"; + echo "
"; + +//show the footer + require_once "includes/footer.php"; + +?> \ No newline at end of file diff --git a/core/users/groupmemberadd.php b/core/users/groupmemberadd.php new file mode 100644 index 0000000000..c93bb456ab --- /dev/null +++ b/core/users/groupmemberadd.php @@ -0,0 +1,80 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('group_member_add') || if_group("superadmin")) { + //access allowed +} +else { + echo "access denied"; + return; +} + +//requires a superadmin to add a user to the superadmin group + if (!if_group("superadmin") && $_GET["group_name"] == "superadmin") { + echo "access denied"; + return; + } + +//get the http values and set them as variables + $group_name = check_str($_POST["group_name"]); + $user_uuid = check_str($_POST["user_uuid"]); + +if (strlen($user_uuid) > 0 && strlen($group_name) > 0) { + $sql_insert = "insert into v_group_users "; + $sql_insert .= "("; + $sql_insert .= "group_user_uuid, "; + $sql_insert .= "domain_uuid, "; + $sql_insert .= "group_name, "; + $sql_insert .= "user_uuid "; + $sql_insert .= ")"; + $sql_insert .= "values "; + $sql_insert .= "("; + $sql_insert .= "'".uuid()."', "; + $sql_insert .= "'$domain_uuid', "; + $sql_insert .= "'$group_name', "; + $sql_insert .= "'$user_uuid' "; + $sql_insert .= ")"; + if (!$db->exec($sql_insert)) { + //echo $db->errorCode() . "
"; + $info = $db->errorInfo(); + print_r($info); + // $info[0] == $db->errorCode() unified error code + // $info[1] is the driver specific error code + // $info[2] is the driver specific error string + } + else { + //log the success + //$log_type = 'group'; $log_status='add'; $log_add_user=$_SESSION["username"]; $log_desc= "username: ".$username." added to group: ".$group_name; + //log_add($db, $log_type, $log_status, $log_desc, $log_add_user, $_SERVER["REMOTE_ADDR"]); + } +} + +//redirect the user + header("Location: groupmembers.php?group_name=$group_name"); + +?> \ No newline at end of file diff --git a/core/users/groupmemberdelete.php b/core/users/groupmemberdelete.php new file mode 100644 index 0000000000..e9019f6983 --- /dev/null +++ b/core/users/groupmemberdelete.php @@ -0,0 +1,68 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('group_member_delete') || if_group("superadmin")) { + //access allowed +} +else { + echo "access denied"; + return; +} + +//requires a superadmin to delete superadmin group + if (!if_group("superadmin") && $_GET["group_name"] == "superadmin") { + echo "access denied"; + return; + } + +//get the http values and set them as variables + $group_name = check_str($_GET["group_name"]); + $user_uuid = check_str($_GET["user_uuid"]); + +//delete the group membership + $sql_delete = "delete from v_group_users "; + $sql_delete .= "where domain_uuid = '$domain_uuid' "; + $sql_delete .= "and user_uuid = '$user_uuid' "; + $sql_delete .= "and group_name = '$group_name' "; + if (!$db->exec($sql_delete)) { + //echo $db->errorCode() . "
"; + $info = $db->errorInfo(); + print_r($info); + // $info[0] == $db->errorCode() unified error code + // $info[1] is the driver specific error code + // $info[2] is the driver specific error string + } + else { + //$log_type = 'group'; $log_status='remove'; $log_add_user=$_SESSION["username"]; $log_desc= "username: ".$username." removed from group: ".$group_name; + //log_add($db, $log_type, $log_status, $log_desc, $log_add_user, $_SERVER["REMOTE_ADDR"]); + } + +//redirect the user + header("Location: groupmembers.php?group_name=$group_name"); + +?> \ No newline at end of file diff --git a/core/users/groupmembers.php b/core/users/groupmembers.php new file mode 100644 index 0000000000..2ee1ae6589 --- /dev/null +++ b/core/users/groupmembers.php @@ -0,0 +1,166 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('group_members_view') || if_group("superadmin")) { + //access allowed +} +else { + echo "access denied"; + return; +} + +//requires a superadmin to view members of the superadmin group + if (!if_group("superadmin") && $_GET["group_name"] == "superadmin") { + echo "access denied"; + return; + } + +//get the http value and set as a variable + $group_name = $_GET["group_name"]; + +//define the if group members function + function if_group_members($db, $group_name, $user_uuid) { + $sql = "select * from v_group_users "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and group_name = '$group_name' "; + $sql .= "and user_uuid = '$user_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + if (count($prep_statement->fetchAll(PDO::FETCH_NAMED)) == 0) { return true; } else { return false; } + unset ($sql, $prep_statement); + } + //$exampledatareturned = example("apples", 1); + +//include the header + require_once "includes/header.php"; + +//show the content + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + + echo "
\n"; + echo ""; + echo ""; + echo "
\n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " Member list for $group_name"; + echo " \n"; + echo " "; + echo "    \n"; + echo "
\n"; + + $sql = "SELECT u.user_uuid, u.username, g.group_user_uuid FROM v_group_users as g, v_users as u "; + $sql .= "where g.user_uuid = u.user_uuid "; + $sql .= "and g.domain_uuid = '$domain_uuid' "; + $sql .= "and g.group_name = '$group_name' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + + $strlist = "\n"; + $strlist .= "\n"; + $strlist .= " \n"; + $strlist .= " \n"; + $strlist .= " \n"; + $strlist .= "\n"; + + $count = 0; + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $group_user_uuid = $row["group_user_uuid"]; + $username = $row["username"]; + $user_uuid = $row["user_uuid"]; + $strlist .= ""; + $strlist .= "\n"; + $strlist .= "\n"; + $strlist .= "\n"; + $strlist .= "\n"; + + if ($c==0) { $c=1; } else { $c=0; } + $count++; + } + + $strlist .= "
  Username       \n"; + $strlist .= "  \n"; + $strlist .= "
  $username     \n"; + if (permission_exists('group_member_delete')) { + $strlist .= " $v_link_label_delete\n"; + } + $strlist .= "
\n"; + echo $strlist; + + echo "
"; + echo "
"; + + echo "
"; + echo "
"; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
"; + + $sql = "SELECT * FROM v_users "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "order by username "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + + echo ""; + unset($sql, $result); + + echo " "; + if (permission_exists('group_member_add')) { + echo " "; + echo " "; + } + echo "
"; + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/core/users/index.php b/core/users/index.php new file mode 100644 index 0000000000..b4fb355ab6 --- /dev/null +++ b/core/users/index.php @@ -0,0 +1,57 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('user_view') || if_group("superadmin")) { + //access allowed +} +else { + echo "access denied"; + return; +} + +//include the header + require_once "includes/header.php"; + +//show the user list + echo "
"; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
"; + require_once "userlist.php"; + echo "
"; + echo "
"; + echo "
"; + echo "
"; + echo "
"; + +//include the footer + include "includes/footer.php"; + +?> diff --git a/core/users/root.php b/core/users/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/core/users/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/core/users/signup.php b/core/users/signup.php new file mode 100644 index 0000000000..c67892b240 --- /dev/null +++ b/core/users/signup.php @@ -0,0 +1,258 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; + +if (if_group("admin") || if_group("superadmin")) { + //access allowed +} +else { + echo "access denied"; + return; +} + +$username = check_str($_POST["username"]); +$password = check_str($_POST["password"]); +$confirmpassword = check_str($_POST["confirmpassword"]); +$contact_organization = check_str($_POST["contact_organization"]); +$contact_name_given = check_str($_POST["contact_name_given"]); +$contact_name_family = check_str($_POST["contact_name_family"]); +$user_email = check_str($_POST["user_email"]); + +if (count($_POST)>0 && check_str($_POST["persistform"]) != "1") { + + $msgerror = ''; + + //--- begin captcha verification --------------------- + //session_start(); //make sure sessions are started + if (strtolower($_SESSION["captcha"]) != strtolower($_REQUEST["captcha"]) || strlen($_SESSION["captcha"]) == 0) { + //$msgerror .= "Captcha Verification Failed
\n"; + } + else { + //echo "verified"; + } + //--- end captcha verification ----------------------- + + //username is already used. + if (strlen($username) == 0) { + $msgerror .= "Please provide a Username.
\n"; + } + else { + $sql = "SELECT * FROM v_users "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and username = '$username' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + if (count($prep_statement->fetchAll(PDO::FETCH_NAMED)) > 0) { + $msgerror .= "Please choose a different Username.
\n"; + } + } + + if (strlen($password) == 0) { $msgerror .= "Password cannot be blank.
\n"; } + if ($password != $confirmpassword) { $msgerror .= "Passwords did not match.
\n"; } + //if (strlen($contact_organization) == 0) { $msgerror .= "Please provide a organization name.
\n"; } + //if (strlen($contact_name_given) == 0) { $msgerror .= "Please provide a first name.
\n"; } + //if (strlen($contact_name_family) == 0) { $msgerror .= "Please provide a last name $user_last_name.
\n"; } + if (strlen($user_email) == 0) { $msgerror .= "Please provide an email.
\n"; } + + if (strlen($msgerror) > 0) { + require_once "includes/header.php"; + echo "
"; + echo "
"; + echo $msgerror; + echo "
"; + require_once "includes/persistform.php"; + echo persistform($_POST); + echo "
"; + require_once "includes/footer.php"; + return; + } + + //salt used with the password to create a one way hash + $salt = generate_password('20', '4'); + + //prepare the uuids + $user_uuid = uuid(); + $contact_uuid = uuid(); + + //add the user + $sql = "insert into v_users "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "user_uuid, "; + $sql .= "contact_uuid, "; + $sql .= "username, "; + $sql .= "password, "; + $sql .= "salt, "; + $sql .= "user_add_date, "; + $sql .= "user_add_user "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$user_uuid', "; + $sql .= "'$contact_uuid', "; + $sql .= "'$username', "; + $sql .= "'".md5($salt.$password)."', "; + $sql .= "'".$salt."', "; + $sql .= "now(), "; + $sql .= "'".$_SESSION["username"]."' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //add to contacts + $sql = "insert into v_contacts "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "contact_uuid, "; + $sql .= "contact_type, "; + $sql .= "contact_organization, "; + $sql .= "contact_name_given, "; + $sql .= "contact_name_family, "; + $sql .= "contact_nickname, "; + $sql .= "contact_email "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$contact_uuid', "; + $sql .= "'user', "; + $sql .= "'$contact_organization', "; + $sql .= "'$contact_name_given', "; + $sql .= "'$contact_name_family', "; + $sql .= "'$username', "; + $sql .= "'$user_email' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //log the success + //$log_type = 'user'; $log_status='add'; $log_add_user=$_SESSION["username"]; $log_desc= "username: ".$username." user added."; + //log_add($db, $log_type, $log_status, $log_desc, $log_add_user, $_SERVER["REMOTE_ADDR"]); + + $group_name = 'user'; + $sql = "insert into v_group_users "; + $sql .= "("; + $sql .= "group_user_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "group_name, "; + $sql .= "user_uuid "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$domain_uuid', "; + $sql .= "'$group_name', "; + $sql .= "'$user_uuid' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + require_once "includes/header.php"; + echo "\n"; + echo "
Add Complete
"; + require_once "includes/footer.php"; + return; +} + +//show the header + require_once "includes/header.php"; + +//show the content + echo "
"; + echo "\n"; + echo "\n"; + echo " "; + echo " "; + echo "
\n"; + echo "
"; + + $tablewidth ='width="100%"'; + echo "
"; + echo "
\n"; + + echo ""; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " To add a user, please fill out this form completely. All fields are required.
"; + echo "
\n"; + echo " \n"; + echo "
\n"; + + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo "
Username:
Password:
Confirm Password:
Email:
First Name:
Last Name:
Company Name:
"; + echo "
"; + + echo "
\n"; + echo ""; + echo " "; + echo " "; + echo " "; + echo "
"; + echo " "; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +//show the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/core/users/userdelete.php b/core/users/userdelete.php new file mode 100644 index 0000000000..492abcc9fc --- /dev/null +++ b/core/users/userdelete.php @@ -0,0 +1,87 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists('user_delete')) { + //access allowed +} +else { + echo "access denied"; + return; +} + +//get the id + $user_uuid = check_str($_GET["id"]); + +//get the username from v_users + $sql = ""; + $sql .= "select * from v_users "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and user_uuid = '$user_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $username = $row["username"]; + break; //limit to 1 row + } + unset ($prep_statement); + +//required to be a superadmin to delete a member of the superadmin group + $superadmin_list = superadmin_list($db); + if (if_superadmin($superadmin_list, $_SESSION['user_uuid'])) { + if (!if_group("superadmin")) { + echo "access denied"; + return; + } + } +//delete the user + $sql_delete = "delete from v_users "; + $sql_delete .= "where domain_uuid = '$domain_uuid' "; + $sql_delete .= "and user_uuid = '$user_uuid' "; + if (!$db->exec($sql_delete)) { + //echo $db->errorCode() . "
"; + $info = $db->errorInfo(); + print_r($info); + // $info[0] == $db->errorCode() unified error code + // $info[1] is the driver specific error code + // $info[2] is the driver specific error string + } + +//delete the groups the user is assigned to + $sql_delete = "delete from v_group_users "; + $sql_delete .= "where domain_uuid = '$domain_uuid' "; + $sql_delete .= "and user_uuid = '$user_uuid' "; + if (!$db->exec($sql_delete)) { + $info = $db->errorInfo(); + print_r($info); + } + +//redirect the user + header("Location: index.php"); + +?> \ No newline at end of file diff --git a/core/users/userlist.php b/core/users/userlist.php new file mode 100644 index 0000000000..8afe8d49be --- /dev/null +++ b/core/users/userlist.php @@ -0,0 +1,192 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists("user_view") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} +//require_once "includes/header.php"; + require_once "includes/paging.php"; + +$order_by = $_GET["order_by"]; +$order = $_GET["order"]; +$field_name = $_REQUEST["field_name"]; +$field_value = $_REQUEST["field_value"]; + +echo "
"; +echo "\n"; +echo "\n"; +echo " "; +echo ""; +echo "
\n"; + +//page title and description + echo "\n"; + echo ""; + echo "\n"; + echo "\n"; + echo ""; + echo "\n"; + echo ""; + echo ""; + echo ""; + //echo "  \n"; + echo "\n"; + echo ""; + + echo "\n"; + echo "\n"; + echo "\n"; + +//get the user list from the database + $sql = ""; + $sql .= " select * from v_users "; + $sql .= " where domain_uuid = '$domain_uuid' "; + if (strlen($field_name) > 0 && strlen($field_value) > 0) { + $sql .= " and $field_name = '$field_value' "; + } + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $num_rows = count($result); + unset ($prep_statement, $result, $sql); + $rows_per_page = 200; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + + $sql = ""; + $sql .= " select * from v_users "; + $sql .= " where domain_uuid = '".$_SESSION['domain_uuid']."' "; + if (strlen($field_name) > 0 && strlen($field_value) > 0) { + $sql .= " and $field_name like '%$field_value%' "; + } + if (strlen($order_by)> 0) { + $sql .= "order by $order_by $order "; + } + else { + $sql .= "order by username "; + } + $sql .= " limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + unset ($prep_statement, $sql); + +//alternate the row style + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + +//show the data + echo "
\n"; + echo "
User ManagerSearch by: \n"; + echo " \n"; + echo " 
\n"; + echo "Add, edit, delete, and search for users. \n"; + echo "
\n"; + echo "
\n"; + echo "
\n"; + + echo "\n"; + echo th_order_by('username', 'Username', $order_by, $order); + //echo th_order_by('user_email', 'Email', $order_by, $order); + //echo th_order_by('user_template_name', 'Template', $order_by, $order); + echo "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + if (permission_exists('user_add')) { + echo " $v_link_label_add\n"; + } + echo "
".$row['username']." ".$row['user_email']." \n"; + if (permission_exists('user_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('user_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('user_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
"; + echo ""; + echo "

"; + echo "

"; + +echo "
"; +echo "
"; +echo "

"; + +?> diff --git a/core/users/usersupdate.php b/core/users/usersupdate.php new file mode 100644 index 0000000000..5404f652da --- /dev/null +++ b/core/users/usersupdate.php @@ -0,0 +1,612 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (permission_exists("user_add") || + permission_exists("user_edit") || + permission_exists("user_delete") || + if_group("superadmin")) { + //access allowed +} +else { + echo "access denied"; + return; +} + +//get data from the db + if (strlen($_REQUEST["id"])> 0) { + $user_uuid = $_REQUEST["id"]; + } + else { + if (strlen($_SESSION["username"]) > 0) { + $username = $_SESSION["username"]; + } + } + +//get the username from v_users + $sql = "select * from v_users "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and user_uuid = '$user_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $username = $row["username"]; + break; //limit to 1 row + } + unset ($prep_statement); + +//required to be a superadmin to update an account that is a member of the superadmin group + $superadmin_list = superadmin_list($db); + if (if_superadmin($superadmin_list, $_SESSION['user_uuid'])) { + if (!if_group("superadmin")) { + echo "access denied"; + return; + } + } + +//delete the group from the user + if ($_GET["a"] == "delete" && permission_exists("user_delete")) { + //set the variables + $group_name = check_str($_GET["group_name"]); + //delete the group from the users + $sql = "delete from v_group_users "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and group_name = '$group_name' "; + $sql .= "and user_uuid = '$user_uuid' "; + $db->exec(check_sql($sql)); + //redirect the user + require_once "includes/header.php"; + echo "\n"; + echo "
Update Complete
"; + require_once "includes/footer.php"; + return; + } + +//get the user settings + $sql = "select * from v_user_settings "; + $sql .= "where user_uuid = '".$_SESSION["user_uuid"]."' "; + $sql .= "and user_setting_enabled = 'true' "; + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach($result as $row) { + $name = $row['user_setting_name']; + $category = $row['user_setting_category']; + $subcategory = $row['user_setting_subcategory']; + if (strlen($subcategory) == 0) { + //$$category[$name] = $row['domain_setting_value']; + $user_settings[$category][$name] = $row['user_setting_value']; + } + else { + $user_settings[$category][$subcategory][$name] = $row['user_setting_value']; + } + } + } + +if (count($_POST)>0 && $_POST["persistform"] != "1") { + $user_uuid = $_REQUEST["id"]; + $password = check_str($_POST["password"]); + $confirm_password = check_str($_POST["confirm_password"]); + $user_status = check_str($_POST["user_status"]); + //$user_template_name = check_str($_POST["user_template_name"]); + $user_time_zone = check_str($_POST["user_time_zone"]); + $contact_uuid = check_str($_POST["contact_uuid"]); + $group_member = check_str($_POST["group_member"]); + + //if (strlen($password) == 0) { $msg_error .= "Password cannot be blank.
\n"; } + //if (strlen($username) == 0) { $msg_error .= "Please provide the username.
\n"; } + if ($password != $confirm_password) { $msg_error .= "Passwords did not match.
\n"; } + //if (strlen($contact_uuid) == 0) { $msg_error .= "Please provide an email.
\n"; } + //if (strlen($user_time_zone) == 0) { $msg_error .= "Please provide an time zone.
\n"; } + if ($msg_error) { + require_once "includes/header.php"; + echo "
"; + echo "
"; + echo $msg_error; + echo "
"; + echo "
\n"; + require_once "includes/persistform.php"; + echo persistform($_POST); + echo "
"; + require_once "includes/footer.php"; + return; + } + + //get the number of rows in v_user_settings + $sql = "select count(*) as num_rows from v_user_settings "; + $sql .= "where user_setting_category = 'domain' "; + $sql .= "and user_setting_subcategory = 'time_zone' "; + $sql .= "and user_uuid = '".$user_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] == 0) { + $user_setting_uuid = uuid(); + $sql = "insert into v_user_settings "; + $sql .= "("; + $sql .= "user_setting_uuid, "; + $sql .= "user_setting_category, "; + $sql .= "user_setting_subcategory, "; + $sql .= "user_setting_name, "; + $sql .= "user_setting_value, "; + $sql .= "user_setting_enabled, "; + $sql .= "user_uuid "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$user_setting_uuid."', "; + $sql .= "'domain', "; + $sql .= "'time_zone', "; + $sql .= "'name', "; + $sql .= "'".$user_time_zone."', "; + $sql .= "'true', "; + $sql .= "'".$user_uuid."' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + } + else { + if (strlen($user_time_zone) == 0) { + $sql = "delete from v_user_settings "; + $sql .= "where user_setting_category = 'domain' "; + $sql .= "and user_setting_subcategory = 'time_zone' "; + $sql .= "and user_uuid = '".$user_uuid."' "; + $db->exec(check_sql($sql)); + unset($sql); + } + else { + $sql = "update v_user_settings set "; + $sql .= "user_setting_value = '".$user_time_zone."', "; + $sql .= "user_setting_enabled = 'true' "; + $sql .= "where user_setting_category = 'domain' "; + $sql .= "and user_setting_subcategory = 'time_zone' "; + $sql .= "and user_uuid = '".$user_uuid."' "; + $db->exec(check_sql($sql)); + } + } + } + + //assign the user to the group + if (strlen($_REQUEST["group_name"]) > 0) { + $sql_insert = "insert into v_group_users "; + $sql_insert .= "("; + $sql_insert .= "group_user_uuid, "; + $sql_insert .= "domain_uuid, "; + $sql_insert .= "group_name, "; + $sql_insert .= "user_uuid "; + $sql_insert .= ")"; + $sql_insert .= "values "; + $sql_insert .= "("; + $sql_insert .= "'".uuid()."', "; + $sql_insert .= "'$domain_uuid', "; + $sql_insert .= "'".$_REQUEST["group_name"]."', "; + $sql_insert .= "'$user_uuid' "; + $sql_insert .= ")"; + if ($_REQUEST["group_name"] == "superadmin") { + //only a user in the superadmin group can add other users to that group + if (if_group("superadmin")) { + $db->exec($sql_insert); + } + } + else { + $db->exec($sql_insert); + } + } + + //if the template has not been assigned by the superadmin + //if (strlen($_SESSION['domain']['template']['name']) == 0) { + //set the session theme for the active user + // if ($_SESSION["username"] == $username) { + // $_SESSION['domain']['template']['name'] = $user_template_name; + // } + //} + + //sql update + $sql = "update v_users set "; + if (if_group("admin") && strlen($_POST["username"])> 0) { + $sql .= "username = '$username', "; + } + if (strlen($password) > 0 && $confirm_password == $password) { + //salt used with the password to create a one way hash + $salt = generate_password('20', '4'); + //set the password + $sql .= "password = '".md5($salt.$password)."', "; + $sql .= "salt = '".$salt."', "; + } + $sql .= "user_status = '$user_status', "; + if (strlen($contact_uuid) == 0) { + $sql .= "contact_uuid = null "; + } + else { + $sql .= "contact_uuid = '$contact_uuid' "; + } + if (strlen($user_uuid)> 0) { + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and user_uuid = '$user_uuid' "; + } + else { + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and username = '$username' "; + } + $db->exec(check_sql($sql)); + + //update the user_status + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + $switch_cmd .= "callcenter_config agent set status ".$username."@".$_SESSION['domain_name']." '".$user_status."'"; + $switch_result = event_socket_request($fp, 'api '.$switch_cmd); + + //update the user state + $cmd = "api callcenter_config agent set state ".$username."@".$_SESSION['domain_name']." Waiting"; + $response = event_socket_request($fp, $cmd); + + //clear the template so it will rebuild in case the template was changed + //$_SESSION["template_content"] = ''; + + //redirect the browser + require_once "includes/header.php"; + if (if_group("admin")) { + echo "\n"; + } + else { + echo "\n"; + } + echo "
Update Complete
"; + require_once "includes/footer.php"; + return; +} +else { + $sql = "select * from v_users "; + //allow admin access + if (if_group("admin") || if_group("superadmin")) { + if (strlen($user_uuid)> 0) { + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and user_uuid = '$user_uuid' "; + } + else { + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and username = '$username' "; + } + } + else { + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and username = '$username' "; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $user_uuid = $row["user_uuid"]; + if (if_group("admin")) { + $username = $row["username"]; + } + $password = $row["password"]; + $contact_uuid = $row["contact_uuid"]; + $user_status = $row["user_status"]; + break; //limit to 1 row + } + + //get the groups the user is a member of + //group_members function defined in config.php + $group_members = group_members($db, $user_uuid); +} + +//include the header + require_once "includes/header.php"; + +//show the content + $table_width ='width="100%"'; + echo "
"; + echo "
\n"; + + echo "
"; + echo "\n"; + echo "\n"; + echo ""; + echo " "; + echo "
\n"; + + echo ""; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
User Manager\n"; + echo " "; + echo " "; + echo "
\n"; + echo " Edit user information and group membership. \n"; + echo "
\n"; + + echo "
\n"; + + echo ""; + echo "\n"; + echo " \n"; + echo "\n"; + + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + echo " "; + + echo " "; + echo " "; + echo " "; + echo " "; + echo "
User Info
Username:$username
Password:
Confirm Password:
Groups:"; + + echo "\n"; + $sql = "SELECT * FROM v_group_users "; + $sql .= "where domain_uuid=:domain_uuid "; + $sql .= "and user_uuid=:user_uuid "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->bindParam(':domain_uuid', $domain_uuid); + $prep_statement->bindParam(':user_uuid', $user_uuid); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + foreach($result as $field) { + if (strlen($field['group_name']) > 0) { + echo "\n"; + echo " \n"; + echo " \n"; + echo "\n"; + } + } + echo "
".$field['group_name']."\n"; + if (permission_exists('group_member_delete') || if_group("superadmin")) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + + echo "
\n"; + $sql = "SELECT * FROM v_groups "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + echo ""; + echo "\n"; + unset($sql, $result); + echo "
"; + + echo "
"; + echo "
"; + + echo ""; + echo " \n"; + echo " \n"; + echo " \n"; + + echo " "; + echo " "; + echo " "; + echo " "; + + if ($_SESSION['user_status_display'] == "false") { + //hide the user_status when it is set to false + } + else { + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + } + + //if the template has not been assigned by the superadmin + /* + if (strlen($_SESSION['domain']['template']['name']) == 0) { + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + } + */ + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + echo "
Additional Info
Contact:\n"; + $sql = " select contact_uuid, contact_organization, contact_name_given, contact_name_family from v_contacts "; + $sql .= " where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= " order by contact_organization asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset ($prep_statement, $sql); + echo "\n"; + echo "
\n"; + echo "Assign a contact to this user account.\n"; + if (strlen($contact_uuid) > 0) { + echo " View\n"; + } + echo "
\n"; + echo " Status:\n"; + echo " \n"; + $cmd = "'".PROJECT_PATH."/app/calls_active/v_calls_exec.php?cmd=callcenter_config+agent+set+status+".$_SESSION['username']."@".$_SESSION['domain_name']."+'+this.value"; + echo " \n"; + echo "
\n"; + echo " Select a the user status.
\n"; + echo "
\n"; + echo " Template: \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " Select a template to set as the default and then press save.
\n"; + echo "
\n"; + echo " Time Zone: \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " Select the default time zone.
\n"; + echo "
"; + echo "
"; + + echo "
\n"; + echo ""; + echo " "; + echo " "; + echo " "; + echo "
"; + echo " "; + echo " "; + echo " "; + echo "
"; + + echo "
"; + echo "
"; + echo "
"; + +//include the footer + require_once "includes/footer.php"; + +?> \ No newline at end of file diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000000..e0c7a83001 Binary files /dev/null and b/favicon.ico differ diff --git a/images/background_cell_active.gif b/images/background_cell_active.gif new file mode 100644 index 0000000000..7dbcf6a6fd Binary files /dev/null and b/images/background_cell_active.gif differ diff --git a/images/background_cell_conference.gif b/images/background_cell_conference.gif new file mode 100644 index 0000000000..7b5b792bdc Binary files /dev/null and b/images/background_cell_conference.gif differ diff --git a/images/background_cell_fifo.gif b/images/background_cell_fifo.gif new file mode 100644 index 0000000000..a0082263b6 Binary files /dev/null and b/images/background_cell_fifo.gif differ diff --git a/images/background_cell_light.gif b/images/background_cell_light.gif new file mode 100644 index 0000000000..76d32d0b8d Binary files /dev/null and b/images/background_cell_light.gif differ diff --git a/images/blank.gif b/images/blank.gif new file mode 100644 index 0000000000..75b945d255 Binary files /dev/null and b/images/blank.gif differ diff --git a/images/icon_cal.gif b/images/icon_cal.gif new file mode 100644 index 0000000000..a9c7c87632 Binary files /dev/null and b/images/icon_cal.gif differ diff --git a/images/icon_e.gif b/images/icon_e.gif new file mode 100644 index 0000000000..29508006ff Binary files /dev/null and b/images/icon_e.gif differ diff --git a/images/icon_e.png b/images/icon_e.png new file mode 100644 index 0000000000..5496ed3a23 Binary files /dev/null and b/images/icon_e.png differ diff --git a/images/icon_plus.gif b/images/icon_plus.gif new file mode 100644 index 0000000000..2a94eeb93f Binary files /dev/null and b/images/icon_plus.gif differ diff --git a/images/icon_plus.png b/images/icon_plus.png new file mode 100644 index 0000000000..1a3f39522f Binary files /dev/null and b/images/icon_plus.png differ diff --git a/images/icon_restart.gif b/images/icon_restart.gif new file mode 100644 index 0000000000..e49fbd73c2 Binary files /dev/null and b/images/icon_restart.gif differ diff --git a/images/icon_start.gif b/images/icon_start.gif new file mode 100644 index 0000000000..09bb58fd43 Binary files /dev/null and b/images/icon_start.gif differ diff --git a/images/icon_stop.gif b/images/icon_stop.gif new file mode 100644 index 0000000000..922addc5ca Binary files /dev/null and b/images/icon_stop.gif differ diff --git a/images/icon_up.gif b/images/icon_up.gif new file mode 100644 index 0000000000..883c5a29e8 Binary files /dev/null and b/images/icon_up.gif differ diff --git a/images/icon_view.gif b/images/icon_view.gif new file mode 100644 index 0000000000..d11a5f00c8 Binary files /dev/null and b/images/icon_view.gif differ diff --git a/images/icon_x.gif b/images/icon_x.gif new file mode 100644 index 0000000000..24e4d49297 Binary files /dev/null and b/images/icon_x.gif differ diff --git a/images/icon_x.png b/images/icon_x.png new file mode 100644 index 0000000000..eb08bf4a4f Binary files /dev/null and b/images/icon_x.png differ diff --git a/includes/calendar_lw_layers.js b/includes/calendar_lw_layers.js new file mode 100644 index 0000000000..6154cc9190 --- /dev/null +++ b/includes/calendar_lw_layers.js @@ -0,0 +1,189 @@ +// written by Tan Ling Wee +// last updated 20 June 2003 +// email : fuushikaden@yahoo.com + +////////////////////////////////////////////////////////////////////////////////// +// Layers +////////////////////////////////////////////////////////////////////////////////// + +var layerQueue=new Array() +var layerIndex=-1 + +/* hides and objects (for IE only) +*/ +function showElement( elmID ) +{ + if( ie ) + { + for( i = 0; i < document.getElementsByTagName( elmID ).length; i++ ) + { + obj = document.getElementsByTagName( elmID )[i]; + + if( !obj || !obj.offsetParent ) + { + continue; + } + + obj.style.visibility = ""; + } + } +} + +function lw_createLayer (layerName, top_pos, left_pos, width, height, bgcolor, bordercolor, z_index) { + document.write("") +} + +function lw_getObj (objName) { + return (dom)?document.getElementById(objName).style:ie?eval("document.all."+objName) :eval("document."+objName) +} + +function lw_showLayer (layerName) { + + found=false + for (i=0;i<=layerIndex;i++) + { + if (layerQueue[i]==layerName) + { + found=true + } + } + + if ((lw_getObj(layerName).visibility!="visible")&&(lw_getObj(layerName).visibility!="show")) + { + lw_getObj(layerName).visibility = (dom||ie)?"visible":"show" + layerQueue[++layerIndex] = layerName + + hideElement( 'SELECT', document.getElementById(layerName) ); + hideElement( 'APPLET', document.getElementById(layerName) ); + } +} + +function lw_hideLayer () { + showElement( 'SELECT', document.getElementById(layerQueue[layerIndex]) ); + showElement( 'APPLET', document.getElementById(layerQueue[layerIndex]) ); + + lw_getObj(layerQueue[layerIndex--]).visibility = "hidden" +} + +function lw_hideLayerName (layerName) { + var i + var tmpQueue=new Array() + var newIndex=-1 + + showElement( 'SELECT', document.getElementById(layerName) ); + showElement( 'APPLET', document.getElementById(layerName) ); + + lw_getObj(layerName).visibility = "hidden" + + for (i=0;i<=layerIndex;i++) + { + if ((layerQueue[i]!="")&&(layerQueue[i]!=layerName)) + { + tmpQueue [++newIndex] = layerQueue[i] + hideElement( 'SELECT', document.getElementById(layerQueue[i]) ); + hideElement( 'APPLET', document.getElementById(layerQueue[i]) ); + } + + } + + layerQueue = tmpQueue + layerIndex = newIndex +} + +function lw_closeAllLayers() { + while (layerIndex >= 0) + { + lw_hideLayer() + } +} + +function lw_closeLastLayer() { + if (layerIndex >= 0) + { + while ((lw_getObj(layerQueue[layerIndex]).visibility!="visible") && (layerIndex>0)) + { + layerIndex--; + } + lw_hideLayer() + } +} + +function lw_escLayer (e) { + if (navigator.appName=="Netscape") + { + var keyCode = e.keyCode?e.keyCode:e.which?e.which:e.charCode; + if ((keyCode==27)||(keyCode==1)) + { + lw_closeLastLayer() + } + } + else + if ((event.keyCode==0)||(event.keyCode==27)) + { + lw_closeLastLayer() + } +} + + +var lw_leftpos = 0 +var lw_toppos = 0 +var lw_width = 0 +var lw_height = 0 + +function lw_calcpos(obj) { + lw_leftpos=0 + lw_toppos=0 + lw_width = obj.offsetWidth + lw_height = obj.offsetHeight + + var aTag = obj + do { + lw_leftpos += aTag.offsetLeft; + lw_toppos += aTag.offsetTop; + aTag = aTag.offsetParent; + } while(aTag.tagName!="BODY"); +} + +document.onkeypress = lw_escLayer; +document.onclick = lw_closeAllLayers; diff --git a/includes/calendar_lw_menu.js b/includes/calendar_lw_menu.js new file mode 100644 index 0000000000..91ff20331a --- /dev/null +++ b/includes/calendar_lw_menu.js @@ -0,0 +1,376 @@ +// written by Tan Ling Wee +// last updated 20 June 2003 +// email : fuushikaden@yahoo.com + +var orientation=0 // 0-horizontal 1-vertical +var imgPath = "js/" + +var mainItemForeground = "#000000" +var mainItemBorder = "#f0f0f0" +var mainItemBackground = "#f0f0f0" + +var mainItemHoverForeground = "#000000" +var mainItemHoverBorder = "#a0a0a0" +var mainItemHoverBackground = "#d0d0d0" + +var subItemForeground = "#000000" +var subItemBorder = "#ffffff" +var subItemBackground = "#ffffff" + +var subItemHoverForeground = "#000000" +var subItemHoverBorder = "#a0a0a0" +var subItemHoverBackground = "#d0d0d0" + +var menuFont = "verdana" +var menuSize = "11px" + + +///////////////////////////////////////////////////////////////////////////// + +var ie=(navigator.appName=='Microsoft Internet Explorer') +var ns=(navigator.appName=='Netscape') +var dom=document.getElementById +var lw_menuId, lw_trigger, to1 +var s1 + +///////////////////////////////////////////////////////////////////////////// + +function Tmenu (id, parentId, url, description, img) { + this.id = id + this.parentId = parentId + this.url = url + this.description = description + this.numChild = 0 + this.levelId = 0 + this.img = img +} + +///////////////////////////////////////////////////////////////////////////// + +var menu = new Array() +var menuCounter = 0 +var numLevel = 0 +var prevMenuId = -1 +var nNowAt = 0 + +function displayMenuItem(menuId) { + var sHTML + + if (menu[menuId].parentId>0) + { + ItemForeground = subItemForeground + Border = subItemBorder + Background = subItemBackground + + HoverForeground = subItemHoverForeground + HoverBorder = subItemHoverBorder + HoverBackground = subItemHoverBackground + } + else + { + ItemForeground = mainItemForeground + Border = mainItemBorder + Background = mainItemBackground + + HoverForeground = mainItemHoverForeground + HoverBorder = mainItemHoverBorder + HoverBackground = mainItemHoverBackground + } + + if ((orientation==1)||(menu[menuId].levelId>0)) + { + sHTML += "" + } + + if (menu[menuId].description!='-') + { + sHTML = "" + + if (menu[menuId].levelId>0) + { + sHTML += "" + } + + if ((orientation==0) && (menu[menuId].levelId==0)) + { + nArrowWidth = 0 + } + else + { + nArrowWidth = 25 + } + + sHTML += "
" + menu[menuId].description.replace(" "," ") + "" + if (menu[menuId].numChild>0) + { + if ((orientation==0)&&(menu[menuId].levelId==0)) + { + sHTML += "" + } + else + { + sHTML += "" + } + } + else + { + sHTML += " " + } + sHTML += "
" + } + else + { + sHTML = "" + } + + if ((orientation==1)||(menu[menuId].levelId>0)) + { + sHTML += "" + } + return sHTML +} + +function clearAll(levelId, parentId) { + + if (levelId>0) + { + Border = subItemBorder + Background = subItemBackground + } + else + { + Border = mainItemBorder + Background = mainItemBackground + } + + for (i=0;i0) + { + lw_calcpos(trigger) + + for (var i=0;i0)) + { + lw_getObj("menu_level_"+nLevel).top=lw_toppos + leftpos = lw_leftpos + lw_width + 5 + + if (nLevel==0) { + leftpos -= 3 + } + } + else { + lw_getObj("menu_level_"+nLevel).top = lw_toppos + lw_height + 2 + leftpos = lw_leftpos + } + + lw_getObj("menu_level_"+nLevel).left=leftpos + + sHTML = "" + for (var i=0;i" + } + } + sHTML += "
" + menu[i].description + "
" + + document.writeln(sHTML) + +} + +function getLevel (menuId) { + var pId=menuId + var nLevel=0 + + while (pId!=0) + { + nLevel++ + for (var i=0;i0) + { + for (i=0;i and objects (for IE only) */ + function hideElement( elmID, overDiv ) + { + if( ie ) + { + for( i = 0; i < document.all.tags( elmID ).length; i++ ) + { + obj = document.all.tags( elmID )[i]; + if( !obj || !obj.offsetParent ) + { + continue; + } + + // Find the element's offsetTop and offsetLeft relative to the BODY tag. + objLeft = obj.offsetLeft; + objTop = obj.offsetTop; + objParent = obj.offsetParent; + + while( objParent.tagName.toUpperCase() != "BODY" ) + { + objLeft += objParent.offsetLeft; + objTop += objParent.offsetTop; + objParent = objParent.offsetParent; + } + + objHeight = obj.offsetHeight; + objWidth = obj.offsetWidth; + + if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft ); + else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop ); + else if( overDiv.offsetTop >= ( objTop + objHeight )); + else if( overDiv.offsetLeft >= ( objLeft + objWidth )); + else + { + obj.style.visibility = "hidden"; + } + } + } + } + + /* + * unhides ") + //document.write (""); + } + + var monthName = new Array("January","February","March","April","May","June","July","August","September","October","November","December") + var monthName2 = new Array("JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC") + if (startAt==0) + { + dayName = new Array ("Sun","Mon","Tue","Wed","Thu","Fri","Sat") + } + else + { + dayName = new Array ("Mon","Tue","Wed","Thu","Fri","Sat","Sun") + } + var styleAnchor="text-decoration:none;color:black;" + var styleLightBorder="border-style:solid;border-width:1px;border-color:#a0a0a0;" + + function swapImage(srcImg, destImg){ + if (ie) { document.getElementById(srcImg).setAttribute("src",imgDir + destImg) } + } + + function init() { + if (!ns4) + { + if (!ie) { yearNow += 1900 } + + crossobj=(dom)?document.getElementById("calendar").style : ie? document.all.calendar : document.calendar + hideCalendar() + + crossMonthObj=(dom)?document.getElementById("selectMonth").style : ie? document.all.selectMonth : document.selectMonth + + crossYearObj=(dom)?document.getElementById("selectYear").style : ie? document.all.selectYear : document.selectYear + + monthConstructed=false; + yearConstructed=false; + + if (showToday==1) + { + document.getElementById("lblToday").innerHTML = todayString + " "+dayName[(today.getDay()-startAt==-1)?6:(today.getDay()-startAt)]+", " + dateNow + " " + monthName[monthNow].substring(0,3) + " " + yearNow + "" + } + + sHTML1="   " + sHTML1+="   " + sHTML1+=" " + sHTML1+=" " + + document.getElementById("caption").innerHTML = sHTML1 + + bPageLoaded=true + } + } + + function hideCalendar() { + crossobj.visibility="hidden" + if (crossMonthObj != null){crossMonthObj.visibility="hidden"} + if (crossYearObj != null){crossYearObj.visibility="hidden"} + + showElement( 'SELECT' ); + showElement( 'APPLET' ); + } + + function padZero(num) { + return (num < 10)? '0' + num : num ; + } + + function constructDate(d,m,y) + { + sTmp = dateFormat + sTmp = sTmp.replace ("dd","") + sTmp = sTmp.replace ("d","") + sTmp = sTmp.replace ("",padZero(d)) + sTmp = sTmp.replace ("",d) + sTmp = sTmp.replace ("mmmm","

") + sTmp = sTmp.replace ("mmm","") + sTmp = sTmp.replace ("mm","") + sTmp = sTmp.replace ("m","") + sTmp = sTmp.replace ("",m+1) + sTmp = sTmp.replace ("",padZero(m+1)) + sTmp = sTmp.replace ("",monthName[m]) + sTmp = sTmp.replace ("

",monthName2[m]) + sTmp = sTmp.replace ("yyyy",y) + return sTmp.replace ("yy",padZero(y%100)) + } + + function closeCalendar() { + var sTmp + + hideCalendar(); + ctlToPlaceValue.value = constructDate(dateSelected,monthSelected,yearSelected) + } + + /*** Month Pulldown ***/ + + function StartDecMonth() + { + intervalID1=setInterval("decMonth()",80) + } + + function StartIncMonth() + { + intervalID1=setInterval("incMonth()",80) + } + + function incMonth () { + monthSelected++ + if (monthSelected>11) { + monthSelected=0 + yearSelected++ + } + constructCalendar() + } + + function decMonth () { + monthSelected-- + if (monthSelected<0) { + monthSelected=11 + yearSelected-- + } + constructCalendar() + } + + function constructMonth() { + popDownYear() + if (!monthConstructed) { + sHTML = "" + for (i=0; i<12; i++) { + sName = monthName[i]; + if (i==monthSelected){ + sName = "" + sName + "" + } + sHTML += " " + sName + " " + } + + document.getElementById("selectMonth").innerHTML = "" + sHTML + "
" + + monthConstructed=true + } + } + + function popUpMonth() { + constructMonth() + crossMonthObj.visibility = (dom||ie)? "visible" : "show" + crossMonthObj.left = parseInt(crossobj.left) + 50 + crossMonthObj.top = parseInt(crossobj.top) + 26 + + hideElement( 'SELECT', document.getElementById("selectMonth") ); + hideElement( 'APPLET', document.getElementById("selectMonth") ); + } + + function popDownMonth() { + crossMonthObj.visibility= "hidden" + } + + /*** Year Pulldown ***/ + + function incYear() { + for (i=0; i<7; i++){ + newYear = (i+nStartingYear)+1 + if (newYear==yearSelected) + { txtYear = " " + newYear + " " } + else + { txtYear = " " + newYear + " " } + document.getElementById("y"+i).innerHTML = txtYear + } + nStartingYear ++; + bShow=true + } + + function decYear() { + for (i=0; i<7; i++){ + newYear = (i+nStartingYear)-1 + if (newYear==yearSelected) + { txtYear = " " + newYear + " " } + else + { txtYear = " " + newYear + " " } + document.getElementById("y"+i).innerHTML = txtYear + } + nStartingYear --; + bShow=true + } + + function selectYear(nYear) { + yearSelected=parseInt(nYear+nStartingYear); + yearConstructed=false; + constructCalendar(); + popDownYear(); + } + + function constructYear() { + popDownMonth() + sHTML = "" + if (!yearConstructed) { + + sHTML = "-" + + j = 0 + nStartingYear = yearSelected-3 + for (i=(yearSelected-3); i<=(yearSelected+3); i++) { + sName = i; + if (i==yearSelected){ + sName = "" + sName + "" + } + + sHTML += " " + sName + " " + j ++; + } + + sHTML += "+" + + document.getElementById("selectYear").innerHTML = "" + sHTML + "
" + + yearConstructed = true + } + } + + function popDownYear() { + clearInterval(intervalID1) + clearTimeout(timeoutID1) + clearInterval(intervalID2) + clearTimeout(timeoutID2) + crossYearObj.visibility= "hidden" + } + + function popUpYear() { + var leftOffset + + constructYear() + crossYearObj.visibility = (dom||ie)? "visible" : "show" + leftOffset = parseInt(crossobj.left) + document.getElementById("spanYear").offsetLeft + if (ie) + { + leftOffset += 6 + } + crossYearObj.left = leftOffset + crossYearObj.top = parseInt(crossobj.top) + 26 + } + + /*** calendar ***/ + function WeekNbr(n) { + // Algorithm used: + // From Klaus Tondering's Calendar document (The Authority/Guru) + // hhtp://www.tondering.dk/claus/calendar.html + // a = (14-month) / 12 + // y = year + 4800 - a + // m = month + 12a - 3 + // J = day + (153m + 2) / 5 + 365y + y / 4 - y / 100 + y / 400 - 32045 + // d4 = (J + 31741 - (J mod 7)) mod 146097 mod 36524 mod 1461 + // L = d4 / 1460 + // d1 = ((d4 - L) mod 365) + L + // WeekNumber = d1 / 7 + 1 + + year = n.getFullYear(); + month = n.getMonth() + 1; + if (startAt == 0) { + day = n.getDate() + 1; + } + else { + day = n.getDate(); + } + + a = Math.floor((14-month) / 12); + y = year + 4800 - a; + m = month + 12 * a - 3; + b = Math.floor(y/4) - Math.floor(y/100) + Math.floor(y/400); + J = day + Math.floor((153 * m + 2) / 5) + 365 * y + b - 32045; + d4 = (((J + 31741 - (J % 7)) % 146097) % 36524) % 1461; + L = Math.floor(d4 / 1460); + d1 = ((d4 - L) % 365) + L; + week = Math.floor(d1/7) + 1; + + return week; + } + + function constructCalendar () { + var aNumDays = Array (31,0,31,30,31,30,31,31,30,31,30,31) + + var dateMessage + var startDate = new Date (yearSelected,monthSelected,1) + var endDate + + if (monthSelected==1) + { + endDate = new Date (yearSelected,monthSelected+1,1); + endDate = new Date (endDate - (24*60*60*1000)); + numDaysInMonth = endDate.getDate() + } + else + { + numDaysInMonth = aNumDays[monthSelected]; + } + + datePointer = 0 + dayPointer = startDate.getDay() - startAt + + if (dayPointer<0) + { + dayPointer = 6 + } + + sHTML = "" + + if (showWeekNumber==1) + { + sHTML += "" + } + + for (i=0; i<7; i++) { + sHTML += "" + } + sHTML +="" + + if (showWeekNumber==1) + { + sHTML += "" + } + + for ( var i=1; i<=dayPointer;i++ ) + { + sHTML += "" + } + + for ( datePointer=1; datePointer<=numDaysInMonth; datePointer++ ) + { + dayPointer++; + sHTML += "" + if ((showWeekNumber==1)&&(datePointer" + } + } + } + + document.getElementById("content").innerHTML = sHTML + document.getElementById("spanMonth").innerHTML = " " + monthName[monthSelected] + " " + document.getElementById("spanYear").innerHTML = " " + yearSelected + " " + } + + function popUpCalendar(ctl, ctl2, format) { + var leftpos=0 + var toppos=0 + + if (bPageLoaded) + { + if ( crossobj.visibility == "hidden" ) { + ctlToPlaceValue = ctl2 + dateFormat=format; + + formatChar = " " + aFormat = dateFormat.split(formatChar) + if (aFormat.length<3) + { + formatChar = "/" + aFormat = dateFormat.split(formatChar) + if (aFormat.length<3) + { + formatChar = "." + aFormat = dateFormat.split(formatChar) + if (aFormat.length<3) + { + formatChar = "-" + aFormat = dateFormat.split(formatChar) + if (aFormat.length<3) + { + // invalid date format + formatChar="" + } + } + } + } + + tokensChanged = 0 + if ( formatChar != "" ) + { + // use user's date + aData = ctl2.value.split(formatChar) + + for (i=0;i<3;i++) + { + if ((aFormat[i]=="d") || (aFormat[i]=="dd")) + { + dateSelected = parseInt(aData[i], 10) + tokensChanged ++ + } + else if ((aFormat[i]=="m") || (aFormat[i]=="mm")) + { + monthSelected = parseInt(aData[i], 10) - 1 + tokensChanged ++ + } + else if (aFormat[i]=="yyyy") + { + yearSelected = parseInt(aData[i], 10) + tokensChanged ++ + } + else if (aFormat[i]=="mmm") + { + for (j=0; j<12; j++) + { + if (aData[i]==monthName[j]) + { + monthSelected=j + tokensChanged ++ + } + } + } + else if (aFormat[i]=="mmmm") + { + for (j=0; j<12; j++) + { + if (aData[i]==monthName2[j]) + { + monthSelected=j + tokensChanged ++ + } + } + } + } + } + + if ((tokensChanged!=3)||isNaN(dateSelected)||isNaN(monthSelected)||isNaN(yearSelected)) + { + dateSelected = dateNow + monthSelected = monthNow + yearSelected = yearNow + } + + odateSelected=dateSelected + omonthSelected=monthSelected + oyearSelected=yearSelected + + aTag = ctl + do { + aTag = aTag.offsetParent; + leftpos += aTag.offsetLeft; + toppos += aTag.offsetTop; + } while(aTag.tagName!="BODY"); + + crossobj.left = fixedX==-1 ? ctl.offsetLeft + leftpos : fixedX + crossobj.top = fixedY==-1 ? ctl.offsetTop + toppos + ctl.offsetHeight + 2 : fixedY + constructCalendar (1, monthSelected, yearSelected); + crossobj.visibility=(dom||ie)? "visible" : "show" + + hideElement( 'SELECT', document.getElementById("calendar") ); + hideElement( 'APPLET', document.getElementById("calendar") ); + + bShow = true; + } + else + { + hideCalendar() + if (ctlNow!=ctl) {popUpCalendar(ctl, ctl2, format)} + } + ctlNow = ctl + } + } + + document.onkeypress = function hidecal1 () { + if (event.keyCode==27) + { + hideCalendar() + } + } + document.onclick = function hidecal2 () { + if (!bShow) + { + hideCalendar() + } + bShow = false + } + + if(ie) + { + init() + } + else + { + window.onload=init + } diff --git a/includes/captcha/config.php b/includes/captcha/config.php new file mode 100644 index 0000000000..cef6fe3f95 --- /dev/null +++ b/includes/captcha/config.php @@ -0,0 +1,108 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +$pathtofonts = "/captcha/fonts/"; //path from the root of the website + +/* +//How to use this Captcha + + //Option1: add this to the html form +
" + weekString + ""+ dayName[i]+"
" + WeekNbr(startDate) + "  " + sStyle=styleAnchor + if ((datePointer==odateSelected) && (monthSelected==omonthSelected) && (yearSelected==oyearSelected)) + { sStyle+=styleLightBorder } + + sHint = "" + for (k=0;k " + datePointer + " "} + else if (dayPointer % 7 == (startAt * -1)+1) + { sHTML += " " + datePointer + " " } + else + { sHTML += " " + datePointer + " " } + + sHTML += "" + if ((dayPointer+startAt) % 7 == startAt) { + sHTML += "
+ + + + + + + +
Please type the code you see from the image into the text box below.
+ + //Option2: or add this to the html form +
+ + + + + + + + + + + +
Please enter the text you see from the image below...
Click for a new image.

Can't read the image text? Click the image for a new one.
+
+ + //add this to the top of the page where the form is submitted to + + //--- begin captcha verification --------------------- + //session_start(); //make sure sessions are started + if (strtolower($_SESSION["captcha"]) != strtolower($_REQUEST["captcha"]) || strlen($_SESSION["captcha"]) == 0) { + + echo " Sorry!\n"; + //echo "

\n"; + //echo "\n"; + //echo " Your e-mail was NOT sent.\n"; + echo "

\n"; + echo " Error: Captcha Image Verification Failed
\n"; + echo " \n"; + echo "

\n"; + echo " Try Again?"; + + exit; + } + else { + //echo "verified"; + } + //--- end captcha verification ----------------------- + +//notes + A diverse collection of unique fonts can improve the captcha. + If bots get past the captcha try changing fonts. + + Ideas that may be implemented in the future... + 1. randomize the background with texture, color and/or gradient + 2. distort the image + 3. rotate the characters with different rotations. + 4. use audio, svg, or flash + +//additional fonts can be obtained from + http://simplythebest.net/fonts/ + http://www.1001freefonts.com/afonts.htm + +//Usefull Links + http://sam.zoy.org/pwntcha/ + http://en.wikipedia.org/wiki/Captcha + +*/ + + + +?> diff --git a/includes/captcha/fonts/ROUGD.TTF b/includes/captcha/fonts/ROUGD.TTF new file mode 100644 index 0000000000..81cb3086c5 Binary files /dev/null and b/includes/captcha/fonts/ROUGD.TTF differ diff --git a/includes/captcha/fonts/Zebra.ttf b/includes/captcha/fonts/Zebra.ttf new file mode 100644 index 0000000000..ea555920b1 Binary files /dev/null and b/includes/captcha/fonts/Zebra.ttf differ diff --git a/includes/captcha/fonts/hanshand.ttf b/includes/captcha/fonts/hanshand.ttf new file mode 100644 index 0000000000..e9fb5fe47f Binary files /dev/null and b/includes/captcha/fonts/hanshand.ttf differ diff --git a/includes/captcha/img.php b/includes/captcha/img.php new file mode 100644 index 0000000000..f92bda8f57 --- /dev/null +++ b/includes/captcha/img.php @@ -0,0 +1,123 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "config.php"; +error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ); //hide notices and warnings +session_start(); + + +// Captcha verification image ----------------------- +// Description this page is used to verify the captcha + +$_SESSION["captcha"] = substr(md5(date('r')), 0, 6); +$text = $_SESSION["captcha"]; +//echo $text; +exit; + + +function isfile($filename) { + if (@filesize($filename) > 0) { return true; } else { return false; } +} + +function dircontents($dir) { + clearstatcache(); + $htmldirlist = ''; + $htmlfilelist = ''; + $dirlist = opendir($dir); + while ($file = readdir ($dirlist)) { + if ($file != '.' && $file != '..') { + $newpath = $dir.'/'.$file; + $level = explode('/',$newpath); + + if (is_dir($newpath)) { + //do nothing + } + else { + $mod_array[] = end($level); + } + } + } + + closedir($dirlist); + return $mod_array; +} + +$fontarray = dircontents($pathtofonts); +//print_r($fontarray); + +function make_seed() +{ + list($usec, $sec) = explode(' ', microtime()); + return (float) $sec + ((float) $usec * 100000); +} +srand(make_seed()); +$random = (rand()%count($fontarray)); +$font = $pathtofonts.$fontarray[$random]; +//echo $font; + +//echo phpinfo(); +//exit; + +$fontsize = 16; +if(@$_GET['fontsize']) { + $fontsize = $_GET['fontsize']; +} + +//picked up from a note at http://www.php.net/imagettfbbox +function imagettfbbox_custom($size, $angle, $font, $text) { + $dummy = imagecreate(1, 1); + $black = imagecolorallocate($dummy, 0, 0, 0); + $bbox = imagettftext($dummy, $size, $angle, 0, 0, $black, $font, $text); + imagedestroy($dummy); + return $bbox; +} + + +// Create the image +$size = imagettfbbox_custom($fontsize, 0, $font, $text); +$width = $size[2] + $size[0] + 8; +$height = abs($size[1]) + abs($size[7]); +//$width = 200; +//$height = 200; + +$im = imagecreate($width, $height); + +$colourBlack = imagecolorallocate($im, 255, 255, 255); +imagecolortransparent($im, $colourBlack); + +// Create some colors +$white = imagecolorallocate($im, 255, 255, 255); +$black = imagecolorallocate($im, 0, 0, 0); + +// Add the text +imagefttext($im, $fontsize, 0, 0, abs($size[5]), $black, $font, $text); + +// Set the content-type +header("Content-type: image/png"); +// Using imagepng() results in clearer text compared with +imagepng($im); +imagedestroy($im); +?> diff --git a/includes/captcha/root.php b/includes/captcha/root.php new file mode 100644 index 0000000000..cf38657a09 --- /dev/null +++ b/includes/captcha/root.php @@ -0,0 +1,48 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + define('PROJECT_PATH', '/fusionpbx'); + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + define('PROJECT_PATH', ''); + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/includes/checkauth.php b/includes/checkauth.php new file mode 100644 index 0000000000..01013ad670 --- /dev/null +++ b/includes/checkauth.php @@ -0,0 +1,159 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "includes/require.php"; +session_start(); + +//if the username session is not set the check username and password + if (strlen($_SESSION["username"]) == 0) { + //clear the menu + $_SESSION["menu"] = ""; + + //clear the template only if the template has not been assigned by the superadmin + if (strlen($_SESSION['domain']['template']['name']) == 0) { + $_SESSION["template_content"] = ''; + } + + //if the username from the form is not provided then send to login.php + if (strlen(check_str($_REQUEST["username"])) == 0) { + $php_self = $_SERVER["PHP_SELF"]; + $msg = "username required"; + header("Location: ".PROJECT_PATH."/login.php?path=".urlencode($php_self)."&msg=".urlencode($msg)); + exit; + } + + //check the username and password if they don't match then redirect to the login + $sql = "select * from v_users "; + $sql .= "where domain_uuid=:domain_uuid "; + $sql .= "and username=:username "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->bindParam(':domain_uuid', $domain_uuid); + $prep_statement->bindParam(':username', check_str($_REQUEST["username"])); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + if (count($result) == 0) { + $auth_failed = true; + } + else { + foreach ($result as &$row) { + //get the salt from the database + $salt = $row["salt"]; + //if salt is not defined then use the default salt for backwards compatibility + if (strlen($salt) == 0) { + $salt = 'e3.7d.12'; + } + //compare the password provided by the user with the one in the database + if (md5($salt.check_str($_REQUEST["password"])) != $row["password"]) { + $auth_failed = true; + } + //end the loop + break; + } + } + if ($auth_failed) { + //log the failed auth attempt to the system, to be available for fail2ban. + openlog('FusionPBX', LOG_NDELAY, LOG_AUTH); + syslog(LOG_WARNING, '['.$_SERVER['REMOTE_ADDR']."] authentication failed for ".$_REQUEST["username"]); + closelog(); + //redirect the user to the login page + $php_self = $_SERVER["PHP_SELF"]; + $msg = "incorrect account information"; + header("Location: ".PROJECT_PATH."/login.php?path=".urlencode($php_self)."&msg=".urlencode($msg)); + exit; + } + $_SESSION["username"] = check_str($_REQUEST["username"]); + foreach ($result as &$row) { + //allow the user to choose a template only if the template has not been assigned by the superadmin + if (strlen($_SESSION['domain']['template']['name']) == 0) { + $_SESSION['domain']['template']['name'] = $row["user_template_name"]; + } + $_SESSION["time_zone"]["user"] = ''; + if (strlen($row["user_time_zone"]) > 0) { + //user defined time zone + $_SESSION["time_zone"]["user"] = $row["user_time_zone"]; + } + // add the user_uuid to the session + $_SESSION['user_uuid'] = $row['user_uuid']; + break; + } + //echo "username: ".$_SESSION["username"]." and password are correct"; + + //get the groups assigned to the user and then set the groups in $_SESSION["groups"] + $sql = "SELECT * FROM v_group_users "; + $sql .= "where domain_uuid=:domain_uuid "; + $sql .= "and user_uuid=:user_uuid "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->bindParam(':domain_uuid', $domain_uuid); + $prep_statement->bindParam(':user_uuid', $_SESSION["user_uuid"]); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $_SESSION["groups"] = $result; + unset($sql, $row_count, $prep_statement); + + //get the permissions assigned to the groups that the user is a member of set the permissions in $_SESSION['permissions'] + $x = 0; + $sql = "select distinct(permission_name) from v_group_permissions "; + foreach($_SESSION["groups"] as $field) { + if (strlen($field['group_name']) > 0) { + if ($x == 0) { + $sql .= "where (domain_uuid = '".$domain_uuid."' and group_name = '".$field['group_name']."') "; + } + else { + $sql .= "or (domain_uuid = '".$domain_uuid."' and group_name = '".$field['group_name']."') "; + } + $x++; + } + } + $prep_statement_sub = $db->prepare($sql); + $prep_statement_sub->execute(); + $_SESSION['permissions'] = $prep_statement_sub->fetchAll(PDO::FETCH_NAMED); + unset($sql, $prep_statement_sub); + + //redirect the user + if (check_str($_REQUEST["rdr"]) !== 'n'){ + $path = check_str($_POST["path"]); + if(isset($path) && !empty($path) && $path!="index2.php" && $path!="/install.php") { + header("Location: ".$path); + exit(); + } + } + } + +//set the time zone + if (strlen($_SESSION["time_zone"]["user"]) == 0) { + //set the domain time zone as the default time zone + date_default_timezone_set($_SESSION['domain']['time_zone']['name']); + } + else { + //set the user defined time zone + date_default_timezone_set($_SESSION["time_zone"]["user"]); + } + +//hide the path unless logged in as a superadmin. + if (!if_group("superadmin")) { + $v_path_show = false; + } + +?> \ No newline at end of file diff --git a/includes/checkstring.php b/includes/checkstring.php new file mode 100644 index 0000000000..e5cf5abe7a --- /dev/null +++ b/includes/checkstring.php @@ -0,0 +1,30 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +function check_string($str) { + $str = str_replace ("\'", "''", $str); //escape the single quote + return $str; +} +?> diff --git a/includes/class.phpmailer.php b/includes/class.phpmailer.php new file mode 100644 index 0000000000..2ddc30fd27 --- /dev/null +++ b/includes/class.phpmailer.php @@ -0,0 +1,1896 @@ +ContentType = 'text/html'; + } else { + $this->ContentType = 'text/plain'; + } + } + + /** + * Sets Mailer to send message using SMTP. + * @return void + */ + function IsSMTP() { + $this->Mailer = 'smtp'; + } + + /** + * Sets Mailer to send message using PHP mail() function. + * @return void + */ + function IsMail() { + $this->Mailer = 'mail'; + } + + /** + * Sets Mailer to send message using the $Sendmail program. + * @return void + */ + function IsSendmail() { + $this->Mailer = 'sendmail'; + } + + /** + * Sets Mailer to send message using the qmail MTA. + * @return void + */ + function IsQmail() { + $this->Sendmail = '/var/qmail/bin/sendmail'; + $this->Mailer = 'sendmail'; + } + + ///////////////////////////////////////////////// + // METHODS, RECIPIENTS + ///////////////////////////////////////////////// + + /** + * Adds a "To" address. + * @param string $address + * @param string $name + * @return void + */ + function AddAddress($address, $name = '') { + $cur = count($this->to); + $this->to[$cur][0] = trim($address); + $this->to[$cur][1] = $name; + } + + /** + * Adds a "Cc" address. Note: this function works + * with the SMTP mailer on win32, not with the "mail" + * mailer. + * @param string $address + * @param string $name + * @return void + */ + function AddCC($address, $name = '') { + $cur = count($this->cc); + $this->cc[$cur][0] = trim($address); + $this->cc[$cur][1] = $name; + } + + /** + * Adds a "Bcc" address. Note: this function works + * with the SMTP mailer on win32, not with the "mail" + * mailer. + * @param string $address + * @param string $name + * @return void + */ + function AddBCC($address, $name = '') { + $cur = count($this->bcc); + $this->bcc[$cur][0] = trim($address); + $this->bcc[$cur][1] = $name; + } + + /** + * Adds a "Reply-To" address. + * @param string $address + * @param string $name + * @return void + */ + function AddReplyTo($address, $name = '') { + $cur = count($this->ReplyTo); + $this->ReplyTo[$cur][0] = trim($address); + $this->ReplyTo[$cur][1] = $name; + } + + ///////////////////////////////////////////////// + // METHODS, MAIL SENDING + ///////////////////////////////////////////////// + + /** + * Creates message and assigns Mailer. If the message is + * not sent successfully then it returns false. Use the ErrorInfo + * variable to view description of the error. + * @return bool + */ + function Send() { + $header = ''; + $body = ''; + $result = true; + + if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { + $this->SetError($this->Lang('provide_address')); + return false; + } + + /* Set whether the message is multipart/alternative */ + if(!empty($this->AltBody)) { + $this->ContentType = 'multipart/alternative'; + } + + $this->error_count = 0; // reset errors + $this->SetMessageType(); + $header .= $this->CreateHeader(); + $body = $this->CreateBody(); + + if($body == '') { + return false; + } + + /* Choose the mailer */ + switch($this->Mailer) { + case 'sendmail': + $result = $this->SendmailSend($header, $body); + break; + case 'smtp': + $result = $this->SmtpSend($header, $body); + break; + case 'mail': + $result = $this->MailSend($header, $body); + break; + default: + $result = $this->MailSend($header, $body); + break; + //$this->SetError($this->Mailer . $this->Lang('mailer_not_supported')); + //$result = false; + //break; + } + + return $result; + } + + /** + * Sends mail using the $Sendmail program. + * @access private + * @return bool + */ + function SendmailSend($header, $body) { + if ($this->Sender != '') { + $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender)); + } else { + $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail)); + } + + if(!@$mail = popen($sendmail, 'w')) { + $this->SetError($this->Lang('execute') . $this->Sendmail); + return false; + } + + fputs($mail, $header); + fputs($mail, $body); + + $result = pclose($mail); + if (version_compare(phpversion(), '4.2.3') == -1) { + $result = $result >> 8 & 0xFF; + } + if($result != 0) { + $this->SetError($this->Lang('execute') . $this->Sendmail); + return false; + } + return true; + } + + /** + * Sends mail using the PHP mail() function. + * @access private + * @return bool + */ + function MailSend($header, $body) { + + $to = ''; + for($i = 0; $i < count($this->to); $i++) { + if($i != 0) { $to .= ', '; } + $to .= $this->AddrFormat($this->to[$i]); + } + + $toArr = split(',', $to); + + $params = sprintf("-oi -f %s", $this->Sender); + if ($this->Sender != '' && strlen(ini_get('safe_mode')) < 1) { + $old_from = ini_get('sendmail_from'); + ini_set('sendmail_from', $this->Sender); + if ($this->SingleTo === true && count($toArr) > 1) { + foreach ($toArr as $key => $val) { + $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); + } + } else { + $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); + } + } else { + if ($this->SingleTo === true && count($toArr) > 1) { + foreach ($toArr as $key => $val) { + $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); + } + } else { + $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header); + } + } + + if (isset($old_from)) { + ini_set('sendmail_from', $old_from); + } + + if(!$rt) { + $this->SetError($this->Lang('instantiate')); + return false; + } + + return true; + } + + /** + * Sends mail via SMTP using PhpSMTP (Author: + * Chris Ryan). Returns bool. Returns false if there is a + * bad MAIL FROM, RCPT, or DATA input. + * @access private + * @return bool + */ + function SmtpSend($header, $body) { + include_once($this->PluginDir . 'class.smtp.php'); + $error = ''; + $bad_rcpt = array(); + + if(!$this->SmtpConnect()) { + return false; + } + + $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender; + if(!$this->smtp->Mail($smtp_from)) { + $error = $this->Lang('from_failed') . $smtp_from; + $this->SetError($error); + $this->smtp->Reset(); + return false; + } + + /* Attempt to send attach all recipients */ + for($i = 0; $i < count($this->to); $i++) { + if(!$this->smtp->Recipient($this->to[$i][0])) { + $bad_rcpt[] = $this->to[$i][0]; + } + } + for($i = 0; $i < count($this->cc); $i++) { + if(!$this->smtp->Recipient($this->cc[$i][0])) { + $bad_rcpt[] = $this->cc[$i][0]; + } + } + for($i = 0; $i < count($this->bcc); $i++) { + if(!$this->smtp->Recipient($this->bcc[$i][0])) { + $bad_rcpt[] = $this->bcc[$i][0]; + } + } + + if(count($bad_rcpt) > 0) { // Create error message + for($i = 0; $i < count($bad_rcpt); $i++) { + if($i != 0) { + $error .= ', '; + } + $error .= $bad_rcpt[$i]; + } + $error = $this->Lang('recipients_failed') . $error; + $this->SetError($error); + $this->smtp->Reset(); + return false; + } + + if(!$this->smtp->Data($header . $body)) { + $this->SetError($this->Lang('data_not_accepted')); + $this->smtp->Reset(); + return false; + } + if($this->SMTPKeepAlive == true) { + $this->smtp->Reset(); + } else { + $this->SmtpClose(); + } + + return true; + } + + /** + * Initiates a connection to an SMTP server. Returns false if the + * operation failed. + * @access private + * @return bool + */ + function SmtpConnect() { + if($this->smtp == NULL) { + $this->smtp = new SMTP(); + } + + $this->smtp->do_debug = $this->SMTPDebug; + $hosts = explode(';', $this->Host); + $index = 0; + $connection = ($this->smtp->Connected()); + + /* Retry while there is no connection */ + while($index < count($hosts) && $connection == false) { + $hostinfo = array(); + if(eregi('^(.+):([0-9]+)$', $hosts[$index], $hostinfo)) { + $host = $hostinfo[1]; + $port = $hostinfo[2]; + } else { + $host = $hosts[$index]; + $port = $this->Port; + } + + if($this->smtp->Connect(((!empty($this->SMTPSecure))?$this->SMTPSecure.'://':'').$host, $port, $this->Timeout)) { + if ($this->Helo != '') { + $this->smtp->Hello($this->Helo); + } else { + $this->smtp->Hello($this->ServerHostname()); + } + + $connection = true; + if($this->SMTPAuth) { + if(!$this->smtp->Authenticate($this->Username, $this->Password)) { + $this->SetError($this->Lang('authenticate')); + $this->smtp->Reset(); + $connection = false; + } + } + } + $index++; + } + if(!$connection) { + $this->SetError($this->Lang('connect_host')); + } + + return $connection; + } + + /** + * Closes the active SMTP session if one exists. + * @return void + */ + function SmtpClose() { + if($this->smtp != NULL) { + if($this->smtp->Connected()) { + $this->smtp->Quit(); + $this->smtp->Close(); + } + } + } + + /** + * Sets the language for all class error messages. Returns false + * if it cannot load the language file. The default language type + * is English. + * @param string $lang_type Type of language (e.g. Portuguese: "br") + * @param string $lang_path Path to the language file directory + * @access public + * @return bool + */ + function SetLanguage($lang_type, $lang_path = 'language/') { + if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php')) { + include($lang_path.'phpmailer.lang-'.$lang_type.'.php'); + } elseif (file_exists($lang_path.'phpmailer.lang-en.php')) { + include($lang_path.'phpmailer.lang-en.php'); + } else { + $this->SetError('Could not load language file'); + return false; + } + $this->language = $PHPMAILER_LANG; + + return true; + } + + ///////////////////////////////////////////////// + // METHODS, MESSAGE CREATION + ///////////////////////////////////////////////// + + /** + * Creates recipient headers. + * @access private + * @return string + */ + function AddrAppend($type, $addr) { + $addr_str = $type . ': '; + $addr_str .= $this->AddrFormat($addr[0]); + if(count($addr) > 1) { + for($i = 1; $i < count($addr); $i++) { + $addr_str .= ', ' . $this->AddrFormat($addr[$i]); + } + } + $addr_str .= $this->LE; + + return $addr_str; + } + + /** + * Formats an address correctly. + * @access private + * @return string + */ + function AddrFormat($addr) { + if(empty($addr[1])) { + $formatted = $this->SecureHeader($addr[0]); + } else { + $formatted = $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">"; + } + + return $formatted; + } + + /** + * Wraps message for use with mailers that do not + * automatically perform wrapping and for quoted-printable. + * Original written by philippe. + * @access private + * @return string + */ + function WrapText($message, $length, $qp_mode = false) { + $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE; + // If utf-8 encoding is used, we will need to make sure we don't + // split multibyte characters when we wrap + $is_utf8 = (strtolower($this->CharSet) == "utf-8"); + + $message = $this->FixEOL($message); + if (substr($message, -1) == $this->LE) { + $message = substr($message, 0, -1); + } + + $line = explode($this->LE, $message); + $message = ''; + for ($i=0 ;$i < count($line); $i++) { + $line_part = explode(' ', $line[$i]); + $buf = ''; + for ($e = 0; $e $length)) { + $space_left = $length - strlen($buf) - 1; + if ($e != 0) { + if ($space_left > 20) { + $len = $space_left; + if ($is_utf8) { + $len = $this->UTF8CharBoundary($word, $len); + } elseif (substr($word, $len - 1, 1) == "=") { + $len--; + } elseif (substr($word, $len - 2, 1) == "=") { + $len -= 2; + } + $part = substr($word, 0, $len); + $word = substr($word, $len); + $buf .= ' ' . $part; + $message .= $buf . sprintf("=%s", $this->LE); + } else { + $message .= $buf . $soft_break; + } + $buf = ''; + } + while (strlen($word) > 0) { + $len = $length; + if ($is_utf8) { + $len = $this->UTF8CharBoundary($word, $len); + } elseif (substr($word, $len - 1, 1) == "=") { + $len--; + } elseif (substr($word, $len - 2, 1) == "=") { + $len -= 2; + } + $part = substr($word, 0, $len); + $word = substr($word, $len); + + if (strlen($word) > 0) { + $message .= $part . sprintf("=%s", $this->LE); + } else { + $buf = $part; + } + } + } else { + $buf_o = $buf; + $buf .= ($e == 0) ? $word : (' ' . $word); + + if (strlen($buf) > $length and $buf_o != '') { + $message .= $buf_o . $soft_break; + $buf = $word; + } + } + } + $message .= $buf . $this->LE; + } + + return $message; + } + + /** + * Finds last character boundary prior to maxLength in a utf-8 + * quoted (printable) encoded string. + * Original written by Colin Brown. + * @access private + * @param string $encodedText utf-8 QP text + * @param int $maxLength find last character boundary prior to this length + * @return int + */ + function UTF8CharBoundary($encodedText, $maxLength) { + $foundSplitPos = false; + $lookBack = 3; + while (!$foundSplitPos) { + $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack); + $encodedCharPos = strpos($lastChunk, "="); + if ($encodedCharPos !== false) { + // Found start of encoded character byte within $lookBack block. + // Check the encoded byte value (the 2 chars after the '=') + $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2); + $dec = hexdec($hex); + if ($dec < 128) { // Single byte character. + // If the encoded char was found at pos 0, it will fit + // otherwise reduce maxLength to start of the encoded char + $maxLength = ($encodedCharPos == 0) ? $maxLength : + $maxLength - ($lookBack - $encodedCharPos); + $foundSplitPos = true; + } elseif ($dec >= 192) { // First byte of a multi byte character + // Reduce maxLength to split at start of character + $maxLength = $maxLength - ($lookBack - $encodedCharPos); + $foundSplitPos = true; + } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back + $lookBack += 3; + } + } else { + // No encoded character found + $foundSplitPos = true; + } + } + return $maxLength; + } + + /** + * Set the body wrapping. + * @access private + * @return void + */ + function SetWordWrap() { + if($this->WordWrap < 1) { + return; + } + + switch($this->message_type) { + case 'alt': + /* fall through */ + case 'alt_attachments': + $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap); + break; + default: + $this->Body = $this->WrapText($this->Body, $this->WordWrap); + break; + } + } + + /** + * Assembles message header. + * @access private + * @return string + */ + function CreateHeader() { + $result = ''; + + /* Set the boundaries */ + $uniq_id = md5(uniqid(time())); + $this->boundary[1] = 'b1_' . $uniq_id; + $this->boundary[2] = 'b2_' . $uniq_id; + + $result .= $this->HeaderLine('Date', $this->RFCDate()); + if($this->Sender == '') { + $result .= $this->HeaderLine('Return-Path', trim($this->From)); + } else { + $result .= $this->HeaderLine('Return-Path', trim($this->Sender)); + } + + /* To be created automatically by mail() */ + if($this->Mailer != 'mail') { + if(count($this->to) > 0) { + $result .= $this->AddrAppend('To', $this->to); + } elseif (count($this->cc) == 0) { + $result .= $this->HeaderLine('To', 'undisclosed-recipients:;'); + } + if(count($this->cc) > 0) { + $result .= $this->AddrAppend('Cc', $this->cc); + } + } + + $from = array(); + $from[0][0] = trim($this->From); + $from[0][1] = $this->FromName; + $result .= $this->AddrAppend('From', $from); + + /* sendmail and mail() extract Cc from the header before sending */ + if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->cc) > 0)) { + $result .= $this->AddrAppend('Cc', $this->cc); + } + + /* sendmail and mail() extract Bcc from the header before sending */ + if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) { + $result .= $this->AddrAppend('Bcc', $this->bcc); + } + + if(count($this->ReplyTo) > 0) { + $result .= $this->AddrAppend('Reply-To', $this->ReplyTo); + } + + /* mail() sets the subject itself */ + if($this->Mailer != 'mail') { + $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject))); + } + + if($this->MessageID != '') { + $result .= $this->HeaderLine('Message-ID',$this->MessageID); + } else { + $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE); + } + $result .= $this->HeaderLine('X-Priority', $this->Priority); + $result .= $this->HeaderLine('X-Mailer', 'PHPMailer (phpmailer.sourceforge.net) [version ' . $this->Version . ']'); + + if($this->ConfirmReadingTo != '') { + $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>'); + } + + // Add custom headers + for($index = 0; $index < count($this->CustomHeader); $index++) { + $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1]))); + } + if (!$this->sign_key_file) { + $result .= $this->HeaderLine('MIME-Version', '1.0'); + $result .= $this->GetMailMIME(); + } + + return $result; + } + + /** + * Returns the message MIME. + * @access private + * @return string + */ + function GetMailMIME() { + $result = ''; + switch($this->message_type) { + case 'plain': + $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding); + $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet); + break; + case 'attachments': + /* fall through */ + case 'alt_attachments': + if($this->InlineImageExists()){ + $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE); + } else { + $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;'); + $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); + } + break; + case 'alt': + $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); + $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); + break; + } + + if($this->Mailer != 'mail') { + $result .= $this->LE.$this->LE; + } + + return $result; + } + + /** + * Assembles the message body. Returns an empty string on failure. + * @access private + * @return string + */ + function CreateBody() { + $result = ''; + if ($this->sign_key_file) { + $result .= $this->GetMailMIME(); + } + + $this->SetWordWrap(); + + switch($this->message_type) { + case 'alt': + $result .= $this->GetBoundary($this->boundary[1], '', 'text/plain', ''); + $result .= $this->EncodeString($this->AltBody, $this->Encoding); + $result .= $this->LE.$this->LE; + $result .= $this->GetBoundary($this->boundary[1], '', 'text/html', ''); + $result .= $this->EncodeString($this->Body, $this->Encoding); + $result .= $this->LE.$this->LE; + $result .= $this->EndBoundary($this->boundary[1]); + break; + case 'plain': + $result .= $this->EncodeString($this->Body, $this->Encoding); + break; + case 'attachments': + $result .= $this->GetBoundary($this->boundary[1], '', '', ''); + $result .= $this->EncodeString($this->Body, $this->Encoding); + $result .= $this->LE; + $result .= $this->AttachAll(); + break; + case 'alt_attachments': + $result .= sprintf("--%s%s", $this->boundary[1], $this->LE); + $result .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE); + $result .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body + $result .= $this->EncodeString($this->AltBody, $this->Encoding); + $result .= $this->LE.$this->LE; + $result .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body + $result .= $this->EncodeString($this->Body, $this->Encoding); + $result .= $this->LE.$this->LE; + $result .= $this->EndBoundary($this->boundary[2]); + $result .= $this->AttachAll(); + break; + } + + if($this->IsError()) { + $result = ''; + } else if ($this->sign_key_file) { + $file = tempnam("", "mail"); + $fp = fopen($file, "w"); + fwrite($fp, $result); + fclose($fp); + $signed = tempnam("", "signed"); + + if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_key_file, array("file://".$this->sign_key_file, $this->sign_key_pass), null)) { + $fp = fopen($signed, "r"); + $result = fread($fp, filesize($this->sign_key_file)); + fclose($fp); + } else { + $this->SetError($this->Lang("signing").openssl_error_string()); + $result = ''; + } + + unlink($file); + unlink($signed); + } + + return $result; + } + + /** + * Returns the start of a message boundary. + * @access private + */ + function GetBoundary($boundary, $charSet, $contentType, $encoding) { + $result = ''; + if($charSet == '') { + $charSet = $this->CharSet; + } + if($contentType == '') { + $contentType = $this->ContentType; + } + if($encoding == '') { + $encoding = $this->Encoding; + } + $result .= $this->TextLine('--' . $boundary); + $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet); + $result .= $this->LE; + $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding); + $result .= $this->LE; + + return $result; + } + + /** + * Returns the end of a message boundary. + * @access private + */ + function EndBoundary($boundary) { + return $this->LE . '--' . $boundary . '--' . $this->LE; + } + + /** + * Sets the message type. + * @access private + * @return void + */ + function SetMessageType() { + if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) { + $this->message_type = 'plain'; + } else { + if(count($this->attachment) > 0) { + $this->message_type = 'attachments'; + } + if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) { + $this->message_type = 'alt'; + } + if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) { + $this->message_type = 'alt_attachments'; + } + } + } + + /* Returns a formatted header line. + * @access private + * @return string + */ + function HeaderLine($name, $value) { + return $name . ': ' . $value . $this->LE; + } + + /** + * Returns a formatted mail line. + * @access private + * @return string + */ + function TextLine($value) { + return $value . $this->LE; + } + + ///////////////////////////////////////////////// + // CLASS METHODS, ATTACHMENTS + ///////////////////////////////////////////////// + + /** + * Adds an attachment from a path on the filesystem. + * Returns false if the file could not be found + * or accessed. + * @param string $path Path to the attachment. + * @param string $name Overrides the attachment name. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @return bool + */ + function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { + if(!@is_file($path)) { + $this->SetError($this->Lang('file_access') . $path); + return false; + } + + $filename = basename($path); + if($name == '') { + $name = $filename; + } + + $cur = count($this->attachment); + $this->attachment[$cur][0] = $path; + $this->attachment[$cur][1] = $filename; + $this->attachment[$cur][2] = $name; + $this->attachment[$cur][3] = $encoding; + $this->attachment[$cur][4] = $type; + $this->attachment[$cur][5] = false; // isStringAttachment + $this->attachment[$cur][6] = 'attachment'; + $this->attachment[$cur][7] = 0; + + return true; + } + + /** + * Attaches all fs, string, and binary attachments to the message. + * Returns an empty string on failure. + * @access private + * @return string + */ + function AttachAll() { + /* Return text of body */ + $mime = array(); + + /* Add all attachments */ + for($i = 0; $i < count($this->attachment); $i++) { + /* Check for string attachment */ + $bString = $this->attachment[$i][5]; + if ($bString) { + $string = $this->attachment[$i][0]; + } else { + $path = $this->attachment[$i][0]; + } + + $filename = $this->attachment[$i][1]; + $name = $this->attachment[$i][2]; + $encoding = $this->attachment[$i][3]; + $type = $this->attachment[$i][4]; + $disposition = $this->attachment[$i][6]; + $cid = $this->attachment[$i][7]; + + $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE); + $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $name, $this->LE); + $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE); + + if($disposition == 'inline') { + $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); + } + + $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $name, $this->LE.$this->LE); + + /* Encode as string attachment */ + if($bString) { + $mime[] = $this->EncodeString($string, $encoding); + if($this->IsError()) { + return ''; + } + $mime[] = $this->LE.$this->LE; + } else { + $mime[] = $this->EncodeFile($path, $encoding); + if($this->IsError()) { + return ''; + } + $mime[] = $this->LE.$this->LE; + } + } + + $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE); + + return join('', $mime); + } + + /** + * Encodes attachment in requested format. Returns an + * empty string on failure. + * @access private + * @return string + */ + function EncodeFile ($path, $encoding = 'base64') { + if(!@$fd = fopen($path, 'rb')) { + $this->SetError($this->Lang('file_open') . $path); + return ''; + } + $magic_quotes = get_magic_quotes_runtime(); + set_magic_quotes_runtime(0); + $file_buffer = fread($fd, filesize($path)); + $file_buffer = $this->EncodeString($file_buffer, $encoding); + fclose($fd); + set_magic_quotes_runtime($magic_quotes); + + return $file_buffer; + } + + /** + * Encodes string to requested format. Returns an + * empty string on failure. + * @access private + * @return string + */ + function EncodeString ($str, $encoding = 'base64') { + $encoded = ''; + switch(strtolower($encoding)) { + case 'base64': + /* chunk_split is found in PHP >= 3.0.6 */ + $encoded = chunk_split(base64_encode($str), 76, $this->LE); + break; + case '7bit': + case '8bit': + $encoded = $this->FixEOL($str); + if (substr($encoded, -(strlen($this->LE))) != $this->LE) + $encoded .= $this->LE; + break; + case 'binary': + $encoded = $str; + break; + case 'quoted-printable': + $encoded = $this->EncodeQP($str); + break; + default: + $this->SetError($this->Lang('encoding') . $encoding); + break; + } + return $encoded; + } + + /** + * Encode a header string to best of Q, B, quoted or none. + * @access private + * @return string + */ + function EncodeHeader ($str, $position = 'text') { + $x = 0; + + switch (strtolower($position)) { + case 'phrase': + if (!preg_match('/[\200-\377]/', $str)) { + /* Can't use addslashes as we don't know what value has magic_quotes_sybase. */ + $encoded = addcslashes($str, "\0..\37\177\\\""); + if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) { + return ($encoded); + } else { + return ("\"$encoded\""); + } + } + $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches); + break; + case 'comment': + $x = preg_match_all('/[()"]/', $str, $matches); + /* Fall-through */ + case 'text': + default: + $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches); + break; + } + + if ($x == 0) { + return ($str); + } + + $maxlen = 75 - 7 - strlen($this->CharSet); + /* Try to select the encoding which should produce the shortest output */ + if (strlen($str)/3 < $x) { + $encoding = 'B'; + if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) { + // Use a custom function which correctly encodes and wraps long + // multibyte strings without breaking lines within a character + $encoded = $this->Base64EncodeWrapMB($str); + } else { + $encoded = base64_encode($str); + $maxlen -= $maxlen % 4; + $encoded = trim(chunk_split($encoded, $maxlen, "\n")); + } + } else { + $encoding = 'Q'; + $encoded = $this->EncodeQ($str, $position); + $encoded = $this->WrapText($encoded, $maxlen, true); + $encoded = str_replace('='.$this->LE, "\n", trim($encoded)); + } + + $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded); + $encoded = trim(str_replace("\n", $this->LE, $encoded)); + + return $encoded; + } + + /** + * Checks if a string contains multibyte characters. + * @access private + * @param string $str multi-byte text to wrap encode + * @return bool + */ + function HasMultiBytes($str) { + if (function_exists('mb_strlen')) { + return (strlen($str) > mb_strlen($str, $this->CharSet)); + } else { // Assume no multibytes (we can't handle without mbstring functions anyway) + return False; + } + } + + /** + * Correctly encodes and wraps long multibyte strings for mail headers + * without breaking lines within a character. + * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php + * @access private + * @param string $str multi-byte text to wrap encode + * @return string + */ + function Base64EncodeWrapMB($str) { + $start = "=?".$this->CharSet."?B?"; + $end = "?="; + $encoded = ""; + + $mb_length = mb_strlen($str, $this->CharSet); + // Each line must have length <= 75, including $start and $end + $length = 75 - strlen($start) - strlen($end); + // Average multi-byte ratio + $ratio = $mb_length / strlen($str); + // Base64 has a 4:3 ratio + $offset = $avgLength = floor($length * $ratio * .75); + + for ($i = 0; $i < $mb_length; $i += $offset) { + $lookBack = 0; + + do { + $offset = $avgLength - $lookBack; + $chunk = mb_substr($str, $i, $offset, $this->CharSet); + $chunk = base64_encode($chunk); + $lookBack++; + } + while (strlen($chunk) > $length); + + $encoded .= $chunk . $this->LE; + } + + // Chomp the last linefeed + $encoded = substr($encoded, 0, -strlen($this->LE)); + return $encoded; + } + + /** + * Encode string to quoted-printable. + * @access private + * @return string + */ + function EncodeQP( $input = '', $line_max = 76, $space_conv = false ) { + $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); + $lines = preg_split('/(?:\r\n|\r|\n)/', $input); + $eol = "\r\n"; + $escape = '='; + $output = ''; + while( list(, $line) = each($lines) ) { + $linlen = strlen($line); + $newline = ''; + for($i = 0; $i < $linlen; $i++) { + $c = substr( $line, $i, 1 ); + $dec = ord( $c ); + if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E + $c = '=2E'; + } + if ( $dec == 32 ) { + if ( $i == ( $linlen - 1 ) ) { // convert space at eol only + $c = '=20'; + } else if ( $space_conv ) { + $c = '=20'; + } + } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required + $h2 = floor($dec/16); + $h1 = floor($dec%16); + $c = $escape.$hex[$h2].$hex[$h1]; + } + if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted + $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay + $newline = ''; + // check if newline first character will be point or not + if ( $dec == 46 ) { + $c = '=2E'; + } + } + $newline .= $c; + } // end of for + $output .= $newline.$eol; + } // end of while + return trim($output); + } + + /** + * Encode string to q encoding. + * @access private + * @return string + */ + function EncodeQ ($str, $position = 'text') { + /* There should not be any EOL in the string */ + $encoded = preg_replace("[\r\n]", '', $str); + + switch (strtolower($position)) { + case 'phrase': + $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); + break; + case 'comment': + $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); + case 'text': + default: + /* Replace every high ascii, control =, ? and _ characters */ + $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e', + "'='.sprintf('%02X', ord('\\1'))", $encoded); + break; + } + + /* Replace every spaces to _ (more readable than =20) */ + $encoded = str_replace(' ', '_', $encoded); + + return $encoded; + } + + /** + * Adds a string or binary attachment (non-filesystem) to the list. + * This method can be used to attach ascii or binary data, + * such as a BLOB record from a database. + * @param string $string String attachment data. + * @param string $filename Name of the attachment. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @return void + */ + function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') { + /* Append to $attachment array */ + $cur = count($this->attachment); + $this->attachment[$cur][0] = $string; + $this->attachment[$cur][1] = $filename; + $this->attachment[$cur][2] = $filename; + $this->attachment[$cur][3] = $encoding; + $this->attachment[$cur][4] = $type; + $this->attachment[$cur][5] = true; // isString + $this->attachment[$cur][6] = 'attachment'; + $this->attachment[$cur][7] = 0; + } + + /** + * Adds an embedded attachment. This can include images, sounds, and + * just about any other document. Make sure to set the $type to an + * image type. For JPEG images use "image/jpeg" and for GIF images + * use "image/gif". + * @param string $path Path to the attachment. + * @param string $cid Content ID of the attachment. Use this to identify + * the Id for accessing the image in an HTML form. + * @param string $name Overrides the attachment name. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @return bool + */ + function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { + + if(!@is_file($path)) { + $this->SetError($this->Lang('file_access') . $path); + return false; + } + + $filename = basename($path); + if($name == '') { + $name = $filename; + } + + /* Append to $attachment array */ + $cur = count($this->attachment); + $this->attachment[$cur][0] = $path; + $this->attachment[$cur][1] = $filename; + $this->attachment[$cur][2] = $name; + $this->attachment[$cur][3] = $encoding; + $this->attachment[$cur][4] = $type; + $this->attachment[$cur][5] = false; + $this->attachment[$cur][6] = 'inline'; + $this->attachment[$cur][7] = $cid; + + return true; + } + + /** + * Returns true if an inline attachment is present. + * @access private + * @return bool + */ + function InlineImageExists() { + $result = false; + for($i = 0; $i < count($this->attachment); $i++) { + if($this->attachment[$i][6] == 'inline') { + $result = true; + break; + } + } + + return $result; + } + + ///////////////////////////////////////////////// + // CLASS METHODS, MESSAGE RESET + ///////////////////////////////////////////////// + + /** + * Clears all recipients assigned in the TO array. Returns void. + * @return void + */ + function ClearAddresses() { + $this->to = array(); + } + + /** + * Clears all recipients assigned in the CC array. Returns void. + * @return void + */ + function ClearCCs() { + $this->cc = array(); + } + + /** + * Clears all recipients assigned in the BCC array. Returns void. + * @return void + */ + function ClearBCCs() { + $this->bcc = array(); + } + + /** + * Clears all recipients assigned in the ReplyTo array. Returns void. + * @return void + */ + function ClearReplyTos() { + $this->ReplyTo = array(); + } + + /** + * Clears all recipients assigned in the TO, CC and BCC + * array. Returns void. + * @return void + */ + function ClearAllRecipients() { + $this->to = array(); + $this->cc = array(); + $this->bcc = array(); + } + + /** + * Clears all previously set filesystem, string, and binary + * attachments. Returns void. + * @return void + */ + function ClearAttachments() { + $this->attachment = array(); + } + + /** + * Clears all custom headers. Returns void. + * @return void + */ + function ClearCustomHeaders() { + $this->CustomHeader = array(); + } + + ///////////////////////////////////////////////// + // CLASS METHODS, MISCELLANEOUS + ///////////////////////////////////////////////// + + /** + * Adds the error message to the error container. + * Returns void. + * @access private + * @return void + */ + function SetError($msg) { + $this->error_count++; + $this->ErrorInfo = $msg; + } + + /** + * Returns the proper RFC 822 formatted date. + * @access private + * @return string + */ + function RFCDate() { + $tz = date('Z'); + $tzs = ($tz < 0) ? '-' : '+'; + $tz = abs($tz); + $tz = (int)($tz/3600)*100 + ($tz%3600)/60; + $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz); + + return $result; + } + + /** + * Returns the appropriate server variable. Should work with both + * PHP 4.1.0+ as well as older versions. Returns an empty string + * if nothing is found. + * @access private + * @return mixed + */ + function ServerVar($varName) { + global $HTTP_SERVER_VARS; + global $HTTP_ENV_VARS; + + if(!isset($_SERVER)) { + $_SERVER = $HTTP_SERVER_VARS; + if(!isset($_SERVER['REMOTE_ADDR'])) { + $_SERVER = $HTTP_ENV_VARS; // must be Apache + } + } + + if(isset($_SERVER[$varName])) { + return $_SERVER[$varName]; + } else { + return ''; + } + } + + /** + * Returns the server hostname or 'localhost.localdomain' if unknown. + * @access private + * @return string + */ + function ServerHostname() { + if ($this->Hostname != '') { + $result = $this->Hostname; + } elseif ($this->ServerVar('SERVER_NAME') != '') { + $result = $this->ServerVar('SERVER_NAME'); + } else { + $result = 'localhost.localdomain'; + } + + return $result; + } + + /** + * Returns a message in the appropriate language. + * @access private + * @return string + */ + function Lang($key) { + if(count($this->language) < 1) { + $this->SetLanguage('en'); // set the default language + } + + if(isset($this->language[$key])) { + return $this->language[$key]; + } else { + return 'Language string failed to load: ' . $key; + } + } + + /** + * Returns true if an error occurred. + * @return bool + */ + function IsError() { + return ($this->error_count > 0); + } + + /** + * Changes every end of line from CR or LF to CRLF. + * @access private + * @return string + */ + function FixEOL($str) { + $str = str_replace("\r\n", "\n", $str); + $str = str_replace("\r", "\n", $str); + $str = str_replace("\n", $this->LE, $str); + return $str; + } + + /** + * Adds a custom header. + * @return void + */ + function AddCustomHeader($custom_header) { + $this->CustomHeader[] = explode(':', $custom_header, 2); + } + + /** + * Evaluates the message and returns modifications for inline images and backgrounds + * @access public + * @return $message + */ + function MsgHTML($message,$basedir='') { + preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images); + if(isset($images[2])) { + foreach($images[2] as $i => $url) { + // do not change urls for absolute images (thanks to corvuscorax) + if (!preg_match('/^[A-z][A-z]*:\/\//',$url)) { + $filename = basename($url); + $directory = dirname($url); + ($directory == '.')?$directory='':''; + $cid = 'cid:' . md5($filename); + $fileParts = split("\.", $filename); + $ext = $fileParts[1]; + $mimeType = $this->_mime_types($ext); + if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; } + if ( strlen($directory) > 1 && substr($basedir,-1) != '/') { $directory .= '/'; } + $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64', $mimeType); + if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) { + $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message); + } + } + } + } + $this->IsHTML(true); + $this->Body = $message; + $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message))); + if ( !empty($textMsg) && empty($this->AltBody) ) { + $this->AltBody = $textMsg; + } + if ( empty($this->AltBody) ) { + $this->AltBody = 'To view this email message, open the email in with HTML compatibility!' . "\n\n"; + } + } + + /** + * Gets the mime type of the embedded or inline image + * @access private + * @return mime type of ext + */ + function _mime_types($ext = '') { + $mimes = array( + 'hqx' => 'application/mac-binhex40', + 'cpt' => 'application/mac-compactpro', + 'doc' => 'application/msword', + 'bin' => 'application/macbinary', + 'dms' => 'application/octet-stream', + 'lha' => 'application/octet-stream', + 'lzh' => 'application/octet-stream', + 'exe' => 'application/octet-stream', + 'class' => 'application/octet-stream', + 'psd' => 'application/octet-stream', + 'so' => 'application/octet-stream', + 'sea' => 'application/octet-stream', + 'dll' => 'application/octet-stream', + 'oda' => 'application/oda', + 'pdf' => 'application/pdf', + 'ai' => 'application/postscript', + 'eps' => 'application/postscript', + 'ps' => 'application/postscript', + 'smi' => 'application/smil', + 'smil' => 'application/smil', + 'mif' => 'application/vnd.mif', + 'xls' => 'application/vnd.ms-excel', + 'ppt' => 'application/vnd.ms-powerpoint', + 'wbxml' => 'application/vnd.wap.wbxml', + 'wmlc' => 'application/vnd.wap.wmlc', + 'dcr' => 'application/x-director', + 'dir' => 'application/x-director', + 'dxr' => 'application/x-director', + 'dvi' => 'application/x-dvi', + 'gtar' => 'application/x-gtar', + 'php' => 'application/x-httpd-php', + 'php4' => 'application/x-httpd-php', + 'php3' => 'application/x-httpd-php', + 'phtml' => 'application/x-httpd-php', + 'phps' => 'application/x-httpd-php-source', + 'js' => 'application/x-javascript', + 'swf' => 'application/x-shockwave-flash', + 'sit' => 'application/x-stuffit', + 'tar' => 'application/x-tar', + 'tgz' => 'application/x-tar', + 'xhtml' => 'application/xhtml+xml', + 'xht' => 'application/xhtml+xml', + 'zip' => 'application/zip', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mpga' => 'audio/mpeg', + 'mp2' => 'audio/mpeg', + 'mp3' => 'audio/mpeg', + 'aif' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'aifc' => 'audio/x-aiff', + 'ram' => 'audio/x-pn-realaudio', + 'rm' => 'audio/x-pn-realaudio', + 'rpm' => 'audio/x-pn-realaudio-plugin', + 'ra' => 'audio/x-realaudio', + 'rv' => 'video/vnd.rn-realvideo', + 'wav' => 'audio/x-wav', + 'bmp' => 'image/bmp', + 'gif' => 'image/gif', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'jpe' => 'image/jpeg', + 'png' => 'image/png', + 'tiff' => 'image/tiff', + 'tif' => 'image/tiff', + 'css' => 'text/css', + 'html' => 'text/html', + 'htm' => 'text/html', + 'shtml' => 'text/html', + 'txt' => 'text/plain', + 'text' => 'text/plain', + 'log' => 'text/plain', + 'rtx' => 'text/richtext', + 'rtf' => 'text/rtf', + 'xml' => 'text/xml', + 'xsl' => 'text/xml', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpe' => 'video/mpeg', + 'qt' => 'video/quicktime', + 'mov' => 'video/quicktime', + 'avi' => 'video/x-msvideo', + 'movie' => 'video/x-sgi-movie', + 'doc' => 'application/msword', + 'word' => 'application/msword', + 'xl' => 'application/excel', + 'eml' => 'message/rfc822' + ); + return ( ! isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)]; + } + + /** + * Set (or reset) Class Objects (variables) + * + * Usage Example: + * $page->set('X-Priority', '3'); + * + * @access public + * @param string $name Parameter Name + * @param mixed $value Parameter Value + * NOTE: will not work with arrays, there are no arrays to set/reset + */ + function set ( $name, $value = '' ) { + if ( isset($this->$name) ) { + $this->$name = $value; + } else { + $this->SetError('Cannot set or reset variable ' . $name); + return false; + } + } + + /** + * Read a file from a supplied filename and return it. + * + * @access public + * @param string $filename Parameter File Name + */ + function getFile($filename) { + $return = ''; + if ($fp = fopen($filename, 'rb')) { + while (!feof($fp)) { + $return .= fread($fp, 1024); + } + fclose($fp); + return $return; + } else { + return false; + } + } + + /** + * Strips newlines to prevent header injection. + * @access private + * @param string $str String + * @return string + */ + function SecureHeader($str) { + $str = trim($str); + $str = str_replace("\r", "", $str); + $str = str_replace("\n", "", $str); + return $str; + } + + /** + * Set the private key file and password to sign the message. + * + * @access public + * @param string $key_filename Parameter File Name + * @param string $key_pass Password for private key + */ + function Sign($key_filename, $key_pass) { + $this->sign_key_file = $key_filename; + $this->sign_key_pass = $key_pass; + } + +} + +?> diff --git a/includes/class.smtp.php b/includes/class.smtp.php new file mode 100644 index 0000000000..398c3ffbac --- /dev/null +++ b/includes/class.smtp.php @@ -0,0 +1,1062 @@ +smtp_conn = 0; + $this->error = null; + $this->helo_rply = null; + + $this->do_debug = 0; + } + + /************************************************************* + * CONNECTION FUNCTIONS * + ***********************************************************/ + + /** + * Connect to the server specified on the port specified. + * If the port is not specified use the default SMTP_PORT. + * If tval is specified then a connection will try and be + * established with the server for that number of seconds. + * If tval is not specified the default is 30 seconds to + * try on the connection. + * + * SMTP CODE SUCCESS: 220 + * SMTP CODE FAILURE: 421 + * @access public + * @return bool + */ + function Connect($host,$port=0,$tval=30) { + # set the error val to null so there is no confusion + $this->error = null; + + # make sure we are __not__ connected + if($this->connected()) { + # ok we are connected! what should we do? + # for now we will just give an error saying we + # are already connected + $this->error = array("error" => "Already connected to a server"); + return false; + } + + if(empty($port)) { + $port = $this->SMTP_PORT; + } + + #connect to the smtp server + $this->smtp_conn = fsockopen($host, # the host of the server + $port, # the port to use + $errno, # error number if any + $errstr, # error message if any + $tval); # give up after ? secs + # verify we connected properly + if(empty($this->smtp_conn)) { + $this->error = array("error" => "Failed to connect to server", + "errno" => $errno, + "errstr" => $errstr); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": $errstr ($errno)" . $this->CRLF; + } + return false; + } + + # sometimes the SMTP server takes a little longer to respond + # so we will give it a longer timeout for the first read + // Windows still does not have support for this timeout function + if(substr(PHP_OS, 0, 3) != "WIN") + socket_set_timeout($this->smtp_conn, $tval, 0); + + # get any announcement stuff + $announce = $this->get_lines(); + + # set the timeout of any socket functions at 1/10 of a second + //if(function_exists("socket_set_timeout")) + // socket_set_timeout($this->smtp_conn, 0, 100000); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce; + } + + return true; + } + + /** + * Performs SMTP authentication. Must be run after running the + * Hello() method. Returns true if successfully authenticated. + * @access public + * @return bool + */ + function Authenticate($username, $password) { + // Start authentication + fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($code != 334) { + $this->error = + array("error" => "AUTH not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + // Send encoded username + fputs($this->smtp_conn, base64_encode($username) . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($code != 334) { + $this->error = + array("error" => "Username not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + // Send encoded password + fputs($this->smtp_conn, base64_encode($password) . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($code != 235) { + $this->error = + array("error" => "Password not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + return true; + } + + /** + * Returns true if connected to a server otherwise false + * @access private + * @return bool + */ + function Connected() { + if(!empty($this->smtp_conn)) { + $sock_status = socket_get_status($this->smtp_conn); + if($sock_status["eof"]) { + # hmm this is an odd situation... the socket is + # valid but we are not connected anymore + if($this->do_debug >= 1) { + echo "SMTP -> NOTICE:" . $this->CRLF . + "EOF caught while checking if connected"; + } + $this->Close(); + return false; + } + return true; # everything looks good + } + return false; + } + + /** + * Closes the socket and cleans up the state of the class. + * It is not considered good to use this function without + * first trying to use QUIT. + * @access public + * @return void + */ + function Close() { + $this->error = null; # so there is no confusion + $this->helo_rply = null; + if(!empty($this->smtp_conn)) { + # close the connection and cleanup + fclose($this->smtp_conn); + $this->smtp_conn = 0; + } + } + + /*************************************************************** + * SMTP COMMANDS * + *************************************************************/ + + /** + * Issues a data command and sends the msg_data to the server + * finializing the mail transaction. $msg_data is the message + * that is to be send with the headers. Each header needs to be + * on a single line followed by a with the message headers + * and the message body being seperated by and additional . + * + * Implements rfc 821: DATA + * + * SMTP CODE INTERMEDIATE: 354 + * [data] + * . + * SMTP CODE SUCCESS: 250 + * SMTP CODE FAILURE: 552,554,451,452 + * SMTP CODE FAILURE: 451,554 + * SMTP CODE ERROR : 500,501,503,421 + * @access public + * @return bool + */ + function Data($msg_data) { + $this->error = null; # so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Data() without being connected"); + return false; + } + + fputs($this->smtp_conn,"DATA" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 354) { + $this->error = + array("error" => "DATA command not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + # the server is ready to accept data! + # according to rfc 821 we should not send more than 1000 + # including the CRLF + # characters on a single line so we will break the data up + # into lines by \r and/or \n then if needed we will break + # each of those into smaller lines to fit within the limit. + # in addition we will be looking for lines that start with + # a period '.' and append and additional period '.' to that + # line. NOTE: this does not count towards are limit. + + # normalize the line breaks so we know the explode works + $msg_data = str_replace("\r\n","\n",$msg_data); + $msg_data = str_replace("\r","\n",$msg_data); + $lines = explode("\n",$msg_data); + + # we need to find a good way to determine is headers are + # in the msg_data or if it is a straight msg body + # currently I am assuming rfc 822 definitions of msg headers + # and if the first field of the first line (':' sperated) + # does not contain a space then it _should_ be a header + # and we can process all lines before a blank "" line as + # headers. + $field = substr($lines[0],0,strpos($lines[0],":")); + $in_headers = false; + if(!empty($field) && !strstr($field," ")) { + $in_headers = true; + } + + $max_line_length = 998; # used below; set here for ease in change + + while(list(,$line) = @each($lines)) { + $lines_out = null; + if($line == "" && $in_headers) { + $in_headers = false; + } + # ok we need to break this line up into several + # smaller lines + while(strlen($line) > $max_line_length) { + $pos = strrpos(substr($line,0,$max_line_length)," "); + + # Patch to fix DOS attack + if(!$pos) { + $pos = $max_line_length - 1; + } + + $lines_out[] = substr($line,0,$pos); + $line = substr($line,$pos + 1); + # if we are processing headers we need to + # add a LWSP-char to the front of the new line + # rfc 822 on long msg headers + if($in_headers) { + $line = "\t" . $line; + } + } + $lines_out[] = $line; + + # now send the lines to the server + while(list(,$line_out) = @each($lines_out)) { + if(strlen($line_out) > 0) + { + if(substr($line_out, 0, 1) == ".") { + $line_out = "." . $line_out; + } + } + fputs($this->smtp_conn,$line_out . $this->CRLF); + } + } + + # ok all the message data has been sent so lets get this + # over with aleady + fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "DATA not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * Expand takes the name and asks the server to list all the + * people who are members of the _list_. Expand will return + * back and array of the result or false if an error occurs. + * Each value in the array returned has the format of: + * [ ] + * The definition of is defined in rfc 821 + * + * Implements rfc 821: EXPN + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE FAILURE: 550 + * SMTP CODE ERROR : 500,501,502,504,421 + * @access public + * @return string array + */ + function Expand($name) { + $this->error = null; # so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Expand() without being connected"); + return false; + } + + fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "EXPN not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + # parse the reply and place in our array to return to user + $entries = explode($this->CRLF,$rply); + while(list(,$l) = @each($entries)) { + $list[] = substr($l,4); + } + + return $list; + } + + /** + * Sends the HELO command to the smtp server. + * This makes sure that we and the server are in + * the same known state. + * + * Implements from rfc 821: HELO + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE ERROR : 500, 501, 504, 421 + * @access public + * @return bool + */ + function Hello($host="") { + $this->error = null; # so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Hello() without being connected"); + return false; + } + + # if a hostname for the HELO was not specified determine + # a suitable one to send + if(empty($host)) { + # we need to determine some sort of appopiate default + # to send to the server + $host = "localhost"; + } + + // Send extended hello first (RFC 2821) + if(!$this->SendHello("EHLO", $host)) + { + if(!$this->SendHello("HELO", $host)) + return false; + } + + return true; + } + + /** + * Sends a HELO/EHLO command. + * @access private + * @return bool + */ + function SendHello($hello, $host) { + fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => $hello . " not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + $this->helo_rply = $rply; + + return true; + } + + /** + * Gets help information on the keyword specified. If the keyword + * is not specified then returns generic help, ussually contianing + * A list of keywords that help is available on. This function + * returns the results back to the user. It is up to the user to + * handle the returned data. If an error occurs then false is + * returned with $this->error set appropiately. + * + * Implements rfc 821: HELP [ ] + * + * SMTP CODE SUCCESS: 211,214 + * SMTP CODE ERROR : 500,501,502,504,421 + * @access public + * @return string + */ + function Help($keyword="") { + $this->error = null; # to avoid confusion + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Help() without being connected"); + return false; + } + + $extra = ""; + if(!empty($keyword)) { + $extra = " " . $keyword; + } + + fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 211 && $code != 214) { + $this->error = + array("error" => "HELP not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + return $rply; + } + + /** + * Starts a mail transaction from the email address specified in + * $from. Returns true if successful or false otherwise. If True + * the mail transaction is started and then one or more Recipient + * commands may be called followed by a Data command. + * + * Implements rfc 821: MAIL FROM: + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE SUCCESS: 552,451,452 + * SMTP CODE SUCCESS: 500,501,421 + * @access public + * @return bool + */ + function Mail($from) { + $this->error = null; # so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Mail() without being connected"); + return false; + } + + $useVerp = ($this->do_verp ? "XVERP" : ""); + fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "MAIL not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * Sends the command NOOP to the SMTP server. + * + * Implements from rfc 821: NOOP + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE ERROR : 500, 421 + * @access public + * @return bool + */ + function Noop() { + $this->error = null; # so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Noop() without being connected"); + return false; + } + + fputs($this->smtp_conn,"NOOP" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "NOOP not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * Sends the quit command to the server and then closes the socket + * if there is no error or the $close_on_error argument is true. + * + * Implements from rfc 821: QUIT + * + * SMTP CODE SUCCESS: 221 + * SMTP CODE ERROR : 500 + * @access public + * @return bool + */ + function Quit($close_on_error=true) { + $this->error = null; # so there is no confusion + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Quit() without being connected"); + return false; + } + + # send the quit command to the server + fputs($this->smtp_conn,"quit" . $this->CRLF); + + # get any good-bye messages + $byemsg = $this->get_lines(); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg; + } + + $rval = true; + $e = null; + + $code = substr($byemsg,0,3); + if($code != 221) { + # use e as a tmp var cause Close will overwrite $this->error + $e = array("error" => "SMTP server rejected quit command", + "smtp_code" => $code, + "smtp_rply" => substr($byemsg,4)); + $rval = false; + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $e["error"] . ": " . + $byemsg . $this->CRLF; + } + } + + if(empty($e) || $close_on_error) { + $this->Close(); + } + + return $rval; + } + + /** + * Sends the command RCPT to the SMTP server with the TO: argument of $to. + * Returns true if the recipient was accepted false if it was rejected. + * + * Implements from rfc 821: RCPT TO: + * + * SMTP CODE SUCCESS: 250,251 + * SMTP CODE FAILURE: 550,551,552,553,450,451,452 + * SMTP CODE ERROR : 500,501,503,421 + * @access public + * @return bool + */ + function Recipient($to) { + $this->error = null; # so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Recipient() without being connected"); + return false; + } + + fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250 && $code != 251) { + $this->error = + array("error" => "RCPT not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * Sends the RSET command to abort and transaction that is + * currently in progress. Returns true if successful false + * otherwise. + * + * Implements rfc 821: RSET + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE ERROR : 500,501,504,421 + * @access public + * @return bool + */ + function Reset() { + $this->error = null; # so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Reset() without being connected"); + return false; + } + + fputs($this->smtp_conn,"RSET" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "RSET failed", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + + return true; + } + + /** + * Starts a mail transaction from the email address specified in + * $from. Returns true if successful or false otherwise. If True + * the mail transaction is started and then one or more Recipient + * commands may be called followed by a Data command. This command + * will send the message to the users terminal if they are logged + * in. + * + * Implements rfc 821: SEND FROM: + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE SUCCESS: 552,451,452 + * SMTP CODE SUCCESS: 500,501,502,421 + * @access public + * @return bool + */ + function Send($from) { + $this->error = null; # so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Send() without being connected"); + return false; + } + + fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "SEND not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * Starts a mail transaction from the email address specified in + * $from. Returns true if successful or false otherwise. If True + * the mail transaction is started and then one or more Recipient + * commands may be called followed by a Data command. This command + * will send the message to the users terminal if they are logged + * in and send them an email. + * + * Implements rfc 821: SAML FROM: + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE SUCCESS: 552,451,452 + * SMTP CODE SUCCESS: 500,501,502,421 + * @access public + * @return bool + */ + function SendAndMail($from) { + $this->error = null; # so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called SendAndMail() without being connected"); + return false; + } + + fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "SAML not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * Starts a mail transaction from the email address specified in + * $from. Returns true if successful or false otherwise. If True + * the mail transaction is started and then one or more Recipient + * commands may be called followed by a Data command. This command + * will send the message to the users terminal if they are logged + * in or mail it to them if they are not. + * + * Implements rfc 821: SOML FROM: + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE SUCCESS: 552,451,452 + * SMTP CODE SUCCESS: 500,501,502,421 + * @access public + * @return bool + */ + function SendOrMail($from) { + $this->error = null; # so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called SendOrMail() without being connected"); + return false; + } + + fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250) { + $this->error = + array("error" => "SOML not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return true; + } + + /** + * This is an optional command for SMTP that this class does not + * support. This method is here to make the RFC821 Definition + * complete for this class and __may__ be implimented in the future + * + * Implements from rfc 821: TURN + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE FAILURE: 502 + * SMTP CODE ERROR : 500, 503 + * @access public + * @return bool + */ + function Turn() { + $this->error = array("error" => "This method, TURN, of the SMTP ". + "is not implemented"); + if($this->do_debug >= 1) { + echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF; + } + return false; + } + + /** + * Verifies that the name is recognized by the server. + * Returns false if the name could not be verified otherwise + * the response from the server is returned. + * + * Implements rfc 821: VRFY + * + * SMTP CODE SUCCESS: 250,251 + * SMTP CODE FAILURE: 550,551,553 + * SMTP CODE ERROR : 500,501,502,421 + * @access public + * @return int + */ + function Verify($name) { + $this->error = null; # so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Verify() without being connected"); + return false; + } + + fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply; + } + + if($code != 250 && $code != 251) { + $this->error = + array("error" => "VRFY failed on name '$name'", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . + ": " . $rply . $this->CRLF; + } + return false; + } + return $rply; + } + + /******************************************************************* + * INTERNAL FUNCTIONS * + ******************************************************************/ + + /** + * Read in as many lines as possible + * either before eof or socket timeout occurs on the operation. + * With SMTP we can tell if we have more lines to read if the + * 4th character is '-' symbol. If it is a space then we don't + * need to read anything else. + * @access private + * @return string + */ + function get_lines() { + $data = ""; + while($str = @fgets($this->smtp_conn,515)) { + if($this->do_debug >= 4) { + echo "SMTP -> get_lines(): \$data was \"$data\"" . + $this->CRLF; + echo "SMTP -> get_lines(): \$str is \"$str\"" . + $this->CRLF; + } + $data .= $str; + if($this->do_debug >= 4) { + echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF; + } + # if the 4th character is a space then we are done reading + # so just break the loop + if(substr($str,3,1) == " ") { break; } + } + return $data; + } + +} + + + ?> diff --git a/includes/class_vcard.php b/includes/class_vcard.php new file mode 100644 index 0000000000..6e211218e7 --- /dev/null +++ b/includes/class_vcard.php @@ -0,0 +1,198 @@ +log = "New vcard() called
"; + $this->data = array( + "display_name"=>null + ,"first_name"=>null + ,"last_name"=>null + ,"additional_name"=>null + ,"name_prefix"=>null + ,"name_suffix"=>null + ,"nickname"=>null + ,"title"=>null + ,"role"=>null + ,"department"=>null + ,"company"=>null + ,"work_po_box"=>null + ,"work_extended_address"=>null + ,"work_address"=>null + ,"work_city"=>null + ,"work_state"=>null + ,"work_postal_code"=>null + ,"work_country"=>null + ,"home_po_box"=>null + ,"home_extended_address"=>null + ,"home_address"=>null + ,"home_city"=>null + ,"home_state"=>null + ,"home_postal_code"=>null + ,"home_country"=>null + ,"office_tel"=>null + ,"home_tel"=>null + ,"cell_tel"=>null + ,"fax_tel"=>null + ,"pager_tel"=>null + ,"email1"=>null + ,"email2"=>null + ,"url"=>null + ,"photo"=>null + ,"birthday"=>null + ,"timezone"=>null + ,"sort_string"=>null + ,"note"=>null + ); + return true; + } + + /* + build() method checks all the values, builds appropriate defaults for + missing values, generates the vcard data string. + */ + function build() { + $this->log .= "vcard build() called
"; + /* + For many of the values, if they are not passed in, we set defaults or + build them based on other values. + */ + if (!$this->class) { $this->class = "PUBLIC"; } + if (!$this->data['display_name']) { + $this->data['display_name'] = trim($this->data['first_name']." ".$this->data['last_name']); + } + if (!$this->data['sort_string']) { $this->data['sort_string'] = $this->data['last_name']; } + if (!$this->data['sort_string']) { $this->data['sort_string'] = $this->data['company']; } + if (!$this->data['timezone']) { $this->data['timezone'] = date("O"); } + if (!$this->revision_date) { $this->revision_date = date('Y-m-d H:i:s'); } + + $this->card = "BEGIN:VCARD\r\n"; + $this->card .= "VERSION:3.0\r\n"; + //$this->card .= "CLASS:".$this->class."\r\n"; + //$this->card .= "PRODID:-//class_vcard from TroyWolf.com//NONSGML Version 1//EN\r\n"; + $this->card .= "REV:".$this->revision_date."\r\n"; + $this->card .= "FN:".$this->data['display_name']."\r\n"; + $this->card .= "N:"; + $this->card .= $this->data['last_name'].";"; + $this->card .= $this->data['first_name'].";"; + if (strlen($this->data['additional_name']) > 0) { + $this->card .= $this->data['additional_name'].";"; + } + if (strlen($this->data['name_prefix']) > 0) { + $this->card .= $this->data['name_prefix'].";"; + } + if (strlen($this->data['name_suffix']) > 0) { + $this->card .= $this->data['name_suffix']."\r\n"; + } + if ($this->data['nickname']) { $this->card .= "NICKNAME:".$this->data['contact_nickname']."\r\n"; } + if ($this->data['title']) { $this->card .= "TITLE:".$this->data['title']."\r\n"; } + if ($this->data['company']) { $this->card .= "ORG:".$this->data['company']; } + if ($this->data['department']) { $this->card .= ";".$this->data['department']; } + $this->card .= "\r\n"; + + if ($this->data['work_po_box'] + || $this->data['work_extended_address'] + || $this->data['work_address'] + || $this->data['work_city'] + || $this->data['work_state'] + || $this->data['work_postal_code'] + || $this->data['work_country']) { + $this->card .= "ADR;TYPE=work:"; + if (strlen($this->data['work_po_box']) > 0) { + $this->card .= $this->data['work_po_box'].";"; + } + if (strlen($this->data['work_extended_address']) > 0) { + $this->card .= $this->data['work_extended_address'].";"; + } + if (strlen($this->data['work_address']) > 0) { + $this->card .= $this->data['work_address'].";"; + } + if (strlen($this->data['work_city']) > 0) { + $this->card .= $this->data['work_city'].";"; + } + if (strlen($this->data['work_state']) > 0) { + $this->card .= $this->data['work_state'].";"; + } + if (strlen($this->data['work_postal_code']) > 0) { + $this->card .= $this->data['work_postal_code'].";"; + } + if (strlen($this->data['work_country']) > 0) { + $this->card .= $this->data['work_country'].""; + } + $this->card .= "\r\n"; + } + if ($this->data['home_po_box'] + || $this->data['home_extended_address'] + || $this->data['home_address'] + || $this->data['home_city'] + || $this->data['home_state'] + || $this->data['home_postal_code'] + || $this->data['home_country']) { + $this->card .= "ADR;TYPE=home:"; + if (strlen($this->data['home_po_box']) > 0) { + $this->card .= $this->data['home_po_box'].";"; + } + if (strlen($this->data['home_extended_address']) > 0) { + $this->card .= $this->data['home_extended_address'].";"; + } + if (strlen($this->data['home_address']) > 0) { + $this->card .= $this->data['home_address'].";"; + } + if (strlen($this->data['home_city']) > 0) { + $this->card .= $this->data['home_city'].";"; + } + if (strlen($this->data['home_state']) > 0) { + $this->card .= $this->data['home_state'].""; + } + if (strlen($this->data['home_postal_code']) > 0) { + $this->card .= $this->data['home_postal_code'].";"; + } + if (strlen($this->data['home_country']) > 0) { + $this->card .= $this->data['home_country']; + } + $this->card .= "\r\n"; + } + if ($this->data['email1']) { $this->card .= "EMAIL;TYPE=internet,pref:".$this->data['email1']."\r\n"; } + if ($this->data['email2']) { $this->card .= "EMAIL;TYPE=internet:".$this->data['email2']."\r\n"; } + if ($this->data['office_tel']) { $this->card .= "TEL;TYPE=work,voice:".$this->data['office_tel']."\r\n"; } + if ($this->data['home_tel']) { $this->card .= "TEL;TYPE=home,voice:".$this->data['home_tel']."\r\n"; } + if ($this->data['cell_tel']) { $this->card .= "TEL;TYPE=cell,voice:".$this->data['cell_tel']."\r\n"; } + if ($this->data['fax_tel']) { $this->card .= "TEL;TYPE=work,fax:".$this->data['fax_tel']."\r\n"; } + if ($this->data['pager_tel']) { $this->card .= "TEL;TYPE=work,pager:".$this->data['pager_tel']."\r\n"; } + if ($this->data['url']) { $this->card .= "URL;TYPE=work:".$this->data['url']."\r\n"; } + if ($this->data['birthday']) { $this->card .= "BDAY:".$this->data['birthday']."\r\n"; } + if ($this->data['role']) { $this->card .= "ROLE:".$this->data['role']."\r\n"; } + if ($this->data['note']) { $this->card .= "NOTE:".$this->data['note']."\r\n"; } + $this->card .= "TZ:".$this->data['timezone']."\r\n"; + $this->card .= "END:VCARD\r\n"; + } + + /* + download() method streams the vcard to the browser client. + */ + function download() { + $this->log .= "vcard download() called
"; + if (!$this->card) { $this->build(); } + if (!$this->filename) { $this->filename = trim($this->data['display_name']); } + $this->filename = str_replace(" ", "_", $this->filename); + header("Content-type: text/directory"); + header("Content-Disposition: attachment; filename=".$this->filename.".vcf"); + header("Pragma: public"); + echo $this->card; + return true; + } +} diff --git a/includes/classes/array_order.php b/includes/classes/array_order.php new file mode 100644 index 0000000000..e4e72c1a80 --- /dev/null +++ b/includes/classes/array_order.php @@ -0,0 +1,45 @@ +sort_fields = array_slice($args, 1); + if (!$this->sort_fields) return $array(); + + if ($this->numeric) { + usort($array, array($this, 'numericCompare')); + } else { + usort($array, array($this, 'stringCompare')); + } + return $array; + } + + function numericCompare($a, $b) { + foreach($this->sort_fields as $sort_field) { + if ($a[$sort_field] == $b[$sort_field]) { + continue; + } + return ($a[$sort_field] < $b[$sort_field]) ? ($this->backwards ? 1 : -1) : ($this->backwards ? -1 : 1); + } + return 0; + } + + function stringCompare($a, $b) { + foreach($this->sort_fields as $sort_field) { + $cmp_result = strcasecmp($a[$sort_field], $b[$sort_field]); + if ($cmp_result == 0) continue; + return ($this->backwards ? -$cmp_result : $cmp_result); + } + return 0; + } +} +//$order = new array_order(); +//$registrations = $order->sort($registrations, 'domain', 'user'); + +?> \ No newline at end of file diff --git a/includes/classes/call_forward.php b/includes/classes/call_forward.php new file mode 100644 index 0000000000..b681c56e9f --- /dev/null +++ b/includes/classes/call_forward.php @@ -0,0 +1,195 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; + +//define the call_forward class + class call_forward { + public $domain_uuid; + public $db_type; + public $call_forward_uuid; + public $extension; + public $call_forward_enabled; + public $call_forward_number; + + public function call_forward_add() { + global $db; + $hunt_group_extension = $this->extension; + $huntgroup_name = 'call_forward_'.$this->extension; + $hunt_group_type = 'call_forward'; + $hunt_group_context = $_SESSION['context']; + $hunt_group_timeout_destination = $this->extension; + $hunt_group_timeout_type = 'voicemail'; + $hunt_group_ring_back = 'us-ring'; + $hunt_group_cid_name_prefix = ''; + $hunt_group_pin = ''; + $huntgroup_caller_announce = 'false'; + $hunt_group_user_list = ''; + $hunt_group_enabled = $this->call_forward_enabled; + $hunt_group_description = 'call forward '.$this->extension; + + $sql = "insert into v_hunt_groups "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "hunt_group_uuid, "; + $sql .= "hunt_group_extension, "; + $sql .= "hunt_group_name, "; + $sql .= "hunt_group_type, "; + $sql .= "hunt_group_context, "; + $sql .= "hunt_group_timeout, "; + $sql .= "hunt_group_timeout_destination, "; + $sql .= "hunt_group_timeout_type, "; + $sql .= "hunt_group_ringback, "; + $sql .= "hunt_group_cid_name_prefix, "; + $sql .= "hunt_group_pin, "; + $sql .= "hunt_group_call_prompt, "; + $sql .= "hunt_group_caller_announce, "; + $sql .= "hunt_group_user_list, "; + $sql .= "hunt_group_enabled, "; + $sql .= "hunt_group_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$this->domain_uuid', "; + $sql .= "'".$this->call_forward_uuid."', "; + $sql .= "'$hunt_group_extension', "; + $sql .= "'$huntgroup_name', "; + $sql .= "'$hunt_group_type', "; + $sql .= "'$hunt_group_context', "; + $sql .= "'$hunt_group_timeout', "; + $sql .= "'$hunt_group_timeout_destination', "; + $sql .= "'$hunt_group_timeout_type', "; + $sql .= "'$hunt_group_ring_back', "; + $sql .= "'$hunt_group_cid_name_prefix', "; + $sql .= "'$hunt_group_pin', "; + $sql .= "'$hunt_group_call_prompt', "; + $sql .= "'$huntgroup_caller_announce', "; + $sql .= "'$hunt_group_user_list', "; + $sql .= "'$hunt_group_enabled', "; + $sql .= "'$hunt_group_description' "; + $sql .= ")"; + if ($v_debug) { + echo "add: ".$sql."
"; + } + $db->exec(check_sql($sql)); + unset($sql); + $this->call_forward_destination(); + } + + public function call_forward_update() { + global $db; + $hunt_group_extension = $this->extension; + $huntgroup_name = 'call_forward_'.$this->extension; + $hunt_group_type = 'call_forward'; + $hunt_group_context = $_SESSION['context']; + $hunt_group_timeout_destination = $this->extension; + $hunt_group_timeout_type = 'voicemail'; + $hunt_group_ring_back = 'us-ring'; + $hunt_group_cid_name_prefix = ''; + $hunt_group_pin = ''; + $huntgroup_caller_announce = 'false'; + $hunt_group_user_list = ''; + $hunt_group_enabled = $this->call_forward_enabled; + $hunt_group_description = 'call forward '.$this->extension; + + $sql = "update v_hunt_groups set "; + $sql .= "hunt_group_extension = '$hunt_group_extension', "; + $sql .= "hunt_group_name = '$huntgroup_name', "; + $sql .= "hunt_group_type = '$hunt_group_type', "; + $sql .= "hunt_group_context = '$hunt_group_context', "; + $sql .= "hunt_group_timeout = '$hunt_group_timeout', "; + $sql .= "hunt_group_timeout_destination = '$hunt_group_timeout_destination', "; + $sql .= "hunt_group_timeout_type = '$hunt_group_timeout_type', "; + $sql .= "hunt_group_ringback = '$hunt_group_ring_back', "; + $sql .= "hunt_group_cid_name_prefix = '$hunt_group_cid_name_prefix', "; + $sql .= "hunt_group_pin = '$hunt_group_pin', "; + $sql .= "hunt_group_call_prompt = '$hunt_group_call_prompt', "; + $sql .= "hunt_group_caller_announce = '$huntgroup_caller_announce', "; + $sql .= "hunt_group_user_list = '$hunt_group_user_list', "; + $sql .= "hunt_group_enabled = '$hunt_group_enabled', "; + $sql .= "hunt_group_description = '$hunt_group_description' "; + $sql .= "where domain_uuid = '$this->domain_uuid' "; + $sql .= "and hunt_group_uuid = '$this->call_forward_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + $this->call_forward_destination(); + } //end function + + public function call_forward_destination() { + global $db; + //delete related v_hunt_group_destinations + $sql = "delete from v_hunt_group_destinations where hunt_group_uuid = '$this->call_forward_uuid' "; + $db->exec(check_sql($sql)); + //check whether the number is an extension or external number + if (strlen($this->call_forward_number) > 7) { + $destination_type = 'sip uri'; + $destination_profile = ''; + } + else { + $destination_type = 'extension'; + $destination_profile = 'internal'; + } + //prepare the variables + $destination_data = $this->call_forward_number; + $destination_timeout = ''; + $destination_order = '1'; + $destination_enabled = 'true'; + $destination_description = 'call forward'; + //add the hunt group destination + if ($this->call_forward_uuid) { + $sql = "insert into v_hunt_group_destinations "; + $sql .= "("; + $sql .= "hunt_group_destination_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "hunt_group_uuid, "; + $sql .= "destination_data, "; + $sql .= "destination_type, "; + $sql .= "destination_profile, "; + $sql .= "destination_timeout, "; + $sql .= "destination_order, "; + $sql .= "destination_enabled, "; + $sql .= "destination_description "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$this->domain_uuid', "; + $sql .= "'$this->call_forward_uuid', "; + $sql .= "'$destination_data', "; + $sql .= "'$destination_type', "; + $sql .= "'$destination_profile', "; + $sql .= "'$destination_timeout', "; + $sql .= "'$destination_order', "; + $sql .= "'$destination_enabled', "; + $sql .= "'$destination_description' "; + $sql .= ")"; + + $db->exec(check_sql($sql)); + unset($sql); + } + } //end function + } + +?> \ No newline at end of file diff --git a/includes/classes/database.php b/includes/classes/database.php new file mode 100644 index 0000000000..078ab4788d --- /dev/null +++ b/includes/classes/database.php @@ -0,0 +1,469 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; + +//define the database class + if (!class_exists('database')) { + class database { + public $db; + public $result; + public $type; + public $table; + public $where; //array + public $order_by; //array + public $order_type; + public $limit; + public $offset; + public $fields; + public $count; + public $sql; + + public function connect() { + //include config.php + include "root.php"; + include "includes/config.php"; + + //set defaults + if (isset($db_type) > 0) { $this->db_type = $db_type; } + if (isset($db_host) > 0) { $this->db_host = $db_host; } + if (isset($db_port) > 0) { $this->db_port = $db_port; } + if (isset($db_name) > 0) { $this->db_name = $db_name; } + if (isset($db_username) > 0) { $this->db_username = $db_username; } + if (isset($db_password) > 0) { $this->db_password = $db_password; } + if (isset($db_path) > 0) { $this->db_path = $db_path; } + if (isset($db_name) > 0) { $this->db_name = $db_name; } + + //backwards compatibility + if (isset($dbtype) > 0) { $db_type = $dbtype; } + if (isset($dbhost) > 0) { $db_host = $dbhost; } + if (isset($dbport) > 0) { $db_port = $dbport; } + if (isset($dbname) > 0) { $db_name = $dbname; } + if (isset($dbusername) > 0) { $db_username = $dbusername; } + if (isset($dbpassword) > 0) { $db_password = $dbpassword; } + if (isset($dbfilepath) > 0) { $db_path = $db_file_path; } + if (isset($dbfilename) > 0) { $db_name = $dbfilename; } + + if ($this->db_type == "sqlite") { + if (strlen($this->db_name) == 0) { + $server_name = $_SERVER["SERVER_NAME"]; + $server_name = str_replace ("www.", "", $server_name); + $db_name_short = $server_name; + $this->db_name = $server_name.'.db'; + } + else { + $db_name_short = $this->db_name; + } + $this->db_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure'; + $this->db_path = realpath($this->db_path); + if (file_exists($this->db_path.'/'.$this->db_name)) { + //echo "main file exists
"; + } + else { + $file_name = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/sql/sqlite.sql'; + $file_contents = file_get_contents($file_name); + try { + //$db = new PDO('sqlite2:example.db'); //sqlite 2 + //$db = new PDO('sqlite::memory:'); //sqlite 3 + $db = new PDO('sqlite:'.$this->db_path.'/'.$this->db_name); //sqlite 3 + $db->beginTransaction(); + } + catch (PDOException $error) { + print "error: " . $error->getMessage() . "
"; + die(); + } + + //replace \r\n with \n then explode on \n + $file_contents = str_replace("\r\n", "\n", $file_contents); + + //loop line by line through all the lines of sql code + $stringarray = explode("\n", $file_contents); + $x = 0; + foreach($stringarray as $sql) { + try { + $db->query($sql); + } + catch (PDOException $error) { + echo "error: " . $error->getMessage() . " sql: $sql
"; + } + $x++; + } + unset ($file_contents, $sql); + $db->commit(); + + if (is_writable($this->db_path.'/'.$this->db_name)) { + //is writable - use database in current location + } + else { + //not writable + echo "The database ".$this->db_path."/".$this->db_name." is not writeable."; + exit; + } + } + try { + //$db = new PDO('sqlite2:example.db'); //sqlite 2 + //$db = new PDO('sqlite::memory:'); //sqlite 3 + $this->db = new PDO('sqlite:'.$this->db_path.'/'.$this->db_name); //sqlite 3 + + //add additional functions to SQLite so that they are accessible inside SQL + //bool PDO::sqliteCreateFunction ( string function_name, callback callback [, int num_args] ) + $this->db->sqliteCreateFunction('md5', 'php_md5', 1); + $this->db->sqliteCreateFunction('unix_timestamp', 'php_unix_time_stamp', 1); + $this->db->sqliteCreateFunction('now', 'php_now', 0); + $this->db->sqliteCreateFunction('str_left', 'php_left', 2); + $this->db->sqliteCreateFunction('str_right', 'php_right', 2); + } + catch (PDOException $error) { + print "error: " . $error->getMessage() . "
"; + die(); + } + } + + if ($this->db_type == "mysql") { + try { + //required for mysql_real_escape_string + if (function_exists(mysql_connect)) { + $mysql_connection = mysql_connect($this->db_host, $this->db_username, $this->db_password); + } + //mysql pdo connection + if (strlen($this->db_host) == 0 && strlen($this->db_port) == 0) { + //if both host and port are empty use the unix socket + $this->db = new PDO("mysql:host=$this->db_host;unix_socket=/var/run/mysqld/mysqld.sock;dbname=$this->db_name", $this->db_username, $this->db_password); + } + else { + if (strlen($this->db_port) == 0) { + //leave out port if it is empty + $this->db = new PDO("mysql:host=$this->db_host;dbname=$this->db_name;", $this->db_username, $this->db_password, array( + PDO::ATTR_ERRMODE, + PDO::ERRMODE_EXCEPTION + )); + } + else { + $this->db = new PDO("mysql:host=$this->db_host;port=$this->db_port;dbname=$this->db_name;", $this->db_username, $this->db_password, array( + PDO::ATTR_ERRMODE, + PDO::ERRMODE_EXCEPTION + )); + } + } + } + catch (PDOException $error) { + print "error: " . $error->getMessage() . "
"; + die(); + } + } + + if ($this->db_type == "pgsql") { + //database connection + try { + if (strlen($this->db_host) > 0) { + if (strlen($this->db_port) == 0) { $this->db_port = "5432"; } + $this->db = new PDO("pgsql:host=$this->db_host port=$this->db_port dbname=$this->db_name user=$this->db_username password=$this->db_password"); + } + else { + $this->db = new PDO("pgsql:dbname=$this->db_name user=$this->db_username password=$this->db_password"); + } + } + catch (PDOException $error) { + print "error: " . $error->getMessage() . "
"; + die(); + } + } + } + + //public function disconnect() { + // return null; + //} + + public function find() { + //connect; + //table; + //where; + //order_by; + //limit; + //offset; + + //connect to the database if needed + if (!$this->db) { + $this->connect(); + } + //get data from the database + $sql = ""; + $sql .= " select * from ".$this->table." "; + if ($this->where) { + $i = 0; + foreach($this->where as $row) { + if ($i == 0) { + $sql .= 'where '.$row['name']." ".$row['operator']." '".$row['value']."' "; + } + else { + $sql .= "and ".$row['name']." ".$row['operator']." '".$row['value']."' "; + } + $i++; + } + } + if ($this->order_by) { + $sql .= "order by "; + $i = 1; + foreach($this->order_by as $row) { + if (count($this->order_by) == $i) { + $sql .= $row['name']." "; + } + else { + $sql .= $row['name'].", "; + } + $i++; + } + if ($this->order_type) { + $sql .= $this->order_type." "; + } + } + if ($this->limit) { + $sql .= " limit ".$this->limit." offset ".$this->offset." "; + } + //echo $sql; + $prep_statement = $this->db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + return $prep_statement->fetchAll(PDO::FETCH_ASSOC); + } + else { + return false; + } + } + + public function add(){ + //connect to the database if needed + if (!$this->db) { + $this->connect(); + } + //add data to the database + $sql = "insert into ".$this->table; + $sql .= "("; + $i = 1; + foreach($this->fields as $name => $value) { + if (count($this->fields) == $i) { + $sql .= $name." "; + } + else { + $sql .= $name.", "; + } + $i++; + } + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $i = 1; + foreach($this->fields as $name => $value) { + if (count($this->fields) == $i) { + if (strlen($value) > 0) { + $sql .= "'".$value."' "; + } + else { + $sql .= "'".$value."' "; + } + } + else { + if (strlen($value) > 0) { + $sql .= "'".$value."', "; + } + else { + $sql .= "null, "; + } + } + $i++; + } + $sql .= ")"; + $this->sql = $sql; + $this->db->exec($sql); + unset($this->fields); + unset($sql); + } + + public function update() { + //connect to the database if needed + if (!$this->db) { + $this->connect(); + } + //udate the database + $sql = "update ".$this->table." set "; + $i = 1; + foreach($this->fields as $name => $value) { + if (count($this->fields) == $i) { + if (strlen($name) > 0 && $value == null) { + $sql .= $name." = null "; + } + else { + $sql .= $name." = '".$value."' "; + } + } + else { + if (strlen($name) > 0 && $value == null) { + $sql .= $name." = null, "; + } + else { + $sql .= $name." = '".$value."', "; + } + } + $i++; + } + $i = 0; + foreach($this->where as $row) { + if ($i == 0) { + $sql .= 'where '.$row['name']." ".$row['operator']." '".$row['value']."' "; + } + else { + $sql .= "and ".$row['name']." ".$row['operator']." '".$row['value']."' "; + } + $i++; + } + $this->db->exec(check_sql($sql)); + unset($this->fields); + unset($this->where); + unset($sql); + } + + public function delete(){ + //connect to the database if needed + if (!$this->db) { + $this->connect(); + } + //delete from the database + $sql = "delete from ".$this->table." "; + if ($this->where) { + $i = 0; + foreach($this->where as $row) { + if ($i == 0) { + $sql .= "where ".$row['name']." ".$row['operator']." '".$row['value']."' "; + } + else { + $sql .= "and ".$row['name']." ".$row['operator']." '".$row['value']."' "; + } + $i++; + } + } + //echo $sql."
\n"; + $prep_statement = $this->db->prepare($sql); + $prep_statement->execute(); + unset($sql); + unset($this->where); + } + + public function count() { + //connect to the database if needed + if (!$this->db) { + $this->connect(); + } + //get the number of rows + $sql = " select count(*) as num_rows from ".$this->table; + if ($this->where) { + $i = 0; + foreach($this->where as $row) { + if ($i == 0) { + $sql .= "where ".$row['name']." ".$row['operator']." '".$row['value']."' "; + } + else { + $sql .= "and ".$row['name']." ".$row['operator']." '".$row['value']."' "; + } + $i++; + } + } + unset($this->where); + $prep_statement = $this->db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $this->result = $row['num_rows']; + } + else { + $this->result = 0; + } + } + unset($prep_statement); + } + } + } + +if (!function_exists('php_md5')) { + function php_md5($string) { + return md5($string); + } +} + +if (!function_exists('php_unix_time_stamp')) { + function php_unix_time_stamp($string) { + return strtotime($string); + } +} + +if (!function_exists('php_now')) { + function php_now() { + return date("Y-m-d H:i:s"); + } +} + +if (!function_exists('php_left')) { + function php_left($string, $num) { + return substr($string, 0, $num); + } +} + +if (!function_exists('php_right')) { + function php_right($string, $num) { + return substr($string, (strlen($string)-$num), strlen($string)); + } +} + +//example usage +/* +//find + require_once "includes/classes/database.php"; + $database = new database; + $database->domain_uuid = $_SESSION["domain_uuid"]; + $database->type = $db_type; + $database->table = "v_extensions"; + $where[0]['name'] = 'domain_uuid'; + $where[0]['value'] = $_SESSION["domain_uuid"]; + $where[0]['operator'] = '='; + $database->where = $where; + $order_by[0]['name'] = 'extension'; + $database->order_by = $order_by; + $database->order_type = 'desc'; + $database->limit = '2'; + $database->offset = '0'; + $database->find(); + print_r($database->result); +//insert + require_once "includes/classes/database.php"; + $database = new database; + $database->domain_uuid = $_SESSION["domain_uuid"]; + $database->type = $db_type; + $database->table = "v_ivr_menus"; + $fields[0]['name'] = 'domain_uuid'; + $fields[0]['value'] = $_SESSION["domain_uuid"]; + $database->add(); + print_r($database->result); +*/ +?> \ No newline at end of file diff --git a/includes/classes/dialplan.php b/includes/classes/dialplan.php new file mode 100644 index 0000000000..f59ef5bca9 --- /dev/null +++ b/includes/classes/dialplan.php @@ -0,0 +1,343 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; + +//define the dialplan class + if (!class_exists('dialplan')) { + class dialplan { + //variables + public $result; + public $domain_uuid; + public $dialplan_uuid; + public $xml; + public $json; + public $display_type; + + //dialplans + public $dialplan_name; + public $dialplan_continue; + public $dialplan_order; + public $dialplan_context; + public $dialplan_enabled; + public $dialplan_description; + + //dialplan_details + public $dialplan_detail_tag; + public $dialplan_detail_order; + public $dialplan_detail_type; + public $dialplan_detail_data; + public $dialplan_detail_break; + public $dialplan_detail_inline; + public $dialplan_detail_group; + + public function dialplan_add() { + global $db; + $sql = "insert into v_dialplans "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "app_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_name, "; + $sql .= "dialplan_continue, "; + $sql .= "dialplan_order, "; + $sql .= "dialplan_context, "; + $sql .= "dialplan_enabled, "; + $sql .= "dialplan_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".check_str($this->domain_uuid)."', "; + $sql .= "'".check_str($this->app_uuid)."', "; + $sql .= "'".check_str($this->dialplan_uuid)."', "; + $sql .= "'".check_str($this->dialplan_name)."', "; + $sql .= "'".check_str($this->dialplan_continue)."', "; + $sql .= "'".check_str($this->dialplan_order)."', "; + $sql .= "'".check_str($this->dialplan_context)."', "; + $sql .= "'".check_str($this->dialplan_enabled)."', "; + $sql .= "'".check_str($this->dialplan_description)."' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } //end function + + public function dialplan_update() { + global $db; + $sql = "update v_dialplans set "; + $sql .= "dialplan_name = '".check_str($this->dialplan_name)."', "; + if (strlen($this->dialplan_continue) > 0) { + $sql .= "dialplan_continue = '".check_str($this->dialplan_continue)."', "; + } + $sql .= "dialplan_order = '".check_str($this->dialplan_order)."', "; + $sql .= "dialplan_context = '".check_str($this->dialplan_context)."', "; + $sql .= "dialplan_enabled = '".check_str($this->dialplan_enabled)."', "; + $sql .= "dialplan_description = '".check_str($this->dialplan_description)."' "; + $sql .= "where domain_uuid = '".check_str($this->domain_uuid)."' "; + $sql .= "and dialplan_uuid = '".check_str($this->dialplan_uuid)."' "; + //echo "sql: ".$sql."
"; + $db->query($sql); + unset($sql); + } + + public function dialplan_detail_add() { + global $db; + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "dialplan_detail_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_order, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data, "; + $sql .= "dialplan_detail_break, "; + $sql .= "dialplan_detail_inline, "; + $sql .= "dialplan_detail_group "; + $sql .= ") "; + $sql .= "values "; + $sql .= "( "; + $sql .= "'".$dialplan_detail_uuid."', "; + $sql .= "'".check_str($this->domain_uuid)."', "; + $sql .= "'".check_str($this->dialplan_uuid)."', "; + $sql .= "'".check_str($this->dialplan_detail_tag)."', "; + $sql .= "'".check_str($this->dialplan_detail_order)."', "; + $sql .= "'".check_str($this->dialplan_detail_type)."', "; + $sql .= "'".check_str($this->dialplan_detail_data)."', "; + if (strlen($this->dialplan_detail_break) == 0) { + $sql .= "null, "; + } + else { + $sql .= "'".check_str($this->dialplan_detail_break)."', "; + } + if (strlen($this->dialplan_detail_inline) == 0) { + $sql .= "null, "; + } + else { + $sql .= "'".check_str($this->dialplan_detail_inline)."', "; + } + if (strlen($this->dialplan_detail_group) == 0) { + $sql .= "null "; + } + else { + $sql .= "'".check_str($this->dialplan_detail_group)."' "; + } + $sql .= ")"; + //echo $sql."\n\n"; + $db->exec(check_sql($sql)); + unset($sql); + } //end function + + public function dialplan_detail_update() { + global $db; + $sql = "update v_dialplans set "; + $sql .= "dialplan_detail_order = '".check_str($this->dialplan_detail_order)."', "; + $sql .= "dialplan_detail_type = '".check_str($this->dialplan_detail_type)."', "; + $sql .= "dialplan_detail_data = '".check_str($this->dialplan_detail_data)."', "; + if (strlen($this->dialplan_detail_break) > 0) { + $sql .= "dialplan_detail_break = '".check_str($this->dialplan_detail_break)."', "; + } + if (strlen($this->dialplan_detail_inline) > 0) { + $sql .= "dialplan_detail_inline = '".check_str($this->dialplan_detail_inline)."', "; + } + if (strlen($this->dialplan_detail_group) > 0) { + $sql .= "dialplan_detail_group = '".check_str($this->dialplan_detail_group)."', "; + } + $sql .= "dialplan_detail_tag = '".check_str($this->dialplan_detail_tag)."' "; + $sql .= "where domain_uuid = '".check_str($this->domain_uuid)."' "; + $sql .= "and dialplan_uuid = '".check_str($this->dialplan_uuid)."' "; + //echo "sql: ".$sql."
"; + $db->query($sql); + unset($sql); + } //end function + + public function restore_advanced_xml() { + $switch_dialplan_dir = $this->switch_dialplan_dir; + if (is_dir($switch_dialplan_dir)) { + //get the contents of the dialplan/default.xml + $file_default_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/templates/conf/dialplan/default.xml'; + $file_default_contents = file_get_contents($file_default_path); + //prepare the file contents and the path + if (count($_SESSION['domains']) < 2) { + //replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number + $file_default_contents = str_replace("{v_domain}", 'default', $file_default_contents); + //set the file path + $file_path = $switch_dialplan_dir.'/default.xml'; + } + else { + //replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number + $file_default_contents = str_replace("{v_domain}", $_SESSION['domain_name'], $file_default_contents); + //set the file path + $file_path = $switch_dialplan_dir.'/'.$_SESSION['domain_name'].'.xml'; + } + //write the default dialplan + $fh = fopen($file_path,'w') or die('Unable to write to '.$file_path.'. Make sure the path exists and permissons are set correctly.'); + fwrite($fh, $file_default_contents); + fclose($fh); + //set the message + $this->result['dialplan']['restore']['msg'] = "Default Restored"; + } + } + + private function app_uuid_exists() { + global $db; + $sql = "select count(*) as num_rows from v_dialplans "; + $sql .= "where domain_uuid = '".$this->domain_uuid."' "; + $sql .= "and app_uuid = '".$this->app_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + return true; + } + else { + return false; + } + } + unset($prep_statement, $result); + } + + public function import() { + if (strlen($this->xml) > 0) { + //convert the xml string to an xml object + $xml = simplexml_load_string($this->xml); + //convert to json + $json = json_encode($xml); + //convert to an array + $dialplan = json_decode($json, true); + } + if (strlen($this->json) > 0) { + //convert to an array + $dialplan = json_decode($json, true); + } + //ensure the condition array uniform + if (!is_array($dialplan['condition'][0])) { + $tmp = $dialplan['condition']; + unset($dialplan['condition']); + $dialplan['condition'][0] = $tmp; + } + //check if the dialplan app uuid exists + $this->app_uuid = $dialplan['@attributes']['app_uuid']; + if ($this->app_uuid_exists()) { + //dialplan entry already exists do nothing + } + else { + //get the attributes + $this->dialplan_uuid = uuid(); + $this->dialplan_name = $dialplan['@attributes']['name']; + if ($this->display_type == "text") { + echo " ".$this->dialplan_name.": added\n"; + } + if (strlen($dialplan['@attributes']['continue']) > 0) { + $this->dialplan_continue = $dialplan['@attributes']['continue']; + } + if (strlen($dialplan['@attributes']['enabled']) > 0) { + $this->dialplan_enabled = $dialplan['@attributes']['enabled']; + } + else { + $this->dialplan_enabled = "true"; + } + $this->dialplan_description = ''; + $this->dialplan_add(); + //loop through the condition array + $x = 0; + $group = 0; + $order = 5; + foreach ($dialplan['condition'] as &$row) { + unset($this->dialplan_detail_break); + unset($this->dialplan_detail_inline); + $this->dialplan_detail_tag = 'condition'; + $this->dialplan_detail_type = $row['@attributes']['field']; + $this->dialplan_detail_data = $row['@attributes']['expression']; + $this->dialplan_detail_group = $group; + $this->dialplan_detail_order = $order; + if (strlen($row['@attributes']['break']) > 0) { + $this->dialplan_detail_break = $row['@attributes']['break']; + } + $this->dialplan_detail_add(); + if (is_array($row['action']) || is_array($row['anti-action'])) { + $condition_self_closing_tag = false; + if (!is_array($row['action'][0])) { + if ($row['action']['@attributes']['application']) { + $tmp = $row['action']; + unset($row['action']); + $row['action'][0] = $tmp; + } + } + if (!is_array($row['anti-action'][0])) { + if ($row['anti-action']['@attributes']['application']) { + $tmp = $row['anti-action']; + unset($row['anti-action']); + $row['anti-action'][0] = $tmp; + } + } + $order = $order + 5; + unset($this->dialplan_detail_break); + unset($this->dialplan_detail_inline); + foreach ($row['action'] as &$row2) { + $this->dialplan_detail_tag = 'action'; + $this->dialplan_detail_type = $row2['@attributes']['application']; + $this->dialplan_detail_data = $row2['@attributes']['data']; + $this->dialplan_detail_data = str_replace("{v_pin_number}", generate_password(8, 1), $this->dialplan_detail_data); + $this->dialplan_detail_data = str_replace("{v_context}", $this->dialplan_context, $this->dialplan_detail_data); + $this->dialplan_detail_data = str_replace("{v_switch_recordings_dir}", $_SESSION['switch']['recordings']['dir'], $this->dialplan_detail_data); + if (strlen($row2['@attributes']['inline']) > 0) { + $this->dialplan_detail_inline = $row2['@attributes']['inline']; + } + $this->dialplan_detail_group = $group; + $this->dialplan_detail_order = $order; + $this->dialplan_detail_add(); + $order = $order + 5; + } + foreach ($row['anti-action'] as &$row2) { + $this->dialplan_detail_tag = 'anti-action'; + $this->dialplan_detail_type = $row2['@attributes']['application']; + $this->dialplan_detail_data = $row2['@attributes']['data']; + $this->dialplan_detail_data = str_replace("{v_pin_number}", generate_password(8, 1), $this->dialplan_detail_data); + $this->dialplan_detail_data = str_replace("{v_context}", $this->dialplan_context, $this->dialplan_detail_data); + $this->dialplan_detail_data = str_replace("{v_switch_recordings_dir}", $_SESSION['switch']['recordings']['dir'], $this->dialplan_detail_data); + $this->dialplan_detail_group = $group; + $this->dialplan_detail_order = $order; + $this->dialplan_detail_add(); + $order = $order + 5; + } + } + else { + $condition_self_closing_tag = true; + } + //if not a self closing tag then increment the group + if (!$condition_self_closing_tag) { + $group++; + } + $row['group'] = $group; + $order = $order + 5; + $x++; + } + } + } + } + } +?> \ No newline at end of file diff --git a/includes/classes/do_not_disturb.php b/includes/classes/do_not_disturb.php new file mode 100644 index 0000000000..f046cd09ee --- /dev/null +++ b/includes/classes/do_not_disturb.php @@ -0,0 +1,169 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; + +//define the dnd class + class do_not_disturb { + public $domain_uuid; + public $dnd_uuid; + public $domain_name; + public $extension; + public $dnd_enabled; + + //update the user_status + public function dnd_status() { + global $db; + if ($this->dnd_enabled == "true") { + //update the call center status + $user_status = "Logged Out"; + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + if ($fp) { + $switch_cmd .= "callcenter_config agent set status ".$_SESSION['username']."@".$domain_name." '".$user_status."'"; + $switch_result = event_socket_request($fp, 'api '.$switch_cmd); + } + + //update the database user_status + $user_status = "Do Not Disturb"; + $sql = "update v_users set "; + $sql .= "user_status = '$user_status' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and username = '".$_SESSION['username']."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + } + } //function + + public function dnd_add() { + global $db; + $hunt_group_extension = $this->extension; + $huntgroup_name = 'dnd_'.$this->extension; + $hunt_group_type = 'dnd'; + $hunt_group_context = $_SESSION['context']; + $hunt_group_timeout = '1'; + $hunt_group_timeout_destination = $this->extension; + $hunt_group_timeout_type = 'voicemail'; + $hunt_group_ring_back = 'us-ring'; + //$hunt_group_cid_name_prefix = ''; + //$hunt_group_pin = ''; + //$hunt_group_call_prompt = 'false'; + $huntgroup_caller_announce = 'false'; + //$hunt_group_user_list = ''; + $hunt_group_enabled = $this->dnd_enabled; + $hunt_group_description = 'dnd '.$this->extension; + + $sql = "insert into v_hunt_groups "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "hunt_group_uuid, "; + $sql .= "hunt_group_extension, "; + $sql .= "hunt_group_name, "; + $sql .= "hunt_group_type, "; + $sql .= "hunt_group_context, "; + $sql .= "hunt_group_timeout, "; + $sql .= "hunt_group_timeout_destination, "; + $sql .= "hunt_group_timeout_type, "; + $sql .= "hunt_group_ringback, "; + //$sql .= "hunt_group_cid_name_prefix, "; + //$sql .= "hunt_group_pin, "; + $sql .= "hunt_group_call_prompt, "; + $sql .= "hunt_group_caller_announce, "; + //$sql .= "hunt_group_user_list, "; + $sql .= "hunt_group_enabled, "; + $sql .= "hunt_group_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$this->domain_uuid', "; + $sql .= "'$this->dnd_uuid', "; + $sql .= "'$hunt_group_extension', "; + $sql .= "'$huntgroup_name', "; + $sql .= "'$hunt_group_type', "; + $sql .= "'$hunt_group_context', "; + $sql .= "'$hunt_group_timeout', "; + $sql .= "'$hunt_group_timeout_destination', "; + $sql .= "'$hunt_group_timeout_type', "; + $sql .= "'$hunt_group_ring_back', "; + //$sql .= "'$hunt_group_cid_name_prefix', "; + //$sql .= "'$hunt_group_pin', "; + $sql .= "'$hunt_group_call_prompt', "; + $sql .= "'$huntgroup_caller_announce', "; + //$sql .= "'$hunt_group_user_list', "; + $sql .= "'$hunt_group_enabled', "; + $sql .= "'$hunt_group_description' "; + $sql .= ")"; + if ($this->debug) { + echo $sql."
"; + } + $db->exec(check_sql($sql)); + unset($sql); + } //function + + public function dnd_update() { + global $db; + + $hunt_group_extension = $this->extension; + $huntgroup_name = 'dnd_'.$this->extension; + $hunt_group_type = 'dnd'; + $hunt_group_context = $_SESSION['context']; + $hunt_group_timeout = '1'; + $hunt_group_timeout_destination = $this->extension; + $hunt_group_timeout_type = 'voicemail'; + $hunt_group_ring_back = 'us-ring'; + //$hunt_group_cid_name_prefix = ''; + //$hunt_group_pin = ''; + //$hunt_group_call_prompt = 'false'; + $huntgroup_caller_announce = 'false'; + //$hunt_group_user_list = ''; + $hunt_group_enabled = $this->dnd_enabled; + $hunt_group_description = 'dnd '.$this->extension; + + $sql = "update v_hunt_groups set "; + $sql .= "hunt_group_extension = '$hunt_group_extension', "; + $sql .= "hunt_group_name = '$huntgroup_name', "; + $sql .= "hunt_group_type = '$hunt_group_type', "; + $sql .= "hunt_group_context = '$hunt_group_context', "; + $sql .= "hunt_group_timeout = '$hunt_group_timeout', "; + $sql .= "hunt_group_timeout_destination = '$hunt_group_timeout_destination', "; + $sql .= "hunt_group_timeout_type = '$hunt_group_timeout_type', "; + $sql .= "hunt_group_ringback = '$hunt_group_ring_back', "; + //$sql .= "hunt_group_cid_name_prefix = '$hunt_group_cid_name_prefix', "; + //$sql .= "hunt_group_pin = '$hunt_group_pin', "; + $sql .= "hunt_group_call_prompt = '$hunt_group_call_prompt', "; + $sql .= "hunt_group_caller_announce = 'false', "; + //$sql .= "hunt_group_user_list = '$hunt_group_user_list', "; + $sql .= "hunt_group_enabled = '$hunt_group_enabled', "; + $sql .= "hunt_group_description = '$hunt_group_description' "; + $sql .= "where domain_uuid = '$this->domain_uuid' "; + $sql .= "and hunt_group_uuid = '$this->dnd_uuid' "; + if ($this->debug) { + echo $sql."
"; + } + $db->exec(check_sql($sql)); + unset($sql); + } //function + } //class + +?> \ No newline at end of file diff --git a/includes/classes/follow_me.php b/includes/classes/follow_me.php new file mode 100644 index 0000000000..bc4a0b924b --- /dev/null +++ b/includes/classes/follow_me.php @@ -0,0 +1,338 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; + +//define the follow me class + class follow_me { + public $domain_uuid; + public $db_type; + public $follow_me_uuid; + public $extension; + public $follow_me_enabled; + public $follow_me_type; + public $hunt_group_call_prompt; + public $hunt_group_timeout; + + public $destination_data_1; + public $destination_type_1; + public $destination_timeout_1; + + public $destination_data_2; + public $destination_type_2; + public $destination_timeout_2; + + public $destination_data_3; + public $destination_type_3; + public $destination_timeout_3; + + public $destination_data_4; + public $destination_type_4; + public $destination_timeout_4; + + public $destination_data_5; + public $destination_type_5; + public $destination_timeout_5; + + public $destination_profile = 'internal'; + public $destination_timeout = ''; + public $destination_order = 1; + public $destination_enabled = 'true'; + public $destination_description = 'follow me'; + + public function follow_me_add() { + global $db; + + $hunt_group_extension = $this->extension; + $hunt_group_name = 'follow_me_'.$this->extension; + $hunt_group_type = $this->follow_me_type; + $hunt_group_context = $_SESSION['context']; + $hunt_group_timeout = $this->hunt_group_timeout; + $hunt_group_timeout_destination = $this->extension; + $hunt_group_timeout_type = 'voicemail'; + $hunt_group_ring_back = 'us-ring'; + //$hunt_group_cid_name_prefix = ''; + //$hunt_group_pin = ''; + $huntgroup_caller_announce = 'false'; + //$hunt_group_user_list = ''; + $hunt_group_enabled = $this->follow_me_enabled; + $hunt_group_description = 'follow me '.$this->extension; + + $sql = "insert into v_hunt_groups "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "hunt_group_uuid, "; + $sql .= "hunt_group_extension, "; + $sql .= "hunt_group_name, "; + $sql .= "hunt_group_type, "; + $sql .= "hunt_group_context, "; + $sql .= "hunt_group_timeout, "; + $sql .= "hunt_group_timeout_destination, "; + $sql .= "hunt_group_timeout_type, "; + $sql .= "hunt_group_ringback, "; + $sql .= "hunt_group_cid_name_prefix, "; + $sql .= "hunt_group_pin, "; + $sql .= "hunt_group_call_prompt, "; + $sql .= "hunt_group_caller_announce, "; + $sql .= "hunt_group_user_list, "; + $sql .= "hunt_group_enabled, "; + $sql .= "hunt_group_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$this->domain_uuid', "; + $sql .= "'$this->follow_me_uuid', "; + $sql .= "'$hunt_group_extension', "; + $sql .= "'$hunt_group_name', "; + $sql .= "'$hunt_group_type', "; + $sql .= "'$hunt_group_context', "; + $sql .= "'$hunt_group_timeout', "; + $sql .= "'$hunt_group_timeout_destination', "; + $sql .= "'$hunt_group_timeout_type', "; + $sql .= "'$hunt_group_ring_back', "; + $sql .= "'$hunt_group_cid_name_prefix', "; + $sql .= "'$hunt_group_pin', "; + $sql .= "'$hunt_group_call_prompt', "; + $sql .= "'$huntgroup_caller_announce', "; + $sql .= "'$hunt_group_user_list', "; + $sql .= "'$hunt_group_enabled', "; + $sql .= "'$hunt_group_description' "; + $sql .= ")"; + if ($v_debug) { + echo $sql."
"; + } + $db->exec(check_sql($sql)); + unset($sql); + $this->follow_me_destinations(); + } //end function + + public function follow_me_update() { + global $db; + + $hunt_group_extension = $this->extension; + $hunt_group_name = 'follow_me_'.$this->extension; + $hunt_group_type = $this->follow_me_type; + $hunt_group_context = $_SESSION['context']; + $hunt_group_timeout = $this->hunt_group_timeout; + $hunt_group_timeout_destination = $this->extension; + $hunt_group_timeout_type = 'voicemail'; + $hunt_group_ring_back = 'us-ring'; + //$hunt_group_cid_name_prefix = ''; + //$hunt_group_pin = ''; + $huntgroup_caller_announce = 'false'; + //$hunt_group_user_list = ''; + $hunt_group_enabled = $this->follow_me_enabled; + $hunt_group_description = 'follow me '.$this->extension; + + $sql = "update v_hunt_groups set "; + $sql .= "hunt_group_extension = '$hunt_group_extension', "; + $sql .= "hunt_group_name = '$hunt_group_name', "; + $sql .= "hunt_group_type = '$hunt_group_type', "; + $sql .= "hunt_group_context = '$hunt_group_context', "; + $sql .= "hunt_group_timeout = '$hunt_group_timeout', "; + $sql .= "hunt_group_timeout_destination = '$hunt_group_timeout_destination', "; + $sql .= "hunt_group_timeout_type = '$hunt_group_timeout_type', "; + $sql .= "hunt_group_ringback = '$hunt_group_ring_back', "; + $sql .= "hunt_group_cid_name_prefix = '$hunt_group_cid_name_prefix', "; + $sql .= "hunt_group_pin = '$hunt_group_pin', "; + $sql .= "hunt_group_call_prompt = '$this->hunt_group_call_prompt', "; + $sql .= "hunt_group_caller_announce = '$huntgroup_caller_announce', "; + $sql .= "hunt_group_user_list = '$hunt_group_user_list', "; + $sql .= "hunt_group_enabled = '$hunt_group_enabled', "; + $sql .= "hunt_group_description = '$hunt_group_description' "; + $sql .= "where domain_uuid = '$this->domain_uuid' "; + $sql .= "and hunt_group_uuid = '$this->follow_me_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + $this->follow_me_destinations(); + } //end function + + public function follow_me_destinations() { + global $db; + + //delete related v_hunt_group_destinations + $sql = "delete from v_hunt_group_destinations where hunt_group_uuid = '$this->follow_me_uuid' "; + $db->exec(check_sql($sql)); + + //insert the v_hunt_group_destinations set destination_data_1 + if (strlen($this->destination_data_1) > 0) { + $sql = "insert into v_hunt_group_destinations "; + $sql .= "("; + $sql .= "hunt_group_destination_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "hunt_group_uuid, "; + $sql .= "destination_data, "; + $sql .= "destination_type, "; + $sql .= "destination_profile, "; + $sql .= "destination_timeout, "; + $sql .= "destination_order, "; + $sql .= "destination_enabled, "; + $sql .= "destination_description "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$this->domain_uuid', "; + $sql .= "'$this->follow_me_uuid', "; + $sql .= "'$this->destination_data_1', "; + $sql .= "'$this->destination_type_1', "; + $sql .= "'$this->destination_profile', "; + $sql .= "'$this->destination_timeout_1', "; + $sql .= "'$this->destination_order', "; + $sql .= "'$this->destination_enabled', "; + $sql .= "'$this->destination_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + $this->destination_order++; + unset($sql); + } + if (strlen($this->destination_data_2) > 0) { + $sql = "insert into v_hunt_group_destinations "; + $sql .= "("; + $sql .= "hunt_group_destination_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "hunt_group_uuid, "; + $sql .= "destination_data, "; + $sql .= "destination_type, "; + $sql .= "destination_profile, "; + $sql .= "destination_timeout, "; + $sql .= "destination_order, "; + $sql .= "destination_enabled, "; + $sql .= "destination_description "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$this->domain_uuid', "; + $sql .= "'$this->follow_me_uuid', "; + $sql .= "'$this->destination_data_2', "; + $sql .= "'$this->destination_type_2', "; + $sql .= "'$this->destination_profile', "; + $sql .= "'$this->destination_timeout_2', "; + $sql .= "'$this->destination_order', "; + $sql .= "'$this->destination_enabled', "; + $sql .= "'$this->destination_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + $this->destination_order++; + unset($sql); + } + if (strlen($this->destination_data_3) > 0) { + $sql = "insert into v_hunt_group_destinations "; + $sql .= "("; + $sql .= "hunt_group_destination_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "hunt_group_uuid, "; + $sql .= "destination_data, "; + $sql .= "destination_type, "; + $sql .= "destination_profile, "; + $sql .= "destination_timeout, "; + $sql .= "destination_order, "; + $sql .= "destination_enabled, "; + $sql .= "destination_description "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$this->domain_uuid', "; + $sql .= "'$this->follow_me_uuid', "; + $sql .= "'$this->destination_data_3', "; + $sql .= "'$this->destination_type_3', "; + $sql .= "'$this->destination_profile', "; + $sql .= "'$this->destination_timeout_3', "; + $sql .= "'$this->destination_order', "; + $sql .= "'$this->destination_enabled', "; + $sql .= "'$this->destination_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + $this->destination_order++; + unset($sql); + } + if (strlen($this->destination_data_4) > 0) { + $sql = "insert into v_hunt_group_destinations "; + $sql .= "("; + $sql .= "hunt_group_destination_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "hunt_group_uuid, "; + $sql .= "destination_data, "; + $sql .= "destination_type, "; + $sql .= "destination_profile, "; + $sql .= "destination_timeout, "; + $sql .= "destination_order, "; + $sql .= "destination_enabled, "; + $sql .= "destination_description "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$this->domain_uuid', "; + $sql .= "'$this->follow_me_uuid', "; + $sql .= "'$this->destination_data_4', "; + $sql .= "'$this->destination_type_4', "; + $sql .= "'$this->destination_profile', "; + $sql .= "'$this->destination_timeout_4', "; + $sql .= "'$this->destination_order', "; + $sql .= "'$this->destination_enabled', "; + $sql .= "'$this->destination_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + $this->destination_order++; + unset($sql); + } + if (strlen($this->destination_data_5) > 0) { + $sql = "insert into v_hunt_group_destinations "; + $sql .= "("; + $sql .= "hunt_group_destination_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "hunt_group_uuid, "; + $sql .= "destination_data, "; + $sql .= "destination_type, "; + $sql .= "destination_profile, "; + $sql .= "destination_timeout, "; + $sql .= "destination_order, "; + $sql .= "destination_enabled, "; + $sql .= "destination_description "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$this->domain_uuid', "; + $sql .= "'$this->follow_me_uuid', "; + $sql .= "'$this->destination_data_5', "; + $sql .= "'$this->destination_type_5', "; + $sql .= "'$this->destination_profile', "; + $sql .= "'$this->destination_timeout_5', "; + $sql .= "'$this->destination_order', "; + $sql .= "'$this->destination_enabled', "; + $sql .= "'$this->destination_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + $this->destination_order++; + unset($sql); + } + } //function + } //class + +?> \ No newline at end of file diff --git a/includes/classes/install.php b/includes/classes/install.php new file mode 100644 index 0000000000..5ce3d3459e --- /dev/null +++ b/includes/classes/install.php @@ -0,0 +1,217 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; + +//define the install class + class install { + + var $result; + var $domain_uuid; + var $domain; + var $switch_conf_dir; + var $switch_scripts_dir; + var $switch_sounds_dir; + + function recursive_copy($src, $dst) { + $dir = opendir($src); + if (!$dir) { + if (!mkdir($src, 0755, true)) { + throw new Exception("recursive_copy() source directory '".$src."' does not exist."); + } + } + if (!is_dir($dst)) { + if (!mkdir($dst, 0755, true)) { + //throw new Exception("recursive_copy() failed to create destination directory '".$dst."'"); + } + } + while(false !== ($file = readdir($dir))) { + if (($file != '.') && ($file != '..')) { + if (is_dir($src.'/'.$file)) { + $this->recursive_copy($src.'/'.$file, $dst.'/'.$file); + } + else { + if (!file_exists($dst.'/'.$file)) { + //echo "copy(".$src."/".$file.", ".$dst."/".$file.");
\n"; + copy($src.'/'.$file, $dst.'/'.$file); + } + } + } + } + closedir($dir); + } + + function recursive_delete($dir) { + if (strlen($dir) > 0) { + foreach (glob($dir) as $file) { + if (is_dir($file)) { + $this->recursive_delete("$file/*"); + rmdir($file); + //echo "rm dir: ".$file."\n"; + } else { + //echo "delete file: ".$file."\n"; + unlink($file); + } + } + } + clearstatcache(); + } + + function copy() { + $this->copy_scripts(); + $this->copy_sounds(); + $this->copy_swf(); + $this->copy_phrases(); + } + + function copy_conf() { + clearstatcache(); + $src_dir = $this->switch_conf_dir; + $dst_dir = $this->switch_conf_dir.'.orig'; + if ($src_dir != "/conf") { + mkdir($src_dir, 0755, true); + } + if (is_readable($src_dir)) { + //make a backup copy of the conf directory + if (substr(strtoupper(PHP_OS), 0, 3) == "WIN") { + $this->recursive_copy($src_dir, $dst_dir); + $this->recursive_delete($this->switch_conf_dir); + } + else { + exec ('mv '.$src_dir.' '.$dst_dir); + //exec ('cp -RLp '.$src_dir.' '.$dst_dir); + } + //make sure the conf directory exists + if (!mkdir($this->switch_conf_dir, 0755, true)) { + //throw new Exception("Failed to create the switch conf directory '".$this->switch_conf_dir."'. "); + } + } + } + + function copy_scripts() { + clearstatcache(); + $src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/scripts'; + $dst_dir = $this->switch_scripts_dir; + if (is_readable($this->switch_scripts_dir)) { + if ($handle = opendir($src_dir)) { + $i = 0; + $files = array(); + while (false !== ($file = readdir($handle))) { + if ($file != "." && $file != ".." && is_file($src_dir.'/'.$file)) { + if (!file_exists($dst_dir.'/'.$file) ) { + //copy the file if it does not exist in the destination directory + if (copy($src_dir.'/'.$file, $dst_dir.'/'.$file)) { + $this->result['copy']['scripts'][] = "copied from ".$src_dir."/".$file." to ".$dst_dir."/".$file."
\n"; + } + else { + $this->result['copy']['scripts'][] = "copy failed from ".$src_dir."/".$file." to ".$dst_dir."/".$file."
\n"; + } + } + } + } + } + unset($src_dir, $dst_dir); + } + } + + function copy_sounds() { + clearstatcache(); + $src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/sounds/en/us/callie/custom/8000'; + $dst_dir = $this->switch_sounds_dir.'/en/us/callie/custom/8000'; + if (is_readable($this->switch_sounds_dir)) { + if ($handle = opendir($src_dir)) { + $i = 0; + $files = array(); + while (false !== ($file = readdir($handle))) { + if ($file != "." && $file != ".." && is_file($src_dir.'/'.$file)) { + if (!file_exists($dst_dir.'/'.$file) ) { + //copy the file if it does not exist in the destination directory + if (copy($src_dir.'/'.$file, $dst_dir.'/'.$file)) { + $this->result['copy']['sounds']['8000'][] = "copied from ".$src_dir."/".$file." to ".$dst_dir."/".$file."
\n"; + } + else { + $this->result['copy']['sounds']['8000'][] = "copy failed from ".$src_dir."/".$file." to ".$dst_dir."/".$file."
\n"; + } + } + } + } + } + + $src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/sounds/en/us/callie/custom/16000'; + $dst_dir = $this->switch_sounds_dir.'/en/us/callie/custom/16000'; + if ($handle = opendir($src_dir)) { + $i = 0; + $files = array(); + while (false !== ($file = readdir($handle))) { + if ($file != "." && $file != ".." && is_file($src_dir.'/'.$file)) { + if (!file_exists($dst_dir.'/'.$file) ) { + //copy the file if it does not exist in the destination directory + if (copy($src_dir.'/'.$file, $dst_dir.'/'.$file)) { + $this->result['copy']['sounds']['16000'][] = "copied from ".$src_dir."/".$file." to ".$dst_dir."/".$file."
\n"; + } + else { + $this->result['copy']['sounds']['16000'][] = "copy failed from ".$src_dir."/".$file." to ".$dst_dir."/".$file."
\n"; + } + } + } + } + } + } + } + + function copy_swf() { + clearstatcache(); + $file = "slim.swf"; + $src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/htdocs'; + $dst_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/app/recordings'; + if (copy($src_dir.'/'.$file, $dst_dir.'/'.$file)) { + $this->result['copy']['swf'][] = "copied from ".$src_dir."/".$file." to ".$dst_dir."/".$file."
\n"; + } + else { + $this->result['copy']['swf'][] = "copy failed from ".$src_dir."/".$file." to ".$dst_dir."/".$file."
\n"; + } + } + + function copy_phrases() { + clearstatcache(); + $src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/conf/lang"; + $dst_dir = $this->switch_conf_dir."/lang"; + if (is_readable($this->switch_conf_dir)) { + $this->recursive_copy($src_dir, $dst_dir); + } + } + + } + +//how to use the class + //include "includes/classes/install.php"; + //$install = new install; + //$install->domain_uuid = $domain_uuid; + //$install->switch_conf_dir = $switch_conf_dir; + //$install->switch_scripts_dir = $switch_scripts_dir; + //$install->switch_sounds_dir = $switch_sounds_dir; + //$install->copy(); + //print_r($install->result); +?> \ No newline at end of file diff --git a/includes/classes/menu.php b/includes/classes/menu.php new file mode 100644 index 0000000000..dcaac5651a --- /dev/null +++ b/includes/classes/menu.php @@ -0,0 +1,340 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//define the follow me class + class menu { + public $menu_uuid; + + //delete items in the menu that are not protected + function delete() { + //set the variable + $db = $this->db; + //remove the old menu + $sql = "delete from v_menu_items "; + $sql .= "where menu_uuid = '".$this->menu_uuid."' "; + $sql .= "and (menu_item_protected <> 'true' "; + $sql .= "or menu_item_protected is null); "; + $db->exec(check_sql($sql)); + } + + //restore the menu + function restore() { + //set the variables + $db = $this->db; + + //get the $apps array from the installed apps from the core and mod directories + $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php"); + $x=0; + foreach ($config_list as &$config_path) { + include($config_path); + $x++; + } + + //use the app array to restore the default menu + //$db->beginTransaction(); + foreach ($apps as $row) { + foreach ($row['menu'] as $menu) { + //set the variables + $menu_item_title = $menu['title']['en']; + $menu_item_language = 'en'; + $menu_item_uuid = $menu['uuid']; + $menu_item_parent_uuid = $menu['parent_uuid']; + $menu_item_category = $menu['category']; + $menu_item_path = $menu['path']; + $menu_item_order = $menu['order']; + $menu_item_description = $menu['desc']; + + //if the item uuid is not currently in the db then add it + $sql = "select * from v_menu_items "; + $sql .= "where menu_uuid = '".$this->menu_uuid."' "; + $sql .= "and menu_item_uuid = '$menu_item_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + if (count($result) == 0) { + //insert the default menu into the database + $sql = "insert into v_menu_items "; + $sql .= "("; + $sql .= "menu_item_uuid, "; + $sql .= "menu_uuid, "; + //$sql .= "menu_item_language, "; + $sql .= "menu_item_title, "; + $sql .= "menu_item_link, "; + $sql .= "menu_item_category, "; + if (strlen($menu_item_order) > 0) { + $sql .= "menu_item_order, "; + } + if (strlen($menu_item_parent_uuid) > 0) { + $sql .= "menu_item_parent_uuid, "; + } + $sql .= "menu_item_description "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$menu_item_uuid."', "; + $sql .= "'".$this->menu_uuid."', "; + //$sql .= "'$menu_item_language', "; + $sql .= "'$menu_item_title', "; + $sql .= "'$menu_item_path', "; + $sql .= "'$menu_item_category', "; + if (strlen($menu_item_order) > 0) { + $sql .= "'$menu_item_order', "; + } + if (strlen($menu_item_parent_uuid) > 0) { + $sql .= "'$menu_item_parent_uuid', "; + } + $sql .= "'$menu_item_description' "; + $sql .= ")"; + if ($menu_item_uuid == $menu_item_parent_uuid) { + //echo $sql."
\n"; + } + else { + $db->exec(check_sql($sql)); + } + unset($sql); + } + } + } + } + + //if there are no groups listed in v_menu_item_groups under menu_uuid then add the default groups + $sql = "select count(*) as count from v_menu_item_groups "; + $sql .= "where menu_uuid = '".$this->menu_uuid."' "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + $sub_result = $prep_statement->fetch(PDO::FETCH_ASSOC); + unset ($prep_statement); + if ($sub_result['count'] == 0) { + //no menu item groups found add the defaults + foreach($apps as $app) { + foreach ($app['menu'] as $sub_row) { + foreach ($sub_row['groups'] as $group) { + //add the record + $sql = "insert into v_menu_item_groups "; + $sql .= "("; + $sql .= "menu_uuid, "; + $sql .= "menu_item_uuid, "; + $sql .= "group_name "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$this->menu_uuid."', "; + $sql .= "'".$sub_row['uuid']."', "; + $sql .= "'".$group."' "; + $sql .= ")"; + $db->exec($sql); + unset($sql); + } + } + } + } + + //save the changes to the database + //$db->commit(); + } //end function + + //create the menu + function build_html($sql, $menu_item_level) { + + $db = $this->db; + $db_menu_full = ''; + + if (!isset($_SESSION['groups'])) { + $_SESSION['groups'][0]['group_name'] = 'public'; + } + + if (strlen($sql) == 0) { //default sql for base of the menu + $sql = "select * from v_menu_items "; + $sql .= "where menu_uuid = '".$this->menu_uuid."' "; + $sql .= "and menu_item_parent_uuid is null "; + $sql .= "and menu_item_uuid in "; + $sql .= "(select menu_item_uuid from v_menu_item_groups where menu_uuid = '".$this->menu_uuid."' "; + $sql .= "and ( "; + if (!isset($_SESSION['groups'])) { + $sql .= "group_name = 'public' "; + } + else { + $x = 0; + foreach($_SESSION['groups'] as $row) { + if ($x == 0) { + $sql .= "group_name = '".$row['group_name']."' "; + } + else { + $sql .= "or group_name = '".$row['group_name']."' "; + } + $x++; + } + } + $sql .= ") "; + $sql .= "and menu_item_uuid is not null "; + $sql .= ") "; + $sql .= "order by menu_item_order asc "; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach($result as $field) { + $menu_tags = ''; + switch ($field['menu_item_category']) { + case "internal": + $menu_tags = "href='".PROJECT_PATH.$field['menu_item_link']."'"; + break; + case "external": + if (substr($field['menu_item_link'], 0,1) == "/") { + $field['menu_item_link'] = PROJECT_PATH . $field['menu_item_link']; + } + $menu_tags = "href='".$field['menu_item_link']."' target='_blank'"; + break; + case "email": + $menu_tags = "href='mailto:".$field['menu_item_link']."'"; + break; + } + + if ($menu_item_level == "main") { + $db_menu = "

\n\n"; + } + + $db_menu_full .= $db_menu; + } //end for each + + unset($prep_statement, $sql, $result); + return $db_menu_full; + } + + //create the sub menus + function build_child_html($menu_item_level, $menu_item_uuid) { + + $db = $this->db; + $menu_item_level = $menu_item_level+1; + + if (count($_SESSION['groups']) == 0) { + $_SESSION['groups'][0]['group_name'] = 'public'; + } + + $sql = "select * from v_menu_items "; + $sql .= "where menu_uuid = '".$this->menu_uuid."' "; + $sql .= "and menu_item_parent_uuid = '$menu_item_uuid' "; + $sql .= "and menu_item_uuid in "; + $sql .= "(select menu_item_uuid from v_menu_item_groups where menu_uuid = '".$this->menu_uuid."' "; + $sql .= "and ( "; + if (count($_SESSION['groups']) == 0) { + $sql .= "group_name = 'public' "; + } + else { + $x = 0; + foreach($_SESSION['groups'] as $row) { + if ($x == 0) { + $sql .= "group_name = '".$row['group_name']."' "; + } + else { + $sql .= "or group_name = '".$row['group_name']."' "; + } + $x++; + } + } + $sql .= ") "; + $sql .= ") "; + $sql .= "order by menu_item_order, menu_item_title asc "; + $prep_statement_2 = $db->prepare($sql); + $prep_statement_2->execute(); + $result_2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED); + if (count($result_2) > 0) { + //child menu found + $db_menu_sub = "\n"; + return $db_menu_sub; + } + unset($prep_statement_2, $sql); + } + } + +?> \ No newline at end of file diff --git a/includes/classes/root.php b/includes/classes/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/includes/classes/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); } + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/includes/classes/schema.php b/includes/classes/schema.php new file mode 100644 index 0000000000..668eba1303 --- /dev/null +++ b/includes/classes/schema.php @@ -0,0 +1,121 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; + +//define the follow me class + class schema { + public $db; + public $apps; + public $db_type; + public $result; + + //get the list of installed apps from the core and mod directories + public function __construct() { + $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php"); + $x=0; + foreach ($config_list as &$config_path) { + include($config_path); + $x++; + } + $this->apps = $apps; + } + + //create the database schema + public function sql() { + $sql = ''; + $sql_schema = ''; + foreach ($this->apps as $app) { + if (count($app['db'])) { + foreach ($app['db'] as $row) { + //create the sql string + $table_name = $row['table']; + $sql = "CREATE TABLE " . $row['table'] . " (\n"; + $field_count = 0; + foreach ($row['fields'] as $field) { + if ($field['deprecated'] == "true") { + //skip this field + } + else { + if ($field_count > 0 ) { $sql .= ",\n"; } + if (is_array($field['name'])) { + $sql .= $field['name']['text']." "; + } + else { + $sql .= $field['name']." "; + } + if (is_array($field['type'])) { + $sql .= $field['type'][$this->db_type]; + } + else { + $sql .= $field['type']; + } + if ($field['key']['type'] == "primary") { + $sql .= " PRIMARY KEY"; + } + if ($field['key']['type'] == "foreign") { + if ($this->db_type == "pgsql") { + //$sql .= " references ".$field['key']['reference']['table']."(".$field['key']['reference']['field'].")"; + } + if ($this->db_type == "sqlite") { + //$sql .= " references ".$field['key']['reference']['table']."(".$field['key']['reference']['field'].")"; + } + if ($this->db_type == "mysql") { + //$sql .= " references ".$field['key']['reference']['table']."(".$field['key']['reference']['field'].")"; + } + } + $field_count++; + } + } + if ($this->db_type == "mysql") { + $sql .= ") ENGINE=INNODB;"; + } + else { + $sql .= ");"; + } + $this->result['sql'][] = $sql; + unset($sql); + } + } + } + } + + //create the database schema + public function exec() { + foreach ($this->result['sql'] as $sql) { + //start the sql transaction + $this->db->beginTransaction(); + //execute the sql query + try { + $this->db->query($sql); + } + catch (PDOException $error) { + echo "error: " . $error->getMessage() . " sql: $sql
"; + } + //complete the transaction + $this->db->commit(); + } + } + } \ No newline at end of file diff --git a/includes/classes/switch_directory.php b/includes/classes/switch_directory.php new file mode 100644 index 0000000000..2ab3fc1740 --- /dev/null +++ b/includes/classes/switch_directory.php @@ -0,0 +1,694 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; + +//define the directory class + class switch_directory { + public $domain_uuid; + public $domain_name; + public $db_type; + public $extension; + public $number_alias; + public $password; + public $vm_password; + public $accountcode; + public $effective_caller_id_name; + public $effective_caller_id_number; + public $outbound_caller_id_name; + public $outbound_caller_id_number; + public $limit_max=5; + public $limit_destination; + public $vm_enabled=1; + public $vm_mailto; + public $vm_attach_file; + public $vm_keep_local_after_email; + public $user_context; + public $range; + public $autogen_users; + public $toll_allow; + public $call_group; + public $hold_music; + public $auth_acl; + public $cidr; + public $sip_force_contact; + public $sip_force_expires; + public $nibble_account; + public $mwi_account; + public $sip_bypass_media; + public $enabled; + public $description; + public $cidr; + public $number_alias; + + // get domain_uuid + public function get_domain_uuid() { + return $this->domain_uuid; + } + // set domain_uuid + public function set_domain_uuid($domain_uuid){ + $this->domain_uuid = $domain_uuid; + } + + // get domain_name + public function get_domain_name() { + return $this->domain_name; + } + // set domain_name + public function set_domain_name($domain_name){ + $this->domain_name = $domain_name; + } + + // get db_type + public function get_db_type() { + return $this->db_type; + } + // set db_type + public function set_db_type($db_type){ + $this->db_type = $db_type; + } + + // get extension + public function get_extension() { + return $this->extension; + } + // set extension + public function set_extension($extension){ + $this->extension = $extension; + } + + public function add() { + global $db; + $domain_uuid = $this->domain_uuid; + $domain_name = $this->domain_name; + $extension = $this->extension; + $number_alias = $this->number_alias; + $password = $this->password; + $autogen_users = $this->autogen_users; + $provisioning_list = $this->provisioning_list; + $vm_password = $this->vm_password; + $accountcode = $this->accountcode; + $effective_caller_id_name = $this->effective_caller_id_name; + $effective_caller_id_number = $this->effective_caller_id_number; + $outbound_caller_id_name = $this->outbound_caller_id_name; + $outbound_caller_id_number = $this->outbound_caller_id_number; + $limit_max = $this->limit_max; + $limit_destination = $this->limit_destination; + $vm_enabled = $this->vm_enabled; + $vm_mailto = $this->vm_mailto; + $vm_attach_file = $this->vm_attach_file; + $vm_keep_local_after_email = $this->vm_keep_local_after_email; + $user_context = $this->user_context; + $toll_allow = $this->toll_allow; + $call_group = $this->call_group; + $hold_music = $this->hold_music; + $auth_acl = $this->auth_acl; + $cidr = $this->cidr; + $sip_force_contact = $this->sip_force_contact; + $sip_force_expires = $this->sip_force_expires; + $nibble_account = $this->nibble_account; + $mwi_account = $this->mwi_account; + $sip_bypass_media = $this->sip_bypass_media; + $enabled = $this->enabled; + $description = $this->description; + + $db->beginTransaction(); + for ($i=1; $i<=$range; $i++) { + if (extension_exists($extension)) { + //extension exists + } + else { + //extension does not exist add it + $password = generate_password(); + $sql = "insert into v_extensions "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "extension_uuid, "; + $sql .= "extension, "; + $sql .= "number_alias, "; + $sql .= "password, "; + $sql .= "provisioning_list, "; + $sql .= "vm_password, "; + $sql .= "accountcode, "; + $sql .= "effective_caller_id_name, "; + $sql .= "effective_caller_id_number, "; + $sql .= "outbound_caller_id_name, "; + $sql .= "outbound_caller_id_number, "; + $sql .= "limit_max, "; + $sql .= "limit_destination, "; + $sql .= "vm_enabled, "; + $sql .= "vm_mailto, "; + $sql .= "vm_attach_file, "; + $sql .= "vm_keep_local_after_email, "; + $sql .= "user_context, "; + $sql .= "toll_allow, "; + $sql .= "call_group, "; + $sql .= "hold_music, "; + $sql .= "auth_acl, "; + $sql .= "cidr, "; + $sql .= "sip_force_contact, "; + if (strlen($sip_force_expires) > 0) { + $sql .= "sip_force_expires, "; + } + if (strlen($nibble_account) > 0) { + $sql .= "nibble_account, "; + } + if (strlen($mwi_account) > 0) { + $sql .= "mwi_account, "; + } + $sql .= "sip_bypass_media, "; + $sql .= "enabled, "; + $sql .= "description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$extension_uuid', "; + $sql .= "'$extension', "; + $sql .= "'$number_alias', "; + $sql .= "'$password', "; + $sql .= "'$provisioning_list', "; + $sql .= "'user-choose', "; + $sql .= "'$accountcode', "; + $sql .= "'$effective_caller_id_name', "; + $sql .= "'$effective_caller_id_number', "; + $sql .= "'$outbound_caller_id_name', "; + $sql .= "'$outbound_caller_id_number', "; + $sql .= "'$limit_max', "; + $sql .= "'$limit_destination', "; + $sql .= "'$vm_enabled', "; + $sql .= "'$vm_mailto', "; + $sql .= "'$vm_attach_file', "; + $sql .= "'$vm_keep_local_after_email', "; + $sql .= "'$user_context', "; + $sql .= "'$toll_allow', "; + $sql .= "'$call_group', "; + $sql .= "'$hold_music', "; + $sql .= "'$auth_acl', "; + $sql .= "'$cidr', "; + $sql .= "'$sip_force_contact', "; + if (strlen($sip_force_expires) > 0) { + $sql .= "'$sip_force_expires', "; + } + if (strlen($nibble_account) > 0) { + $sql .= "'$nibble_account', "; + } + if (strlen($mwi_account) > 0) { + if (strpos($mwi_account, '@') === false) { + if (count($_SESSION["domains"]) > 1) { + $mwi_account .= "@".$domain_name; + } + else { + $mwi_account .= "@\$\${domain}"; + } + } + $sql .= "'$mwi_account', "; + } + $sql .= "'$sip_bypass_media', "; + $sql .= "'$enabled', "; + $sql .= "'$description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + $extension++; + } + $db->commit(); + } + + public function update() { + global $db; + + $domain_uuid = $this->domain_uuid; + $domain_name = $this->domain_name; + $extension = $this->extension; + $number_alias = $this->number_alias; + $password = $this->password; + $autogen_users = $this->autogen_users; + $provisioning_list = $this->provisioning_list; + $vm_password = $this->vm_password; + $accountcode = $this->accountcode; + $effective_caller_id_name = $this->effective_caller_id_name; + $effective_caller_id_number = $this->effective_caller_id_number; + $outbound_caller_id_name = $this->outbound_caller_id_name; + $outbound_caller_id_number = $this->outbound_caller_id_number; + $limit_max = $this->limit_max; + $limit_destination = $this->limit_destination; + $vm_enabled = $this->vm_enabled; + $vm_mailto = $this->vm_mailto; + $vm_attach_file = $this->vm_attach_file; + $vm_keep_local_after_email = $this->vm_keep_local_after_email; + $user_context = $this->user_context; + $toll_allow = $this->toll_allow; + $call_group = $this->call_group; + $hold_music = $this->hold_music; + $auth_acl = $this->auth_acl; + $cidr = $this->cidr; + $sip_force_contact = $this->sip_force_contact; + $sip_force_expires = $this->sip_force_expires; + $nibble_account = $this->nibble_account; + $mwi_account = $this->mwi_account; + $sip_bypass_media = $this->sip_bypass_media; + $enabled = $this->enabled; + $description = $this->description; + + //$user_list_array = explode("|", $user_list); + //foreach($user_list_array as $tmp_user){ + // $user_password = generate_password(); + // if (strlen($tmp_user) > 0) { + // user_add($tmp_user, $user_password, $user_email); + // } + //} + //unset($tmp_user); + + if (strlen($password) == 0) { + $password = generate_password(); + } + + $sql = "update v_extensions set "; + $sql .= "extension = '$extension', "; + $sql .= "number_alias = '$number_alias', "; + $sql .= "password = '$password', "; + $sql .= "provisioning_list = '$provisioning_list', "; + if (strlen($vm_password) > 0) { + $sql .= "vm_password = '$vm_password', "; + } + else { + $sql .= "vm_password = 'user-choose', "; + } + $sql .= "accountcode = '$accountcode', "; + $sql .= "effective_caller_id_name = '$effective_caller_id_name', "; + $sql .= "effective_caller_id_number = '$effective_caller_id_number', "; + $sql .= "outbound_caller_id_name = '$outbound_caller_id_name', "; + $sql .= "outbound_caller_id_number = '$outbound_caller_id_number', "; + $sql .= "limit_max = '$limit_max', "; + $sql .= "limit_destination = '$limit_destination', "; + $sql .= "vm_enabled = '$vm_enabled', "; + $sql .= "vm_mailto = '$vm_mailto', "; + $sql .= "vm_attach_file = '$vm_attach_file', "; + $sql .= "vm_keep_local_after_email = '$vm_keep_local_after_email', "; + $sql .= "user_context = '$user_context', "; + $sql .= "toll_allow = '$toll_allow', "; + $sql .= "call_group = '$call_group', "; + $sql .= "hold_music = '$hold_music', "; + $sql .= "auth_acl = '$auth_acl', "; + $sql .= "cidr = '$cidr', "; + $sql .= "sip_force_contact = '$sip_force_contact', "; + if (strlen($sip_force_expires) == 0) { + $sql .= "sip_force_expires = null, "; + } + else { + $sql .= "sip_force_expires = '$sip_force_expires', "; + } + if (strlen($nibble_account) == 0) { + $sql .= "nibble_account = null, "; + } + else { + $sql .= "nibble_account = '$nibble_account', "; + } + if (strlen($mwi_account) > 0) { + if (strpos($mwi_account, '@') === false) { + if (count($_SESSION["domains"]) > 1) { + $mwi_account .= "@".$domain_name; + } + else { + $mwi_account .= "@\$\${domain}"; + } + } + } + $sql .= "mwi_account = '$mwi_account', "; + $sql .= "sip_bypass_media = '$sip_bypass_media', "; + $sql .= "enabled = '$enabled', "; + $sql .= "description = '$description' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and extension_uuid = '$extension_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + } + + function delete() { + global $db; + $domain_uuid = $this->domain_uuid; + $extension_uuid = $this->extension_uuid; + if (strlen($extension_uuid)>0) { + $sql = ""; + $sql .= "delete from v_extensions "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and extension_uuid = '$extension_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + } + } + + function import_sql($data){ + $count=count($data); + $keys=$values=SplFixedArray($count); + $keys=array_keys($data); + $values=array_values($data); + for($i=0;$i<$count;$i++){ + $keys[$i]= str_replace("-", "_", $keys[$i]); + $this->{$keys[$i]}=$values[$i]; + } + } + + function set_bool(&$var,$default=null){ + $var=strtolower($var); + if ($var==="true") return; + elseif ($var==="false") return; + elseif ($var==true) $var="true"; + elseif ($var==false) $var="false"; + elseif(!is_null($default)) { + $var=$default; + $this->set_bool($var); + } + } + + function generate_xml($single=1){ + //switch_account_code!! How should we be passing this?? + + if ($this->enabled== "false" || !$this->enabled) { + return false;//This the best way?? + } + + $this->vm_password = str_replace("#", "", $this->vm_password); //preserves leading zeros//**Generic Validation! + + /*if(!in_array($this->vm_enabled,array("false","true"))) {//**Generic Validation! + $this->vm_enabled = "true"; + } + if(!in_array($this->vm_attach_file,array("false","true"))) {//**Generic Validation! + $this->vm_attach_file = "true"; + } + if(!in_array($this->vm_keep_local_after_email,array("false","true"))) {//**Generic Validation! + $this->vm_keep_local_after_email = "true"; + } + */ + $this->set_bool($this->vm_enabled,1); + $this->set_bool($this->vm_attach_file,1); + $this->set_bool($this->vm_keep_local_after_email,1); + + //remove invalid characters from the file names //**Generic Validation! + $this->extension = str_replace(" ", "_", $this->extension); + $this->extension = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $this->extension); + + /*if (!$extension_xml_condensed) { <--- what do I do with this?? + $fout = fopen($_SESSION['switch']['extensions']['dir']."/v_".$extension.".xml","w"); + $tmp_xml .= "\n"; + }*/ + if (strlen($this->cidr)) { + $this->cidr = " cidr=\"" . $this->cidr . "\""; + } + if (strlen($this->number_alias)) { + $this->number_alias = " number-alias=\"".$this->number_alias."\""; + } + if($single) $tmp_xml = "\n"; + else $tmp_xml = ""; + $tmp_xml .= " extension."\"".$this->cidr."".$this->number_alias.">\n"; + $tmp_xml .= " \n"; + $tmp_xml .= " password . "\"/>\n"; + $tmp_xml .= " vm_enabled."\"/>\n"; + + if ($this->vm_enabled=="true"){ + $tmp_xml .= " vm_password . "\"/>\n"; + if(strlen($this->vm_mailto)) { + $tmp_xml .= " \n"; + $tmp_xml .= " vm_attach_file."\"/>\n"; + $tmp_xml .= " vm_keep_local_after_email."\"/>\n"; + $tmp_xml .= " vm_mailto . "\"/>\n"; + } + } + if (strlen($this->mwi_account)) { + $tmp_xml .= " mwi_account . "\"/>\n"; + } + if (strlen($this->auth_acl)) { + $tmp_xml .= " auth_acl . "\"/>\n"; + } + $tmp_xml .= " \n"; + + $tmp_xml .= " \n"; + if (strlen($this->hold_music)) { + $tmp_xml .= " hold_music . "\"/>\n"; + } + if (strlen($this->toll_allow)){ + $tmp_xml .= " toll_allow . "\"/>\n"; + } + if (strlen($this->accountcode)){ + $tmp_xml .= " accountcode . "\"/>\n"; + } + $tmp_xml .= " user_context . "\"/>\n"; + if (strlen($this->effective_caller_id_name)) { + $tmp_xml .= " effective_caller_id_name . "\"/>\n"; + } + if (strlen($this->outbound_caller_id_number)) { + $tmp_xml .= " effective_caller_id_number . "\"/>\n"; + } + if (strlen($this->outbound_caller_id_name)) { + $tmp_xml .= " outbound_caller_id_name . "\"/>\n"; + } + if (strlen($this->outbound_caller_id_number)) { + $tmp_xml .= " outbound_caller_id_number . "\"/>\n"; + } + if (!strlen($this->limit_max)) {//**validation + $this->limit_max=5; + } + $tmp_xml .= " limit_max . "\"/>\n"; + if (strlen($this->limit_destination)) { + $tmp_xml .= " limit_destination . "\"/>\n"; + } + if (strlen($this->sip_force_contact)) { + $tmp_xml .= " sip_force_contact . "\"/>\n"; + } + if (strlen($this->sip_force_expires)) { + $tmp_xml .= " sip_force_expires . "\"/>\n"; + } + if (strlen($this->nibble_account)) { + $tmp_xml .= " nibble_account . "\"/>\n"; + } + switch ($this->sip_bypass_media) { + case "bypass-media": + $tmp_xml .= " \n"; + break; + case "bypass-media-after-bridge": + $tmp_xml .= " \n"; + break; + case "proxy-media": + $tmp_xml .= " \n"; + break; + } + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + if($single) { $tmp_xml .= "\n"; } + + return $tmp_xml; + } + + function xml_save_all() { + global $db, $config; + $domain_uuid = $this->domain_uuid; + $domain_name = $this->domain_name; + + //get the system settings paths and set them as variables + $settings_array = v_settings(); + foreach($settings_array as $name => $value) { + $$name = $value; + } + + //determine the extensions parent directory + $extension_parent_dir = realpath($_SESSION['switch']['extensions']['dir']."/.."); + + // delete all old extensions to prepare for new ones + if($dh = opendir($_SESSION['switch']['extensions']['dir'])) { + $files = Array(); + while($file = readdir($dh)) { + if($file != "." && $file != ".." && $file[0] != '.') { + if(is_dir($dir . "/" . $file)) { + //this is a directory do nothing + } else { + //check if file is an extension; verify the file numeric and the extension is xml + if (substr($file,0,2) == 'v_' && substr($file,-4) == '.xml') { + unlink($_SESSION['switch']['extensions']['dir']."/".$file); + } + } + } + } + closedir($dh); + } + + $sql = ""; + $sql .= "select * from v_extensions "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "order by call_group asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $i = 0; + $extension_xml_condensed = false; + if ($extension_xml_condensed) { + $fout = fopen($_SESSION['switch']['extensions']['dir']."/v_extensions.xml","w"); + $tmp_xml = "\n"; + } + while($row = $prep_statement->fetch(PDO::FETCH_ASSOC)) { + $call_group = $row['call_group']; + $call_group = str_replace(";", ",", $call_group); + $tmp_array = explode(",", $call_group); + foreach ($tmp_array as &$tmp_call_group) { + if (strlen($tmp_call_group) > 0) { + if (strlen($call_group_array[$tmp_call_group]) == 0) { + $call_group_array[$tmp_call_group] = $row['extension']; + } + else { + $call_group_array[$tmp_call_group] = $call_group_array[$tmp_call_group].','.$row['extension']; + } + } + $i++; + } + + if ($row['enabled'] != "false") { + //$this->import_sql($row);//Do I need to be worried about ghost values? Maybe I should make a new object? + //if (strlen($switch_account_code)) $this->accountcode=$switch_account_code; + //$tmp_xml.=$this->generate_xml(1); + + $one_row=new fs_directory; + $one_row->import_sql($row);//make a new object to flush ghost rows. And we can call this as static. + if (strlen($switch_account_code)) $one_row->accountcode=$switch_account_code; + $tmp_xml.=$one_row->generate_xml(false); + + if (!$extension_xml_condensed) { + $tmp_xml .= "\n"; + fwrite($fout, $tmp_xml); + unset($tmp_xml); + fclose($fout); + } + } + } + unset ($prep_statement); + if ($extension_xml_condensed) { + $tmp_xml .= "\n"; + fwrite($fout, $tmp_xml); + unset($tmp_xml); + fclose($fout); + } + + //define the group members + $tmp_xml = "\n"; + $tmp_xml .= "\n"; + $tmp_xml .= "\n"; + $tmp_xml .= " \n"; + if ($extension_dir_name == "default") { + $tmp_xml .= " \n"; + } + else { + $tmp_xml .= " \n"; + } + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= "\n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= "\n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= "\n"; + $previous_call_group = ""; + foreach ($call_group_array as $key => $value) { + $call_group = $key; + $extension_list = $value; + if (strlen($call_group) > 0) { + if ($previous_call_group != $call_group) { + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $extension_array = explode(",", $extension_list); + foreach ($extension_array as &$tmp_extension) { + $tmp_xml .= " \n"; + } + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= "\n"; + } + $previous_call_group = $call_group; + } + unset($call_group); + } + $tmp_xml .= " \n"; + $tmp_xml .= "\n"; + $tmp_xml .= " \n"; + $tmp_xml .= ""; + + //remove invalid characters from the file names + $extension_dir_name = str_replace(" ", "_", $extension_dir_name); + $extension_dir_name = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $extension_dir_name); + + //write the xml file + $fout = fopen($extension_parent_dir."/".$extension_dir_name.".xml","w"); + fwrite($fout, $tmp_xml); + unset($tmp_xml); + fclose($fout); + + //syncrhonize the phone directory + sync_directory(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + + //call reloadxml direct + //$cmd = "api reloadxml"; + //event_socket_request_cmd($cmd); + //unset($cmd); + + } //end function + } //class + +?> \ No newline at end of file diff --git a/includes/classes/switch_fax.php b/includes/classes/switch_fax.php new file mode 100644 index 0000000000..ea86ad48d8 --- /dev/null +++ b/includes/classes/switch_fax.php @@ -0,0 +1,530 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; + +//define the directory class + class switch_fax { + + public $db; + public $domain_uuid; + public $domain_name; + public $dialplan_uuid; + public $context; + public $fax_uuid; + public $fax_name; + public $fax_extension; + public $fax_email; + public $fax_pin_number; + public $fax_caller_id_name; + public $fax_caller_id_number; + public $fax_forward_number; + public $fax_user_list; + public $fax_description; + + public function __construct() { + require_once "includes/classes/database.php"; + $this->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440'; + } + + public function __destruct() { + foreach ($this as $key => $value) { + unset($this->$key); + } + } + + public function count() { + $database = new database; + $database->domain_uuid = $this->domain_uuid; + $database->table = "v_fax"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + return $database->count(); + } + + public function find() { + $database = new database; + $database->table = "v_fax"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + if ($this->fax_uuid) { + $database->where[1]['name'] = 'fax_uuid'; + $database->where[1]['value'] = $this->fax_uuid; + $database->where[1]['operator'] = '='; + } + if ($this->order_by) { + $database->order_by = $this->order_by; + } + if ($this->order_type) { + $database->order_type = $this->order_type; + } + return $database->find(); + } + + public function add() { + + //add the fax + if (strlen($this->fax_extension) > 0) { + //add the dialplan + $database = new database; + $database->table = "v_dialplans"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_name'] = $this->fax_name; + $database->fields['dialplan_order'] = '333'; + $database->fields['dialplan_context'] = $this->context; + $database->fields['dialplan_enabled'] = $this->fax_enabled; + $database->fields['dialplan_description'] = $this->fax_description; + $database->fields['app_uuid'] = $this->app_uuid; + $database->add(); + + //add the dialplan details + $detail_data = '^'.$this->fax_extension.'$'; + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'condition'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'destination_number'; + $database->fields['dialplan_detail_data'] = $detail_data; + $database->fields['dialplan_detail_order'] = '005'; + $database->add(); + + if (file_exists(PHP_BINDIR."/php")) { define(PHP_BIN, 'php'); } + if (file_exists(PHP_BINDIR."/php.exe")) { define(PHP_BIN, 'php.exe'); } + $dialplan_detail_data = "api_hangup_hook=system ".PHP_BINDIR."/".PHP_BIN." ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/fax_to_email.php "; + $dialplan_detail_data .= "email=".$this->fax_email." "; + $dialplan_detail_data .= "extension=".$this->fax_extension." "; + $dialplan_detail_data .= "name=\\\\\\\${last_fax} "; + $dialplan_detail_data .= "messages='result: \\\\\\\${fax_result_text} sender:\\\\\\\${fax_remote_station_id} pages:\\\\\\\${fax_document_total_pages}' "; + $dialplan_detail_data .= "domain=".$domain_name." "; + $dialplan_detail_data .= "caller_id_name='\\\\\\\${caller_id_name}' "; + $dialplan_detail_data .= "caller_id_number=\\\\\\\${caller_id_number} "; + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'set'; + $database->fields['dialplan_detail_data'] = $dialplan_detail_data; + $database->fields['dialplan_detail_order'] = '010'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'answer'; + $database->fields['dialplan_detail_data'] = ''; + $database->fields['dialplan_detail_order'] = '015'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'set'; + $database->fields['dialplan_detail_data'] = 'fax_enable_t38=true'; + $database->fields['dialplan_detail_order'] = '020'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'set'; + $database->fields['dialplan_detail_data'] = 'fax_enable_t38_request=true'; + $database->fields['dialplan_detail_order'] = '025'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'playback'; + $database->fields['dialplan_detail_data'] = 'silence_stream://2000'; + $database->fields['dialplan_detail_order'] = '030'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'set'; + $database->fields['dialplan_detail_data'] = 'last_fax=${caller_id_number}-${strftime(%Y-%m-%d-%H-%M-%S)}'; + $database->fields['dialplan_detail_order'] = '035'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'rxfax'; + if (count($_SESSION["domains"]) > 1) { + $dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domains'][$row['domain_uuid']]['domain_name'].'/'.$this->fax_extension.'/inbox/${last_fax}.tif'; + } + else { + $dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$this->fax_extension.'/inbox/${last_fax}.tif'; + } + $database->fields['dialplan_detail_data'] = $dialplan_detail_data; + $database->fields['dialplan_detail_order'] = '040'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'hangup'; + $database->fields['dialplan_detail_data'] = ''; + $database->fields['dialplan_detail_order'] = '045'; + $database->add(); + } + + //add the fax + $fax_uuid = uuid(); + $database = new database; + $database->table = "v_fax"; + $database->fields['domain_uuid'] = $this->domain_uuid; + if (strlen($this->fax_extension) > 0) { + $database->fields['fax_extension'] = $this->fax_extension; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + } + $database->fields['fax_uuid'] = $this->fax_uuid; + $database->fields['fax_name'] = $this->fax_name; + $database->fields['fax_email'] = $this->fax_email; + $database->fields['fax_pin_number'] = $this->fax_pin_number; + $database->fields['fax_caller_id_name'] = $this->fax_caller_id_name; + $database->fields['fax_caller_id_number'] = $this->fax_caller_id_number; + $database->fields['fax_forward_number'] = $this->fax_forward_number; + $database->fields['fax_user_list'] = $this->fax_user_list; + $database->fields['fax_description'] = $this->fax_description; + $database->add(); + } + + public function update() { + + //udate the fax + //get the dialplan uuid + $database = new database; + $database->table = "v_fax"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'fax_uuid'; + $database->where[1]['value'] = $this->fax_uuid; + $database->where[1]['operator'] = '='; + $result = $database->find(); + foreach($result as $row) { + $this->dialplan_uuid = $row['dialplan_uuid']; + } + + //if the extension number is empty and the dialplan exists then delete the dialplan + if (strlen($this->fax_extension) == 0) { + if (strlen($this->dialplan_uuid) > 0) { + //delete dialplan entry + $database = new database; + $database->table = "v_dialplan_details"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'dialplan_uuid'; + $database->where[1]['value'] = $this->dialplan_uuid; + $database->where[1]['operator'] = '='; + $database->delete(); + + //delete the child dialplan information + $database = new database; + $database->table = "v_dialplans"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'dialplan_uuid'; + $database->where[1]['value'] = $this->dialplan_uuid; + $database->where[1]['operator'] = '='; + $database->delete(); + //update the table to remove the dialplan_uuid + $this->dialplan_uuid = ''; + } + } + + //update the fax + $fax_uuid = uuid(); + $database = new database; + $database->table = "v_fax"; + $database->fields['fax_uuid'] = $this->fax_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['fax_name'] = $this->fax_name; + $database->fields['fax_extension'] = $this->fax_extension; + $database->fields['fax_email'] = $this->fax_email; + $database->fields['fax_pin_number'] = $this->fax_pin_number; + $database->fields['fax_caller_id_name'] = $this->fax_caller_id_name; + $database->fields['fax_caller_id_number'] = $this->fax_caller_id_number; + $database->fields['fax_forward_number'] = $this->fax_forward_number; + $database->fields['fax_user_list'] = $this->fax_user_list; + $database->fields['fax_description'] = $this->fax_description; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'fax_uuid'; + $database->where[1]['value'] = $this->fax_uuid; + $database->where[1]['operator'] = '='; + $database->update(); + + if (strlen($this->fax_extension) > 0) { + //update the dialplan + $database = new database; + $database->table = "v_dialplans"; + $database->fields['dialplan_name'] = $this->fax_name; + $database->fields['dialplan_order'] = '333'; + $database->fields['dialplan_context'] = $this->context; + $database->fields['dialplan_enabled'] = $this->fax_enabled; + $database->fields['dialplan_description'] = $this->dialplan_description; + $database->fields['app_uuid'] = $this->app_uuid; + if ($this->dialplan_uuid) { + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'dialplan_uuid'; + $database->where[1]['value'] = $this->dialplan_uuid; + $database->where[1]['operator'] = '='; + $database->update(); + } + else { +// $this->dialplan_uuid = uuid(); + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->add(); + } + + //delete the old dialplan details to prepare for new details + $database = new database; + $database->table = "v_dialplan_details"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'dialplan_uuid'; + $database->where[1]['value'] = $this->dialplan_uuid; + $database->where[1]['operator'] = '='; + $database->delete(); + + //add the dialplan details + $detail_data = '^'.$this->fax_extension.'$'; + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'condition'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'destination_number'; + $database->fields['dialplan_detail_data'] = $detail_data; + $database->fields['dialplan_detail_order'] = '005'; + $database->add(); + + if (file_exists(PHP_BINDIR."/php")) { define(PHP_BIN, 'php'); } + if (file_exists(PHP_BINDIR."/php.exe")) { define(PHP_BIN, 'php.exe'); } + $dialplan_detail_data = "api_hangup_hook=system ".PHP_BINDIR."/".PHP_BIN." ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/fax_to_email.php "; + $dialplan_detail_data .= "email=".$this->fax_email." "; + $dialplan_detail_data .= "extension=".$this->fax_extension." "; + $dialplan_detail_data .= "name=\\\\\\\${last_fax} "; + $dialplan_detail_data .= "messages='result: \\\\\\\${fax_result_text} sender:\\\\\\\${fax_remote_station_id} pages:\\\\\\\${fax_document_total_pages}' "; + $dialplan_detail_data .= "domain=".$domain_name." "; + $dialplan_detail_data .= "caller_id_name='\\\\\\\${caller_id_name}' "; + $dialplan_detail_data .= "caller_id_number=\\\\\\\${caller_id_number} "; + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'set'; + $database->fields['dialplan_detail_data'] = $dialplan_detail_data; + $database->fields['dialplan_detail_order'] = '010'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'answer'; + $database->fields['dialplan_detail_data'] = ''; + $database->fields['dialplan_detail_order'] = '015'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'set'; + $database->fields['dialplan_detail_data'] = 'fax_enable_t38=true'; + $database->fields['dialplan_detail_order'] = '020'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'set'; + $database->fields['dialplan_detail_data'] = 'fax_enable_t38_request=true'; + $database->fields['dialplan_detail_order'] = '025'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'playback'; + $database->fields['dialplan_detail_data'] = 'silence_stream://2000'; + $database->fields['dialplan_detail_order'] = '030'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'set'; + $database->fields['dialplan_detail_data'] = 'last_fax=${caller_id_number}-${strftime(%Y-%m-%d-%H-%M-%S)}'; + $database->fields['dialplan_detail_order'] = '035'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'rxfax'; + if (count($_SESSION["domains"]) > 1) { + $dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domains'][$row['domain_uuid']]['domain_name'].'/'.$this->fax_extension.'/inbox/${last_fax}.tif'; + } + else { + $dialplan_detail_data = $_SESSION['switch']['storage']['dir'].'/fax/'.$this->fax_extension.'/inbox/${last_fax}.tif'; + } + $database->fields['dialplan_detail_data'] = $dialplan_detail_data; + $database->fields['dialplan_detail_order'] = '040'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'hangup'; + $database->fields['dialplan_detail_data'] = ''; + $database->fields['dialplan_detail_order'] = '045'; + $database->add(); + } + } + + function delete() { + //create the database object + $database = new database; + + //start the transaction + //$count = $database->db->exec("BEGIN;"); + + //delete the fax + if (strlen($this->fax_uuid) > 0) { + $database->table = "v_fax"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'fax_uuid'; + $database->where[1]['value'] = $this->fax_uuid; + $database->where[1]['operator'] = '='; + $database->delete(); + unset($this->fax_uuid); + } + + //delete the fax + if (strlen($this->fax_uuid) == 0) { + //select the dialplan entries + $database->table = "v_fax"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'fax_uuid'; + $database->where[1]['value'] = $this->fax_uuid; + $database->where[1]['operator'] = '='; + $result = $database->find(); + foreach($result as $row) { + $this->dialplan_uuid = $row['dialplan_uuid']; + //delete the child dialplan information + $database->table = "v_dialplan_details"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'dialplan_uuid'; + $database->where[1]['value'] = $this->dialplan_uuid; + $database->where[1]['operator'] = '='; + $database->delete(); + //delete the dialplan information + $database->table = "v_dialplans"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'dialplan_uuid'; + $database->where[1]['value'] = $this->dialplan_uuid; + $database->where[1]['operator'] = '='; + $database->delete(); + } + + //delete the fax + if (strlen($this->fax_uuid) > 0) { + $database->table = "v_fax"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'fax_uuid'; + $database->where[1]['value'] = $this->fax_uuid; + $database->where[1]['operator'] = '='; + $database->delete(); + unset($this->fax_uuid); + } + + //commit the transaction + //$count = $database->db->exec("COMMIT;"); + } + } + } +/* +require_once "includes/classes/database.php"; +require_once "includes/classes/switch_fax.php"; +$fax = new switch_fax; +$fax->domain_uuid = $_SESSION["domain_uuid"]; +print_r($fax->find()); +*/ +?> \ No newline at end of file diff --git a/includes/classes/switch_ivr_menu.php b/includes/classes/switch_ivr_menu.php new file mode 100644 index 0000000000..adddbad415 --- /dev/null +++ b/includes/classes/switch_ivr_menu.php @@ -0,0 +1,621 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; + +//define the directory class + class switch_ivr_menu { + public $db; + public $domain_uuid; + public $domain_name; + public $dialplan_uuid; + public $ivr_menu_uuid; + public $ivr_menu_name; + public $ivr_menu_extension; + public $ivr_menu_greet_long; + public $ivr_menu_greet_short; + public $ivr_menu_invalid_sound; + public $ivr_menu_exit_sound; + public $ivr_menu_confirm_macro; + public $ivr_menu_confirm_key; + public $ivr_menu_tts_engine; + public $ivr_menu_tts_voice; + public $ivr_menu_confirm_attempts; + public $ivr_menu_timeout; + public $ivr_menu_exit_app; + public $ivr_menu_exit_data; + public $ivr_menu_inter_digit_timeout; + public $ivr_menu_max_failures; + public $ivr_menu_max_timeouts; + public $ivr_menu_digit_len; + public $ivr_menu_direct_dial; + public $ivr_menu_enabled; + public $ivr_menu_description; + public $ivr_menu_option_uuid; + public $ivr_menu_option_digits; + public $ivr_menu_option_action; + public $ivr_menu_option_param; + public $ivr_menu_option_order; + public $ivr_menu_option_description; + + public function __construct() { + require_once "includes/classes/database.php"; + $this->app_uuid = 'a5788e9b-58bc-bd1b-df59-fff5d51253ab'; + } + + public function __destruct() { + foreach ($this as $key => $value) { + unset($this->$key); + } + } + + public function get_domain_uuid() { + return $this->domain_uuid; + } + public function set_domain_uuid($domain_uuid){ + $this->domain_uuid = $domain_uuid; + } + + public function get_fields($table) { + //get the $apps array from the installed apps from the core and mod directories + $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php"); + $x=0; + foreach ($config_list as &$config_path) { + include($config_path); + $x++; + } + + //update the app db array add exists true or false + $sql = ''; + foreach ($apps as $x => &$app) { + foreach ($app['db'] as $y => &$row) { + if ($row['table'] == $table) { + //check if the column exists + foreach ($row['fields'] as $z => $field) { + if ($field['deprecated'] == "true") { + //skip this field + } + else { + if (is_array($field['name'])) { + $field_name = $field['name']['text']; + } + else { + $field_name = $field['name']; + } + if (strlen(field_name) > 0) { + $fields[$z]['name'] = $field_name; + } + unset($field_name); + } + } + } + } + } + return $fields; + } + + public function count() { + $database = new database; + if ($this->db) { + $database->db = $this->db; + } + $database->domain_uuid = $this->domain_uuid; + $database->table = "v_ivr_menus"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + return $database->count(); + } + + public function find() { + $database = new database; + if ($this->db) { + $database->db = $this->db; + } + $database->table = "v_ivr_menus"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + if (isset($this->ivr_menu_uuid)) { + $database->where[1]['name'] = 'ivr_menu_uuid'; + $database->where[1]['value'] = $this->ivr_menu_uuid; + $database->where[1]['operator'] = '='; + } + if (isset($this->ivr_menu_option_uuid)) { + $database->where[2]['name'] = 'ivr_menu_uuid'; + $database->where[2]['value'] = $this->ivr_menu_uuid; + $database->where[2]['operator'] = '='; + } + if (isset($this->order_by)) { + $database->order_by = $this->order_by; + } + if (isset($this->order_type)) { + $database->order_type = $this->order_type; + } + return $database->find(); + } + + public function add() { + + //add the ivr menu + if (strlen($this->ivr_menu_option_action) == 0) { + + if (strlen($this->ivr_menu_extension) > 0) { + //add the dialplan + $database = new database; + if ($this->db) { + $database->db = $this->db; + } + $database->table = "v_dialplans"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_name'] = $this->ivr_menu_name; + $database->fields['dialplan_order'] = '333'; + $database->fields['dialplan_context'] = $_SESSION['context']; + $database->fields['dialplan_enabled'] = $this->ivr_menu_enabled; + $database->fields['dialplan_description'] = $this->ivr_menu_description; + $database->fields['app_uuid'] = $this->app_uuid; + $database->add(); + + //add the dialplan details + $detail_data = '^'.$this->ivr_menu_extension.'$'; + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'condition'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'destination_number'; + $database->fields['dialplan_detail_data'] = $detail_data; + $database->fields['dialplan_detail_order'] = '005'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'answer'; + $database->fields['dialplan_detail_data'] = ''; + $database->fields['dialplan_detail_order'] = '010'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'sleep'; + $database->fields['dialplan_detail_data'] = '1000'; + $database->fields['dialplan_detail_order'] = '015'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'set'; + $database->fields['dialplan_detail_data'] = 'hangup_after_bridge=true'; + $database->fields['dialplan_detail_order'] = '020'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'ivr'; + if (count($_SESSION["domains"]) > 1) { + $database->fields['dialplan_detail_data'] = $_SESSION['domain_name'].'-'.$this->ivr_menu_name; + } + else { + $database->fields['dialplan_detail_data'] = $this->ivr_menu_name; + } + $database->fields['dialplan_detail_order'] = '025'; + $database->add(); + + if (strlen($this->ivr_menu_exit_app) > 0) { + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = $this->ivr_menu_exit_app; + $database->fields['dialplan_detail_data'] = $this->ivr_menu_exit_data; + $database->fields['dialplan_detail_order'] = '030'; + $database->add(); + } + } + + //add the ivr menu + $ivr_menu_uuid = uuid(); + $database = new database; + if ($this->db) { + $database->db = $this->db; + } + $database->table = "v_ivr_menus"; + $database->fields['domain_uuid'] = $this->domain_uuid; + if (strlen($this->ivr_menu_extension) > 0) { + $database->fields['ivr_menu_extension'] = $this->ivr_menu_extension; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + } + $database->fields['ivr_menu_uuid'] = $this->ivr_menu_uuid; + $database->fields['ivr_menu_name'] = $this->ivr_menu_name; + $database->fields['ivr_menu_greet_long'] = $this->ivr_menu_greet_long; + $database->fields['ivr_menu_greet_short'] = $this->ivr_menu_greet_short; + $database->fields['ivr_menu_invalid_sound'] = $this->ivr_menu_invalid_sound; + $database->fields['ivr_menu_exit_sound'] = $this->ivr_menu_exit_sound; + $database->fields['ivr_menu_confirm_macro'] = $this->ivr_menu_confirm_macro; + $database->fields['ivr_menu_confirm_key'] = $this->ivr_menu_confirm_key; + $database->fields['ivr_menu_tts_engine'] = $this->ivr_menu_tts_engine; + $database->fields['ivr_menu_tts_voice'] = $this->ivr_menu_tts_voice; + $database->fields['ivr_menu_confirm_attempts'] = $this->ivr_menu_confirm_attempts; + $database->fields['ivr_menu_timeout'] = $this->ivr_menu_timeout; + $database->fields['ivr_menu_exit_app'] = $this->ivr_menu_exit_app; + $database->fields['ivr_menu_exit_data'] = $this->ivr_menu_exit_data; + $database->fields['ivr_menu_inter_digit_timeout'] = $this->ivr_menu_inter_digit_timeout; + $database->fields['ivr_menu_max_failures'] = $this->ivr_menu_max_failures; + $database->fields['ivr_menu_max_timeouts'] = $this->ivr_menu_max_timeouts; + $database->fields['ivr_menu_max_timeouts'] = $this->ivr_menu_max_timeouts; + $database->fields['ivr_menu_digit_len'] = $this->ivr_menu_digit_len; + $database->fields['ivr_menu_digit_len'] = $this->ivr_menu_digit_len; + $database->fields['ivr_menu_direct_dial'] = $this->ivr_menu_direct_dial; + $database->fields['ivr_menu_direct_dial'] = $this->ivr_menu_direct_dial; + $database->fields['ivr_menu_enabled'] = $this->ivr_menu_enabled; + $database->fields['ivr_menu_description'] = $this->ivr_menu_description; + $database->add(); + } + + //add the ivr menu option + if (strlen($this->ivr_menu_option_action) > 0) { + $ivr_menu_uuid = uuid(); + $database = new database; + if ($this->db) { + $database->db = $this->db; + } + $database->table = "v_ivr_menu_options"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['ivr_menu_uuid'] = $this->ivr_menu_uuid; + $database->fields['ivr_menu_option_uuid'] = $this->ivr_menu_option_uuid; + $database->fields['ivr_menu_option_digits'] = $this->ivr_menu_option_digits; + $database->fields['ivr_menu_option_action'] = $this->ivr_menu_option_action; + $database->fields['ivr_menu_option_param'] = $this->ivr_menu_option_param; + $database->fields['ivr_menu_option_order'] = $this->ivr_menu_option_order; + $database->fields['ivr_menu_option_description'] = $this->ivr_menu_option_description; + $database->add(); + } + } + + public function update() { + + //udate the ivr menu + if (strlen($this->ivr_menu_option_action) == 0) { + //get the dialplan uuid + $database = new database; + if ($this->db) { + $database->db = $this->db; + } + $database->table = "v_ivr_menus"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'ivr_menu_uuid'; + $database->where[1]['value'] = $this->ivr_menu_uuid; + $database->where[1]['operator'] = '='; + $result = $database->find(); + foreach($result as $row) { + $this->dialplan_uuid = $row['dialplan_uuid']; + } + + //if the extension number is empty and the dialplan exists then delete the dialplan + if (strlen($this->ivr_menu_extension) == 0) { + if (strlen($this->dialplan_uuid) > 0) { + //delete dialplan entry + $database = new database; + $database->table = "v_dialplan_details"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'dialplan_uuid'; + $database->where[1]['value'] = $this->dialplan_uuid; + $database->where[1]['operator'] = '='; + $database->delete(); + + //delete the child dialplan information + $database = new database; + $database->table = "v_dialplans"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'dialplan_uuid'; + $database->where[1]['value'] = $this->dialplan_uuid; + $database->where[1]['operator'] = '='; + $database->delete(); + //update the table to remove the dialplan_uuid + $this->dialplan_uuid = ''; + } + } + + //update the ivr menu + $ivr_menu_uuid = uuid(); + $database = new database; + $database->table = "v_ivr_menus"; + $database->fields['ivr_menu_uuid'] = $this->ivr_menu_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['ivr_menu_name'] = $this->ivr_menu_name; + $database->fields['ivr_menu_extension'] = $this->ivr_menu_extension; + $database->fields['ivr_menu_greet_long'] = $this->ivr_menu_greet_long; + $database->fields['ivr_menu_greet_short'] = $this->ivr_menu_greet_short; + $database->fields['ivr_menu_invalid_sound'] = $this->ivr_menu_invalid_sound; + $database->fields['ivr_menu_exit_sound'] = $this->ivr_menu_exit_sound; + $database->fields['ivr_menu_confirm_macro'] = $this->ivr_menu_confirm_macro; + $database->fields['ivr_menu_confirm_key'] = $this->ivr_menu_confirm_key; + $database->fields['ivr_menu_tts_engine'] = $this->ivr_menu_tts_engine; + $database->fields['ivr_menu_tts_voice'] = $this->ivr_menu_tts_voice; + $database->fields['ivr_menu_confirm_attempts'] = $this->ivr_menu_confirm_attempts; + $database->fields['ivr_menu_timeout'] = $this->ivr_menu_timeout; + $database->fields['ivr_menu_exit_app'] = $this->ivr_menu_exit_app; + $database->fields['ivr_menu_exit_data'] = $this->ivr_menu_exit_data; + $database->fields['ivr_menu_inter_digit_timeout'] = $this->ivr_menu_inter_digit_timeout; + $database->fields['ivr_menu_max_failures'] = $this->ivr_menu_max_failures; + $database->fields['ivr_menu_max_timeouts'] = $this->ivr_menu_max_timeouts; + $database->fields['ivr_menu_max_timeouts'] = $this->ivr_menu_max_timeouts; + $database->fields['ivr_menu_digit_len'] = $this->ivr_menu_digit_len; + $database->fields['ivr_menu_digit_len'] = $this->ivr_menu_digit_len; + $database->fields['ivr_menu_direct_dial'] = $this->ivr_menu_direct_dial; + $database->fields['ivr_menu_direct_dial'] = $this->ivr_menu_direct_dial; + $database->fields['ivr_menu_enabled'] = $this->ivr_menu_enabled; + $database->fields['ivr_menu_description'] = $this->ivr_menu_description; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'ivr_menu_uuid'; + $database->where[1]['value'] = $this->ivr_menu_uuid; + $database->where[1]['operator'] = '='; + $database->update(); + + if (strlen($this->ivr_menu_extension) > 0) { + //update the dialplan + $database = new database; + $database->table = "v_dialplans"; + $database->fields['dialplan_name'] = $this->ivr_menu_name; + $database->fields['dialplan_order'] = '333'; + $database->fields['dialplan_context'] = $_SESSION['context']; + $database->fields['dialplan_enabled'] = $this->ivr_menu_enabled; + $database->fields['dialplan_description'] = $this->ivr_menu_description; + $database->fields['app_uuid'] = $this->app_uuid; + if ($this->dialplan_uuid) { + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'dialplan_uuid'; + $database->where[1]['value'] = $this->dialplan_uuid; + $database->where[1]['operator'] = '='; + $database->update(); + } + else { + $this->dialplan_uuid = uuid(); + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->add(); + } + + //delete the old dialplan details to prepare for new details + $database = new database; + $database->table = "v_dialplan_details"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'dialplan_uuid'; + $database->where[1]['value'] = $this->dialplan_uuid; + $database->where[1]['operator'] = '='; + $database->delete(); + + //add the dialplan details + $detail_data = '^'.$this->ivr_menu_extension.'$'; + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'condition'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'destination_number'; + $database->fields['dialplan_detail_data'] = $detail_data; + $database->fields['dialplan_detail_order'] = '005'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'answer'; + $database->fields['dialplan_detail_data'] = ''; + $database->fields['dialplan_detail_order'] = '010'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'sleep'; + $database->fields['dialplan_detail_data'] = '1000'; + $database->fields['dialplan_detail_order'] = '015'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'set'; + $database->fields['dialplan_detail_data'] = 'hangup_after_bridge=true'; + $database->fields['dialplan_detail_order'] = '020'; + $database->add(); + + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = 'ivr'; + if (count($_SESSION["domains"]) > 1) { + $database->fields['dialplan_detail_data'] = $_SESSION['domain_name'].'-'.$this->ivr_menu_name; + } + else { + $database->fields['dialplan_detail_data'] = $this->ivr_menu_name; + } + $database->fields['dialplan_detail_order'] = '025'; + $database->add(); + + if (strlen($this->ivr_menu_exit_app) > 0) { + $database->table = "v_dialplan_details"; + $database->fields['domain_uuid'] = $this->domain_uuid; + $database->fields['dialplan_uuid'] = $this->dialplan_uuid; + $database->fields['dialplan_detail_uuid'] = uuid(); + $database->fields['dialplan_detail_tag'] = 'action'; //condition, action, antiaction + $database->fields['dialplan_detail_type'] = $this->ivr_menu_exit_app; + $database->fields['dialplan_detail_data'] = $this->ivr_menu_exit_data; + $database->fields['dialplan_detail_order'] = '030'; + $database->add(); + } + } + } + + //update the ivr menu option + if (strlen($this->ivr_menu_option_action) > 0) { + $database = new database; + $database->table = "v_ivr_menu_options"; + $database->fields['ivr_menu_option_digits'] = $this->ivr_menu_option_digits; + $database->fields['ivr_menu_option_action'] = $this->ivr_menu_option_action; + $database->fields['ivr_menu_option_param'] = $this->ivr_menu_option_param; + $database->fields['ivr_menu_option_order'] = $this->ivr_menu_option_order; + $database->fields['ivr_menu_option_description'] = $this->ivr_menu_option_description; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'ivr_menu_uuid'; + $database->where[1]['value'] = $this->ivr_menu_uuid; + $database->where[1]['operator'] = '='; + $database->where[2]['name'] = 'ivr_menu_option_uuid'; + $database->where[2]['value'] = $this->ivr_menu_option_uuid; + $database->where[2]['operator'] = '='; + $database->update(); + } + } + + function delete() { + //create the database object + $database = new database; + if ($this->db) { + $database->db = $this->db; + } + //start the transaction + //$count = $database->db->exec("BEGIN;"); + + //delete the ivr menu option + if (strlen($this->ivr_menu_option_uuid) > 0) { + $database->table = "v_ivr_menu_options"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'ivr_menu_option_uuid'; + $database->where[1]['value'] = $this->ivr_menu_option_uuid; + $database->where[1]['operator'] = '='; + $database->delete(); + unset($this->ivr_menu_option_uuid); + } + + //delete the ivr menu + if (strlen($this->ivr_menu_option_uuid) == 0) { + //select the dialplan entries + $database->table = "v_ivr_menus"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'ivr_menu_uuid'; + $database->where[1]['value'] = $this->ivr_menu_uuid; + $database->where[1]['operator'] = '='; + $result = $database->find(); + foreach($result as $row) { + $this->dialplan_uuid = $row['dialplan_uuid']; + //delete the child dialplan information + $database->table = "v_dialplan_details"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'dialplan_uuid'; + $database->where[1]['value'] = $this->dialplan_uuid; + $database->where[1]['operator'] = '='; + $database->delete(); + //delete the dialplan information + $database->table = "v_dialplans"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'dialplan_uuid'; + $database->where[1]['value'] = $this->dialplan_uuid; + $database->where[1]['operator'] = '='; + $database->delete(); + } + + //delete child data + $database->table = "v_ivr_menu_options"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'ivr_menu_uuid'; + $database->where[1]['value'] = $this->ivr_menu_uuid; + $database->where[1]['operator'] = '='; + $database->delete(); + + //delete parent data + $database->table = "v_ivr_menus"; + $database->where[0]['name'] = 'domain_uuid'; + $database->where[0]['value'] = $this->domain_uuid; + $database->where[0]['operator'] = '='; + $database->where[1]['name'] = 'ivr_menu_uuid'; + $database->where[1]['value'] = $this->ivr_menu_uuid; + $database->where[1]['operator'] = '='; + $database->delete(); + + //commit the transaction + //$count = $database->db->exec("COMMIT;"); + } + } + + function get_xml(){ + return $xml; + } + + function save_xml($xml){ + return $xml; + } + + function xml_save_all() { + } + } + +?> \ No newline at end of file diff --git a/includes/classes/switch_modules.php b/includes/classes/switch_modules.php new file mode 100644 index 0000000000..0396740487 --- /dev/null +++ b/includes/classes/switch_modules.php @@ -0,0 +1,766 @@ + + Copyright (C) 2010 + All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; + +//add the database structure +/* +require_once "includes/classes/modules.php"; +$mod = new switch_modules; +$mod->dir = $_SESSION['switch']['mod']['dir']; +echo $mod->dir."\n"; +//database connection object + $mod->db = $db; +//get modules from the database + $mod->get_modules(); +//module exists + if ($mod->exists("mod_lua")) { + echo "exists true\n"; + } + else { + echo "exists false\n"; + } +//module active + if ($mod->active("mod_lua")) { + echo "active true\n"; + } + else { + echo "active false\n"; + } +//synch + $mod->synch(); + echo $mod->msg; +//show module info + $result = $mod->info("mod_lua"); + echo "
\n";
+	print_r($result);
+	echo "
\n"; +//list modules + //$result = $mod->modules + //echo "
\n";
+	//print_r($result);
+	//echo "
\n"; +*/ + +//define the directory class + class switch_modules { + public $db; + public $dir; + public $fp; + public $modules; + public $msg; + + // get the additional information about a specific module + public function info($name) { + $module_label = substr($name, 4); + $module_label = ucwords(str_replace("_", " ", $module_label)); + $mod['module_label'] = $module_label; + $mod['module_name'] = $name; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + $mod['module_description'] = ''; + switch ($name) { + case "mod_amr": + $mod['module_label'] = 'AMR'; + $mod['module_category'] = 'Codecs'; + $mod['module_description'] = 'AMR codec.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_avmd": + $mod['module_label'] = 'AVMD'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Advanced voicemail beep detection.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_blacklist": + $mod['module_label'] = 'Blacklist'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Blacklist.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_bv": + $mod['module_label'] = 'BV'; + $mod['module_category'] = 'Codecs'; + $mod['module_description'] = 'BroadVoice16 and BroadVoice32 audio codecs.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_cdr_csv": + $mod['module_label'] = 'CDR CSV'; + $mod['module_category'] = 'Event Handlers'; + $mod['module_description'] = 'CSV call detail record handler.'; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + break; + case "mod_cdr_sqlite": + $mod['module_label'] = 'CDR SQLite'; + $mod['module_category'] = 'Event Handlers'; + $mod['module_description'] = 'SQLite call detail record handler.'; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + break; + case "mod_callcenter": + $mod['module_label'] = 'Call Center'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Call queuing with agents and tiers for call centers.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_cepstral": + $mod['module_label'] = 'Cepstral'; + $mod['module_category'] = 'Speech Recognition / Text to Speech'; + $mod['module_description'] = 'Text to Speech engine.'; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + break; + case "mod_cidlookup": + $mod['module_label'] = 'CID Lookup'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Lookup caller id info.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_cluechoo": + $mod['module_label'] = 'Cluechoo'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'A framework demo module.'; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + break; + case "mod_commands": + $mod['module_label'] = 'Commands'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'API interface commands.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_conference": + $mod['module_label'] = 'Conference'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Conference room module.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_console": + $mod['module_label'] = 'Console'; + $mod['module_category'] = 'Loggers'; + $mod['module_description'] = 'Send logs to the console.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_curl": + $mod['module_label'] = 'CURL'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Allows scripts to make HTTP requests and return responses in plain text or JSON.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_db": + $mod['module_label'] = 'DB'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Database key / value storage functionality, dialing and limit backend.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_dialplan_asterisk": + $mod['module_label'] = 'Dialplan Asterisk'; + $mod['module_category'] = 'Dialplan Interfaces'; + $mod['module_description'] = 'Allows Asterisk dialplans.'; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + break; + case "mod_dialplan_xml": + $mod['module_label'] = 'Dialplan XML'; + $mod['module_category'] = 'Dialplan Interfaces'; + $mod['module_description'] = 'Provides dialplan functionality in XML.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_directory": + $mod['module_label'] = 'Directory'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Dial by name directory.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_distributor": + $mod['module_label'] = 'Distributor'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Round robin call distribution.'; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + break; + case "mod_dptools": + $mod['module_label'] = 'Dialplan Plan Tools'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Provides a number of apps and utilities for the dialplan.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_enum": + $mod['module_label'] = 'ENUM'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Route PSTN numbers over internet according to ENUM servers, such as e164.org.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_esf": + $mod['module_label'] = 'ESF'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Holds the multi cast paging application for SIP.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_event_socket": + $mod['module_label'] = 'Event Socket'; + $mod['module_category'] = 'Event Handlers'; + $mod['module_description'] = 'Sends events via a single socket.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_expr": + $mod['module_label'] = 'Expr'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Expression evaluation library.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_fifo": + $mod['module_label'] = 'FIFO'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'FIFO provides custom call queues including call park.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_flite": + $mod['module_label'] = 'Flite'; + $mod['module_category'] = 'Speech Recognition / Text to Speech'; + $mod['module_description'] = 'Text to Speech engine.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_fsv": + $mod['module_label'] = 'FSV'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Video application (Recording and playback).'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_g723_1": + $mod['module_label'] = 'G.723.1'; + $mod['module_category'] = 'Codecs'; + $mod['module_description'] = 'G.723.1 codec.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_g729": + $mod['module_label'] = 'G.729'; + $mod['module_category'] = 'Codecs'; + $mod['module_description'] = 'G729 codec supports passthrough mode'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_h26x": + $mod['module_label'] = 'H26x'; + $mod['module_category'] = 'Codecs'; + $mod['module_description'] = 'Video codecs'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_hash": + $mod['module_label'] = 'Hash'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Resource limitation.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_httapi": + $mod['module_label'] = 'HT-TAPI'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'HT-TAPI Hypertext Telephony API'; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + break; + case "mod_http_cache": + $mod['module_label'] = 'HTTP Cache'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'HTTP GET with caching'; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + break; + case "mod_ilbc": + $mod['module_label'] = 'iLBC'; + $mod['module_category'] = 'Codecs'; + $mod['module_description'] = 'iLBC codec.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_ladspa": + $mod['module_label'] = 'Ladspa'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Auto-tune calls.'; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + break; + case "mod_lcr": + $mod['module_label'] = 'LCR'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Least cost routing.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_local_stream": + $mod['module_label'] = 'Local Stream'; + $mod['module_category'] = 'Streams / Files'; + $mod['module_description'] = 'For local streams (play all the files in a directory).'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_logfile": + $mod['module_label'] = 'Log File'; + $mod['module_category'] = 'Loggers'; + $mod['module_description'] = 'Send logs to the local file system.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_loopback": + $mod['module_label'] = 'Loopback'; + $mod['module_category'] = 'Endpoints'; + $mod['module_description'] = 'A loopback channel driver to make an outbound call as an inbound call.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_lua": + $mod['module_label'] = 'Lua'; + $mod['module_category'] = 'Languages'; + $mod['module_description'] = 'Lua script.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_memcache": + $mod['module_label'] = 'Memcached'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'API for memcached.'; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + break; + case "mod_native_file": + $mod['module_label'] = 'Native File'; + $mod['module_category'] = 'File Format Interfaces'; + $mod['module_description'] = 'File interface for codec specific file formats.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_nibblebill": + $mod['module_label'] = 'Nibblebill'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Billing module.'; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + break; + case "mod_opus": + $mod['module_label'] = 'Opus'; + $mod['module_category'] = 'Codecs'; + $mod['module_description'] = 'OPUS ultra-low delay audio codec'; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + break; + case "mod_park": + $mod['module_label'] = 'Park'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Park Calls.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_pocketsphinx": + $mod['module_label'] = 'PocketSphinx'; + $mod['module_category'] = 'Speech Recognition / Text to Speech'; + $mod['module_description'] = 'Speech Recognition.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_rtmp": + $mod['module_label'] = 'RTMP'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Real Time Media Protocol'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_say_de": + $mod['module_label'] = 'German'; + $mod['module_category'] = 'Say'; + $mod['module_description'] = ''; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_say_en": + $mod['module_label'] = 'English'; + $mod['module_category'] = 'Say'; + $mod['module_description'] = ''; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_say_es": + $mod['module_label'] = 'Spanish'; + $mod['module_category'] = 'Say'; + $mod['module_description'] = ''; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_say_fr": + $mod['module_label'] = 'French'; + $mod['module_category'] = 'Say'; + $mod['module_description'] = ''; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_say_he": + $mod['module_label'] = 'Hebrew'; + $mod['module_category'] = 'Say'; + $mod['module_description'] = ''; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_say_hu": + $mod['module_label'] = 'Hungarian'; + $mod['module_category'] = 'Say'; + $mod['module_description'] = ''; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_say_it": + $mod['module_label'] = 'Italian'; + $mod['module_category'] = 'Say'; + $mod['module_description'] = ''; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_say_nl": + $mod['module_label'] = 'Dutch'; + $mod['module_category'] = 'Say'; + $mod['module_description'] = ''; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_say_pt": + $mod['module_label'] = 'Portuguese'; + $mod['module_category'] = 'Say'; + $mod['module_description'] = ''; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_say_ru": + $mod['module_label'] = 'Russian'; + $mod['module_category'] = 'Say'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_say_th": + $mod['module_label'] = 'Thai'; + $mod['module_category'] = 'Say'; + $mod['module_description'] = ''; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_say_zh": + $mod['module_label'] = 'Chinese'; + $mod['module_category'] = 'Say'; + $mod['module_description'] = ''; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_shout": + $mod['module_label'] = 'Shout'; + $mod['module_category'] = 'Streams / Files'; + $mod['module_description'] = 'MP3 files and shoutcast streams.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_siren": + $mod['module_label'] = 'Siren'; + $mod['module_category'] = 'Codecs'; + $mod['module_description'] = 'Siren codec'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_sms": + $mod['module_label'] = 'SMS'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Chat messages'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_sndfile": + $mod['module_label'] = 'Sound File'; + $mod['module_category'] = 'File Format Interfaces'; + $mod['module_description'] = 'Multi-format file format transcoder (WAV, etc).'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_sofia": + $mod['module_label'] = 'Sofia'; + $mod['module_category'] = 'Endpoints'; + $mod['module_description'] = 'SIP module.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_spandsp": + $mod['module_label'] = 'SpanDSP'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'FAX provides fax send and receive.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_speex": + $mod['module_label'] = 'Speex'; + $mod['module_category'] = 'Codecs'; + $mod['module_description'] = 'Speex codec.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_spidermonkey": + $mod['module_label'] = 'SpiderMonkey'; + $mod['module_category'] = 'Languages'; + $mod['module_description'] = 'JavaScript support.'; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + break; + case "mod_spidermonkey_core_db": + $mod['module_label'] = 'SpiderMonkey Core DB'; + $mod['module_category'] = 'Languages'; + $mod['module_description'] = 'Javascript support for SQLite.'; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + break; + case "mod_spidermonkey_curl": + $mod['module_label'] = 'SpiderMonkey Curl'; + $mod['module_category'] = 'Languages'; + $mod['module_description'] = 'Javascript curl support.'; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + break; + case "mod_spidermonkey_socket": + $mod['module_label'] = 'SpiderMonkey Socket'; + $mod['module_category'] = 'Languages'; + $mod['module_description'] = 'Javascript socket support.'; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + break; + case "mod_spidermonkey_teletone": + $mod['module_label'] = 'SpiderMonkey Teletone'; + $mod['module_category'] = 'Languages'; + $mod['module_description'] = 'Javascript teletone support.'; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + break; + case "mod_syslog": + $mod['module_label'] = 'Syslog'; + $mod['module_category'] = 'Loggers'; + $mod['module_description'] = 'Send logs to a remote syslog server.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_tone_stream": + $mod['module_label'] = 'Tone Stream'; + $mod['module_category'] = 'Streams / Files'; + $mod['module_description'] = 'Generate tone streams.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_tts_commandline": + $mod['module_label'] = 'TTS Commandline'; + $mod['module_category'] = 'Speech Recognition / Text to Speech'; + $mod['module_description'] = 'Commandline text to speech engine.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_unimrcp": + $mod['module_label'] = 'MRCP'; + $mod['module_category'] = 'Speech Recognition / Text to Speech'; + $mod['module_description'] = 'Media Resource Control Protocol.'; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + break; + case "mod_valet_parking": + $mod['module_label'] = 'Valet Parking'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Call parking'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_voicemail": + $mod['module_label'] = 'Voicemail'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Full featured voicemail module.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_voicemail_ivr": + $mod['module_label'] = 'Voicemail IVR'; + $mod['module_category'] = 'Applications'; + $mod['module_description'] = 'Voicemail IVR interface.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_xml_cdr": + $mod['module_label'] = 'XML CDR'; + $mod['module_category'] = 'XML Interfaces'; + $mod['module_description'] = 'XML based call detail record handler.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + case "mod_xml_curl": + $mod['module_label'] = 'XML Curl'; + $mod['module_category'] = 'XML Interfaces'; + $mod['module_description'] = 'Request XML config files dynamically.'; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + break; + case "mod_xml_rpc": + $mod['module_label'] = 'XML RPC'; + $mod['module_category'] = 'XML Interfaces'; + $mod['module_description'] = 'XML Remote Procedure Calls. Issue commands from your web application.'; + $mod['module_enabled'] = 'true'; + $mod['module_default_enabled'] = 'true'; + break; + default: + $mod['module_category'] = 'Auto'; + $mod['module_enabled'] = 'false'; + $mod['module_default_enabled'] = 'false'; + } + return $mod; + } + + //check to see if the module exists in the array + public function exists($name) { + //set the default + $result = false; + //look for the module + foreach ($this->modules as &$row) { + if ($row['module_name'] == $name) { + $result = true; + break; + } + } + //return the result + return $result; + } + + //check the status of the module + public function active($name) { + if (!$this->fp) { + $this->fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + } + if ($this->fp) { + $cmd = "api module_exists ".$name; + $response = trim(event_socket_request($this->fp, $cmd)); + if ($response == "true") { + return true; + } + else { + return false; + } + } + else { + return false; + } + } + + //get the list of modules + public function get_modules() { + $sql = " select * from v_modules "; + $sql .= "order by module_category, module_label"; + $prep_statement = $this->db->prepare($sql); + $prep_statement->execute(); + $this->modules = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + unset ($prep_statement, $sql); + } + + //add missing modules for more module info see http://wiki.freeswitch.com/wiki/Modules + public function synch() { + if ($handle = opendir($this->dir)) { + $modules_new = ''; + $module_found = false; + while (false !== ($file = readdir($handle))) { + if ($file != "." && $file != "..") { + if (substr($file, -3) == ".so" || substr($file, -4) == ".dll") { + if (substr($file, -3) == ".so") { + $name = substr($file, 0, -3); + } + if (substr($file, -4) == ".dll") { + $name = substr($file, 0, -4); + } + if (!$this->exists($name)) { + //set module found to true + $module_found = true; + //get the module array + $mod = $this->info($name); + //append the module label + $modules_new .= "
  • ".$mod['module_label']."
  • \n"; + //insert the data + $module_uuid = uuid(); + $sql = "insert into v_modules "; + $sql .= "("; + $sql .= "module_uuid, "; + $sql .= "module_label, "; + $sql .= "module_name, "; + $sql .= "module_description, "; + $sql .= "module_category, "; + $sql .= "module_enabled, "; + $sql .= "module_default_enabled "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$module_uuid."', "; + $sql .= "'".$mod['module_label']."', "; + $sql .= "'".$mod['module_name']."', "; + $sql .= "'".$mod['module_description']."', "; + $sql .= "'".$mod['module_category']."', "; + $sql .= "'".$mod['module_enabled']."', "; + $sql .= "'".$mod['module_default_enabled']."' "; + $sql .= ")"; + $this->db->exec($sql); + unset($sql); + } + } + } + } + closedir($handle); + if ($module_found) { + //save_module_xml(); + $msg = "Added New Modules:
    \n"; + $msg .= "
      \n"; + $msg .= $modules_new; + $msg .= "
    \n"; + $this->msg = $msg; + } + } + } + } //class + +?> \ No newline at end of file diff --git a/includes/cmd.php b/includes/cmd.php new file mode 100644 index 0000000000..b02e3fba9f --- /dev/null +++ b/includes/cmd.php @@ -0,0 +1,53 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; +if (if_group("admin") || if_group("superadmin")) { + //access granted +} +else { + echo "access denied"; + exit; +} + +$cmd = $_GET['cmd']; +$rdr = $_GET['rdr']; + +$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); +if ($fp) { + $response = event_socket_request($fp, $cmd); + fclose($fp); +} + +if ($rdr == "false") { + //redirect false + echo $response; +} +else { + header("Location: v_status.php?savemsg=".urlencode($response)); +} +?> \ No newline at end of file diff --git a/includes/config.php.dist b/includes/config.php.dist new file mode 100644 index 0000000000..748d2be866 --- /dev/null +++ b/includes/config.php.dist @@ -0,0 +1,62 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//----------------------------------------------------- +// settings: +//----------------------------------------------------- + + //set the database type + $db_type = 'sqlite'; //sqlite, mysql, pgsql, others with a manually created PDO connection + + //sqlite: the dbfilename and db_file_path are automatically assigned however the values can be overidden by setting the values here. + $dbfilename = 'fusionpbx.db'; //host name/ip address + '.db' is the default database filename + $db_file_path = '\fusionpbx\Program\www\localhost\fusionpbx\secure'; //the path is determined by a php variable + + //mysql: database connection information + //$db_host = ''; + //$db_port = ''; + //$db_name = ''; + //$db_username = ''; + //$db_password = ''; + + //pgsql: database connection information + //$db_host = ''; //set the host only if the database is not local + //$db_port = ''; + //$db_name = ''; + //$db_username = ''; + //$db_password = ''; + + //set the host ip or name that the will be used to communicate with the phone system + $host = '127.0.0.1'; + + //show errors + ini_set('display_errors', '1'); + //error_reporting (E_ALL); // Report everything + //error_reporting (E_ALL ^ E_NOTICE); // Report everything + error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ); //hide notices and warnings + + +?> diff --git a/includes/directory.php b/includes/directory.php new file mode 100644 index 0000000000..aa5d4992ba --- /dev/null +++ b/includes/directory.php @@ -0,0 +1,278 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; + +if (!function_exists('phone_letter_to_number')) { + function phone_letter_to_number($tmp) { + if ($tmp == "a" | $tmp == "b" | $tmp == "c") { return 2; } + if ($tmp == "d" | $tmp == "e" | $tmp == "f") { return 3; } + if ($tmp == "g" | $tmp == "h" | $tmp == "i") { return 4; } + if ($tmp == "j" | $tmp == "k" | $tmp == "l") { return 5; } + if ($tmp == "m" | $tmp == "n" | $tmp == "o") { return 6; } + if ($tmp == "p" | $tmp == "q" | $tmp == "r" | $tmp == "s") { return 7; } + if ($tmp == "t" | $tmp == "u" | $tmp == "v") { return 8; } + if ($tmp == "w" | $tmp == "x" | $tmp == "y" | $tmp == "z") { return 9; } + } +} + +if (!function_exists('sync_directory')) { + function sync_directory() { + + global $domain_uuid, $db; + $settings_array = v_settings(); + foreach($settings_array as $name => $value) { + $$name = $value; + } + + $tmp = "include(\"config.js\");\n"; + $tmp .= "//var sounds_dir\n"; + $tmp .= "var admin_pin = \"\";\n"; + $tmp .= "var search_type = \"\";\n"; + $tmp .= "//var tmp_dir\n"; + $tmp .= "var digitmaxlength = 0;\n"; + $tmp .= "var timeoutpin = 5000;\n"; + $tmp .= "var timeouttransfer = 5000;\n"; + $tmp .= "\n"; + $tmp .= "var dtmf = new Object( );\n"; + $tmp .= "dtmf.digits = \"\";\n"; + $tmp .= "\n"; + $tmp .= "function mycb( session, type, obj, arg ) {\n"; + $tmp .= " try {\n"; + $tmp .= " if ( type == \"dtmf\" ) {\n"; + $tmp .= " console_log( \"info\", \"digit: \"+obj.digit+\"\\n\" );\n"; + $tmp .= " if ( obj.digit == \"#\" ) {\n"; + $tmp .= " //console_log( \"info\", \"detected pound sign.\\n\" );\n"; + $tmp .= " exit = true;\n"; + $tmp .= " return( false );\n"; + $tmp .= " }\n"; + $tmp .= " if ( obj.digit == \"*\" ) {\n"; + $tmp .= " //console_log( \"info\", \"detected pound sign.\\n\" );\n"; + $tmp .= " exit = true;\n"; + $tmp .= " return( false );\n"; + $tmp .= " }\n"; + $tmp .= " dtmf.digits += obj.digit;\n"; + $tmp .= " if ( dtmf.digits.length >= digitmaxlength ) {\n"; + $tmp .= " exit = true;\n"; + $tmp .= " return( false );\n"; + $tmp .= " }\n"; + $tmp .= " }\n"; + $tmp .= " } catch (e) {\n"; + $tmp .= " console_log( \"err\", e+\"\\n\" );\n"; + $tmp .= " }\n"; + $tmp .= " return( true );\n"; + $tmp .= "} //end function mycb\n"; + $tmp .= "\n"; + $tmp .= "function directory_search(search_type) {\n"; + $tmp .= "\n"; + $tmp .= " digitmaxlength = 3;\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-enter_person.wav\");\n"; + $tmp .= " if (search_type == \"last_name\") {\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-last_name.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-to_search_by.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-first_name.wav\", mycb, \"dtmf\");\n"; + $tmp .= " }\n"; + $tmp .= " if (search_type == \"first_name\") {\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-first_name.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-to_search_by.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-last_name.wav\", mycb, \"dtmf\");\n"; + $tmp .= " }\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-press.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.execute(\"say\", \"en name_spelled iterated 1\");\n"; + $tmp .= " session.collectInput( mycb, dtmf, timeoutpin );\n"; + $tmp .= " var dtmf_search = dtmf.digits;\n"; + $tmp .= " //console_log( \"info\", \"--\" + dtmf.digits + \"--\\n\" );\n"; + $tmp .= " if (dtmf_search == \"1\") {\n"; + $tmp .= " //console_log( \"info\", \"press 1 detected: \" + dtmf.digits + \"\\n\" );\n"; + $tmp .= " //console_log( \"info\", \"press 1 detected: \" + search_type + \"\\n\" );\n"; + $tmp .= " if (search_type == \"last_name\") {\n"; + $tmp .= " //console_log( \"info\", \"press 1 detected last_name: \" + search_type + \"\\n\" );\n"; + $tmp .= " search_type = \"first_name\";\n"; + $tmp .= " }\n"; + $tmp .= " else {\n"; + $tmp .= " //console_log( \"info\", \"press 1 detected first_name: \" + search_type + \"\\n\" );\n"; + $tmp .= " search_type = \"last_name\";\n"; + $tmp .= " }\n"; + $tmp .= " dtmf_search = \"\";\n"; + $tmp .= " dtmf.digits = \"\";\n"; + $tmp .= " directory_search(search_type);\n"; + $tmp .= " return;\n"; + $tmp .= " }\n"; + $tmp .= " console_log( \"info\", \"first 3 letters of first or last name: \" + dtmf.digits + \"\\n\" );\n"; + $tmp .= "\n"; + $tmp .= " //session.execute(\"say\", \"en name_spelled pronounced mark\");\n"; + $tmp .= " //\n"; + $tmp .= " //session.execute(\"say\", \"en number iterated 12345\");\n"; + $tmp .= " //session.execute(\"say\", \"en number pronounced 1001\");\n"; + $tmp .= " //session.execute(\"say\", \"en short_date_time pronounced [timestamp]\");\n"; + $tmp .= " //session.execute(\"say\", \"en CURRENT_TIME pronounced CURRENT_TIME\");\n"; + $tmp .= " //session.execute(\"say\", \"en CURRENT_DATE pronounced CURRENT_DATE\");\n"; + $tmp .= " //session.execute(\"say\", \"en CURRENT_DATE_TIME pronounced CURRENT_DATE_TIME\");\n"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= " //take each name and convert it to the equivalent number in php when this file is generated\n"; + $tmp .= " //then test each number see if it matches the user dtmf search keys\n"; + $tmp .= "\n"; + $tmp .= " var result_array = new Array();\n"; + $tmp .= " var x = 0;\n"; + + //get a list of extensions and the users assigned to them + $sql = ""; + $sql .= " select * from v_extensions "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $x = 0; + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + //print_r($row); + $extension = $row["extension"]; + $effective_caller_id_name = $row["effective_caller_id_name"]; + //$user_list = $row["user_list"]; + //$user_list = trim($user_list, "|"); + //echo $user_list."
    \n"; + //$username_array = explode ("|", $user_list); + //print_r($username_array); + foreach ($username_array as &$username) { + if (strlen($username) > 0) { + $sql = ""; + $sql .= "select * from v_users "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and username = '$username' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $tmp_result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($tmp_result as &$row_tmp) { + $user_first_name = $row_tmp["user_first_name"]; + $user_last_name = $row_tmp["user_last_name"]; + if ($user_first_name == "na") { $user_first_name = ""; } + if ($user_last_name == "na") { $user_last_name = ""; } + if (strlen($user_first_name.$user_last_name) == 0) { + $name_array = explode (" ", $effective_caller_id_name); + $user_first_name = $name_array[0]; + if (count($name_array) > 1) { + $user_last_name = $name_array[1]; + } + } + + break; //limit to 1 row + } + $f1 = phone_letter_to_number(substr($user_first_name, 0,1)); + $f2 = phone_letter_to_number(substr($user_first_name, 1,1)); + $f3 = phone_letter_to_number(substr($user_first_name, 2,1)); + + $l1 = phone_letter_to_number(substr($user_last_name, 0,1)); + $l2 = phone_letter_to_number(substr($user_last_name, 1,1)); + $l3 = phone_letter_to_number(substr($user_last_name, 2,1)); + + //echo $sql." extension: $extension firstname $user_first_name lastname $user_last_name $tmp
    "; + + $tmp .= " if (search_type == \"first_name\" && dtmf_search == \"".$f1.$f2.$f3."\" || search_type == \"last_name\" && dtmf_search == \"".$l1.$l2.$l3."\") {\n"; + $tmp .= " result_array[x]=new Array()\n"; + $tmp .= " result_array[x]['first_name'] =\"".$user_first_name."\";\n"; + $tmp .= " result_array[x]['last_name'] =\"".$user_last_name."\";\n"; + $tmp .= " result_array[x]['extension'] = \"".$extension."\";\n"; + $tmp .= " //console_log( \"info\", \"found: ".$user_first_name." ".$user_last_name."\\n\" );\n"; + $tmp .= " x++;\n"; + $tmp .= " }\n"; + } + } + } + unset ($prep_statement); + + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= " //say the number of results that matched\n"; + $tmp .= " \$result_count = result_array.length;\n"; + $tmp .= " session.execute(\"say\", \"en number iterated \"+\$result_count);\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-result_match.wav\", mycb, \"dtmf\");\n"; + $tmp .= "\n"; + $tmp .= " //clear values\n"; + $tmp .= " dtmf_search = 0;\n"; + $tmp .= " dtmf.digits = '';\n"; + $tmp .= "\n"; + $tmp .= " if (\$result_count == 0) {\n"; + $tmp .= " //session.execute(\"transfer\", \"*347 XML default\");\n"; + $tmp .= " directory_search(search_type);\n"; + $tmp .= " return;\n"; + $tmp .= " }\n"; + $tmp .= "\n"; + $tmp .= " session.execute(\"set\", \"tts_engine=flite\");\n"; + $tmp .= " session.execute(\"set\", \"tts_voice=rms\"); //rms //kal //awb //slt\n"; + $tmp .= " session.execute(\"set\", \"playback_terminators=#\");\n"; + $tmp .= " //session.speak(\"flite\",\"kal\",\"Thanks for.. calling\");\n"; + $tmp .= "\n"; + $tmp .= " i=1;\n"; + $tmp .= " for ( i in result_array ) {\n"; + $tmp .= "\n"; + $tmp .= " //say first name and last name is at extension 1001\n"; + $tmp .= " //session.execute(\"speak\", result_array[i]['first_name']);\n"; + $tmp .= " //session.execute(\"speak\", result_array[i]['last_name']);\n"; + $tmp .= " session.execute(\"say\", \"en name_spelled pronounced \"+result_array[i]['first_name']);\n"; + $tmp .= " session.execute(\"sleep\", \"500\");\n"; + $tmp .= " session.execute(\"say\", \"en name_spelled pronounced \"+result_array[i]['last_name']);\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-at_extension.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.execute(\"say\", \"en number pronounced \"+result_array[i]['extension']);\n"; + $tmp .= "\n"; + $tmp .= " //to select this entry press 1\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-to_select_entry.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-press.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.execute(\"say\", \"en number iterated 1\");\n"; + $tmp .= "\n"; + $tmp .= " //console_log( \"info\", \"first name: \" + result_array[i]['first_name'] + \"\\n\" );\n"; + $tmp .= " //console_log( \"info\", \"last name: \" + result_array[i]['last_name'] + \"\\n\" );\n"; + $tmp .= " //console_log( \"info\", \"extension: \" + result_array[i]['extension'] + \"\\n\" );\n"; + $tmp .= "\n"; + $tmp .= " //if 1 is pressed then transfer the call\n"; + $tmp .= " dtmf.digits = session.getDigits(1, \"#\", 3000);\n"; + $tmp .= " if (dtmf.digits == \"1\") {\n"; + $tmp .= " console_log( \"info\", \"directory: call transfered to: \" + result_array[i]['extension'] + \"\\n\" );\n"; + $tmp .= " session.execute(\"transfer\", result_array[i]['extension']+\" XML default\");\n"; + $tmp .= " }\n"; + $tmp .= "\n"; + $tmp .= " }\n"; + $tmp .= "}\n"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= "if ( session.ready() ) {\n"; + $tmp .= " session.answer();\n"; + $tmp .= " search_type = \"last_name\";\n"; + $tmp .= " directory_search(search_type);\n"; + $tmp .= " session.hangup(\"NORMAL_CLEARING\");\n"; + $tmp .= "}\n"; + $tmp .= ""; + + //write the file + $fout = fopen($_SESSION['switch']['scripts']['dir']."/directory.js","w"); + fwrite($fout, $tmp); + fclose($fout); + + } //end sync_directory +} //end if function exists + +sync_directory(); +?> \ No newline at end of file diff --git a/includes/download.php b/includes/download.php new file mode 100644 index 0000000000..9b4a0e9630 --- /dev/null +++ b/includes/download.php @@ -0,0 +1,36 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +//require_once "includes/checkauth.php"; + +$file = $_GET["f"]; +require_once "includes/securedownload.php"; +//echo $file; +DownloadFile($file_dir.$file); + +?> + diff --git a/includes/edit_area/edit_area_full.gz b/includes/edit_area/edit_area_full.gz new file mode 100644 index 0000000000..8cfc846f16 Binary files /dev/null and b/includes/edit_area/edit_area_full.gz differ diff --git a/includes/edit_area/edit_area_full.js b/includes/edit_area/edit_area_full.js new file mode 100644 index 0000000000..db136a89a0 --- /dev/null +++ b/includes/edit_area/edit_area_full.js @@ -0,0 +1,38 @@ + function EAL(){var t=this;t.version="0.8.1.1";date=new Date();t.start_time=date.getTime();t.win="loading";t.error=false;t.baseURL="";t.template="";t.lang={};t.load_syntax={};t.syntax={};t.loadedFiles=[];t.waiting_loading={};t.scripts_to_load=[];t.sub_scripts_to_load=[];t.resize=[];t.hidden={};t.default_settings={debug:false,smooth_selection:true,font_size:"10",font_family:"monospace",start_highlight:false,toolbar:"search,go_to_line,fullscreen,|,undo,redo,|,select_font,|,change_smooth_selection,highlight,reset_highlight,word_wrap,|,help",begin_toolbar:"",end_toolbar:"",is_multi_files:false,allow_resize:"both",show_line_colors:false,min_width:400,min_height:125,replace_tab_by_spaces:false,allow_toggle:true,language:"en",syntax:"",syntax_selection_allow:"basic,brainfuck,c,coldfusion,cpp,css,html,java,js,pas,perl,php,python,ruby,robotstxt,sql,tsql,vb,xml",display:"onload",max_undo:30,browsers:"known",plugins:"",gecko_spellcheck:false,fullscreen:false,is_editable:true,cursor_position:"begin",word_wrap:false,autocompletion:false,load_callback:"",save_callback:"",change_callback:"",submit_callback:"",EA_init_callback:"",EA_delete_callback:"",EA_load_callback:"",EA_unload_callback:"",EA_toggle_on_callback:"",EA_toggle_off_callback:"",EA_file_switch_on_callback:"",EA_file_switch_off_callback:"",EA_file_close_callback:""};t.advanced_buttons=[ ['new_document','newdocument.gif','new_document',false],['search','search.gif','show_search',false],['go_to_line','go_to_line.gif','go_to_line',false],['undo','undo.gif','undo',true],['redo','redo.gif','redo',true],['change_smooth_selection','smooth_selection.gif','change_smooth_selection_mode',true],['reset_highlight','reset_highlight.gif','resync_highlight',true],['highlight','highlight.gif','change_highlight',true],['help','help.gif','show_help',false],['save','save.gif','save',false],['load','load.gif','load',false],['fullscreen','fullscreen.gif','toggle_full_screen',false],['word_wrap','word_wrap.gif','toggle_word_wrap',true],['autocompletion','autocompletion.gif','toggle_autocompletion',true] ];t.set_browser_infos(t);if(t.isIE>=6||t.isGecko||(t.isWebKit&&!t.isSafari<3)||t.isOpera>=9||t.isCamino)t.isValidBrowser=true; +else t.isValidBrowser=false;t.set_base_url();for(var i=0;i0)s["toolbar"]=s["begin_toolbar"]+","+s["toolbar"];if(s["end_toolbar"].length>0)s["toolbar"]=s["toolbar"]+","+s["end_toolbar"];s["tab_toolbar"]=s["toolbar"].replace(/ /g,"").split(",");s["plugins"]=s["plugins"].replace(/ /g,"").split(",");for(i=0;i0){s["syntax"]=s["syntax"].toLowerCase();t.load_script(t.baseURL+"reg_syntax/"+s["syntax"]+".js");}eAs[s["id"]]={"settings":s};eAs[s["id"]]["displayed"]=false;eAs[s["id"]]["hidden"]=false;t.start(s["id"]);},delete_instance:function(id){var d=document,fs=window.frames,span,iframe;eAL.execCommand(id,"EA_delete");if(fs["frame_"+id]&&fs["frame_"+id].editArea){if(eAs[id]["displayed"])eAL.toggle(id,"off");fs["frame_"+id].editArea.execCommand("EA_unload");}span=d.getElementById("EditAreaArroundInfos_"+id);if(span)span.parentNode.removeChild(span);iframe=d.getElementById("frame_"+id);if(iframe){iframe.parentNode.removeChild(iframe);try{delete fs["frame_"+id];}catch(e){}}delete eAs[id];},start:function(id){var t=this,d=document,f,span,father,next,html='',html_toolbar_content='',template,content,i;if(t.win!="loaded"){setTimeout("eAL.start('"+id+"');",50);return;}for(i in t.waiting_loading){if(t.waiting_loading[i]!="loaded"&&typeof(t.waiting_loading[i])!="function"){setTimeout("eAL.start('"+id+"');",50);return;}}if(!t.lang[eAs[id]["settings"]["language"]]||(eAs[id]["settings"]["syntax"].length>0&&!t.load_syntax[eAs[id]["settings"]["syntax"]])){setTimeout("eAL.start('"+id+"');",50);return;}if(eAs[id]["settings"]["syntax"].length>0)t.init_syntax_regexp();if(!d.getElementById("EditAreaArroundInfos_"+id)&&(eAs[id]["settings"]["debug"]||eAs[id]["settings"]["allow_toggle"])){span=d.createElement("span");span.id="EditAreaArroundInfos_"+id;if(eAs[id]["settings"]["allow_toggle"]){checked=(eAs[id]["settings"]["display"]=="onload")?"checked='checked'":"";html+="
    ";html+="";html+="
    ";}if(eAs[id]["settings"]["debug"])html+="
    ";html=t.translate(html,eAs[id]["settings"]["language"]);span.innerHTML=html;father=d.getElementById(id).parentNode;next=d.getElementById(id).nextSibling;if(next==null)father.appendChild(span); +else father.insertBefore(span,next);}if(!eAs[id]["initialized"]){t.execCommand(id,"EA_init");if(eAs[id]["settings"]["display"]=="later"){eAs[id]["initialized"]=true;return;}}if(t.isIE){t.init_ie_textarea(id);}area=eAs[id];for(i=0;i';}for(i=0;i';t.iframe_script+='';}if(!t.iframe_css){t.iframe_css="";}template=t.template.replace(/\[__BASEURL__\]/g,t.baseURL);template=template.replace("[__TOOLBAR__]",html_toolbar_content);template=t.translate(template,area["settings"]["language"],"template");template=template.replace("[__CSSRULES__]",t.iframe_css);template=template.replace("[__JSCODE__]",t.iframe_script);template=template.replace("[__EA_VERSION__]",t.version);area.textarea=d.getElementById(area["settings"]["id"]);eAs[area["settings"]["id"]]["textarea"]=area.textarea;if(typeof(window.frames["frame_"+area["settings"]["id"]])!='undefined')delete window.frames["frame_"+area["settings"]["id"]];father=area.textarea.parentNode;content=d.createElement("iframe");content.name="frame_"+area["settings"]["id"];content.id="frame_"+area["settings"]["id"];content.style.borderWidth="0px";setAttribute(content,"frameBorder","0");content.style.overflow="hidden";content.style.display="none";next=area.textarea.nextSibling;if(next==null)father.appendChild(content); +else father.insertBefore(content,next);f=window.frames["frame_"+area["settings"]["id"]];f.document.open();f.eAs=eAs;f.area_id=area["settings"]["id"];f.document.area_id=area["settings"]["id"];f.document.write(template);f.document.close();},toggle:function(id,toggle_to){if(!toggle_to)toggle_to=(eAs[id]["displayed"]==true)?"off":"on";if(eAs[id]["displayed"]==true&&toggle_to=="off"){this.toggle_off(id);} +else if(eAs[id]["displayed"]==false&&toggle_to=="on"){this.toggle_on(id);}return false;},toggle_off:function(id){var fs=window.frames,f,t,parNod,nxtSib,selStart,selEnd,scrollTop,scrollLeft;if(fs["frame_"+id]){f=fs["frame_"+id];t=eAs[id]["textarea"];if(f.editArea.fullscreen['isFull'])f.editArea.toggle_full_screen(false);eAs[id]["displayed"]=false;t.wrap="off";setAttribute(t,"wrap","off");parNod=t.parentNode;nxtSib=t.nextSibling;parNod.removeChild(t);parNod.insertBefore(t,nxtSib);t.value=f.editArea.textarea.value;selStart=f.editArea.last_selection["selectionStart"];selEnd=f.editArea.last_selection["selectionEnd"];scrollTop=f.document.getElementById("result").scrollTop;scrollLeft=f.document.getElementById("result").scrollLeft;document.getElementById("frame_"+id).style.display='none';t.style.display="inline";try{t.focus();}catch(e){};if(this.isIE){t.selectionStart=selStart;t.selectionEnd=selEnd;t.focused=true;set_IE_selection(t);} +else{if(this.isOpera&&this.isOpera < 9.6){t.setSelectionRange(0,0);}try{t.setSelectionRange(selStart,selEnd);}catch(e){};}t.scrollTop=scrollTop;t.scrollLeft=scrollLeft;f.editArea.execCommand("toggle_off");}},toggle_on:function(id){var fs=window.frames,f,t,selStart=0,selEnd=0,scrollTop=0,scrollLeft=0,curPos,elem;if(fs["frame_"+id]){f=fs["frame_"+id];t=eAs[id]["textarea"];area=f.editArea;area.textarea.value=t.value;curPos=eAs[id]["settings"]["cursor_position"];if(t.use_last==true){selStart=t.last_selectionStart;selEnd=t.last_selectionEnd;scrollTop=t.last_scrollTop;scrollLeft=t.last_scrollLeft;t.use_last=false;} +else if(curPos=="auto"){try{selStart=t.selectionStart;selEnd=t.selectionEnd;scrollTop=t.scrollTop;scrollLeft=t.scrollLeft;}catch(ex){}}this.set_editarea_size_from_textarea(id,document.getElementById("frame_"+id));t.style.display="none";document.getElementById("frame_"+id).style.display="inline";area.execCommand("focus");eAs[id]["displayed"]=true;area.execCommand("update_size");f.document.getElementById("result").scrollTop=scrollTop;f.document.getElementById("result").scrollLeft=scrollLeft;area.area_select(selStart,selEnd-selStart);area.execCommand("toggle_on");} +else{elem=document.getElementById(id);elem.last_selectionStart=elem.selectionStart;elem.last_selectionEnd=elem.selectionEnd;elem.last_scrollTop=elem.scrollTop;elem.last_scrollLeft=elem.scrollLeft;elem.use_last=true;eAL.start(id);}},set_editarea_size_from_textarea:function(id,frame){var elem,width,height;elem=document.getElementById(id);width=Math.max(eAs[id]["settings"]["min_width"],elem.offsetWidth)+"px";height=Math.max(eAs[id]["settings"]["min_height"],elem.offsetHeight)+"px";if(elem.style.width.indexOf("%")!=-1)width=elem.style.width;if(elem.style.height.indexOf("%")!=-1)height=elem.style.height;frame.style.width=width;frame.style.height=height;},set_base_url:function(){var t=this,elems,i,docBasePath;if(!this.baseURL){elems=document.getElementsByTagName('script');for(i=0;i';html+='';return html;},get_control_html:function(button_name,lang){var t=this,i,but,html,si;for(i=0;i";case "|":case "separator":return '';case "select_font":html="";return html;case "syntax_selection":html="";return html;}return "["+button_name+"]";},get_template:function(){if(this.template==""){var xhr_object=null;if(window.XMLHttpRequest)xhr_object=new XMLHttpRequest(); +else if(window.ActiveXObject)xhr_object=new ActiveXObject("Microsoft.XMLHTTP"); +else{alert("XMLHTTPRequest not supported. EditArea not loaded");return;}xhr_object.open("GET",this.baseURL+"template.html",false);xhr_object.send(null);if(xhr_object.readyState==4)this.template=xhr_object.responseText; +else this.has_error();}},translate:function(text,lang,mode){if(mode=="word")text=eAL.get_word_translation(text,lang); +else if(mode="template"){eAL.current_language=lang;text=text.replace(/\{\$([^\}]+)\}/gm,eAL.translate_template);}return text;},translate_template:function(){return eAL.get_word_translation(EAL.prototype.translate_template.arguments[1],eAL.current_language);},get_word_translation:function(val,lang){var i;for(i in eAL.lang[lang]){if(i==val)return eAL.lang[lang][i];}return "_"+val;},load_script:function(url){var t=this,d=document,script,head;if(t.loadedFiles[url])return;try{script=d.createElement("script");script.type="text/javascript";script.src=url;script.charset="UTF-8";d.getElementsByTagName("head")[0].appendChild(script);}catch(e){d.write('');}t.loadedFiles[url]=true;},add_event:function(obj,name,handler){try{if(obj.attachEvent){obj.attachEvent("on"+name,handler);} +else{obj.addEventListener(name,handler,false);}}catch(e){}},remove_event:function(obj,name,handler){try{if(obj.detachEvent)obj.detachEvent("on"+name,handler); +else obj.removeEventListener(name,handler,false);}catch(e){}},reset:function(e){var formObj,is_child,i,x;formObj=eAL.isIE ? window.event.srcElement:e.target;if(formObj.tagName!='FORM')formObj=formObj.form;for(i in eAs){is_child=false;for(x=0;x old_sel["start"])this.setSelectionRange(id,new_sel["end"],new_sel["end"]); +else this.setSelectionRange(id,old_sel["start"]+open_tag.length,old_sel["start"]+open_tag.length);},hide:function(id){var fs=window.frames,d=document,t=this,scrollTop,scrollLeft,span;if(d.getElementById(id)&&!t.hidden[id]){t.hidden[id]={};t.hidden[id]["selectionRange"]=t.getSelectionRange(id);if(d.getElementById(id).style.display!="none"){t.hidden[id]["scrollTop"]=d.getElementById(id).scrollTop;t.hidden[id]["scrollLeft"]=d.getElementById(id).scrollLeft;}if(fs["frame_"+id]){t.hidden[id]["toggle"]=eAs[id]["displayed"];if(fs["frame_"+id]&&eAs[id]["displayed"]==true){scrollTop=fs["frame_"+id].document.getElementById("result").scrollTop;scrollLeft=fs["frame_"+id].document.getElementById("result").scrollLeft;} +else{scrollTop=d.getElementById(id).scrollTop;scrollLeft=d.getElementById(id).scrollLeft;}t.hidden[id]["scrollTop"]=scrollTop;t.hidden[id]["scrollLeft"]=scrollLeft;if(eAs[id]["displayed"]==true)eAL.toggle_off(id);}span=d.getElementById("EditAreaArroundInfos_"+id);if(span){span.style.display='none';}d.getElementById(id).style.display="none";}},show:function(id){var fs=window.frames,d=document,t=this,span;if((elem=d.getElementById(id))&&t.hidden[id]){elem.style.display="inline";elem.scrollTop=t.hidden[id]["scrollTop"];elem.scrollLeft=t.hidden[id]["scrollLeft"];span=d.getElementById("EditAreaArroundInfos_"+id);if(span){span.style.display='inline';}if(fs["frame_"+id]){elem.style.display="inline";if(t.hidden[id]["toggle"]==true)eAL.toggle_on(id);scrollTop=t.hidden[id]["scrollTop"];scrollLeft=t.hidden[id]["scrollLeft"];if(fs["frame_"+id]&&eAs[id]["displayed"]==true){fs["frame_"+id].document.getElementById("result").scrollTop=scrollTop;fs["frame_"+id].document.getElementById("result").scrollLeft=scrollLeft;} +else{elem.scrollTop=scrollTop;elem.scrollLeft=scrollLeft;}}sel=t.hidden[id]["selectionRange"];t.setSelectionRange(id,sel["start"],sel["end"]);delete t.hidden[id];}},getCurrentFile:function(id){return this.execCommand(id,'get_file',this.execCommand(id,'curr_file'));},getFile:function(id,file_id){return this.execCommand(id,'get_file',file_id);},getAllFiles:function(id){return this.execCommand(id,'get_all_files()');},openFile:function(id,file_infos){return this.execCommand(id,'open_file',file_infos);},closeFile:function(id,file_id){return this.execCommand(id,'close_file',file_id);},setFileEditedMode:function(id,file_id,to){var reg1,reg2;reg1=new RegExp('\\\\','g');reg2=new RegExp('"','g');return this.execCommand(id,'set_file_edited_mode("'+file_id.replace(reg1,'\\\\').replace(reg2,'\\"')+'",'+to+')');},execCommand:function(id,cmd,fct_param){switch(cmd){case "EA_init":if(eAs[id]['settings']["EA_init_callback"].length>0)eval(eAs[id]['settings']["EA_init_callback"]+"('"+id+"');");break;case "EA_delete":if(eAs[id]['settings']["EA_delete_callback"].length>0)eval(eAs[id]['settings']["EA_delete_callback"]+"('"+id+"');");break;case "EA_submit":if(eAs[id]['settings']["submit_callback"].length>0)eval(eAs[id]['settings']["submit_callback"]+"('"+id+"');");break;}if(window.frames["frame_"+id]&&window.frames["frame_"+id].editArea){if(fct_param!=undefined)return eval('window.frames["frame_'+id+'"].editArea.'+cmd+'(fct_param);'); +else return eval('window.frames["frame_'+id+'"].editArea.'+cmd+';');}return false;}};var eAL=new EAL();var eAs={}; function getAttribute(elm,aName){var aValue,taName,i;try{aValue=elm.getAttribute(aName);}catch(exept){}if(! aValue){for(i=0;i < elm.attributes.length;i++){taName=elm.attributes[i] .name.toLowerCase();if(taName==aName){aValue=elm.attributes[i] .value;return aValue;}}}return aValue;};function setAttribute(elm,attr,val){if(attr=="class"){elm.setAttribute("className",val);elm.setAttribute("class",val);} +else{elm.setAttribute(attr,val);}};function getChildren(elem,elem_type,elem_attribute,elem_attribute_match,option,depth){if(!option)var option="single";if(!depth)var depth=-1;if(elem){var children=elem.childNodes;var result=null;var results=[];for(var x=0;x0){results=results.concat(result);}} +else if(result!=null){return result;}}}}if(option=="all")return results;}return null;};function isChildOf(elem,parent){if(elem){if(elem==parent)return true;while(elem.parentNode !='undefined'){return isChildOf(elem.parentNode,parent);}}return false;};function getMouseX(e){if(e!=null&&typeof(e.pageX)!="undefined"){return e.pageX;} +else{return(e!=null?e.x:event.x)+document.documentElement.scrollLeft;}};function getMouseY(e){if(e!=null&&typeof(e.pageY)!="undefined"){return e.pageY;} +else{return(e!=null?e.y:event.y)+document.documentElement.scrollTop;}};function calculeOffsetLeft(r){return calculeOffset(r,"offsetLeft")};function calculeOffsetTop(r){return calculeOffset(r,"offsetTop")};function calculeOffset(element,attr){var offset=0;while(element){offset+=element[attr];element=element.offsetParent}return offset;};function get_css_property(elem,prop){if(document.defaultView){return document.defaultView.getComputedStyle(elem,null).getPropertyValue(prop);} +else if(elem.currentStyle){var prop=prop.replace(/-\D/gi,function(sMatch){return sMatch.charAt(sMatch.length-1).toUpperCase();});return elem.currentStyle[prop];} +else return null;}var _mCE;function start_move_element(e,id,frame){var elem_id=(e.target||e.srcElement).id;if(id)elem_id=id;if(!frame)frame=window;if(frame.event)e=frame.event;_mCE=frame.document.getElementById(elem_id);_mCE.frame=frame;frame.document.onmousemove=move_element;frame.document.onmouseup=end_move_element;mouse_x=getMouseX(e);mouse_y=getMouseY(e);_mCE.start_pos_x=mouse_x-(_mCE.style.left.replace("px","")||calculeOffsetLeft(_mCE));_mCE.start_pos_y=mouse_y-(_mCE.style.top.replace("px","")||calculeOffsetTop(_mCE));return false;};function end_move_element(e){_mCE.frame.document.onmousemove="";_mCE.frame.document.onmouseup="";_mCE=null;};function move_element(e){var newTop,newLeft,maxLeft;if(_mCE.frame&&_mCE.frame.event)e=_mCE.frame.event;newTop=getMouseY(e)-_mCE.start_pos_y;newLeft=getMouseX(e)-_mCE.start_pos_x;maxLeft=_mCE.frame.document.body.offsetWidth-_mCE.offsetWidth;max_top=_mCE.frame.document.body.offsetHeight-_mCE.offsetHeight;newTop=Math.min(Math.max(0,newTop),max_top);newLeft=Math.min(Math.max(0,newLeft),maxLeft);_mCE.style.top=newTop+"px";_mCE.style.left=newLeft+"px";return false;};var nav=eAL.nav;function getSelectionRange(textarea){return{"start":textarea.selectionStart,"end":textarea.selectionEnd};};function setSelectionRange(t,start,end){t.focus();start=Math.max(0,Math.min(t.value.length,start));end=Math.max(start,Math.min(t.value.length,end));if(this.isOpera&&this.isOpera < 9.6){t.selectionEnd=1;t.selectionStart=0;t.selectionEnd=1;t.selectionStart=0;}t.selectionStart=start;t.selectionEnd=end;if(isIE)set_IE_selection(t);};function get_IE_selection(t){var d=document,div,range,stored_range,elem,scrollTop,relative_top,line_start,line_nb,range_start,range_end,tab;if(t&&t.focused){if(!t.ea_line_height){div=d.createElement("div");div.style.fontFamily=get_css_property(t,"font-family");div.style.fontSize=get_css_property(t,"font-size");div.style.visibility="hidden";div.innerHTML="0";d.body.appendChild(div);t.ea_line_height=div.offsetHeight;d.body.removeChild(div);}range=d.selection.createRange();try{stored_range=range.duplicate();stored_range.moveToElementText(t);stored_range.setEndPoint('EndToEnd',range);if(stored_range.parentElement()==t){elem=t;scrollTop=0;while(elem.parentNode){scrollTop+=elem.scrollTop;elem=elem.parentNode;}relative_top=range.offsetTop-calculeOffsetTop(t)+scrollTop;line_start=Math.round((relative_top / t.ea_line_height)+1);line_nb=Math.round(range.boundingHeight / t.ea_line_height);range_start=stored_range.text.length-range.text.length;tab=t.value.substr(0,range_start).split("\n");range_start+=(line_start-tab.length)*2;t.selectionStart=range_start;range_end=t.selectionStart+range.text.length;tab=t.value.substr(0,range_start+range.text.length).split("\n");range_end+=(line_start+line_nb-1-tab.length)*2;t.selectionEnd=range_end;}}catch(e){}}setTimeout("get_IE_selection(document.getElementById('"+t.id+"'));",50);};function IE_textarea_focus(){event.srcElement.focused=true;}function IE_textarea_blur(){event.srcElement.focused=false;}function set_IE_selection(t){var nbLineStart,nbLineStart,nbLineEnd,range;if(!window.closed){nbLineStart=t.value.substr(0,t.selectionStart).split("\n").length-1;nbLineEnd=t.value.substr(0,t.selectionEnd).split("\n").length-1;try{range=document.selection.createRange();range.moveToElementText(t);range.setEndPoint('EndToStart',range);range.moveStart('character',t.selectionStart-nbLineStart);range.moveEnd('character',t.selectionEnd-nbLineEnd-(t.selectionStart-nbLineStart));range.select();}catch(e){}}};eAL.waiting_loading["elements_functions.js"]="loaded"; + EAL.prototype.start_resize_area=function(){var d=document,a,div,width,height,father;d.onmouseup=eAL.end_resize_area;d.onmousemove=eAL.resize_area;eAL.toggle(eAL.resize["id"]);a=eAs[eAL.resize["id"]]["textarea"];div=d.getElementById("edit_area_resize");if(!div){div=d.createElement("div");div.id="edit_area_resize";div.style.border="dashed #888888 1px";}width=a.offsetWidth-2;height=a.offsetHeight-2;div.style.display="block";div.style.width=width+"px";div.style.height=height+"px";father=a.parentNode;father.insertBefore(div,a);a.style.display="none";eAL.resize["start_top"]=calculeOffsetTop(div);eAL.resize["start_left"]=calculeOffsetLeft(div);};EAL.prototype.end_resize_area=function(e){var d=document,div,a,width,height;d.onmouseup="";d.onmousemove="";div=d.getElementById("edit_area_resize");a=eAs[eAL.resize["id"]]["textarea"];width=Math.max(eAs[eAL.resize["id"]]["settings"]["min_width"],div.offsetWidth-4);height=Math.max(eAs[eAL.resize["id"]]["settings"]["min_height"],div.offsetHeight-4);if(eAL.isIE==6){width-=2;height-=2;}a.style.width=width+"px";a.style.height=height+"px";div.style.display="none";a.style.display="inline";a.selectionStart=eAL.resize["selectionStart"];a.selectionEnd=eAL.resize["selectionEnd"];eAL.toggle(eAL.resize["id"]);return false;};EAL.prototype.resize_area=function(e){var allow,newHeight,newWidth;allow=eAs[eAL.resize["id"]]["settings"]["allow_resize"];if(allow=="both"||allow=="y"){newHeight=Math.max(20,getMouseY(e)-eAL.resize["start_top"]);document.getElementById("edit_area_resize").style.height=newHeight+"px";}if(allow=="both"||allow=="x"){newWidth=Math.max(20,getMouseX(e)-eAL.resize["start_left"]);document.getElementById("edit_area_resize").style.width=newWidth+"px";}return false;};eAL.waiting_loading["resize_area.js"]="loaded"; + EAL.prototype.get_regexp=function(text_array){res="(\\b)(";for(i=0;i0)res+="|";res+=this.get_escaped_regexp(text_array[i]);}res+=")(\\b)";reg=new RegExp(res);return res;};EAL.prototype.get_escaped_regexp=function(str){return str.toString().replace(/(\.|\?|\*|\+|\\|\(|\)|\[|\]|\}|\{|\$|\^|\|)/g,"\\$1");};EAL.prototype.init_syntax_regexp=function(){var lang_style={};for(var lang in this.load_syntax){if(!this.syntax[lang]){this.syntax[lang]={};this.syntax[lang]["keywords_reg_exp"]={};this.keywords_reg_exp_nb=0;if(this.load_syntax[lang]['KEYWORDS']){param="g";if(this.load_syntax[lang]['KEYWORD_CASE_SENSITIVE']===false)param+="i";for(var i in this.load_syntax[lang]['KEYWORDS']){if(typeof(this.load_syntax[lang]['KEYWORDS'][i])=="function")continue;this.syntax[lang]["keywords_reg_exp"][i]=new RegExp(this.get_regexp(this.load_syntax[lang]['KEYWORDS'][i]),param);this.keywords_reg_exp_nb++;}}if(this.load_syntax[lang]['OPERATORS']){var str="";var nb=0;for(var i in this.load_syntax[lang]['OPERATORS']){if(typeof(this.load_syntax[lang]['OPERATORS'][i])=="function")continue;if(nb>0)str+="|";str+=this.get_escaped_regexp(this.load_syntax[lang]['OPERATORS'][i]);nb++;}if(str.length>0)this.syntax[lang]["operators_reg_exp"]=new RegExp("("+str+")","g");}if(this.load_syntax[lang]['DELIMITERS']){var str="";var nb=0;for(var i in this.load_syntax[lang]['DELIMITERS']){if(typeof(this.load_syntax[lang]['DELIMITERS'][i])=="function")continue;if(nb>0)str+="|";str+=this.get_escaped_regexp(this.load_syntax[lang]['DELIMITERS'][i]);nb++;}if(str.length>0)this.syntax[lang]["delimiters_reg_exp"]=new RegExp("("+str+")","g");}var syntax_trace=[];this.syntax[lang]["quotes"]={};var quote_tab=[];if(this.load_syntax[lang]['QUOTEMARKS']){for(var i in this.load_syntax[lang]['QUOTEMARKS']){if(typeof(this.load_syntax[lang]['QUOTEMARKS'][i])=="function")continue;var x=this.get_escaped_regexp(this.load_syntax[lang]['QUOTEMARKS'][i]);this.syntax[lang]["quotes"][x]=x;quote_tab[quote_tab.length]="("+x+"(\\\\.|[^"+x+"])*(?:"+x+"|$))";syntax_trace.push(x);}}this.syntax[lang]["comments"]={};if(this.load_syntax[lang]['COMMENT_SINGLE']){for(var i in this.load_syntax[lang]['COMMENT_SINGLE']){if(typeof(this.load_syntax[lang]['COMMENT_SINGLE'][i])=="function")continue;var x=this.get_escaped_regexp(this.load_syntax[lang]['COMMENT_SINGLE'][i]);quote_tab[quote_tab.length]="("+x+"(.|\\r|\\t)*(\\n|$))";syntax_trace.push(x);this.syntax[lang]["comments"][x]="\n";}}if(this.load_syntax[lang]['COMMENT_MULTI']){for(var i in this.load_syntax[lang]['COMMENT_MULTI']){if(typeof(this.load_syntax[lang]['COMMENT_MULTI'][i])=="function")continue;var start=this.get_escaped_regexp(i);var end=this.get_escaped_regexp(this.load_syntax[lang]['COMMENT_MULTI'][i]);quote_tab[quote_tab.length]="("+start+"(.|\\n|\\r)*?("+end+"|$))";syntax_trace.push(start);syntax_trace.push(end);this.syntax[lang]["comments"][i]=this.load_syntax[lang]['COMMENT_MULTI'][i];}}if(quote_tab.length>0)this.syntax[lang]["comment_or_quote_reg_exp"]=new RegExp("("+quote_tab.join("|")+")","gi");if(syntax_trace.length>0)this.syntax[lang]["syntax_trace_regexp"]=new RegExp("((.|\n)*?)(\\\\*("+syntax_trace.join("|")+"|$))","gmi");if(this.load_syntax[lang]['SCRIPT_DELIMITERS']){this.syntax[lang]["script_delimiters"]={};for(var i in this.load_syntax[lang]['SCRIPT_DELIMITERS']){if(typeof(this.load_syntax[lang]['SCRIPT_DELIMITERS'][i])=="function")continue;this.syntax[lang]["script_delimiters"][i]=this.load_syntax[lang]['SCRIPT_DELIMITERS'];}}this.syntax[lang]["custom_regexp"]={};if(this.load_syntax[lang]['REGEXPS']){for(var i in this.load_syntax[lang]['REGEXPS']){if(typeof(this.load_syntax[lang]['REGEXPS'][i])=="function")continue;var val=this.load_syntax[lang]['REGEXPS'][i];if(!this.syntax[lang]["custom_regexp"][val['execute']])this.syntax[lang]["custom_regexp"][val['execute']]={};this.syntax[lang]["custom_regexp"][val['execute']][i]={'regexp':new RegExp(val['search'],val['modifiers']),'class':val['class']};}}if(this.load_syntax[lang]['STYLES']){lang_style[lang]={};for(var i in this.load_syntax[lang]['STYLES']){if(typeof(this.load_syntax[lang]['STYLES'][i])=="function")continue;if(typeof(this.load_syntax[lang]['STYLES'][i])!="string"){for(var j in this.load_syntax[lang]['STYLES'][i]){lang_style[lang][j]=this.load_syntax[lang]['STYLES'][i][j];}} +else{lang_style[lang][i]=this.load_syntax[lang]['STYLES'][i];}}}var style="";for(var i in lang_style[lang]){if(lang_style[lang][i].length>0){style+="."+lang+" ."+i.toLowerCase()+" span{"+lang_style[lang][i]+"}\n";style+="."+lang+" ."+i.toLowerCase()+"{"+lang_style[lang][i]+"}\n";}}this.syntax[lang]["styles"]=style;}}};eAL.waiting_loading["reg_syntax.js"]="loaded"; +var editAreaLoader= eAL;var editAreas=eAs;EditAreaLoader=EAL;editAreaLoader.iframe_script= "".replace(/Á/g,'this').replace(/Â/g,'textarea').replace(/Ã/g,'function').replace(/Ä/g,'prototype').replace(/Å/g,'settings').replace(/Æ/g,'length').replace(/Ç/g,'style').replace(/È/g,'parent').replace(/É/g,'last_selection').replace(/Ê/g,'value').replace(/Ë/g,'true').replace(/Ì/g,'false'); +editAreaLoader.template= " EditArea [__CSSRULES__] [__JSCODE__]
    [__TOOLBAR__]
     
     
    {$position}: {$line_abbr} 0, {$char_abbr} 0 {$total}: {$line_abbr} 0, {$char_abbr} 0 resize
    {$processing}
    {$search} {$close_popup}
    {$replace} {$move_popup}

    {$find_next} {$replace} {$replace_all}
    {$close_popup}

    Editarea [__EA_VERSION__]


    {$shortcuts}:

    {$tab}: {$add_tab}
    {$shift}+{$tab}: {$remove_tab}
    {$ctrl}+f: {$search_command}
    {$ctrl}+r: {$replace_command}
    {$ctrl}+h: {$highlight}
    {$ctrl}+g: {$go_to_line}
    {$ctrl}+z: {$undo}
    {$ctrl}+y: {$redo}
    {$ctrl}+e: {$help}
    {$ctrl}+q, {$esc}: {$close_popup}
    {$accesskey} E: {$toggle}

    {$about_notice}
    "; +editAreaLoader.iframe_css= ""; diff --git a/includes/edit_area/images/autocompletion.gif b/includes/edit_area/images/autocompletion.gif new file mode 100644 index 0000000000..f3dfc2e3a9 Binary files /dev/null and b/includes/edit_area/images/autocompletion.gif differ diff --git a/includes/edit_area/images/close.gif b/includes/edit_area/images/close.gif new file mode 100644 index 0000000000..679ca2aa47 Binary files /dev/null and b/includes/edit_area/images/close.gif differ diff --git a/includes/edit_area/images/fullscreen.gif b/includes/edit_area/images/fullscreen.gif new file mode 100644 index 0000000000..66fa6d9217 Binary files /dev/null and b/includes/edit_area/images/fullscreen.gif differ diff --git a/includes/edit_area/images/go_to_line.gif b/includes/edit_area/images/go_to_line.gif new file mode 100644 index 0000000000..06042ec9ab Binary files /dev/null and b/includes/edit_area/images/go_to_line.gif differ diff --git a/includes/edit_area/images/help.gif b/includes/edit_area/images/help.gif new file mode 100644 index 0000000000..51a1ee4207 Binary files /dev/null and b/includes/edit_area/images/help.gif differ diff --git a/includes/edit_area/images/highlight.gif b/includes/edit_area/images/highlight.gif new file mode 100644 index 0000000000..16491f6cfc Binary files /dev/null and b/includes/edit_area/images/highlight.gif differ diff --git a/includes/edit_area/images/load.gif b/includes/edit_area/images/load.gif new file mode 100644 index 0000000000..461698f56b Binary files /dev/null and b/includes/edit_area/images/load.gif differ diff --git a/includes/edit_area/images/move.gif b/includes/edit_area/images/move.gif new file mode 100644 index 0000000000..d15f9f5420 Binary files /dev/null and b/includes/edit_area/images/move.gif differ diff --git a/includes/edit_area/images/newdocument.gif b/includes/edit_area/images/newdocument.gif new file mode 100644 index 0000000000..a9d2938423 Binary files /dev/null and b/includes/edit_area/images/newdocument.gif differ diff --git a/includes/edit_area/images/opacity.png b/includes/edit_area/images/opacity.png new file mode 100644 index 0000000000..b4217cb212 Binary files /dev/null and b/includes/edit_area/images/opacity.png differ diff --git a/includes/edit_area/images/processing.gif b/includes/edit_area/images/processing.gif new file mode 100644 index 0000000000..cce32f20f4 Binary files /dev/null and b/includes/edit_area/images/processing.gif differ diff --git a/includes/edit_area/images/redo.gif b/includes/edit_area/images/redo.gif new file mode 100644 index 0000000000..3af90697f0 Binary files /dev/null and b/includes/edit_area/images/redo.gif differ diff --git a/includes/edit_area/images/reset_highlight.gif b/includes/edit_area/images/reset_highlight.gif new file mode 100644 index 0000000000..0fa3cb7973 Binary files /dev/null and b/includes/edit_area/images/reset_highlight.gif differ diff --git a/includes/edit_area/images/save.gif b/includes/edit_area/images/save.gif new file mode 100644 index 0000000000..2777bebfe7 Binary files /dev/null and b/includes/edit_area/images/save.gif differ diff --git a/includes/edit_area/images/search.gif b/includes/edit_area/images/search.gif new file mode 100644 index 0000000000..cfe76b5d5b Binary files /dev/null and b/includes/edit_area/images/search.gif differ diff --git a/includes/edit_area/images/smooth_selection.gif b/includes/edit_area/images/smooth_selection.gif new file mode 100644 index 0000000000..8a532e5e62 Binary files /dev/null and b/includes/edit_area/images/smooth_selection.gif differ diff --git a/includes/edit_area/images/spacer.gif b/includes/edit_area/images/spacer.gif new file mode 100644 index 0000000000..388486517f Binary files /dev/null and b/includes/edit_area/images/spacer.gif differ diff --git a/includes/edit_area/images/statusbar_resize.gif b/includes/edit_area/images/statusbar_resize.gif new file mode 100644 index 0000000000..af89d803f8 Binary files /dev/null and b/includes/edit_area/images/statusbar_resize.gif differ diff --git a/includes/edit_area/images/undo.gif b/includes/edit_area/images/undo.gif new file mode 100644 index 0000000000..520796d69d Binary files /dev/null and b/includes/edit_area/images/undo.gif differ diff --git a/includes/edit_area/images/word_wrap.gif b/includes/edit_area/images/word_wrap.gif new file mode 100644 index 0000000000..8f256ccbff Binary files /dev/null and b/includes/edit_area/images/word_wrap.gif differ diff --git a/includes/edit_area/langs/bg.js b/includes/edit_area/langs/bg.js new file mode 100644 index 0000000000..a1c141b8b3 --- /dev/null +++ b/includes/edit_area/langs/bg.js @@ -0,0 +1,73 @@ +/* + * Bulgarian translation + * Author: Valentin Hristov + * Company: SOFTKIT Bulgarian + * Site: http://www.softkit-bg.com + */ +editAreaLoader.lang["bg"]={ +new_document: "нов документ", +search_button: "търсене и замяна", +search_command: "търси следващия / отвори прозорец с търсачка", +search: "търсене", +replace: "замяна", +replace_command: "замяна / отвори прозорец с търсачка", +find_next: "намери следващия", +replace_all: "замени всички", +reg_exp: "реголярни изрази", +match_case: "чуствителен към регистъра", +not_found: "няма резултат.", +occurrence_replaced: "замяната е осъществена.", +search_field_empty: "Полето за търсене е празно", +restart_search_at_begin: "До края на документа. Почни с началото.", +move_popup: "премести прозореца с търсачката", +font_size: "--Размер на шрифта--", +go_to_line: "премени към реда", +go_to_line_prompt: "премени към номера на реда:", +undo: "отмени", +redo: "върни", +change_smooth_selection: "включи/изключи някой от функциите за преглед (по красиво, но повече натоварва)", +highlight: "превключване на оцветяване на синтаксиса включена/изключена", +reset_highlight: "въстанови оцветяване на синтаксиса (ако не е синхронизиран с текста)", +word_wrap: "режим на пренасяне на дълги редове", +help: "за програмата", +save: "съхрани", +load: "зареди", +line_abbr: "Стр", +char_abbr: "Стлб", +position: "Позиция", +total: "Всичко", +close_popup: "затвори прозореца", +shortcuts: "Бързи клавиши", +add_tab: "добави табулация в текста", +remove_tab: "премахни табулацията в текста", +about_notice: "Внимание: използвайте функцията оцветяване на синтаксиса само за малки текстове", +toggle: "Превключи редактор", +accesskey: "Бърз клавиш", +tab: "Tab", +shift: "Shift", +ctrl: "Ctrl", +esc: "Esc", +processing: "Зареждане...", +fullscreen: "на цял екран", +syntax_selection: "--Синтаксис--", +syntax_css: "CSS", +syntax_html: "HTML", +syntax_js: "Javascript", +syntax_php: "PHP", +syntax_python: "Python", +syntax_vb: "Visual Basic", +syntax_xml: "XML", +syntax_c: "C", +syntax_cpp: "C++", +syntax_basic: "Basic", +syntax_pas: "Pascal", +syntax_brainfuck: "Brainfuck", +syntax_sql: "SQL", +syntax_ruby: "Ruby", +syntax_robotstxt: "Robots txt", +syntax_tsql: "T-SQL", +syntax_perl: "Perl", +syntax_coldfusion: "Coldfusion", +syntax_java: "Java", +close_tab: "Затвори файла" +}; diff --git a/includes/edit_area/langs/cs.js b/includes/edit_area/langs/cs.js new file mode 100644 index 0000000000..e9ca96752e --- /dev/null +++ b/includes/edit_area/langs/cs.js @@ -0,0 +1,67 @@ +editAreaLoader.lang["cs"]={ +new_document: "Nový dokument", +search_button: "Najdi a nahraď", +search_command: "Hledej další / otevři vyhledávací pole", +search: "Hledej", +replace: "Nahraď", +replace_command: "Nahraď / otevři vyhledávací pole", +find_next: "Najdi další", +replace_all: "Nahraď vše", +reg_exp: "platné výrazy", +match_case: "vyhodnocené výrazy", +not_found: "nenalezené.", +occurrence_replaced: "výskyty nahrazené.", +search_field_empty: "Pole vyhledávání je prázdné", +restart_search_at_begin: "Dosažen konec souboru, začínám od začátku.", +move_popup: "Přesuň vyhledávací okno", +font_size: "--Velikost textu--", +go_to_line: "Přejdi na řádek", +go_to_line_prompt: "Přejdi na řádek:", +undo: "krok zpět", +redo: "znovu", +change_smooth_selection: "Povolit nebo zakázat některé ze zobrazených funkcí (účelnější zobrazení požaduje větší zatížení procesoru)", +highlight: "Zvýrazňování syntaxe zap./vyp.", +reset_highlight: "Obnovit zvýraznění (v případě nesrovnalostí)", +word_wrap: "toggle word wrapping mode", +help: "O programu", +save: "Uložit", +load: "Otevřít", +line_abbr: "Ř.", +char_abbr: "S.", +position: "Pozice", +total: "Celkem", +close_popup: "Zavřít okno", +shortcuts: "Zkratky", +add_tab: "Přidat tabulování textu", +remove_tab: "Odtsranit tabulování textu", +about_notice: "Upozornění! Funkce zvýrazňování textu je k dispozici pouze pro malý text", +toggle: "Přepnout editor", +accesskey: "Přístupová klávesa", +tab: "Záložka", +shift: "Shift", +ctrl: "Ctrl", +esc: "Esc", +processing: "Zpracovávám ...", +fullscreen: "Celá obrazovka", +syntax_selection: "--vyber zvýrazňovač--", +syntax_css: "CSS", +syntax_html: "HTML", +syntax_js: "Javascript", +syntax_php: "Php", +syntax_python: "Python", +syntax_vb: "Visual Basic", +syntax_xml: "Xml", +syntax_c: "C", +syntax_cpp: "CPP", +syntax_basic: "Basic", +syntax_pas: "Pascal", +syntax_brainfuck: "Brainfuck", +syntax_sql: "SQL", +syntax_ruby: "Ruby", +syntax_robotstxt: "Robots txt", +syntax_tsql: "T-SQL", +syntax_perl: "Perl", +syntax_coldfusion: "Coldfusion", +syntax_java: "Java", +close_tab: "Close file" +}; diff --git a/includes/edit_area/langs/de.js b/includes/edit_area/langs/de.js new file mode 100644 index 0000000000..9af06c5d2b --- /dev/null +++ b/includes/edit_area/langs/de.js @@ -0,0 +1,67 @@ +editAreaLoader.lang["de"]={ +new_document: "Neues Dokument", +search_button: "Suchen und Ersetzen", +search_command: "Weitersuchen / öffne Suchfeld", +search: "Suchen", +replace: "Ersetzen", +replace_command: "Ersetzen / öffne Suchfeld", +find_next: "Weitersuchen", +replace_all: "Ersetze alle Treffer", +reg_exp: "reguläre Ausdrücke", +match_case: "passt auf den Begriff
    ", +not_found: "Nicht gefunden.", +occurrence_replaced: "Die Vorkommen wurden ersetzt.", +search_field_empty: "Leeres Suchfeld", +restart_search_at_begin: "Ende des zu durchsuchenden Bereiches erreicht. Es wird die Suche von Anfang an fortgesetzt.", //find a shorter translation +move_popup: "Suchfenster bewegen", +font_size: "--Schriftgröße--", +go_to_line: "Gehe zu Zeile", +go_to_line_prompt: "Gehe zu Zeilennummmer:", +undo: "Rückgängig", +redo: "Wiederherstellen", +change_smooth_selection: "Aktiviere/Deaktiviere einige Features (weniger Bildschirmnutzung aber mehr CPU-Belastung)", +highlight: "Syntax Highlighting an- und ausschalten", +reset_highlight: "Highlighting zurücksetzen (falls mit Text nicht konform)", +word_wrap: "Toggle word wrapping mode", +help: "Info", +save: "Speichern", +load: "Öffnen", +line_abbr: "Ln", +char_abbr: "Ch", +position: "Position", +total: "Gesamt", +close_popup: "Popup schließen", +shortcuts: "Shortcuts", +add_tab: "Tab zum Text hinzufügen", +remove_tab: "Tab aus Text entfernen", +about_notice: "Bemerkung: Syntax Highlighting ist nur für kurze Texte", +toggle: "Editor an- und ausschalten", +accesskey: "Accesskey", +tab: "Tab", +shift: "Shift", +ctrl: "Ctrl", +esc: "Esc", +processing: "In Bearbeitung...", +fullscreen: "Full-Screen", +syntax_selection: "--Syntax--", +syntax_css: "CSS", +syntax_html: "HTML", +syntax_js: "Javascript", +syntax_php: "Php", +syntax_python: "Python", +syntax_vb: "Visual Basic", +syntax_xml: "Xml", +syntax_c: "C", +syntax_cpp: "CPP", +syntax_basic: "Basic", +syntax_pas: "Pascal", +syntax_brainfuck: "Brainfuck", +syntax_sql: "SQL", +syntax_ruby: "Ruby", +syntax_robotstxt: "Robots txt", +syntax_tsql: "T-SQL", +syntax_perl: "Perl", +syntax_coldfusion: "Coldfusion", +syntax_java: "Java", +close_tab: "Close file" +}; diff --git a/includes/edit_area/langs/dk.js b/includes/edit_area/langs/dk.js new file mode 100644 index 0000000000..45abd1d6a5 --- /dev/null +++ b/includes/edit_area/langs/dk.js @@ -0,0 +1,67 @@ +editAreaLoader.lang["dk"]={ +new_document: "nyt tomt dokument", +search_button: "søg og erstat", +search_command: "find næste / åben søgefelt", +search: "søg", +replace: "erstat", +replace_command: "erstat / åben søgefelt", +find_next: "find næste", +replace_all: "erstat alle", +reg_exp: "regular expressions", +match_case: "forskel på store/små bogstaver
    ", +not_found: "not found.", +occurrence_replaced: "occurences replaced.", +search_field_empty: "Search field empty", +restart_search_at_begin: "End of area reached. Restart at begin.", +move_popup: "flyt søgepopup", +font_size: "--Skriftstørrelse--", +go_to_line: "gå til linie", +go_to_line_prompt: "gå til linienummer:", +undo: "fortryd", +redo: "gentag", +change_smooth_selection: "slå display funktioner til/fra (smartere display men mere CPU krævende)", +highlight: "slå syntax highlight til/fra", +reset_highlight: "nulstil highlight (hvis den er desynkroniseret fra teksten)", +word_wrap: "toggle word wrapping mode", +help: "om", +save: "gem", +load: "hent", +line_abbr: "Ln", +char_abbr: "Ch", +position: "Position", +total: "Total", +close_popup: "luk popup", +shortcuts: "Genveje", +add_tab: "tilføj tabulation til tekst", +remove_tab: "fjern tabulation fra tekst", +about_notice: "Husk: syntax highlight funktionen bør kun bruge til små tekster", +toggle: "Slå editor til / fra", +accesskey: "Accesskey", +tab: "Tab", +shift: "Skift", +ctrl: "Ctrl", +esc: "Esc", +processing: "Processing...", +fullscreen: "fullscreen", +syntax_selection: "--Syntax--", +syntax_css: "CSS", +syntax_html: "HTML", +syntax_js: "Javascript", +syntax_php: "Php", +syntax_python: "Python", +syntax_vb: "Visual Basic", +syntax_xml: "Xml", +syntax_c: "C", +syntax_cpp: "CPP", +syntax_basic: "Basic", +syntax_pas: "Pascal", +syntax_brainfuck: "Brainfuck", +syntax_sql: "SQL", +syntax_ruby: "Ruby", +syntax_robotstxt: "Robots txt", +syntax_tsql: "T-SQL", +syntax_perl: "Perl", +syntax_coldfusion: "Coldfusion", +syntax_java: "Java", +close_tab: "Close file" +}; diff --git a/includes/edit_area/langs/en.js b/includes/edit_area/langs/en.js new file mode 100644 index 0000000000..e88692224b --- /dev/null +++ b/includes/edit_area/langs/en.js @@ -0,0 +1,67 @@ +editAreaLoader.lang["en"]={ +new_document: "new empty document", +search_button: "search and replace", +search_command: "search next / open search area", +search: "search", +replace: "replace", +replace_command: "replace / open search area", +find_next: "find next", +replace_all: "replace all", +reg_exp: "regular expressions", +match_case: "match case", +not_found: "not found.", +occurrence_replaced: "occurences replaced.", +search_field_empty: "Search field empty", +restart_search_at_begin: "End of area reached. Restart at begin.", +move_popup: "move search popup", +font_size: "--Font size--", +go_to_line: "go to line", +go_to_line_prompt: "go to line number:", +undo: "undo", +redo: "redo", +change_smooth_selection: "enable/disable some display features (smarter display but more CPU charge)", +highlight: "toggle syntax highlight on/off", +reset_highlight: "reset highlight (if desyncronized from text)", +word_wrap: "toggle word wrapping mode", +help: "about", +save: "save", +load: "load", +line_abbr: "Ln", +char_abbr: "Ch", +position: "Position", +total: "Total", +close_popup: "close popup", +shortcuts: "Shortcuts", +add_tab: "add tabulation to text", +remove_tab: "remove tabulation to text", +about_notice: "Notice: syntax highlight function is only for small text", +toggle: "Toggle editor", +accesskey: "Accesskey", +tab: "Tab", +shift: "Shift", +ctrl: "Ctrl", +esc: "Esc", +processing: "Processing...", +fullscreen: "fullscreen", +syntax_selection: "--Syntax--", +syntax_css: "CSS", +syntax_html: "HTML", +syntax_js: "Javascript", +syntax_php: "Php", +syntax_python: "Python", +syntax_vb: "Visual Basic", +syntax_xml: "Xml", +syntax_c: "C", +syntax_cpp: "CPP", +syntax_basic: "Basic", +syntax_pas: "Pascal", +syntax_brainfuck: "Brainfuck", +syntax_sql: "SQL", +syntax_ruby: "Ruby", +syntax_robotstxt: "Robots txt", +syntax_tsql: "T-SQL", +syntax_perl: "Perl", +syntax_coldfusion: "Coldfusion", +syntax_java: "Java", +close_tab: "Close file" +}; diff --git a/includes/edit_area/langs/eo.js b/includes/edit_area/langs/eo.js new file mode 100644 index 0000000000..889ef9a59c --- /dev/null +++ b/includes/edit_area/langs/eo.js @@ -0,0 +1,67 @@ +editAreaLoader.lang["eo"]={ +new_document: "nova dokumento (vakigas la enhavon)", +search_button: "serĉi / anstataŭigi", +search_command: "pluserĉi / malfermi la serĉo-fenestron", +search: "serĉi", +replace: "anstataŭigi", +replace_command: "anstataŭigi / malfermi la serĉo-fenestron", +find_next: "serĉi", +replace_all: "anstataŭigi ĉion", +reg_exp: "regula esprimo", +match_case: "respekti la usklecon", +not_found: "ne trovita.", +occurrence_replaced: "anstataŭigoj plenumitaj.", +search_field_empty: "La kampo estas malplena.", +restart_search_at_begin: "Fino de teksto ĝisrirata, ĉu daŭrigi el la komenco?", +move_popup: "movi la serĉo-fenestron", +font_size: "--Tipara grando--", +go_to_line: "iri al la linio", +go_to_line_prompt: "iri al la linio numero:", +undo: "rezigni", +redo: "refari", +change_smooth_selection: "ebligi/malebligi la funkcioj de vidigo (pli bona vidigo, sed pli da ŝarĝo de la ĉeforgano)", +highlight: "ebligi/malebligi la sintaksan kolorigon", +reset_highlight: "repravalorizi la sintaksan kolorigon (se malsinkronigon de la teksto)", +word_wrap: "toggle word wrapping mode", +help: "pri", +save: "registri", +load: "ŝarĝi", +line_abbr: "Ln", +char_abbr: "Sg", +position: "Pozicio", +total: "Sumo", +close_popup: "fermi la ŝprucfenestron", +shortcuts: "Fulmoklavo", +add_tab: "aldoni tabon en la tekston", +remove_tab: "forigi tablon el la teksto", +about_notice: "Noto: la sintaksa kolorigo estas nur prikalkulita por mallongaj tekstoj.", +toggle: "baskuligi la redaktilon", +accesskey: "Fulmoklavo", +tab: "Tab", +shift: "Maj", +ctrl: "Ktrl", +esc: "Esk", +processing: "ŝargante...", +fullscreen: "plenekrane", +syntax_selection: "--Sintakso--", +syntax_css: "CSS", +syntax_html: "HTML", +syntax_js: "Javascript", +syntax_php: "Php", +syntax_python: "Pitono", +syntax_vb: "Visual Basic", +syntax_xml: "Xml", +syntax_c: "C", +syntax_cpp: "CPP", +syntax_basic: "Basic", +syntax_pas: "Pascal", +syntax_brainfuck: "Brainfuck", +syntax_sql: "SQL", +syntax_ruby: "Ruby", +syntax_robotstxt: "Robots txt", +syntax_tsql: "T-SQL", +syntax_perl: "Perl", +syntax_coldfusion: "Coldfusion", +syntax_java: "Java", +close_tab: "Fermi la dosieron" +}; \ No newline at end of file diff --git a/includes/edit_area/langs/es.js b/includes/edit_area/langs/es.js new file mode 100644 index 0000000000..22a46ed720 --- /dev/null +++ b/includes/edit_area/langs/es.js @@ -0,0 +1,64 @@ +editAreaLoader.lang["es"]={ +new_document: "nuevo documento vacío", +search_button: "buscar y reemplazar", +search_command: "buscar siguiente / abrir área de búsqueda", +search: "buscar", +replace: "reemplazar", +replace_command: "reemplazar / abrir área de búsqueda", +find_next: "encontrar siguiente", +replace_all: "reemplazar todos", +reg_exp: "expresiones regulares", +match_case: "coincidir capitalización", +not_found: "no encontrado.", +occurrence_replaced: "ocurrencias reemplazadas.", +search_field_empty: "Campo de búsqueda vacío", +restart_search_at_begin: "Se ha llegado al final del área. Se va a seguir desde el principio.", +move_popup: "mover la ventana de búsqueda", +font_size: "--Tamaño de la fuente--", +go_to_line: "ir a la línea", +go_to_line_prompt: "ir a la línea número:", +undo: "deshacer", +redo: "rehacer", +change_smooth_selection: "activar/desactivar algunas características de visualización (visualización más inteligente pero más carga de CPU)", +highlight: "intercambiar resaltado de sintaxis", +reset_highlight: "reinicializar resaltado (si no esta sincronizado con el texto)", +word_wrap: "toggle word wrapping mode", +help: "acerca", +save: "guardar", +load: "cargar", +line_abbr: "Ln", +char_abbr: "Ch", +position: "Posición", +total: "Total", +close_popup: "recuadro de cierre", +shortcuts: "Atajos", +add_tab: "añadir tabulado al texto", +remove_tab: "borrar tabulado del texto", +about_notice: "Aviso: el resaltado de sintaxis sólo funciona para texto pequeño", +toggle: "Cambiar editor", +accesskey: "Tecla de acceso", +tab: "Tab", +shift: "Mayúsc", +ctrl: "Ctrl", +esc: "Esc", +processing: "Procesando...", +fullscreen: "pantalla completa", +syntax_selection: "--Syntax--", +syntax_css: "CSS", +syntax_html: "HTML", +syntax_js: "Javascript", +syntax_php: "Php", +syntax_python: "Python", +syntax_vb: "Visual Basic", +syntax_xml: "Xml", +syntax_c: "C", +syntax_cpp: "CPP", +syntax_basic: "Basic", +syntax_pas: "Pascal", +syntax_brainfuck: "Brainfuck", +syntax_sql: "SQL", +syntax_ruby: "Ruby", +syntax_coldfusion: "Coldfusion", +syntax_java: "Java", +close_tab: "Close file" +}; diff --git a/includes/edit_area/langs/fi.js b/includes/edit_area/langs/fi.js new file mode 100644 index 0000000000..a830b2de2d --- /dev/null +++ b/includes/edit_area/langs/fi.js @@ -0,0 +1,67 @@ +editAreaLoader.lang["fi"]={ +new_document: "uusi tyhjä dokumentti", +search_button: "etsi ja korvaa", +search_command: "etsi seuraava / avaa etsintävalikko", +search: "etsi", +replace: "korvaa", +replace_command: "korvaa / avaa etsintävalikko", +find_next: "etsi seuraava", +replace_all: "korvaa kaikki", +reg_exp: "säännölliset lausekkeet", +match_case: "täsmää kirjainkokoon", +not_found: "ei löytynyt.", +occurrence_replaced: "esiintymää korvattu.", +search_field_empty: "Haettava merkkijono on tyhjä", +restart_search_at_begin: "Alueen loppu saavutettiin. Aloitetaan alusta.", +move_popup: "siirrä etsintävalikkoa", +font_size: "--Fontin koko--", +go_to_line: "siirry riville", +go_to_line_prompt: "mene riville:", +undo: "peruuta", +redo: "tee uudelleen", +change_smooth_selection: "kytke/sammuta joitakin näyttötoimintoja (Älykkäämpi toiminta, mutta suurempi CPU kuormitus)", +highlight: "kytke syntaksikorostus päälle/pois", +reset_highlight: "resetoi syntaksikorostus (jos teksti ei ole synkassa korostuksen kanssa)", +word_wrap: "toggle word wrapping mode", +help: "tietoja", +save: "tallenna", +load: "lataa", +line_abbr: "Rv", +char_abbr: "Pos", +position: "Paikka", +total: "Yhteensä", +close_popup: "sulje valikko", +shortcuts: "Pikatoiminnot", +add_tab: "lisää sisennys tekstiin", +remove_tab: "poista sisennys tekstistä", +about_notice: "Huomautus: syntaksinkorostus toimii vain pienelle tekstille", +toggle: "Kytke editori", +accesskey: "Pikanäppäin", +tab: "Tab", +shift: "Shift", +ctrl: "Ctrl", +esc: "Esc", +processing: "Odota...", +fullscreen: "koko ruutu", +syntax_selection: "--Syntaksi--", +syntax_css: "CSS", +syntax_html: "HTML", +syntax_js: "Javascript", +syntax_php: "Php", +syntax_python: "Python", +syntax_vb: "Visual Basic", +syntax_xml: "Xml", +syntax_c: "C", +syntax_cpp: "CPP", +syntax_basic: "Basic", +syntax_pas: "Pascal", +syntax_brainfuck: "Brainfuck", +syntax_sql: "SQL", +syntax_ruby: "Ruby", +syntax_robotstxt: "Robots txt", +syntax_tsql: "T-SQL", +syntax_perl: "Perl", +syntax_coldfusion: "Coldfusion", +syntax_java: "Java", +close_tab: "Sulje tiedosto" +}; \ No newline at end of file diff --git a/includes/edit_area/langs/fr.js b/includes/edit_area/langs/fr.js new file mode 100644 index 0000000000..9a3bfe2767 --- /dev/null +++ b/includes/edit_area/langs/fr.js @@ -0,0 +1,67 @@ +editAreaLoader.lang["fr"]={ +new_document: "nouveau document (efface le contenu)", +search_button: "rechercher / remplacer", +search_command: "rechercher suivant / ouvrir la fenêtre de recherche", +search: "rechercher", +replace: "remplacer", +replace_command: "remplacer / ouvrir la fenêtre de recherche", +find_next: "rechercher", +replace_all: "tout remplacer", +reg_exp: "expr. régulière", +match_case: "respecter la casse", +not_found: "pas trouvé.", +occurrence_replaced: "remplacements éffectués.", +search_field_empty: "Le champ de recherche est vide.", +restart_search_at_begin: "Fin du texte atteint, poursuite au début.", +move_popup: "déplacer la fenêtre de recherche", +font_size: "--Taille police--", +go_to_line: "aller à la ligne", +go_to_line_prompt: "aller a la ligne numero:", +undo: "annuler", +redo: "refaire", +change_smooth_selection: "activer/désactiver des fonctions d'affichage (meilleur affichage mais plus de charge processeur)", +highlight: "activer/désactiver la coloration syntaxique", +reset_highlight: "réinitialiser la coloration syntaxique (si désyncronisée du texte)", +word_wrap: "activer/désactiver les retours à la ligne automatiques", +help: "à propos", +save: "sauvegarder", +load: "charger", +line_abbr: "Ln", +char_abbr: "Ch", +position: "Position", +total: "Total", +close_popup: "fermer le popup", +shortcuts: "Racourcis clavier", +add_tab: "ajouter une tabulation dans le texte", +remove_tab: "retirer une tabulation dans le texte", +about_notice: "Note: la coloration syntaxique n'est prévue que pour de courts textes.", +toggle: "basculer l'éditeur", +accesskey: "Accesskey", +tab: "Tab", +shift: "Maj", +ctrl: "Ctrl", +esc: "Esc", +processing: "chargement...", +fullscreen: "plein écran", +syntax_selection: "--Syntaxe--", +syntax_css: "CSS", +syntax_html: "HTML", +syntax_js: "Javascript", +syntax_php: "Php", +syntax_python: "Python", +syntax_vb: "Visual Basic", +syntax_xml: "Xml", +syntax_c: "C", +syntax_cpp: "CPP", +syntax_basic: "Basic", +syntax_pas: "Pascal", +syntax_brainfuck: "Brainfuck", +syntax_sql: "SQL", +syntax_ruby: "Ruby", +syntax_robotstxt: "Robots txt", +syntax_tsql: "T-SQL", +syntax_perl: "Perl", +syntax_coldfusion: "Coldfusion", +syntax_java: "Java", +close_tab: "Fermer le fichier" +}; diff --git a/includes/edit_area/langs/hr.js b/includes/edit_area/langs/hr.js new file mode 100644 index 0000000000..7ee249fdeb --- /dev/null +++ b/includes/edit_area/langs/hr.js @@ -0,0 +1,67 @@ +editAreaLoader.lang["hr"]={ +new_document: "Novi dokument", +search_button: "Traži i izmijeni", +search_command: "Traži dalje / Otvori prozor za traženje", +search: "Traži", +replace: "Izmijeni", +replace_command: "Izmijeni / Otvori prozor za traženje", +find_next: "Traži dalje", +replace_all: "Izmjeni sve", +reg_exp: "Regularni izrazi", +match_case: "Bitna vel. slova", +not_found: "nije naðeno.", +occurrence_replaced: "izmjenjenih.", +search_field_empty: "Prazno polje za traženje!", +restart_search_at_begin: "Došao do kraja. Poèeo od poèetka.", +move_popup: "Pomakni prozor", +font_size: "--Velièina teksta--", +go_to_line: "Odi na redak", +go_to_line_prompt: "Odi na redak:", +undo: "Vrati natrag", +redo: "Napravi ponovo", +change_smooth_selection: "Ukljuèi/iskljuèi neke moguænosti prikaza (pametniji prikaz, ali zagušeniji CPU)", +highlight: "Ukljuèi/iskljuèi bojanje sintakse", +reset_highlight: "Ponovi kolorizaciju (ako je nesinkronizirana s tekstom)", +word_wrap: "toggle word wrapping mode", +help: "O edit_area", +save: "Spremi", +load: "Uèitaj", +line_abbr: "Ln", +char_abbr: "Zn", +position: "Pozicija", +total: "Ukupno", +close_popup: "Zatvori prozor", +shortcuts: "Kratice", +add_tab: "Dodaj tabulaciju", +remove_tab: "Makni tabulaciju", +about_notice: "Napomena: koloriziranje sintakse je samo za kratke kodove", +toggle: "Prebaci naèin ureðivanja", +accesskey: "Accesskey", +tab: "Tab", +shift: "Shift", +ctrl: "Ctrl", +esc: "Esc", +processing: "Procesiram...", +fullscreen: "Cijeli prozor", +syntax_selection: "--Syntax--", +syntax_css: "CSS", +syntax_html: "HTML", +syntax_js: "Javascript", +syntax_php: "Php", +syntax_python: "Python", +syntax_vb: "Visual Basic", +syntax_xml: "Xml", +syntax_c: "C", +syntax_cpp: "CPP", +syntax_basic: "Basic", +syntax_pas: "Pascal", +syntax_brainfuck: "Brainfuck", +syntax_sql: "SQL", +syntax_ruby: "Ruby", +syntax_robotstxt: "Robots txt", +syntax_tsql: "T-SQL", +syntax_perl: "Perl", +syntax_coldfusion: "Coldfusion", +syntax_java: "Java", +close_tab: "Close file" +}; diff --git a/includes/edit_area/langs/it.js b/includes/edit_area/langs/it.js new file mode 100644 index 0000000000..f930dbf4a6 --- /dev/null +++ b/includes/edit_area/langs/it.js @@ -0,0 +1,67 @@ +editAreaLoader.lang["it"]={ +new_document: "nuovo documento vuoto", +search_button: "cerca e sostituisci", +search_command: "trova successivo / apri finestra di ricerca", +search: "cerca", +replace: "sostituisci", +replace_command: "sostituisci / apri finestra di ricerca", +find_next: "trova successivo", +replace_all: "sostituisci tutti", +reg_exp: "espressioni regolari", +match_case: "confronta maiuscole/minuscole
    ", +not_found: "non trovato.", +occurrence_replaced: "occorrenze sostituite.", +search_field_empty: "Campo ricerca vuoto", +restart_search_at_begin: "Fine del testo raggiunta. Ricomincio dall'inizio.", +move_popup: "sposta popup di ricerca", +font_size: "-- Dimensione --", +go_to_line: "vai alla linea", +go_to_line_prompt: "vai alla linea numero:", +undo: "annulla", +redo: "ripeti", +change_smooth_selection: "abilita/disabilita alcune caratteristiche della visualizzazione", +highlight: "abilita/disabilita colorazione della sintassi", +reset_highlight: "aggiorna colorazione (se non sincronizzata)", +word_wrap: "toggle word wrapping mode", +help: "informazioni su...", +save: "salva", +load: "carica", +line_abbr: "Ln", +char_abbr: "Ch", +position: "Posizione", +total: "Totale", +close_popup: "chiudi popup", +shortcuts: "Scorciatoie", +add_tab: "aggiungi tabulazione", +remove_tab: "rimuovi tabulazione", +about_notice: "Avviso: la colorazione della sintassi vale solo con testo piccolo", +toggle: "Abilita/disabilita editor", +accesskey: "Accesskey", +tab: "Tab", +shift: "Shift", +ctrl: "Ctrl", +esc: "Esc", +processing: "In corso...", +fullscreen: "fullscreen", +syntax_selection: "--Syntax--", +syntax_css: "CSS", +syntax_html: "HTML", +syntax_js: "Javascript", +syntax_php: "Php", +syntax_python: "Python", +syntax_vb: "Visual Basic", +syntax_xml: "Xml", +syntax_c: "C", +syntax_cpp: "CPP", +syntax_basic: "Basic", +syntax_pas: "Pascal", +syntax_brainfuck: "Brainfuck", +syntax_sql: "SQL", +syntax_ruby: "Ruby", +syntax_robotstxt: "Robots txt", +syntax_tsql: "T-SQL", +syntax_perl: "Perl", +syntax_coldfusion: "Coldfusion", +syntax_java: "Java", +close_tab: "Close file" +}; diff --git a/includes/edit_area/langs/ja.js b/includes/edit_area/langs/ja.js new file mode 100644 index 0000000000..c061b4b639 --- /dev/null +++ b/includes/edit_area/langs/ja.js @@ -0,0 +1,67 @@ +editAreaLoader.lang["ja"]={ +new_document: "新規作成", +search_button: "検索・置換", +search_command: "次を検索 / 検索窓を表示", +search: "検索", +replace: "置換", +replace_command: "置換 / 置換窓を表示", +find_next: "次を検索", +replace_all: "全置換", +reg_exp: "正規表現", +match_case: "大文字小文字の区別", +not_found: "見つかりません。", +occurrence_replaced: "置換しました。", +search_field_empty: "検索対象文字列が空です。", +restart_search_at_begin: "終端に達しました、始めに戻ります", +move_popup: "検索窓を移動", +font_size: "--フォントサイズ--", +go_to_line: "指定行へ移動", +go_to_line_prompt: "指定行へ移動します:", +undo: "元に戻す", +redo: "やり直し", +change_smooth_selection: "スムース表示の切り替え(CPUを使います)", +highlight: "構文強調表示の切り替え", +reset_highlight: "構文強調表示のリセット", +word_wrap: "toggle word wrapping mode", +help: "ヘルプを表示", +save: "保存", +load: "読み込み", +line_abbr: "行", +char_abbr: "文字", +position: "位置", +total: "合計", +close_popup: "ポップアップを閉じる", +shortcuts: "ショートカット", +add_tab: "タブを挿入する", +remove_tab: "タブを削除する", +about_notice: "注意:構文強調表示は短いテキストでしか有効に機能しません。", +toggle: "テキストエリアとeditAreaの切り替え", +accesskey: "アクセスキー", +tab: "Tab", +shift: "Shift", +ctrl: "Ctrl", +esc: "Esc", +processing: "処理中です...", +fullscreen: "fullscreen", +syntax_selection: "--Syntax--", +syntax_css: "CSS", +syntax_html: "HTML", +syntax_js: "Javascript", +syntax_php: "Php", +syntax_python: "Python", +syntax_vb: "Visual Basic", +syntax_xml: "Xml", +syntax_c: "C", +syntax_cpp: "CPP", +syntax_basic: "Basic", +syntax_pas: "Pascal", +syntax_brainfuck: "Brainfuck", +syntax_sql: "SQL", +syntax_ruby: "Ruby", +syntax_robotstxt: "Robots txt", +syntax_tsql: "T-SQL", +syntax_perl: "Perl", +syntax_coldfusion: "Coldfusion", +syntax_java: "Java", +close_tab: "Close file" +}; diff --git a/includes/edit_area/langs/mk.js b/includes/edit_area/langs/mk.js new file mode 100644 index 0000000000..a2d9d215ca --- /dev/null +++ b/includes/edit_area/langs/mk.js @@ -0,0 +1,67 @@ +editAreaLoader.lang["mk"]={ +new_document: "Нов документ", +search_button: "Најди и замени", +search_command: "Барај следно / Отвори нов прозорец за пребарување", +search: "Барај", +replace: "Замени", +replace_command: "Замени / Отвори прозорец за пребарување", +find_next: "најди следно", +replace_all: "Замени ги сите", +reg_exp: "Регуларни изрази", +match_case: "Битна е големината на буквите", +not_found: "не е пронајдено.", +occurrence_replaced: "замени.", +search_field_empty: "Полето за пребарување е празно", +restart_search_at_begin: "Крај на областа. Стартувај од почеток.", +move_popup: "Помести го прозорецот", +font_size: "--Големина на текстот--", +go_to_line: "Оди на линија", +go_to_line_prompt: "Оди на линија со број:", +undo: "Врати", +redo: "Повтори", +change_smooth_selection: "Вклучи/исклучи некои карактеристики за приказ (попаметен приказ, но поголемо оптеретување за процесорот)", +highlight: "Вклучи/исклучи осветлување на синтакса", +reset_highlight: "Ресетирај го осветлувањето на синтакса (доколку е десинхронизиранo со текстот)", +word_wrap: "toggle word wrapping mode", +help: "За", +save: "Зачувај", +load: "Вчитај", +line_abbr: "Лн", +char_abbr: "Зн", +position: "Позиција", +total: "Вкупно", +close_popup: "Затвори го прозорецот", +shortcuts: "Кратенки", +add_tab: "Додај табулација на текстот", +remove_tab: "Отстрани ја табулацијата", +about_notice: "Напомена: Осветлувањето на синтанса е само за краток текст", +toggle: "Смени начин на уредување", +accesskey: "Accesskey", +tab: "Tab", +shift: "Shift", +ctrl: "Ctrl", +esc: "Esc", +processing: "Обработувам...", +fullscreen: "Цел прозорец", +syntax_selection: "--Синтакса--", +syntax_css: "CSS", +syntax_html: "HTML", +syntax_js: "Javascript", +syntax_php: "Php", +syntax_python: "Python", +syntax_vb: "Visual Basic", +syntax_xml: "Xml", +syntax_c: "C", +syntax_cpp: "CPP", +syntax_basic: "Basic", +syntax_pas: "Pascal", +syntax_brainfuck: "Brainfuck", +syntax_sql: "SQL", +syntax_ruby: "Ruby", +syntax_robotstxt: "Robots txt", +syntax_tsql: "T-SQL", +syntax_perl: "Perl", +syntax_coldfusion: "Coldfusion", +syntax_java: "Java", +close_tab: "Избери датотека" +}; diff --git a/includes/edit_area/langs/nl.js b/includes/edit_area/langs/nl.js new file mode 100644 index 0000000000..28ec3bfe8c --- /dev/null +++ b/includes/edit_area/langs/nl.js @@ -0,0 +1,67 @@ +editAreaLoader.lang["nl"]={ +new_document: "nieuw leeg document", +search_button: "zoek en vervang", +search_command: "zoek volgende / zoekscherm openen", +search: "zoek", +replace: "vervang", +replace_command: "vervang / zoekscherm openen", +find_next: "volgende vinden", +replace_all: "alles vervangen", +reg_exp: "reguliere expressies", +match_case: "hoofdletter gevoelig", +not_found: "niet gevonden.", +occurrence_replaced: "object vervangen.", +search_field_empty: "Zoek veld leeg", +restart_search_at_begin: "Niet meer instanties gevonden, begin opnieuw", +move_popup: "versleep zoek scherm", +font_size: "--Letter grootte--", +go_to_line: "Ga naar regel", +go_to_line_prompt: "Ga naar regel nummer:", +undo: "Ongedaan maken", +redo: "Opnieuw doen", +change_smooth_selection: "zet wat schermopties aan/uit (kan langzamer zijn)", +highlight: "zet syntax highlight aan/uit", +reset_highlight: "reset highlight (indien gedesynchronizeerd)", +word_wrap: "toggle word wrapping mode", +help: "informatie", +save: "opslaan", +load: "laden", +line_abbr: "Ln", +char_abbr: "Ch", +position: "Positie", +total: "Totaal", +close_popup: "Popup sluiten", +shortcuts: "Snelkoppelingen", +add_tab: "voeg tabs toe in tekst", +remove_tab: "verwijder tabs uit tekst", +about_notice: "Notitie: syntax highlight functie is alleen voor kleine tekst", +toggle: "geavanceerde bewerkingsopties", +accesskey: "Accessknop", +tab: "Tab", +shift: "Shift", +ctrl: "Ctrl", +esc: "Esc", +processing: "Verwerken...", +fullscreen: "fullscreen", +syntax_selection: "--Syntax--", +syntax_css: "CSS", +syntax_html: "HTML", +syntax_js: "Javascript", +syntax_php: "Php", +syntax_python: "Python", +syntax_vb: "Visual Basic", +syntax_xml: "Xml", +syntax_c: "C", +syntax_cpp: "CPP", +syntax_basic: "Basic", +syntax_pas: "Pascal", +syntax_brainfuck: "Brainfuck", +syntax_sql: "SQL", +syntax_ruby: "Ruby", +syntax_robotstxt: "Robots txt", +syntax_tsql: "T-SQL", +syntax_perl: "Perl", +syntax_coldfusion: "Coldfusion", +syntax_java: "Java", +close_tab: "Close file" +}; diff --git a/includes/edit_area/langs/pl.js b/includes/edit_area/langs/pl.js new file mode 100644 index 0000000000..358af92db3 --- /dev/null +++ b/includes/edit_area/langs/pl.js @@ -0,0 +1,67 @@ +editAreaLoader.lang["pl"]={ +new_document: "nowy dokument", +search_button: "znajdź i zamień", +search_command: "znajdź następny", +search: "znajdź", +replace: "zamień", +replace_command: "zamień", +find_next: "następny", +replace_all: "zamień wszystko", +reg_exp: "wyrażenie regularne", +match_case: "uwzględnij wielkość liter
    ", +not_found: "nie znaleziono.", +occurrence_replaced: "wystąpień zamieniono.", +search_field_empty: "Nie wprowadzono tekstu", +restart_search_at_begin: "Koniec dokumentu. Wyszukiwanie od początku.", +move_popup: "przesuń okienko wyszukiwania", +font_size: "Rozmiar", +go_to_line: "idź do linii", +go_to_line_prompt: "numer linii:", +undo: "cofnij", +redo: "przywróć", +change_smooth_selection: "włącz/wyłącz niektóre opcje wyglądu (zaawansowane opcje wyglądu obciążają procesor)", +highlight: "włącz/wyłącz podświetlanie składni", +reset_highlight: "odśwież podświetlanie składni (jeśli rozsynchronizowało się z tekstem)", +word_wrap: "toggle word wrapping mode", +help: "o programie", +save: "zapisz", +load: "otwórz", +line_abbr: "Ln", +char_abbr: "Zn", +position: "Pozycja", +total: "W sumie", +close_popup: "zamknij okienko", +shortcuts: "Skróty klawiaturowe", +add_tab: "dodaj wcięcie do zaznaczonego tekstu", +remove_tab: "usuń wcięcie", +about_notice: "Uwaga: podświetlanie składni nie jest zalecane dla długich tekstów", +toggle: "Włącz/wyłącz edytor", +accesskey: "Alt+", +tab: "Tab", +shift: "Shift", +ctrl: "Ctrl", +esc: "Esc", +processing: "Przetwarzanie...", +fullscreen: "fullscreen", +syntax_selection: "--Syntax--", +syntax_css: "CSS", +syntax_html: "HTML", +syntax_js: "Javascript", +syntax_php: "Php", +syntax_python: "Python", +syntax_vb: "Visual Basic", +syntax_xml: "Xml", +syntax_c: "C", +syntax_cpp: "CPP", +syntax_basic: "Basic", +syntax_pas: "Pascal", +syntax_brainfuck: "Brainfuck", +syntax_sql: "SQL", +syntax_ruby: "Ruby", +syntax_robotstxt: "Robots txt", +syntax_tsql: "T-SQL", +syntax_perl: "Perl", +syntax_coldfusion: "Coldfusion", +syntax_java: "Java", +close_tab: "Close file" +}; diff --git a/includes/edit_area/langs/pt.js b/includes/edit_area/langs/pt.js new file mode 100644 index 0000000000..baa839d922 --- /dev/null +++ b/includes/edit_area/langs/pt.js @@ -0,0 +1,67 @@ +editAreaLoader.lang["pt"]={ +new_document: "Novo documento", +search_button: "Localizar e substituir", +search_command: "Localizar próximo", +search: "Localizar", +replace: "Substituir", +replace_command: "Substituir", +find_next: "Localizar", +replace_all: "Subst. tudo", +reg_exp: "Expressões regulares", +match_case: "Diferenciar maiúsculas e minúsculas", +not_found: "Não encontrado.", +occurrence_replaced: "Ocorrências substituidas", +search_field_empty: "Campo localizar vazio.", +restart_search_at_begin: "Fim das ocorrências. Recomeçar do inicio.", +move_popup: "Mover janela", +font_size: "--Tamanho da fonte--", +go_to_line: "Ir para linha", +go_to_line_prompt: "Ir para a linha:", +undo: "Desfazer", +redo: "Refazer", +change_smooth_selection: "Opções visuais", +highlight: "Cores de sintaxe", +reset_highlight: "Resetar cores (se não sincronizado)", +word_wrap: "toggle word wrapping mode", +help: "Sobre", +save: "Salvar", +load: "Carregar", +line_abbr: "Ln", +char_abbr: "Ch", +position: "Posição", +total: "Total", +close_popup: "Fechar", +shortcuts: "Shortcuts", +add_tab: "Adicionar tabulação", +remove_tab: "Remover tabulação", +about_notice: "Atenção: Cores de sintaxe são indicados somente para textos pequenos", +toggle: "Exibir editor", +accesskey: "Accesskey", +tab: "Tab", +shift: "Shift", +ctrl: "Ctrl", +esc: "Esc", +processing: "Processando...", +fullscreen: "fullscreen", +syntax_selection: "--Syntax--", +syntax_css: "CSS", +syntax_html: "HTML", +syntax_js: "Javascript", +syntax_php: "Php", +syntax_python: "Python", +syntax_vb: "Visual Basic", +syntax_xml: "Xml", +syntax_c: "C", +syntax_cpp: "CPP", +syntax_basic: "Basic", +syntax_pas: "Pascal", +syntax_brainfuck: "Brainfuck", +syntax_sql: "SQL", +syntax_ruby: "Ruby", +syntax_robotstxt: "Robots txt", +syntax_tsql: "T-SQL", +syntax_perl: "Perl", +syntax_coldfusion: "Coldfusion", +syntax_java: "Java", +close_tab: "Close file" +}; diff --git a/includes/edit_area/langs/ru.js b/includes/edit_area/langs/ru.js new file mode 100644 index 0000000000..89b47452a6 --- /dev/null +++ b/includes/edit_area/langs/ru.js @@ -0,0 +1,67 @@ +editAreaLoader.lang["ru"]={ +new_document: "новый пустой документ", +search_button: "поиск и замена", +search_command: "искать следующий / открыть панель поиска", +search: "поиск", +replace: "замена", +replace_command: "заменить / открыть панель поиска", +find_next: "найти следующее", +replace_all: "заменить все", +reg_exp: "регулярное выражение", +match_case: "учитывать регистр", +not_found: "не найдено.", +occurrence_replaced: "вхождение заменено.", +search_field_empty: "Поле поиска пустое", +restart_search_at_begin: "Достигнут конец документа. Начинаю с начала.", +move_popup: "переместить окно поиска", +font_size: "--Размер шрифта--", +go_to_line: "перейти к строке", +go_to_line_prompt: "перейти к строке номер:", +undo: "отменить", +redo: "вернуть", +change_smooth_selection: "включить/отключить некоторые функции просмотра (более красиво, но больше использует процессор)", +highlight: "переключить подсветку синтаксиса включена/выключена", +reset_highlight: "восстановить подсветку (если разсинхронизирована от текста)", +word_wrap: "toggle word wrapping mode", +help: "о программе", +save: "сохранить", +load: "загрузить", +line_abbr: "Стр", +char_abbr: "Стлб", +position: "Позиция", +total: "Всего", +close_popup: "закрыть всплывающее окно", +shortcuts: "Горячие клавиши", +add_tab: "добавить табуляцию в текст", +remove_tab: "убрать табуляцию из текста", +about_notice: "Внимание: функция подсветки синтаксиса только для небольших текстов", +toggle: "Переключить редактор", +accesskey: "Горячая клавиша", +tab: "Tab", +shift: "Shift", +ctrl: "Ctrl", +esc: "Esc", +processing: "Обработка...", +fullscreen: "полный экран", +syntax_selection: "--Синтакс--", +syntax_css: "CSS", +syntax_html: "HTML", +syntax_js: "Javascript", +syntax_php: "Php", +syntax_python: "Python", +syntax_vb: "Visual Basic", +syntax_xml: "Xml", +syntax_c: "C", +syntax_cpp: "CPP", +syntax_basic: "Basic", +syntax_pas: "Pascal", +syntax_brainfuck: "Brainfuck", +syntax_sql: "SQL", +syntax_ruby: "Ruby", +syntax_robotstxt: "Robots txt", +syntax_tsql: "T-SQL", +syntax_perl: "Perl", +syntax_coldfusion: "Coldfusion", +syntax_java: "Java", +close_tab: "Закрыть файл" +}; diff --git a/includes/edit_area/langs/sk.js b/includes/edit_area/langs/sk.js new file mode 100644 index 0000000000..4340646dc7 --- /dev/null +++ b/includes/edit_area/langs/sk.js @@ -0,0 +1,67 @@ +editAreaLoader.lang["sk"]={ +new_document: "nový prázdy dokument", +search_button: "vyhľadaj a nahraď", +search_command: "hľadaj ďalsšie / otvor vyhľadávacie pole", +search: "hľadaj", +replace: "nahraď", +replace_command: "nahraď / otvor vyhľadávacie pole", +find_next: "nájdi ďalšie", +replace_all: "nahraď všetko", +reg_exp: "platné výrazy", +match_case: "zhodujúce sa výrazy", +not_found: "nenájdené.", +occurrence_replaced: "výskyty nahradené.", +search_field_empty: "Pole vyhľadávanie je prádzne", +restart_search_at_begin: "End of area reached. Restart at begin.", +move_popup: "presuň vyhľadávacie okno", +font_size: "--Veľkosť textu--", +go_to_line: "prejdi na riadok", +go_to_line_prompt: "prejdi na riadok:", +undo: "krok späť", +redo: "prepracovať", +change_smooth_selection: "povoliť/zamietnúť niektoré zo zobrazených funkcií (účelnejšie zobrazenie vyžaduje väčšie zaťaženie procesora CPU)", +highlight: "prepnúť zvýrazňovanie syntaxe zap/vyp", +reset_highlight: "zrušiť zvýrazňovanie (ak je nesynchronizované s textom)", +word_wrap: "toggle word wrapping mode", +help: "o programe", +save: "uložiť", +load: "načítať", +line_abbr: "Ln", +char_abbr: "Ch", +position: "Pozícia", +total: "Spolu", +close_popup: "zavrieť okno", +shortcuts: "Skratky", +add_tab: "pridať tabulovanie textu", +remove_tab: "odstrániť tabulovanie textu", +about_notice: "Upozornenie: funkcia zvýrazňovania syntaxe je dostupná iba pre malý text", +toggle: "Prepnúť editor", +accesskey: "Accesskey", +tab: "Záložka", +shift: "Shift", +ctrl: "Ctrl", +esc: "Esc", +processing: "Spracúvam...", +fullscreen: "cel=a obrazovka", +syntax_selection: "--Vyber Syntax--", +syntax_css: "CSS", +syntax_html: "HTML", +syntax_js: "Javascript", +syntax_php: "Php", +syntax_python: "Python", +syntax_vb: "Visual Basic", +syntax_xml: "Xml", +syntax_c: "C", +syntax_cpp: "CPP", +syntax_basic: "Basic", +syntax_pas: "Pascal", +syntax_brainfuck: "Brainfuck", +syntax_sql: "SQL", +syntax_ruby: "Ruby", +syntax_robotstxt: "Robots txt", +syntax_tsql: "T-SQL", +syntax_perl: "Perl", +syntax_coldfusion: "Coldfusion", +syntax_java: "Java", +close_tab: "Close file" +}; diff --git a/includes/edit_area/langs/zh.js b/includes/edit_area/langs/zh.js new file mode 100644 index 0000000000..baecca7871 --- /dev/null +++ b/includes/edit_area/langs/zh.js @@ -0,0 +1,67 @@ +editAreaLoader.lang["zh"]={ +new_document: "新建空白文档", +search_button: "查找与替换", +search_command: "查找下一个 / 打开查找框", +search: "查找", +replace: "替换", +replace_command: "替换 / 打开查找框", +find_next: "查找下一个", +replace_all: "全部替换", +reg_exp: "正则表达式", +match_case: "匹配大小写", +not_found: "未找到.", +occurrence_replaced: "处被替换.", +search_field_empty: "查找框没有内容", +restart_search_at_begin: "已到到文档末尾. 从头重新查找.", +move_popup: "移动查找对话框", +font_size: "--字体大小--", +go_to_line: "转到行", +go_to_line_prompt: "转到行:", +undo: "恢复", +redo: "重做", +change_smooth_selection: "启用/禁止一些显示特性(更好看但更耗费资源)", +highlight: "启用/禁止语法高亮", +reset_highlight: "重置语法高亮(当文本显示不同步时)", +word_wrap: "toggle word wrapping mode", +help: "关于", +save: "保存", +load: "加载", +line_abbr: "行", +char_abbr: "字符", +position: "位置", +total: "总计", +close_popup: "关闭对话框", +shortcuts: "快捷键", +add_tab: "添加制表符(Tab)", +remove_tab: "移除制表符(Tab)", +about_notice: "注意:语法高亮功能仅用于较少内容的文本(文件内容太大会导致浏览器反应慢)", +toggle: "切换编辑器", +accesskey: "快捷键", +tab: "Tab", +shift: "Shift", +ctrl: "Ctrl", +esc: "Esc", +processing: "正在处理中...", +fullscreen: "全屏编辑", +syntax_selection: "--语法--", +syntax_css: "CSS", +syntax_html: "HTML", +syntax_js: "Javascript", +syntax_php: "Php", +syntax_python: "Python", +syntax_vb: "Visual Basic", +syntax_xml: "Xml", +syntax_c: "C", +syntax_cpp: "CPP", +syntax_basic: "Basic", +syntax_pas: "Pascal", +syntax_brainfuck: "Brainfuck", +syntax_sql: "SQL", +syntax_ruby: "Ruby", +syntax_robotstxt: "Robots txt", +syntax_tsql: "T-SQL", +syntax_perl: "Perl", +syntax_coldfusion: "Coldfusion", +syntax_java: "Java", +close_tab: "关闭文件" +}; diff --git a/includes/edit_area/plugins/charmap/charmap.js b/includes/edit_area/plugins/charmap/charmap.js new file mode 100644 index 0000000000..631e92ed3e --- /dev/null +++ b/includes/edit_area/plugins/charmap/charmap.js @@ -0,0 +1,90 @@ +/** + * Charmap plugin + * by Christophe Dolivet + * v0.1 (2006/09/22) + * + * + * This plugin allow to use a visual keyboard allowing to insert any UTF-8 characters in the text. + * + * - plugin name to add to the plugin list: "charmap" + * - plugin name to add to the toolbar list: "charmap" + * - possible parameters to add to EditAreaLoader.init(): + * "charmap_default": (String) define the name of the default character range displayed on popup display + * (default: "arrows") + * + * + */ + +var EditArea_charmap= { + /** + * Get called once this file is loaded (editArea still not initialized) + * + * @return nothing + */ + init: function(){ + this.default_language="Arrows"; + } + + /** + * Returns the HTML code for a specific control string or false if this plugin doesn't have that control. + * A control can be a button, select list or any other HTML item to present in the EditArea user interface. + * Language variables such as {$lang_somekey} will also be replaced with contents from + * the language packs. + * + * @param {string} ctrl_name: the name of the control to add + * @return HTML code for a specific control or false. + * @type string or boolean + */ + ,get_control_html: function(ctrl_name){ + switch(ctrl_name){ + case "charmap": + // Control id, button img, command + return parent.editAreaLoader.get_button_html('charmap_but', 'charmap.gif', 'charmap_press', false, this.baseURL); + } + return false; + } + /** + * Get called once EditArea is fully loaded and initialised + * + * @return nothing + */ + ,onload: function(){ + if(editArea.settings["charmap_default"] && editArea.settings["charmap_default"].length>0) + this.default_language= editArea.settings["charmap_default"]; + } + + /** + * Is called each time the user touch a keyboard key. + * + * @param (event) e: the keydown event + * @return true - pass to next handler in chain, false - stop chain execution + * @type boolean + */ + ,onkeydown: function(e){ + + } + + /** + * Executes a specific command, this function handles plugin commands. + * + * @param {string} cmd: the name of the command being executed + * @param {unknown} param: the parameter of the command + * @return true - pass to next handler in chain, false - stop chain execution + * @type boolean + */ + ,execCommand: function(cmd, param){ + // Handle commands + switch(cmd){ + case "charmap_press": + win= window.open(this.baseURL+"popup.html", "charmap", "width=500,height=270,scrollbars=yes,resizable=yes"); + win.focus(); + return false; + } + // Pass to next handler in chain + return true; + } + +}; + +// Adds the plugin class to the list of available EditArea plugins +editArea.add_plugin("charmap", EditArea_charmap); diff --git a/includes/edit_area/plugins/charmap/css/charmap.css b/includes/edit_area/plugins/charmap/css/charmap.css new file mode 100644 index 0000000000..c447509184 --- /dev/null +++ b/includes/edit_area/plugins/charmap/css/charmap.css @@ -0,0 +1,64 @@ +body{ + background-color: #F0F0EE; + font: 12px monospace, sans-serif; +} + +select{ + background-color: #F9F9F9; + border: solid 1px #888888; +} + +h1, h2, h3, h4, h5, h6{ + margin: 0; + padding: 0; + color: #2B6FB6; +} + +h1{ + font-size: 1.5em; +} + +div#char_list{ + height: 200px; + overflow: auto; + padding: 1px; + border: 1px solid #0A246A; + background-color: #F9F9F9; + clear: both; + margin-top: 5px; +} + +a.char{ + display: block; + float: left; + width: 20px; + height: 20px; + line-height: 20px; + margin: 1px; + border: solid 1px #888888; + text-align: center; + cursor: pointer; +} + +a.char:hover{ + background-color: #CCCCCC; +} + +.preview{ + border: solid 1px #888888; + width: 50px; + padding: 2px 5px; + height: 35px; + line-height: 35px; + text-align:center; + background-color: #CCCCCC; + font-size: 2em; + float: right; + font-weight: bold; + margin: 0 0 5px 5px; +} + +#preview_code{ + font-size: 1.1em; + width: 70px; +} diff --git a/includes/edit_area/plugins/charmap/images/charmap.gif b/includes/edit_area/plugins/charmap/images/charmap.gif new file mode 100644 index 0000000000..3cdc4ac913 Binary files /dev/null and b/includes/edit_area/plugins/charmap/images/charmap.gif differ diff --git a/includes/edit_area/plugins/charmap/jscripts/map.js b/includes/edit_area/plugins/charmap/jscripts/map.js new file mode 100644 index 0000000000..e6008473f8 --- /dev/null +++ b/includes/edit_area/plugins/charmap/jscripts/map.js @@ -0,0 +1,373 @@ +var editArea; + + +/** + * UTF-8 list taken from http://www.utf8-chartable.de/unicode-utf8-table.pl?utf8=dec + */ + + +/* +var char_range_list={ +"Basic Latin":"0021,007F", +"Latin-1 Supplement":"0080,00FF", +"Latin Extended-A":"0100,017F", +"Latin Extended-B":"0180,024F", +"IPA Extensions":"0250,02AF", +"Spacing Modifier Letters":"02B0,02FF", + +"Combining Diacritical Marks":"0300,036F", +"Greek and Coptic":"0370,03FF", +"Cyrillic":"0400,04FF", +"Cyrillic Supplement":"0500,052F", +"Armenian":"0530,058F", +"Hebrew":"0590,05FF", +"Arabic":"0600,06FF", +"Syriac":"0700,074F", +"Arabic Supplement":"0750,077F", + +"Thaana":"0780,07BF", +"Devanagari":"0900,097F", +"Bengali":"0980,09FF", +"Gurmukhi":"0A00,0A7F", +"Gujarati":"0A80,0AFF", +"Oriya":"0B00,0B7F", +"Tamil":"0B80,0BFF", +"Telugu":"0C00,0C7F", +"Kannada":"0C80,0CFF", + +"Malayalam":"0D00,0D7F", +"Sinhala":"0D80,0DFF", +"Thai":"0E00,0E7F", +"Lao":"0E80,0EFF", +"Tibetan":"0F00,0FFF", +"Myanmar":"1000,109F", +"Georgian":"10A0,10FF", +"Hangul Jamo":"1100,11FF", +"Ethiopic":"1200,137F", + +"Ethiopic Supplement":"1380,139F", +"Cherokee":"13A0,13FF", +"Unified Canadian Aboriginal Syllabics":"1400,167F", +"Ogham":"1680,169F", +"Runic":"16A0,16FF", +"Tagalog":"1700,171F", +"Hanunoo":"1720,173F", +"Buhid":"1740,175F", +"Tagbanwa":"1760,177F", + +"Khmer":"1780,17FF", +"Mongolian":"1800,18AF", +"Limbu":"1900,194F", +"Tai Le":"1950,197F", +"New Tai Lue":"1980,19DF", +"Khmer Symbols":"19E0,19FF", +"Buginese":"1A00,1A1F", +"Phonetic Extensions":"1D00,1D7F", +"Phonetic Extensions Supplement":"1D80,1DBF", + +"Combining Diacritical Marks Supplement":"1DC0,1DFF", +"Latin Extended Additional":"1E00,1EFF", +"Greek Extended":"1F00,1FFF", +"General Punctuation":"2000,206F", +"Superscripts and Subscripts":"2070,209F", +"Currency Symbols":"20A0,20CF", +"Combining Diacritical Marks for Symbols":"20D0,20FF", +"Letterlike Symbols":"2100,214F", +"Number Forms":"2150,218F", + +"Arrows":"2190,21FF", +"Mathematical Operators":"2200,22FF", +"Miscellaneous Technical":"2300,23FF", +"Control Pictures":"2400,243F", +"Optical Character Recognition":"2440,245F", +"Enclosed Alphanumerics":"2460,24FF", +"Box Drawing":"2500,257F", +"Block Elements":"2580,259F", +"Geometric Shapes":"25A0,25FF", + +"Miscellaneous Symbols":"2600,26FF", +"Dingbats":"2700,27BF", +"Miscellaneous Mathematical Symbols-A":"27C0,27EF", +"Supplemental Arrows-A":"27F0,27FF", +"Braille Patterns":"2800,28FF", +"Supplemental Arrows-B":"2900,297F", +"Miscellaneous Mathematical Symbols-B":"2980,29FF", +"Supplemental Mathematical Operators":"2A00,2AFF", +"Miscellaneous Symbols and Arrows":"2B00,2BFF", + +"Glagolitic":"2C00,2C5F", +"Coptic":"2C80,2CFF", +"Georgian Supplement":"2D00,2D2F", +"Tifinagh":"2D30,2D7F", +"Ethiopic Extended":"2D80,2DDF", +"Supplemental Punctuation":"2E00,2E7F", +"CJK Radicals Supplement":"2E80,2EFF", +"Kangxi Radicals":"2F00,2FDF", +"Ideographic Description Characters":"2FF0,2FFF", + +"CJK Symbols and Punctuation":"3000,303F", +"Hiragana":"3040,309F", +"Katakana":"30A0,30FF", +"Bopomofo":"3100,312F", +"Hangul Compatibility Jamo":"3130,318F", +"Kanbun":"3190,319F", +"Bopomofo Extended":"31A0,31BF", +"CJK Strokes":"31C0,31EF", +"Katakana Phonetic Extensions":"31F0,31FF", + +"Enclosed CJK Letters and Months":"3200,32FF", +"CJK Compatibility":"3300,33FF", +"CJK Unified Ideographs Extension A":"3400,4DBF", +"Yijing Hexagram Symbols":"4DC0,4DFF", +"CJK Unified Ideographs":"4E00,9FFF", +"Yi Syllables":"A000,A48F", +"Yi Radicals":"A490,A4CF", +"Modifier Tone Letters":"A700,A71F", +"Syloti Nagri":"A800,A82F", + +"Hangul Syllables":"AC00,D7AF", +"High Surrogates":"D800,DB7F", +"High Private Use Surrogates":"DB80,DBFF", +"Low Surrogates":"DC00,DFFF", +"Private Use Area":"E000,F8FF", +"CJK Compatibility Ideographs":"F900,FAFF", +"Alphabetic Presentation Forms":"FB00,FB4F", +"Arabic Presentation Forms-A":"FB50,FDFF", +"Variation Selectors":"FE00,FE0F", + +"Vertical Forms":"FE10,FE1F", +"Combining Half Marks":"FE20,FE2F", +"CJK Compatibility Forms":"FE30,FE4F", +"Small Form Variants":"FE50,FE6F", +"Arabic Presentation Forms-B":"FE70,FEFF", +"Halfwidth and Fullwidth Forms":"FF00,FFEF", +"Specials":"FFF0,FFFF", +"Linear B Syllabary":"10000,1007F", +"Linear B Ideograms":"10080,100FF", + +"Aegean Numbers":"10100,1013F", +"Ancient Greek Numbers":"10140,1018F", +"Old Italic":"10300,1032F", +"Gothic":"10330,1034F", +"Ugaritic":"10380,1039F", +"Old Persian":"103A0,103DF", +"Deseret":"10400,1044F", +"Shavian":"10450,1047F", +"Osmanya":"10480,104AF", + +"Cypriot Syllabary":"10800,1083F", +"Kharoshthi":"10A00,10A5F", +"Byzantine Musical Symbols":"1D000,1D0FF", +"Musical Symbols":"1D100,1D1FF", +"Ancient Greek Musical Notation":"1D200,1D24F", +"Tai Xuan Jing Symbols":"1D300,1D35F", +"Mathematical Alphanumeric Symbols":"1D400,1D7FF", +"CJK Unified Ideographs Extension B":"20000,2A6DF", +"CJK Compatibility Ideographs Supplement":"2F800,2FA1F", +"Tags":"E0000,E007F", +"Variation Selectors Supplement":"E0100,E01EF" +}; +*/ +var char_range_list={ +"Aegean Numbers":"10100,1013F", +"Alphabetic Presentation Forms":"FB00,FB4F", +"Ancient Greek Musical Notation":"1D200,1D24F", +"Ancient Greek Numbers":"10140,1018F", +"Arabic":"0600,06FF", +"Arabic Presentation Forms-A":"FB50,FDFF", +"Arabic Presentation Forms-B":"FE70,FEFF", +"Arabic Supplement":"0750,077F", +"Armenian":"0530,058F", +"Arrows":"2190,21FF", +"Basic Latin":"0020,007F", +"Bengali":"0980,09FF", +"Block Elements":"2580,259F", +"Bopomofo Extended":"31A0,31BF", +"Bopomofo":"3100,312F", +"Box Drawing":"2500,257F", +"Braille Patterns":"2800,28FF", +"Buginese":"1A00,1A1F", +"Buhid":"1740,175F", +"Byzantine Musical Symbols":"1D000,1D0FF", +"CJK Compatibility Forms":"FE30,FE4F", +"CJK Compatibility Ideographs Supplement":"2F800,2FA1F", +"CJK Compatibility Ideographs":"F900,FAFF", +"CJK Compatibility":"3300,33FF", +"CJK Radicals Supplement":"2E80,2EFF", +"CJK Strokes":"31C0,31EF", +"CJK Symbols and Punctuation":"3000,303F", +"CJK Unified Ideographs Extension A":"3400,4DBF", +"CJK Unified Ideographs Extension B":"20000,2A6DF", +"CJK Unified Ideographs":"4E00,9FFF", +"Cherokee":"13A0,13FF", +"Combining Diacritical Marks Supplement":"1DC0,1DFF", +"Combining Diacritical Marks for Symbols":"20D0,20FF", +"Combining Diacritical Marks":"0300,036F", +"Combining Half Marks":"FE20,FE2F", +"Control Pictures":"2400,243F", +"Coptic":"2C80,2CFF", +"Currency Symbols":"20A0,20CF", +"Cypriot Syllabary":"10800,1083F", +"Cyrillic Supplement":"0500,052F", +"Cyrillic":"0400,04FF", +"Deseret":"10400,1044F", +"Devanagari":"0900,097F", +"Dingbats":"2700,27BF", +"Enclosed Alphanumerics":"2460,24FF", +"Enclosed CJK Letters and Months":"3200,32FF", +"Ethiopic Extended":"2D80,2DDF", +"Ethiopic Supplement":"1380,139F", +"Ethiopic":"1200,137F", +"General Punctuation":"2000,206F", +"Geometric Shapes":"25A0,25FF", +"Georgian Supplement":"2D00,2D2F", +"Georgian":"10A0,10FF", +"Glagolitic":"2C00,2C5F", +"Gothic":"10330,1034F", +"Greek Extended":"1F00,1FFF", +"Greek and Coptic":"0370,03FF", +"Gujarati":"0A80,0AFF", +"Gurmukhi":"0A00,0A7F", +"Halfwidth and Fullwidth Forms":"FF00,FFEF", +"Hangul Compatibility Jamo":"3130,318F", +"Hangul Jamo":"1100,11FF", +"Hangul Syllables":"AC00,D7AF", +"Hanunoo":"1720,173F", +"Hebrew":"0590,05FF", +"High Private Use Surrogates":"DB80,DBFF", +"High Surrogates":"D800,DB7F", +"Hiragana":"3040,309F", +"IPA Extensions":"0250,02AF", +"Ideographic Description Characters":"2FF0,2FFF", +"Kanbun":"3190,319F", +"Kangxi Radicals":"2F00,2FDF", +"Kannada":"0C80,0CFF", +"Katakana Phonetic Extensions":"31F0,31FF", +"Katakana":"30A0,30FF", +"Kharoshthi":"10A00,10A5F", +"Khmer Symbols":"19E0,19FF", +"Khmer":"1780,17FF", +"Lao":"0E80,0EFF", +"Latin Extended Additional":"1E00,1EFF", +"Latin Extended-A":"0100,017F", +"Latin Extended-B":"0180,024F", +"Latin-1 Supplement":"0080,00FF", +"Letterlike Symbols":"2100,214F", +"Limbu":"1900,194F", +"Linear B Ideograms":"10080,100FF", +"Linear B Syllabary":"10000,1007F", +"Low Surrogates":"DC00,DFFF", +"Malayalam":"0D00,0D7F", +"Mathematical Alphanumeric Symbols":"1D400,1D7FF", +"Mathematical Operators":"2200,22FF", +"Miscellaneous Mathematical Symbols-A":"27C0,27EF", +"Miscellaneous Mathematical Symbols-B":"2980,29FF", +"Miscellaneous Symbols and Arrows":"2B00,2BFF", +"Miscellaneous Symbols":"2600,26FF", +"Miscellaneous Technical":"2300,23FF", +"Modifier Tone Letters":"A700,A71F", +"Mongolian":"1800,18AF", +"Musical Symbols":"1D100,1D1FF", +"Myanmar":"1000,109F", +"New Tai Lue":"1980,19DF", +"Number Forms":"2150,218F", +"Ogham":"1680,169F", +"Old Italic":"10300,1032F", +"Old Persian":"103A0,103DF", +"Optical Character Recognition":"2440,245F", +"Oriya":"0B00,0B7F", +"Osmanya":"10480,104AF", +"Phonetic Extensions Supplement":"1D80,1DBF", +"Phonetic Extensions":"1D00,1D7F", +"Private Use Area":"E000,F8FF", +"Runic":"16A0,16FF", +"Shavian":"10450,1047F", +"Sinhala":"0D80,0DFF", +"Small Form Variants":"FE50,FE6F", +"Spacing Modifier Letters":"02B0,02FF", +"Specials":"FFF0,FFFF", +"Superscripts and Subscripts":"2070,209F", +"Supplemental Arrows-A":"27F0,27FF", +"Supplemental Arrows-B":"2900,297F", +"Supplemental Mathematical Operators":"2A00,2AFF", +"Supplemental Punctuation":"2E00,2E7F", +"Syloti Nagri":"A800,A82F", +"Syriac":"0700,074F", +"Tagalog":"1700,171F", +"Tagbanwa":"1760,177F", +"Tags":"E0000,E007F", +"Tai Le":"1950,197F", +"Tai Xuan Jing Symbols":"1D300,1D35F", +"Tamil":"0B80,0BFF", +"Telugu":"0C00,0C7F", +"Thaana":"0780,07BF", +"Thai":"0E00,0E7F", +"Tibetan":"0F00,0FFF", +"Tifinagh":"2D30,2D7F", +"Ugaritic":"10380,1039F", +"Unified Canadian Aboriginal Syllabics":"1400,167F", +"Variation Selectors Supplement":"E0100,E01EF", +"Variation Selectors":"FE00,FE0F", +"Vertical Forms":"FE10,FE1F", +"Yi Radicals":"A490,A4CF", +"Yi Syllables":"A000,A48F", +"Yijing Hexagram Symbols":"4DC0,4DFF" +}; + +var insert="charmap_insert"; + +function map_load(){ + editArea=opener.editArea; + // translate the document + insert= editArea.get_translation(insert, "word"); + //alert(document.title); + document.title= editArea.get_translation(document.title, "template"); + document.body.innerHTML= editArea.get_translation(document.body.innerHTML, "template"); + //document.title= editArea.get_translation(document.getElementBytitle, "template"); + + var selected_lang=opener.EditArea_charmap.default_language.toLowerCase(); + var selected=0; + + var select= document.getElementById("select_range") + for(var i in char_range_list){ + if(i.toLowerCase()==selected_lang) + selected=select.options.length; + select.options[select.options.length]=new Option(i, char_range_list[i]); + } + select.options[selected].selected=true; +/* start=0; + end=127; + content=""; + for(var i=start; i"+ String.fromCharCode(i) +""; + } + document.getElementById("char_list").innerHTML= html; + document.getElementById("preview_char").innerHTML=""; +} + +function previewChar(i){ + document.getElementById("preview_char").innerHTML= String.fromCharCode(i); + document.getElementById("preview_code").innerHTML= "&#"+ i +";"; +} + +function insertChar(i){ + opener.parent.editAreaLoader.setSelectedText(editArea.id, String.fromCharCode( i)); + range= opener.parent.editAreaLoader.getSelectionRange(editArea.id); + opener.parent.editAreaLoader.setSelectionRange(editArea.id, range["end"], range["end"]); + window.focus(); +} diff --git a/includes/edit_area/plugins/charmap/langs/bg.js b/includes/edit_area/plugins/charmap/langs/bg.js new file mode 100644 index 0000000000..1755beb0ef --- /dev/null +++ b/includes/edit_area/plugins/charmap/langs/bg.js @@ -0,0 +1,12 @@ +/* + * Bulgarian translation + * Author: Valentin Hristov + * Company: SOFTKIT Bulgarian + * Site: http://www.softkit-bg.com + */ +editArea.add_lang("bg",{ +charmap_but: "Виртуална клавиатура", +charmap_title: "Виртуална клавиатура", +charmap_choose_block: "избери езиков блок", +charmap_insert:"постави този символ" +}); diff --git a/includes/edit_area/plugins/charmap/langs/cs.js b/includes/edit_area/plugins/charmap/langs/cs.js new file mode 100644 index 0000000000..ff1a566d96 --- /dev/null +++ b/includes/edit_area/plugins/charmap/langs/cs.js @@ -0,0 +1,6 @@ +editArea.add_lang("cs",{ +charmap_but: "Visual keyboard", +charmap_title: "Visual keyboard", +charmap_choose_block: "select language block", +charmap_insert:"insert this character" +}); diff --git a/includes/edit_area/plugins/charmap/langs/de.js b/includes/edit_area/plugins/charmap/langs/de.js new file mode 100644 index 0000000000..8c420d1db7 --- /dev/null +++ b/includes/edit_area/plugins/charmap/langs/de.js @@ -0,0 +1,6 @@ +editArea.add_lang("de",{ +charmap_but: "Sonderzeichen", +charmap_title: "Sonderzeichen", +charmap_choose_block: "Bereich auswählen", +charmap_insert: "dieses Zeichen einfügen" +}); diff --git a/includes/edit_area/plugins/charmap/langs/dk.js b/includes/edit_area/plugins/charmap/langs/dk.js new file mode 100644 index 0000000000..c25fd987c7 --- /dev/null +++ b/includes/edit_area/plugins/charmap/langs/dk.js @@ -0,0 +1,6 @@ +editArea.add_lang("dk",{ +charmap_but: "Visual keyboard", +charmap_title: "Visual keyboard", +charmap_choose_block: "select language block", +charmap_insert:"insert this character" +}); diff --git a/includes/edit_area/plugins/charmap/langs/en.js b/includes/edit_area/plugins/charmap/langs/en.js new file mode 100644 index 0000000000..b9defcef86 --- /dev/null +++ b/includes/edit_area/plugins/charmap/langs/en.js @@ -0,0 +1,6 @@ +editArea.add_lang("en",{ +charmap_but: "Visual keyboard", +charmap_title: "Visual keyboard", +charmap_choose_block: "select language block", +charmap_insert:"insert this character" +}); diff --git a/includes/edit_area/plugins/charmap/langs/eo.js b/includes/edit_area/plugins/charmap/langs/eo.js new file mode 100644 index 0000000000..d7a5d26694 --- /dev/null +++ b/includes/edit_area/plugins/charmap/langs/eo.js @@ -0,0 +1,6 @@ +editArea.add_lang("eo",{ +charmap_but: "Ekranklavaro", +charmap_title: "Ekranklavaro", +charmap_choose_block: "Elekto de lingvo", +charmap_insert:"enmeti tiun signaron" +}); diff --git a/includes/edit_area/plugins/charmap/langs/es.js b/includes/edit_area/plugins/charmap/langs/es.js new file mode 100644 index 0000000000..42fd0bd9db --- /dev/null +++ b/includes/edit_area/plugins/charmap/langs/es.js @@ -0,0 +1,6 @@ +editArea.add_lang("es",{ +charmap_but: "Visual keyboard", +charmap_title: "Visual keyboard", +charmap_choose_block: "select language block", +charmap_insert:"insert this character" +}); diff --git a/includes/edit_area/plugins/charmap/langs/fr.js b/includes/edit_area/plugins/charmap/langs/fr.js new file mode 100644 index 0000000000..f8f1100f5f --- /dev/null +++ b/includes/edit_area/plugins/charmap/langs/fr.js @@ -0,0 +1,6 @@ +editArea.add_lang("fr",{ +charmap_but: "Clavier visuel", +charmap_title: "Clavier visuel", +charmap_choose_block: "choix du language", +charmap_insert:"insérer ce caractère" +}); diff --git a/includes/edit_area/plugins/charmap/langs/hr.js b/includes/edit_area/plugins/charmap/langs/hr.js new file mode 100644 index 0000000000..ff73127ece --- /dev/null +++ b/includes/edit_area/plugins/charmap/langs/hr.js @@ -0,0 +1,6 @@ +editArea.add_lang("hr",{ +charmap_but: "Virtualna tipkovnica", +charmap_title: "Virtualna tipkovnica", +charmap_choose_block: "Odaberi blok s jezikom", +charmap_insert:"Ubaci taj znak" +}); diff --git a/includes/edit_area/plugins/charmap/langs/it.js b/includes/edit_area/plugins/charmap/langs/it.js new file mode 100644 index 0000000000..b55d777e4e --- /dev/null +++ b/includes/edit_area/plugins/charmap/langs/it.js @@ -0,0 +1,6 @@ +editArea.add_lang("it",{ +charmap_but: "Tastiera visuale", +charmap_title: "Tastiera visuale", +charmap_choose_block: "seleziona blocco", +charmap_insert:"inserisci questo carattere" +}); diff --git a/includes/edit_area/plugins/charmap/langs/ja.js b/includes/edit_area/plugins/charmap/langs/ja.js new file mode 100644 index 0000000000..9d7dd17330 --- /dev/null +++ b/includes/edit_area/plugins/charmap/langs/ja.js @@ -0,0 +1,6 @@ +editArea.add_lang("ja",{ +charmap_but: "Visual keyboard", +charmap_title: "Visual keyboard", +charmap_choose_block: "select language block", +charmap_insert:"insert this character" +}); diff --git a/includes/edit_area/plugins/charmap/langs/mk.js b/includes/edit_area/plugins/charmap/langs/mk.js new file mode 100644 index 0000000000..2896b0bdc8 --- /dev/null +++ b/includes/edit_area/plugins/charmap/langs/mk.js @@ -0,0 +1,6 @@ +editArea.add_lang("mkn",{ +charmap_but: "Visual keyboard", +charmap_title: "Visual keyboard", +charmap_choose_block: "select language block", +charmap_insert:"insert this character" +}); diff --git a/includes/edit_area/plugins/charmap/langs/nl.js b/includes/edit_area/plugins/charmap/langs/nl.js new file mode 100644 index 0000000000..fb2ed44af0 --- /dev/null +++ b/includes/edit_area/plugins/charmap/langs/nl.js @@ -0,0 +1,6 @@ +editArea.add_lang("nl",{ +charmap_but: "Visueel toetsenbord", +charmap_title: "Visueel toetsenbord", +charmap_choose_block: "Kies een taal blok", +charmap_insert:"Voeg dit symbool in" +}); diff --git a/includes/edit_area/plugins/charmap/langs/pl.js b/includes/edit_area/plugins/charmap/langs/pl.js new file mode 100644 index 0000000000..a4237b4fa5 --- /dev/null +++ b/includes/edit_area/plugins/charmap/langs/pl.js @@ -0,0 +1,6 @@ +editArea.add_lang("pl",{ +charmap_but: "Klawiatura ekranowa", +charmap_title: "Klawiatura ekranowa", +charmap_choose_block: "wybierz grupę znaków", +charmap_insert:"wstaw ten znak" +}); diff --git a/includes/edit_area/plugins/charmap/langs/pt.js b/includes/edit_area/plugins/charmap/langs/pt.js new file mode 100644 index 0000000000..8e04d5e827 --- /dev/null +++ b/includes/edit_area/plugins/charmap/langs/pt.js @@ -0,0 +1,6 @@ +editArea.add_lang("pt",{ +charmap_but: "Visual keyboard", +charmap_title: "Visual keyboard", +charmap_choose_block: "select language block", +charmap_insert:"insert this character" +}); diff --git a/includes/edit_area/plugins/charmap/langs/ru.js b/includes/edit_area/plugins/charmap/langs/ru.js new file mode 100644 index 0000000000..8da6bbb6ce --- /dev/null +++ b/includes/edit_area/plugins/charmap/langs/ru.js @@ -0,0 +1,6 @@ +editArea.add_lang("ru",{ +charmap_but: "Визуальная клавиатура", +charmap_title: "Визуальная клавиатура", +charmap_choose_block: "выбрать языковой блок", +charmap_insert:"вставить этот символ" +}); diff --git a/includes/edit_area/plugins/charmap/langs/sk.js b/includes/edit_area/plugins/charmap/langs/sk.js new file mode 100644 index 0000000000..5ead132664 --- /dev/null +++ b/includes/edit_area/plugins/charmap/langs/sk.js @@ -0,0 +1,6 @@ +editArea.add_lang("sk",{ +charmap_but: "Vizuálna klávesnica", +charmap_title: "Vizuálna klávesnica", +charmap_choose_block: "vyber jazykový blok", +charmap_insert: "vlož tento znak" +}); diff --git a/includes/edit_area/plugins/charmap/langs/zh.js b/includes/edit_area/plugins/charmap/langs/zh.js new file mode 100644 index 0000000000..8f593518c9 --- /dev/null +++ b/includes/edit_area/plugins/charmap/langs/zh.js @@ -0,0 +1,6 @@ +editArea.add_lang("zh",{ +charmap_but: "软键盘", +charmap_title: "软键盘", +charmap_choose_block: "选择一个语言块", +charmap_insert:"插入此字符" +}); diff --git a/includes/edit_area/plugins/charmap/popup.html b/includes/edit_area/plugins/charmap/popup.html new file mode 100644 index 0000000000..4b549db8b0 --- /dev/null +++ b/includes/edit_area/plugins/charmap/popup.html @@ -0,0 +1,24 @@ + + + + +{$charmap_title} + + + + + +
    +
    +

    {$charmap_title}:

    + +
    + +
    + + + + + diff --git a/includes/edit_area/plugins/test/css/test.css b/includes/edit_area/plugins/test/css/test.css new file mode 100644 index 0000000000..1c206591a8 --- /dev/null +++ b/includes/edit_area/plugins/test/css/test.css @@ -0,0 +1,3 @@ +select#test_select{ + background-color: #FF0000; +} diff --git a/includes/edit_area/plugins/test/images/Thumbs.db b/includes/edit_area/plugins/test/images/Thumbs.db new file mode 100644 index 0000000000..863ae41363 Binary files /dev/null and b/includes/edit_area/plugins/test/images/Thumbs.db differ diff --git a/includes/edit_area/plugins/test/images/test.gif b/includes/edit_area/plugins/test/images/test.gif new file mode 100644 index 0000000000..1ab5da4461 Binary files /dev/null and b/includes/edit_area/plugins/test/images/test.gif differ diff --git a/includes/edit_area/plugins/test/langs/bg.js b/includes/edit_area/plugins/test/langs/bg.js new file mode 100644 index 0000000000..dde4f5e7e4 --- /dev/null +++ b/includes/edit_area/plugins/test/langs/bg.js @@ -0,0 +1,10 @@ +/* + * Bulgarian translation + * Author: Valentin Hristov + * Company: SOFTKIT Bulgarian + * Site: http://www.softkit-bg.com + */ +editArea.add_lang("bg",{ +test_select: "избери таг", +test_but: "тествай копието" +}); diff --git a/includes/edit_area/plugins/test/langs/cs.js b/includes/edit_area/plugins/test/langs/cs.js new file mode 100644 index 0000000000..49713c96a2 --- /dev/null +++ b/includes/edit_area/plugins/test/langs/cs.js @@ -0,0 +1,4 @@ +editArea.add_lang("cs",{ +test_select: "select tag", +test_but: "test button" +}); diff --git a/includes/edit_area/plugins/test/langs/de.js b/includes/edit_area/plugins/test/langs/de.js new file mode 100644 index 0000000000..9a758729e8 --- /dev/null +++ b/includes/edit_area/plugins/test/langs/de.js @@ -0,0 +1,4 @@ +editArea.add_lang("de",{ +test_select: "Tag auswählen", +test_but: "Test Button" +}); diff --git a/includes/edit_area/plugins/test/langs/dk.js b/includes/edit_area/plugins/test/langs/dk.js new file mode 100644 index 0000000000..c5e5748ad3 --- /dev/null +++ b/includes/edit_area/plugins/test/langs/dk.js @@ -0,0 +1,4 @@ +editArea.add_lang("dk",{ +test_select: "select tag", +test_but: "test button" +}); diff --git a/includes/edit_area/plugins/test/langs/en.js b/includes/edit_area/plugins/test/langs/en.js new file mode 100644 index 0000000000..30d7a2ca0b --- /dev/null +++ b/includes/edit_area/plugins/test/langs/en.js @@ -0,0 +1,4 @@ +editArea.add_lang("en",{ +test_select: "select tag", +test_but: "test button" +}); diff --git a/includes/edit_area/plugins/test/langs/eo.js b/includes/edit_area/plugins/test/langs/eo.js new file mode 100644 index 0000000000..267c7340be --- /dev/null +++ b/includes/edit_area/plugins/test/langs/eo.js @@ -0,0 +1,4 @@ +editArea.add_lang("eo",{ +test_select:"elekto de marko", +test_but: "provo-butono" +}); diff --git a/includes/edit_area/plugins/test/langs/es.js b/includes/edit_area/plugins/test/langs/es.js new file mode 100644 index 0000000000..d89b14e8f4 --- /dev/null +++ b/includes/edit_area/plugins/test/langs/es.js @@ -0,0 +1,4 @@ +editArea.add_lang("es",{ +test_select: "select tag", +test_but: "test button" +}); diff --git a/includes/edit_area/plugins/test/langs/fr.js b/includes/edit_area/plugins/test/langs/fr.js new file mode 100644 index 0000000000..12a8fed735 --- /dev/null +++ b/includes/edit_area/plugins/test/langs/fr.js @@ -0,0 +1,4 @@ +editArea.add_lang("fr",{ +test_select:"choix balise", +test_but: "bouton de test" +}); diff --git a/includes/edit_area/plugins/test/langs/hr.js b/includes/edit_area/plugins/test/langs/hr.js new file mode 100644 index 0000000000..a23dddeb50 --- /dev/null +++ b/includes/edit_area/plugins/test/langs/hr.js @@ -0,0 +1,4 @@ +editArea.add_lang("hr",{ +test_select: "Odaberi tag", +test_but: "Probna tipka" +}); diff --git a/includes/edit_area/plugins/test/langs/it.js b/includes/edit_area/plugins/test/langs/it.js new file mode 100644 index 0000000000..7a40d4bb97 --- /dev/null +++ b/includes/edit_area/plugins/test/langs/it.js @@ -0,0 +1,4 @@ +editArea.add_lang("it",{ +test_select: "seleziona tag", +test_but: "pulsante di test" +}); diff --git a/includes/edit_area/plugins/test/langs/ja.js b/includes/edit_area/plugins/test/langs/ja.js new file mode 100644 index 0000000000..53dc51cf5b --- /dev/null +++ b/includes/edit_area/plugins/test/langs/ja.js @@ -0,0 +1,4 @@ +editArea.add_lang("ja",{ +test_select: "select tag", +test_but: "test button" +}); diff --git a/includes/edit_area/plugins/test/langs/mk.js b/includes/edit_area/plugins/test/langs/mk.js new file mode 100644 index 0000000000..7db252d324 --- /dev/null +++ b/includes/edit_area/plugins/test/langs/mk.js @@ -0,0 +1,4 @@ +editArea.add_lang("mk",{ +test_select: "select tag", +test_but: "test button" +}); diff --git a/includes/edit_area/plugins/test/langs/nl.js b/includes/edit_area/plugins/test/langs/nl.js new file mode 100644 index 0000000000..3ce9c2680d --- /dev/null +++ b/includes/edit_area/plugins/test/langs/nl.js @@ -0,0 +1,4 @@ +editArea.add_lang("nl",{ +test_select: "select tag", +test_but: "test button" +}); diff --git a/includes/edit_area/plugins/test/langs/pl.js b/includes/edit_area/plugins/test/langs/pl.js new file mode 100644 index 0000000000..161b87cd82 --- /dev/null +++ b/includes/edit_area/plugins/test/langs/pl.js @@ -0,0 +1,4 @@ +editArea.add_lang("pl",{ +test_select: "wybierz tag", +test_but: "test" +}); diff --git a/includes/edit_area/plugins/test/langs/pt.js b/includes/edit_area/plugins/test/langs/pt.js new file mode 100644 index 0000000000..f96606cdcd --- /dev/null +++ b/includes/edit_area/plugins/test/langs/pt.js @@ -0,0 +1,4 @@ +editArea.add_lang("pt",{ +test_select: "select tag", +test_but: "test button" +}); diff --git a/includes/edit_area/plugins/test/langs/ru.js b/includes/edit_area/plugins/test/langs/ru.js new file mode 100644 index 0000000000..621c0d4e34 --- /dev/null +++ b/includes/edit_area/plugins/test/langs/ru.js @@ -0,0 +1,4 @@ +editArea.add_lang("ru",{ +test_select: "выбрать тэг", +test_but: "тестировать кнопку" +}); diff --git a/includes/edit_area/plugins/test/langs/sk.js b/includes/edit_area/plugins/test/langs/sk.js new file mode 100644 index 0000000000..e47acbf2c8 --- /dev/null +++ b/includes/edit_area/plugins/test/langs/sk.js @@ -0,0 +1,4 @@ +editArea.add_lang("sk",{ +test_select: "vyber tag", +test_but: "testovacie tlačidlo" +}); diff --git a/includes/edit_area/plugins/test/langs/zh.js b/includes/edit_area/plugins/test/langs/zh.js new file mode 100644 index 0000000000..0f462a9845 --- /dev/null +++ b/includes/edit_area/plugins/test/langs/zh.js @@ -0,0 +1,4 @@ +editArea.add_lang("zh",{ +test_select: "选择标签", +test_but: "测试按钮" +}); diff --git a/includes/edit_area/plugins/test/test.js b/includes/edit_area/plugins/test/test.js new file mode 100644 index 0000000000..43626e4ae1 --- /dev/null +++ b/includes/edit_area/plugins/test/test.js @@ -0,0 +1,110 @@ +/** + * Plugin designed for test prupose. It add a button (that manage an alert) and a select (that allow to insert tags) in the toolbar. + * This plugin also disable the "f" key in the editarea, and load a CSS and a JS file + */ +var EditArea_test= { + /** + * Get called once this file is loaded (editArea still not initialized) + * + * @return nothing + */ + init: function(){ + // alert("test init: "+ this._someInternalFunction(2, 3)); + editArea.load_css(this.baseURL+"css/test.css"); + editArea.load_script(this.baseURL+"test2.js"); + } + /** + * Returns the HTML code for a specific control string or false if this plugin doesn't have that control. + * A control can be a button, select list or any other HTML item to present in the EditArea user interface. + * Language variables such as {$lang_somekey} will also be replaced with contents from + * the language packs. + * + * @param {string} ctrl_name: the name of the control to add + * @return HTML code for a specific control or false. + * @type string or boolean + */ + ,get_control_html: function(ctrl_name){ + switch(ctrl_name){ + case "test_but": + // Control id, button img, command + return parent.editAreaLoader.get_button_html('test_but', 'test.gif', 'test_cmd', false, this.baseURL); + case "test_select": + html= ""; + return html; + } + return false; + } + /** + * Get called once EditArea is fully loaded and initialised + * + * @return nothing + */ + ,onload: function(){ + alert("test load"); + } + + /** + * Is called each time the user touch a keyboard key. + * + * @param (event) e: the keydown event + * @return true - pass to next handler in chain, false - stop chain execution + * @type boolean + */ + ,onkeydown: function(e){ + var str= String.fromCharCode(e.keyCode); + // desactivate the "f" character + if(str.toLowerCase()=="f"){ + return true; + } + return false; + } + + /** + * Executes a specific command, this function handles plugin commands. + * + * @param {string} cmd: the name of the command being executed + * @param {unknown} param: the parameter of the command + * @return true - pass to next handler in chain, false - stop chain execution + * @type boolean + */ + ,execCommand: function(cmd, param){ + // Handle commands + switch(cmd){ + case "test_select_change": + var val= document.getElementById("test_select").value; + if(val!=-1) + parent.editAreaLoader.insertTags(editArea.id, "<"+val+">", ""); + document.getElementById("test_select").options[0].selected=true; + return false; + case "test_cmd": + alert("user clicked on test_cmd"); + return false; + } + // Pass to next handler in chain + return true; + } + + /** + * This is just an internal plugin method, prefix all internal methods with a _ character. + * The prefix is needed so they doesn't collide with future EditArea callback functions. + * + * @param {string} a Some arg1. + * @param {string} b Some arg2. + * @return Some return. + * @type unknown + */ + ,_someInternalFunction : function(a, b) { + return a+b; + } +}; + +// Adds the plugin class to the list of available EditArea plugins +editArea.add_plugin("test", EditArea_test); diff --git a/includes/edit_area/plugins/test/test2.js b/includes/edit_area/plugins/test/test2.js new file mode 100644 index 0000000000..44a01b61cc --- /dev/null +++ b/includes/edit_area/plugins/test/test2.js @@ -0,0 +1 @@ +alert("test2.js is loaded from test plugin"); diff --git a/includes/edit_area/reg_syntax/basic.js b/includes/edit_area/reg_syntax/basic.js new file mode 100644 index 0000000000..8a5849cd45 --- /dev/null +++ b/includes/edit_area/reg_syntax/basic.js @@ -0,0 +1,69 @@ +editAreaLoader.load_syntax["basic"] = { + 'COMMENT_SINGLE' : {1 : "'", 2 : 'rem'} + ,'COMMENT_MULTI' : { } + ,'QUOTEMARKS' : {1: '"'} + ,'KEYWORD_CASE_SENSITIVE' : false + ,'KEYWORDS' : { + 'statements' : [ + 'if','then','for','wend','while', + 'else','elseif','select','case','end select', + 'until','next','step','to','end if', 'call' + ] + ,'keywords' : [ + 'sub', 'end sub', 'function', 'end function', 'exit', + 'exit function', 'dim', 'redim', 'shared', 'const', + 'is', 'absolute', 'access', 'any', 'append', 'as', + 'base', 'beep', 'binary', 'bload', 'bsave', 'chain', + 'chdir', 'circle', 'clear', 'close', 'cls', 'color', + 'com', 'common', 'data', 'date', 'declare', 'def', + 'defdbl', 'defint', 'deflng', 'defsng', 'defstr', + 'double', 'draw', 'environ', 'erase', 'error', 'field', + 'files', 'fn', 'get', 'gosub', 'goto', 'integer', 'key', + 'kill', 'let', 'line', 'list', 'locate', 'lock', 'long', + 'lprint', 'lset', 'mkdir', 'name', 'off', 'on', 'open', + 'option', 'out', 'output', 'paint', 'palette', 'pcopy', + 'poke', 'preset', 'print', 'pset', 'put', 'random', + 'randomize', 'read', 'reset', 'restore', 'resume', + 'return', 'rmdir', 'rset', 'run', 'screen', 'seg', + 'shell', 'single', 'sleep', 'sound', 'static', 'stop', + 'strig', 'string', 'swap', 'system', 'time', 'timer', + 'troff', 'tron', 'type', 'unlock', 'using', 'view', + 'wait', 'width', 'window', 'write' + ] + ,'functions' : [ + 'abs', 'asc', 'atn', 'cdbl', 'chr', 'cint', 'clng', + 'cos', 'csng', 'csrlin', 'cvd', 'cvdmbf', 'cvi', 'cvl', + 'cvs', 'cvsmbf', 'eof', 'erdev', 'erl', 'err', 'exp', + 'fileattr', 'fix', 'fre', 'freefile', 'hex', 'inkey', + 'inp', 'input', 'instr', 'int', 'ioctl', 'lbound', + 'lcase', 'left', 'len', 'loc', 'lof', 'log', 'lpos', + 'ltrim', 'mid', 'mkd', 'mkdmbf', 'mki', 'mkl', 'mks', + 'mksmbf', 'oct', 'peek', 'pen', 'play', 'pmap', 'point', + 'pos', 'right', 'rnd', 'rtrim', 'seek', 'sgn', 'sin', + 'space', 'spc', 'sqr', 'stick', 'str', 'tab', 'tan', + 'ubound', 'ucase', 'val', 'varptr', 'varseg' + ] + ,'operators' : [ + 'and', 'eqv', 'imp', 'mod', 'not', 'or', 'xor' + ] + } + ,'OPERATORS' :[ + '+', '-', '/', '*', '=', '<', '>', '!', '&' + ] + ,'DELIMITERS' :[ + '(', ')', '[', ']', '{', '}' + ] + ,'STYLES' : { + 'COMMENTS': 'color: #99CC00;' + ,'QUOTESMARKS': 'color: #333399;' + ,'KEYWORDS' : { + 'keywords' : 'color: #3366FF;' + ,'functions' : 'color: #0000FF;' + ,'statements' : 'color: #3366FF;' + ,'operators' : 'color: #FF0000;' + } + ,'OPERATORS' : 'color: #FF0000;' + ,'DELIMITERS' : 'color: #0000FF;' + + } +}; diff --git a/includes/edit_area/reg_syntax/brainfuck.js b/includes/edit_area/reg_syntax/brainfuck.js new file mode 100644 index 0000000000..3625f701ed --- /dev/null +++ b/includes/edit_area/reg_syntax/brainfuck.js @@ -0,0 +1,44 @@ +editAreaLoader.load_syntax["brainfuck"] = { + 'COMMENT_SINGLE' : {} + ,'COMMENT_MULTI' : {} + ,'QUOTEMARKS' : {} + ,'KEYWORD_CASE_SENSITIVE' : true + ,'OPERATORS' :[ + '+', '-' + ] + ,'DELIMITERS' :[ + '[', ']' + ] + ,'REGEXPS' : { + 'bfispis' : { + 'search' : '()(\\.)()' + ,'class' : 'bfispis' + ,'modifiers' : 'g' + ,'execute' : 'before' + } + ,'bfupis' : { + 'search' : '()(\\,)()' + ,'class' : 'bfupis' + ,'modifiers' : 'g' + ,'execute' : 'before' + } + ,'bfmemory' : { + 'search' : '()([<>])()' + ,'class' : 'bfmemory' + ,'modifiers' : 'g' + ,'execute' : 'before' + } + } + ,'STYLES' : { + 'COMMENTS': 'color: #AAAAAA;' + ,'QUOTESMARKS': 'color: #6381F8;' + ,'OPERATORS' : 'color: #88AA00;' + ,'DELIMITERS' : 'color: #00C138;' + ,'REGEXPS' : { + 'bfispis' : 'color: #EE0000;' + ,'bfupis' : 'color: #4455ee;' + ,'bfmemory' : 'color: #DD00DD;' + } + } +}; + diff --git a/includes/edit_area/reg_syntax/c.js b/includes/edit_area/reg_syntax/c.js new file mode 100644 index 0000000000..d4e5771222 --- /dev/null +++ b/includes/edit_area/reg_syntax/c.js @@ -0,0 +1,62 @@ +editAreaLoader.load_syntax["c"] = { + 'COMMENT_SINGLE' : {1 : '//'} + ,'COMMENT_MULTI' : {'/*' : '*/'} + ,'QUOTEMARKS' : {1: "'", 2: '"'} + ,'KEYWORD_CASE_SENSITIVE' : true + ,'KEYWORDS' : { + 'constants' : [ + 'NULL', 'false', 'stdin', 'stdout', 'stderr', 'true' + ] + ,'types' : [ + 'FILE', 'auto', 'char', 'const', 'double', + 'extern', 'float', 'inline', 'int', 'long', 'register', + 'short', 'signed', 'size_t', 'static', 'struct', + 'time_t', 'typedef', 'union', 'unsigned', 'void', + 'volatile' + ] + ,'statements' : [ + 'do', 'else', 'enum', 'for', 'goto', 'if', 'sizeof', + 'switch', 'while' + ] + ,'keywords' : [ + 'break', 'case', 'continue', 'default', 'delete', + 'return' + ] + } + ,'OPERATORS' :[ + '+', '-', '/', '*', '=', '<', '>', '%', '!', '?', ':', '&' + ] + ,'DELIMITERS' :[ + '(', ')', '[', ']', '{', '}' + ] + ,'REGEXPS' : { + 'precompiler' : { + 'search' : '()(#[^\r\n]*)()' + ,'class' : 'precompiler' + ,'modifiers' : 'g' + ,'execute' : 'before' + } +/* ,'precompilerstring' : { + 'search' : '(#[\t ]*include[\t ]*)([^\r\n]*)([^\r\n]*[\r\n])' + ,'class' : 'precompilerstring' + ,'modifiers' : 'g' + ,'execute' : 'before' + }*/ + } + ,'STYLES' : { + 'COMMENTS': 'color: #AAAAAA;' + ,'QUOTESMARKS': 'color: #6381F8;' + ,'KEYWORDS' : { + 'constants' : 'color: #EE0000;' + ,'types' : 'color: #0000EE;' + ,'statements' : 'color: #60CA00;' + ,'keywords' : 'color: #48BDDF;' + } + ,'OPERATORS' : 'color: #FF00FF;' + ,'DELIMITERS' : 'color: #0038E1;' + ,'REGEXPS' : { + 'precompiler' : 'color: #009900;' + ,'precompilerstring' : 'color: #994400;' + } + } +}; diff --git a/includes/edit_area/reg_syntax/coldfusion.js b/includes/edit_area/reg_syntax/coldfusion.js new file mode 100644 index 0000000000..2092f50674 --- /dev/null +++ b/includes/edit_area/reg_syntax/coldfusion.js @@ -0,0 +1,119 @@ +editAreaLoader.load_syntax["coldfusion"] = { + 'COMMENT_SINGLE' : {1 : '//', 2 : '#'} + ,'COMMENT_MULTI' : {''} + ,'COMMENT_MULTI2' : {''} + ,'QUOTEMARKS' : {1: "'", 2: '"'} + ,'KEYWORD_CASE_SENSITIVE' : false + ,'KEYWORDS' : { + 'statements' : [ + 'include', 'require', 'include_once', 'require_once', + 'for', 'foreach', 'as', 'if', 'elseif', 'else', 'while', 'do', 'endwhile', + 'endif', 'switch', 'case', 'endswitch', + 'return', 'break', 'continue' + ] + ,'reserved' : [ + 'AND', 'break', 'case', 'CONTAIN', 'CONTAINS', 'continue', 'default', 'do', + 'DOES', 'else', 'EQ', 'EQUAL', 'EQUALTO', 'EQV', 'FALSE', 'for', 'GE', + 'GREATER', 'GT', 'GTE', 'if', 'IMP', 'in', 'IS', 'LE', 'LESS', 'LT', 'LTE', + 'MOD', 'NEQ', 'NOT', 'OR', 'return', 'switch', 'THAN', 'TO', 'TRUE', 'var', + 'while', 'XOR' + ] + ,'functions' : [ + 'Abs', 'ACos', 'ArrayAppend', 'ArrayAvg', 'ArrayClear', 'ArrayDeleteAt', 'ArrayInsertAt', + 'ArrayIsEmpty', 'ArrayLen', 'ArrayMax', 'ArrayMin', 'ArrayNew', 'ArrayPrepend', 'ArrayResize', + 'ArraySet', 'ArraySort', 'ArraySum', 'ArraySwap', 'ArrayToList', 'Asc', 'ASin', 'Atn', 'AuthenticatedContext', + 'AuthenticatedUser', 'BitAnd', 'BitMaskClear', 'BitMaskRead', 'BitMaskSet', 'BitNot', 'BitOr', + 'BitSHLN', 'BitSHRN', 'BitXor', 'Ceiling', 'Chr', 'CJustify', 'Compare', 'CompareNoCase', 'Cos', + 'CreateDate', 'CreateDateTime', 'CreateODBCDate', 'CreateODBCDateTime', 'CreateODBCTime', + 'CreateTime', 'CreateTimeSpan', 'DateAdd', 'DateCompare', 'DateConvert', 'DateDiff', + 'DateFormat', 'DatePart', 'Day', 'DayOfWeek', 'DayOfWeekAsString', 'DayOfYear', 'DaysInMonth', + 'DaysInYear', 'DE', 'DecimalFormat', 'DecrementValue', 'Decrypt', 'DeleteClientVariable', + 'DirectoryExists', 'DollarFormat', 'Duplicate', 'Encrypt', 'Evaluate', 'Exp', 'ExpandPath', + 'FileExists', 'Find', 'FindNoCase', 'FindOneOf', 'FirstDayOfMonth', 'Fix', 'FormatBaseN', + 'GetBaseTagData', 'GetBaseTagList', 'GetBaseTemplatePath', 'GetClientVariablesList', + 'GetCurrentTemplatePath', 'GetDirectoryFromPath', 'GetException', 'GetFileFromPath', + 'GetFunctionList', 'GetHttpTimeString', 'GetHttpRequestData', 'GetLocale', 'GetMetricData', + 'GetProfileString', 'GetTempDirectory', 'GetTempFile', 'GetTemplatePath', 'GetTickCount', + 'GetTimeZoneInfo', 'GetToken', 'Hash', 'Hour', 'HTMLCodeFormat', 'HTMLEditFormat', 'IIf', + 'IncrementValue', 'InputBaseN', 'Insert', 'Int', 'IsArray', 'IsAuthenticated', 'IsAuthorized', + 'IsBoolean', 'IsBinary', 'IsCustomFunction', 'IsDate', 'IsDebugMode', 'IsDefined', 'IsLeapYear', + 'IsNumeric', 'IsNumericDate', 'IsProtected', 'IsQuery', 'IsSimpleValue', 'IsStruct', 'IsWDDX', + 'JavaCast', 'JSStringFormat', 'LCase', 'Left', 'Len', 'ListAppend', 'ListChangeDelims', + 'ListContains', 'ListContainsNoCase', 'ListDeleteAt', 'ListFind', 'ListFindNoCase', 'ListFirst', + 'ListGetAt', 'ListInsertAt', 'ListLast', 'ListLen', 'ListPrepend', 'ListQualify', 'ListRest', + 'ListSetAt', 'ListSort', 'ListToArray', 'ListValueCount', 'ListValueCountNoCase', 'LJustify', + 'Log', 'Log10', 'LSCurrencyFormat', 'LSDateFormat', 'LSEuroCurrencyFormat', 'LSIsCurrency', + 'LSIsDate', 'LSIsNumeric', 'LSNumberFormat', 'LSParseCurrency', 'LSParseDateTime', 'LSParseNumber', + 'LSTimeFormat', 'LTrim', 'Max', 'Mid', 'Min', 'Minute', 'Month', 'MonthAsString', 'Now', 'NumberFormat', + 'ParagraphFormat', 'ParameterExists', 'ParseDateTime', 'Pi', 'PreserveSingleQuotes', 'Quarter', + 'QueryAddRow', 'QueryNew', 'QuerySetCell', 'QuotedValueList', 'Rand', 'Randomize', 'RandRange', + 'REFind', 'REFindNoCase', 'RemoveChars', 'RepeatString', 'Replace', 'ReplaceList', 'ReplaceNoCase', + 'REReplace', 'REReplaceNoCase', 'Reverse', 'Right', 'RJustify', 'Round', 'RTrim', 'Second', 'SetLocale', + 'SetProfileString', 'SetVariable', 'Sgn', 'Sin', 'SpanExcluding', 'SpanIncluding', 'Sqr', 'StripCR', + 'StructAppend', 'StructClear', 'StructCopy', 'StructCount', 'StructDelete', 'StructFind', 'StructFindKey', + 'StructFindValue', 'StructGet', 'StructInsert', 'StructIsEmpty', 'StructKeyArray', 'StructKeyExists', + 'StructKeyList', 'StructNew', 'StructSort', 'StructUpdate', 'Tan', 'TimeFormat', 'ToBase64', 'ToBinary', + 'ToString', 'Trim', 'UCase', 'URLDecode', 'URLEncodedFormat', 'Val', 'ValueList', 'Week', 'WriteOutput', + 'XMLFormat', 'Year', 'YesNoFormat' + ] + } + ,'OPERATORS' :[ + '+', '-', '/', '*', '%', '!', '&&', '||' + ] + ,'DELIMITERS' :[ + '(', ')', '[', ']', '{', '}' + ] + ,'REGEXPS' : { + 'doctype' : { + 'search' : '()(]*>)()' + ,'class' : 'doctype' + ,'modifiers' : '' + ,'execute' : 'before' // before or after + } + ,'cftags' : { + 'search' : '(<)(/cf[a-z][^ \r\n\t>]*)([^>]*>)' + ,'class' : 'cftags' + ,'modifiers' : 'gi' + ,'execute' : 'before' // before or after + } + ,'cftags2' : { + 'search' : '(<)(cf[a-z][^ \r\n\t>]*)([^>]*>)' + ,'class' : 'cftags2' + ,'modifiers' : 'gi' + ,'execute' : 'before' // before or after + } + ,'tags' : { + 'search' : '(<)(/?[a-z][^ \r\n\t>]*)([^>]*>)' + ,'class' : 'tags' + ,'modifiers' : 'gi' + ,'execute' : 'before' // before or after + } + ,'attributes' : { + 'search' : '( |\n|\r|\t)([^ \r\n\t=]+)(=)' + ,'class' : 'attributes' + ,'modifiers' : 'g' + ,'execute' : 'before' // before or after + } + } + ,'STYLES' : { + 'COMMENTS': 'color: #AAAAAA;' + ,'QUOTESMARKS': 'color: #6381F8;' + ,'KEYWORDS' : { + 'reserved' : 'color: #48BDDF;' + ,'functions' : 'color: #0000FF;' + ,'statements' : 'color: #60CA00;' + } + ,'OPERATORS' : 'color: #E775F0;' + ,'DELIMITERS' : '' + ,'REGEXPS' : { + 'attributes': 'color: #990033;' + ,'cftags': 'color: #990033;' + ,'cftags2': 'color: #990033;' + ,'tags': 'color: #000099;' + ,'doctype': 'color: #8DCFB5;' + ,'test': 'color: #00FF00;' + } + } +}; + + diff --git a/includes/edit_area/reg_syntax/cpp.js b/includes/edit_area/reg_syntax/cpp.js new file mode 100644 index 0000000000..e5e2be0619 --- /dev/null +++ b/includes/edit_area/reg_syntax/cpp.js @@ -0,0 +1,65 @@ +editAreaLoader.load_syntax["cpp"] = { + 'COMMENT_SINGLE' : {1 : '//'} + ,'COMMENT_MULTI' : {'/*' : '*/'} + ,'QUOTEMARKS' : {1: "'", 2: '"'} + ,'KEYWORD_CASE_SENSITIVE' : true + ,'KEYWORDS' : { + 'constants' : [ + 'NULL', 'false', 'std', 'stdin', 'stdout', 'stderr', + 'true' + ] + ,'types' : [ + 'FILE', 'auto', 'char', 'class', 'const', 'double', + 'extern', 'float', 'friend', 'inline', 'int', + 'iterator', 'long', 'map', 'operator', 'queue', + 'register', 'short', 'signed', 'size_t', 'stack', + 'static', 'string', 'struct', 'time_t', 'typedef', + 'union', 'unsigned', 'vector', 'void', 'volatile' + ] + ,'statements' : [ + 'catch', 'do', 'else', 'enum', 'for', 'goto', 'if', + 'sizeof', 'switch', 'this', 'throw', 'try', 'while' + ] + ,'keywords' : [ + 'break', 'case', 'continue', 'default', 'delete', + 'namespace', 'new', 'private', 'protected', 'public', + 'return', 'using' + ] + } + ,'OPERATORS' :[ + '+', '-', '/', '*', '=', '<', '>', '%', '!', '?', ':', '&' + ] + ,'DELIMITERS' :[ + '(', ')', '[', ']', '{', '}' + ] + ,'REGEXPS' : { + 'precompiler' : { + 'search' : '()(#[^\r\n]*)()' + ,'class' : 'precompiler' + ,'modifiers' : 'g' + ,'execute' : 'before' + } +/* ,'precompilerstring' : { + 'search' : '(#[\t ]*include[\t ]*)([^\r\n]*)([^\r\n]*[\r\n])' + ,'class' : 'precompilerstring' + ,'modifiers' : 'g' + ,'execute' : 'before' + }*/ + } + ,'STYLES' : { + 'COMMENTS': 'color: #AAAAAA;' + ,'QUOTESMARKS': 'color: #6381F8;' + ,'KEYWORDS' : { + 'constants' : 'color: #EE0000;' + ,'types' : 'color: #0000EE;' + ,'statements' : 'color: #60CA00;' + ,'keywords' : 'color: #48BDDF;' + } + ,'OPERATORS' : 'color: #FF00FF;' + ,'DELIMITERS' : 'color: #0038E1;' + ,'REGEXPS' : { + 'precompiler' : 'color: #009900;' + ,'precompilerstring' : 'color: #994400;' + } + } +}; diff --git a/includes/edit_area/reg_syntax/css.js b/includes/edit_area/reg_syntax/css.js new file mode 100644 index 0000000000..b8131ccdd5 --- /dev/null +++ b/includes/edit_area/reg_syntax/css.js @@ -0,0 +1,84 @@ +editAreaLoader.load_syntax["css"] = { + 'COMMENT_SINGLE' : {1 : '@'} + ,'COMMENT_MULTI' : {'/*' : '*/'} + ,'QUOTEMARKS' : ['"', "'"] + ,'KEYWORD_CASE_SENSITIVE' : false + ,'KEYWORDS' : { + 'attributes' : [ + 'aqua', 'azimuth', 'background-attachment', 'background-color', + 'background-image', 'background-position', 'background-repeat', + 'background', 'border-bottom-color', 'border-bottom-style', + 'border-bottom-width', 'border-left-color', 'border-left-style', + 'border-left-width', 'border-right', 'border-right-color', + 'border-right-style', 'border-right-width', 'border-top-color', + 'border-top-style', 'border-top-width','border-bottom', 'border-collapse', + 'border-left', 'border-width', 'border-color', 'border-spacing', + 'border-style', 'border-top', 'border', 'caption-side', + 'clear', 'clip', 'color', 'content', 'counter-increment', 'counter-reset', + 'cue-after', 'cue-before', 'cue', 'cursor', 'direction', 'display', + 'elevation', 'empty-cells', 'float', 'font-family', 'font-size', + 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', + 'font-weight', 'font', 'height', 'letter-spacing', 'line-height', + 'list-style', 'list-style-image', 'list-style-position', 'list-style-type', + 'margin-bottom', 'margin-left', 'margin-right', 'margin-top', 'margin', + 'marker-offset', 'marks', 'max-height', 'max-width', 'min-height', + 'min-width', 'opacity', 'orphans', 'outline', 'outline-color', 'outline-style', + 'outline-width', 'overflow', 'padding-bottom', 'padding-left', + 'padding-right', 'padding-top', 'padding', 'page', 'page-break-after', + 'page-break-before', 'page-break-inside', 'pause-after', 'pause-before', + 'pause', 'pitch', 'pitch-range', 'play-during', 'position', 'quotes', + 'richness', 'right', 'size', 'speak-header', 'speak-numeral', 'speak-punctuation', + 'speak', 'speech-rate', 'stress', 'table-layout', 'text-align', 'text-decoration', + 'text-indent', 'text-shadow', 'text-transform', 'top', 'unicode-bidi', + 'vertical-align', 'visibility', 'voice-family', 'volume', 'white-space', 'widows', + 'width', 'word-spacing', 'z-index', 'bottom', 'left' + ] + ,'values' : [ + 'above', 'absolute', 'always', 'armenian', 'aural', 'auto', 'avoid', + 'baseline', 'behind', 'below', 'bidi-override', 'black', 'blue', 'blink', 'block', 'bold', 'bolder', 'both', + 'capitalize', 'center-left', 'center-right', 'center', 'circle', 'cjk-ideographic', + 'close-quote', 'collapse', 'condensed', 'continuous', 'crop', 'crosshair', 'cross', 'cursive', + 'dashed', 'decimal-leading-zero', 'decimal', 'default', 'digits', 'disc', 'dotted', 'double', + 'e-resize', 'embed', 'extra-condensed', 'extra-expanded', 'expanded', + 'fantasy', 'far-left', 'far-right', 'faster', 'fast', 'fixed', 'fuchsia', + 'georgian', 'gray', 'green', 'groove', 'hebrew', 'help', 'hidden', 'hide', 'higher', + 'high', 'hiragana-iroha', 'hiragana', 'icon', 'inherit', 'inline-table', 'inline', + 'inset', 'inside', 'invert', 'italic', 'justify', 'katakana-iroha', 'katakana', + 'landscape', 'larger', 'large', 'left-side', 'leftwards', 'level', 'lighter', 'lime', 'line-through', 'list-item', 'loud', 'lower-alpha', 'lower-greek', 'lower-roman', 'lowercase', 'ltr', 'lower', 'low', + 'maroon', 'medium', 'message-box', 'middle', 'mix', 'monospace', + 'n-resize', 'narrower', 'navy', 'ne-resize', 'no-close-quote', 'no-open-quote', 'no-repeat', 'none', 'normal', 'nowrap', 'nw-resize', + 'oblique', 'olive', 'once', 'open-quote', 'outset', 'outside', 'overline', + 'pointer', 'portrait', 'purple', 'px', + 'red', 'relative', 'repeat-x', 'repeat-y', 'repeat', 'rgb', 'ridge', 'right-side', 'rightwards', + 's-resize', 'sans-serif', 'scroll', 'se-resize', 'semi-condensed', 'semi-expanded', 'separate', 'serif', 'show', 'silent', 'silver', 'slow', 'slower', 'small-caps', 'small-caption', 'smaller', 'soft', 'solid', 'spell-out', 'square', + 'static', 'status-bar', 'super', 'sw-resize', + 'table-caption', 'table-cell', 'table-column', 'table-column-group', 'table-footer-group', 'table-header-group', 'table-row', 'table-row-group', 'teal', 'text', 'text-bottom', 'text-top', 'thick', 'thin', 'transparent', + 'ultra-condensed', 'ultra-expanded', 'underline', 'upper-alpha', 'upper-latin', 'upper-roman', 'uppercase', 'url', + 'visible', + 'w-resize', 'wait', 'white', 'wider', + 'x-fast', 'x-high', 'x-large', 'x-loud', 'x-low', 'x-small', 'x-soft', 'xx-large', 'xx-small', + 'yellow', 'yes' + ] + ,'specials' : [ + 'important' + ] + } + ,'OPERATORS' :[ + ':', ';', '!', '.', '#' + ] + ,'DELIMITERS' :[ + '{', '}' + ] + ,'STYLES' : { + 'COMMENTS': 'color: #AAAAAA;' + ,'QUOTESMARKS': 'color: #6381F8;' + ,'KEYWORDS' : { + 'attributes' : 'color: #48BDDF;' + ,'values' : 'color: #2B60FF;' + ,'specials' : 'color: #FF0000;' + } + ,'OPERATORS' : 'color: #FF00FF;' + ,'DELIMITERS' : 'color: #60CA00;' + + } +}; diff --git a/includes/edit_area/reg_syntax/html.js b/includes/edit_area/reg_syntax/html.js new file mode 100644 index 0000000000..cc2a90e6ec --- /dev/null +++ b/includes/edit_area/reg_syntax/html.js @@ -0,0 +1,50 @@ +/* +* last update: 2006-08-24 +*/ + +editAreaLoader.load_syntax["html"] = { + 'COMMENT_SINGLE' : {} + ,'COMMENT_MULTI' : {''} + ,'QUOTEMARKS' : {1: "'", 2: '"'} + ,'KEYWORD_CASE_SENSITIVE' : false + ,'KEYWORDS' : { + } + ,'OPERATORS' :[ + ] + ,'DELIMITERS' :[ + ] + ,'REGEXPS' : { + 'doctype' : { + 'search' : '()(]*>)()' + ,'class' : 'doctype' + ,'modifiers' : '' + ,'execute' : 'before' // before or after + } + ,'tags' : { + 'search' : '(<)(/?[a-z][^ \r\n\t>]*)([^>]*>)' + ,'class' : 'tags' + ,'modifiers' : 'gi' + ,'execute' : 'before' // before or after + } + ,'attributes' : { + 'search' : '( |\n|\r|\t)([^ \r\n\t=]+)(=)' + ,'class' : 'attributes' + ,'modifiers' : 'g' + ,'execute' : 'before' // before or after + } + } + ,'STYLES' : { + 'COMMENTS': 'color: #AAAAAA;' + ,'QUOTESMARKS': 'color: #6381F8;' + ,'KEYWORDS' : { + } + ,'OPERATORS' : 'color: #E775F0;' + ,'DELIMITERS' : '' + ,'REGEXPS' : { + 'attributes': 'color: #B1AC41;' + ,'tags': 'color: #E62253;' + ,'doctype': 'color: #8DCFB5;' + ,'test': 'color: #00FF00;' + } + } +}; diff --git a/includes/edit_area/reg_syntax/java.js b/includes/edit_area/reg_syntax/java.js new file mode 100644 index 0000000000..2018c66722 --- /dev/null +++ b/includes/edit_area/reg_syntax/java.js @@ -0,0 +1,56 @@ +editAreaLoader.load_syntax["java"] = { +'COMMENT_SINGLE': { 1: '//', 2: '@' } + , 'COMMENT_MULTI': { '/*': '*/' } + , 'QUOTEMARKS': { 1: "'", 2: '"' } + , 'KEYWORD_CASE_SENSITIVE': true + , 'KEYWORDS': { + 'constants': [ + 'null', 'false', 'true' + ] + , 'types': [ + 'String', 'int', 'short', 'long', 'char', 'double', 'byte', + 'float', 'static', 'void', 'private', 'boolean', 'protected', + 'public', 'const', 'class', 'final', 'abstract', 'volatile', + 'enum', 'transient', 'interface' + ] + , 'statements': [ + 'this', 'extends', 'if', 'do', 'while', 'try', 'catch', 'finally', + 'throw', 'throws', 'else', 'for', 'switch', 'continue', 'implements', + 'break', 'case', 'default', 'goto' + ] + , 'keywords': [ + 'new', 'return', 'import', 'native', 'super', 'package', 'assert', 'synchronized', + 'instanceof', 'strictfp' + ] + } + , 'OPERATORS': [ + '+', '-', '/', '*', '=', '<', '>', '%', '!', '?', ':', '&' + ] + , 'DELIMITERS': [ + '(', ')', '[', ']', '{', '}' + ] + , 'REGEXPS': { + 'precompiler': { + 'search': '()(#[^\r\n]*)()' + , 'class': 'precompiler' + , 'modifiers': 'g' + , 'execute': 'before' + } + } + , 'STYLES': { + 'COMMENTS': 'color: #AAAAAA;' + , 'QUOTESMARKS': 'color: #6381F8;' + , 'KEYWORDS': { + 'constants': 'color: #EE0000;' + , 'types': 'color: #0000EE;' + , 'statements': 'color: #60CA00;' + , 'keywords': 'color: #48BDDF;' + } + , 'OPERATORS': 'color: #FF00FF;' + , 'DELIMITERS': 'color: #0038E1;' + , 'REGEXPS': { + 'precompiler': 'color: #009900;' + , 'precompilerstring': 'color: #994400;' + } + } +}; diff --git a/includes/edit_area/reg_syntax/js.js b/includes/edit_area/reg_syntax/js.js new file mode 100644 index 0000000000..eaa7a036cc --- /dev/null +++ b/includes/edit_area/reg_syntax/js.js @@ -0,0 +1,93 @@ +editAreaLoader.load_syntax["js"] = { + 'COMMENT_SINGLE' : {1 : '//'} + ,'COMMENT_MULTI' : {'/*' : '*/'} + ,'QUOTEMARKS' : {1: "'", 2: '"'} + ,'KEYWORD_CASE_SENSITIVE' : false + ,'KEYWORDS' : { + 'statements' : [ + 'as', 'break', 'case', 'catch', 'continue', 'decodeURI', 'delete', 'do', + 'else', 'encodeURI', 'eval', 'finally', 'for', 'if', 'in', 'is', 'item', + 'instanceof', 'return', 'switch', 'this', 'throw', 'try', 'typeof', 'void', + 'while', 'write', 'with' + ] + ,'keywords' : [ + 'class', 'const', 'default', 'debugger', 'export', 'extends', 'false', + 'function', 'import', 'namespace', 'new', 'null', 'package', 'private', + 'protected', 'public', 'super', 'true', 'use', 'var', 'window', 'document', + // the list below must be sorted and checked (if it is a keywords or a function and if it is not present twice + 'Link ', 'outerHeight ', 'Anchor', 'FileUpload', + 'location', 'outerWidth', 'Select', 'Area', 'find', 'Location', 'Packages', 'self', + 'arguments', 'locationbar', 'pageXoffset', 'Form', + 'Math', 'pageYoffset', 'setTimeout', 'assign', 'Frame', 'menubar', 'parent', 'status', + 'blur', 'frames', 'MimeType', 'parseFloat', 'statusbar', 'Boolean', 'Function', 'moveBy', + 'parseInt', 'stop', 'Button', 'getClass', 'moveTo', 'Password', 'String', 'callee', 'Hidden', + 'name', 'personalbar', 'Submit', 'caller', 'history', 'NaN', 'Plugin', 'sun', 'captureEvents', + 'History', 'navigate', 'print', 'taint', 'Checkbox', 'home', 'navigator', 'prompt', 'Text', + 'Image', 'Navigator', 'prototype', 'Textarea', 'clearTimeout', 'Infinity', + 'netscape', 'Radio', 'toolbar', 'close', 'innerHeight', 'Number', 'ref', 'top', 'closed', + 'innerWidth', 'Object', 'RegExp', 'toString', 'confirm', 'isFinite', 'onBlur', 'releaseEvents', + 'unescape', 'constructor', 'isNan', 'onError', 'Reset', 'untaint', 'Date', 'java', 'onFocus', + 'resizeBy', 'unwatch', 'defaultStatus', 'JavaArray', 'onLoad', 'resizeTo', 'valueOf', 'document', + 'JavaClass', 'onUnload', 'routeEvent', 'watch', 'Document', 'JavaObject', 'open', 'scroll', 'window', + 'Element', 'JavaPackage', 'opener', 'scrollbars', 'Window', 'escape', 'length', 'Option', 'scrollBy' + ] + ,'functions' : [ + // common functions for Window object + 'alert', 'Array', 'back', 'blur', 'clearInterval', 'close', 'confirm', 'eval ', 'focus', 'forward', 'home', + 'name', 'navigate', 'onblur', 'onerror', 'onfocus', 'onload', 'onmove', + 'onresize', 'onunload', 'open', 'print', 'prompt', 'scroll', 'scrollTo', 'setInterval', 'status', + 'stop' + ] + } + ,'OPERATORS' :[ + '+', '-', '/', '*', '=', '<', '>', '%', '!' + ] + ,'DELIMITERS' :[ + '(', ')', '[', ']', '{', '}' + ] + ,'STYLES' : { + 'COMMENTS': 'color: #AAAAAA;' + ,'QUOTESMARKS': 'color: #6381F8;' + ,'KEYWORDS' : { + 'statements' : 'color: #60CA00;' + ,'keywords' : 'color: #48BDDF;' + ,'functions' : 'color: #2B60FF;' + } + ,'OPERATORS' : 'color: #FF00FF;' + ,'DELIMITERS' : 'color: #0038E1;' + + } + ,'AUTO_COMPLETION' : { + "default": { // the name of this definition group. It's posisble to have different rules inside the same definition file + "REGEXP": { "before_word": "[^a-zA-Z0-9_]|^" // \\s|\\.| + ,"possible_words_letters": "[a-zA-Z0-9_]+" + ,"letter_after_word_must_match": "[^a-zA-Z0-9_]|$" + ,"prefix_separator": "\\." + } + ,"CASE_SENSITIVE": true + ,"MAX_TEXT_LENGTH": 100 // the maximum length of the text being analyzed before the cursor position + ,"KEYWORDS": { + '': [ // the prefix of thoses items + /** + * 0 : the keyword the user is typing + * 1 : (optionnal) the string inserted in code ("{@}" being the new position of the cursor, "§" beeing the equivalent to the value the typed string indicated if the previous ) + * If empty the keyword will be displayed + * 2 : (optionnal) the text that appear in the suggestion box (if empty, the string to insert will be displayed) + */ + ['Array', '§()', ''] + ,['alert', '§({@})', 'alert(String message)'] + ,['document'] + ,['window'] + ] + ,'window' : [ + ['location'] + ,['document'] + ,['scrollTo', 'scrollTo({@})', 'scrollTo(Int x,Int y)'] + ] + ,'location' : [ + ['href'] + ] + } + } + } +}; diff --git a/includes/edit_area/reg_syntax/pas.js b/includes/edit_area/reg_syntax/pas.js new file mode 100644 index 0000000000..2038539f54 --- /dev/null +++ b/includes/edit_area/reg_syntax/pas.js @@ -0,0 +1,82 @@ +editAreaLoader.load_syntax["pas"] = { + 'COMMENT_SINGLE' : {} + ,'COMMENT_MULTI' : {'{' : '}', '(*':'*)'} + ,'QUOTEMARKS' : {1: '"', 2: "'"} + ,'KEYWORD_CASE_SENSITIVE' : false + ,'KEYWORDS' : { + 'constants' : [ + 'Blink', 'Black', 'Blue', 'Green', 'Cyan', 'Red', + 'Magenta', 'Brown', 'LightGray', 'DarkGray', + 'LightBlue', 'LightGreen', 'LightCyan', 'LightRed', + 'LightMagenta', 'Yellow', 'White', 'MaxSIntValue', + 'MaxUIntValue', 'maxint', 'maxLongint', 'maxSmallint', + 'erroraddr', 'errorcode', 'LineEnding' + ] + ,'keywords' : [ + 'in', 'or', 'div', 'mod', 'and', 'shl', 'shr', 'xor', + 'pow', 'is', 'not','Absolute', 'And_then', 'Array', + 'Begin', 'Bindable', 'Case', 'Const', 'Do', 'Downto', + 'Else', 'End', 'Export', 'File', 'For', 'Function', + 'Goto', 'If', 'Import', 'Implementation', 'Inherited', + 'Inline', 'Interface', 'Label', 'Module', 'Nil', + 'Object', 'Of', 'Only', 'Operator', 'Or_else', + 'Otherwise', 'Packed', 'Procedure', 'Program', + 'Protected', 'Qualified', 'Record', 'Repeat', + 'Restricted', 'Set', 'Then', 'To', 'Type', 'Unit', + 'Until', 'Uses', 'Value', 'Var', 'Virtual', 'While', + 'With' + ] + ,'functions' : [ + 'Abs', 'Addr', 'Append', 'Arctan', 'Assert', 'Assign', + 'Assigned', 'BinStr', 'Blockread', 'Blockwrite', + 'Break', 'Chdir', 'Chr', 'Close', 'CompareByte', + 'CompareChar', 'CompareDWord', 'CompareWord', 'Concat', + 'Continue', 'Copy', 'Cos', 'CSeg', 'Dec', 'Delete', + 'Dispose', 'DSeg', 'Eof', 'Eoln', 'Erase', 'Exclude', + 'Exit', 'Exp', 'Filepos', 'Filesize', 'FillByte', + 'Fillchar', 'FillDWord', 'Fillword', 'Flush', 'Frac', + 'Freemem', 'Getdir', 'Getmem', 'GetMemoryManager', + 'Halt', 'HexStr', 'Hi', 'High', 'Inc', 'Include', + 'IndexByte', 'IndexChar', 'IndexDWord', 'IndexWord', + 'Insert', 'IsMemoryManagerSet', 'Int', 'IOresult', + 'Length', 'Ln', 'Lo', 'LongJmp', 'Low', 'Lowercase', + 'Mark', 'Maxavail', 'Memavail', 'Mkdir', 'Move', + 'MoveChar0', 'New', 'Odd', 'OctStr', 'Ofs', 'Ord', + 'Paramcount', 'Paramstr', 'Pi', 'Pos', 'Power', 'Pred', + 'Ptr', 'Random', 'Randomize', 'Read', 'Readln', + 'Real2Double', 'Release', 'Rename', 'Reset', 'Rewrite', + 'Rmdir', 'Round', 'Runerror', 'Seek', 'SeekEof', + 'SeekEoln', 'Seg', 'SetMemoryManager', 'SetJmp', + 'SetLength', 'SetString', 'SetTextBuf', 'Sin', 'SizeOf', + 'Sptr', 'Sqr', 'Sqrt', 'SSeg', 'Str', 'StringOfChar', + 'Succ', 'Swap', 'Trunc', 'Truncate', 'Upcase', 'Val', + 'Write', 'WriteLn' + ] + ,'types' : [ + 'Integer', 'Shortint', 'SmallInt', 'Longint', + 'Longword', 'Int64', 'Byte', 'Word', 'Cardinal', + 'QWord', 'Boolean', 'ByteBool', 'LongBool', 'Char', + 'Real', 'Single', 'Double', 'Extended', 'Comp', + 'String', 'ShortString', 'AnsiString', 'PChar' + ] + } + ,'OPERATORS' :[ + '@', '*', '+', '-', '/', '^', ':=', '<', '=', '>' + ] + ,'DELIMITERS' :[ + '(', ')', '[', ']' + ] + ,'STYLES' : { + 'COMMENTS': 'color: #AAAAAA;' + ,'QUOTESMARKS': 'color: #6381F8;' + ,'KEYWORDS' : { + 'specials' : 'color: #EE0000;' + ,'constants' : 'color: #654321;' + ,'keywords' : 'color: #48BDDF;' + ,'functions' : 'color: #449922;' + ,'types' : 'color: #2B60FF;' + } + ,'OPERATORS' : 'color: #FF00FF;' + ,'DELIMITERS' : 'color: #60CA00;' + } +}; diff --git a/includes/edit_area/reg_syntax/perl.js b/includes/edit_area/reg_syntax/perl.js new file mode 100644 index 0000000000..fca542811f --- /dev/null +++ b/includes/edit_area/reg_syntax/perl.js @@ -0,0 +1,88 @@ +/*************************************************************************** + * (c) 2008 - file created by Christoph Pinkel, MTC Infomedia OHG. + * + * You may choose any license of the current release or any future release + * of editarea to use, modify and/or redistribute this file. + * + * This language specification file supports for syntax checking on + * a large subset of Perl 5.x. + * The basic common syntax of Perl is fully supported, but as for + * the highlighting of built-in operations, it's mainly designed + * to support for hightlighting Perl code in a Safe environment (compartment) + * as used by CoMaNet for evaluation of administrative scripts. This Safe + * compartment basically allows for all of Opcode's :default operations, + * but little others. See http://perldoc.perl.org/Opcode.html to learn + * more. + ***************************************************************************/ + +editAreaLoader.load_syntax["perl"] = { + + 'COMMENT_SINGLE' : {1 : '#'}, + 'QUOTEMARKS' : {1: "'", 2: '"'}, + 'KEYWORD_CASE_SENSITIVE' : true, + 'KEYWORDS' : + { + 'core' : + [ "if", "else", "elsif", "while", "for", "each", "foreach", + "next", "last", "goto", "exists", "delete", "undef", + "my", "our", "local", "use", "require", "package", "keys", "values", + "sub", "bless", "ref", "return" ], + 'functions' : + [ + //from :base_core + "int", "hex", "oct", "abs", "substr", "vec", "study", "pos", + "length", "index", "rindex", "ord", "chr", "ucfirst", "lcfirst", + "uc", "lc", "quotemeta", "chop", "chomp", "split", "list", "splice", + "push", "pop", "shift", "unshift", "reverse", "and", "or", "dor", + "xor", "warn", "die", "prototype", + //from :base_mem + "concat", "repeat", "join", "range", + //none from :base_loop, as we'll see them as basic statements... + //from :base_orig + "sprintf", "crypt", "tie", "untie", "select", "localtime", "gmtime", + //others + "print", "open", "close" + ] + }, + 'OPERATORS' : + [ '+', '-', '/', '*', '=', '<', '>', '!', '||', '.', '&&', + ' eq ', ' ne ', '=~' ], + 'DELIMITERS' : + [ '(', ')', '[', ']', '{', '}' ], + 'REGEXPS' : + { + 'packagedecl' : { 'search': '(package )([^ \r\n\t#;]*)()', + 'class' : 'scopingnames', + 'modifiers' : 'g', 'execute' : 'before' }, + 'subdecl' : { 'search': '(sub )([^ \r\n\t#]*)()', + 'class' : 'scopingnames', + 'modifiers' : 'g', 'execute' : 'before' }, + 'scalars' : { 'search': '()(\\\$[a-zA-Z0-9_:]*)()', + 'class' : 'vars', + 'modifiers' : 'g', 'execute' : 'after' }, + 'arrays' : { 'search': '()(@[a-zA-Z0-9_:]*)()', + 'class' : 'vars', + 'modifiers' : 'g', 'execute' : 'after' }, + 'hashs' : { 'search': '()(%[a-zA-Z0-9_:]*)()', + 'class' : 'vars', + 'modifiers' : 'g', 'execute' : 'after' }, + }, + + 'STYLES' : + { + 'COMMENTS': 'color: #AAAAAA;', + 'QUOTESMARKS': 'color: #DC0000;', + 'KEYWORDS' : + { + 'core' : 'color: #8aca00;', + 'functions' : 'color: #2B60FF;' + }, + 'OPERATORS' : 'color: #8aca00;', + 'DELIMITERS' : 'color: #0038E1;', + 'REGEXPS': + { + 'scopingnames' : 'color: #ff0000;', + 'vars' : 'color: #00aaaa;', + } + } //'STYLES' +}; diff --git a/includes/edit_area/reg_syntax/php.js b/includes/edit_area/reg_syntax/php.js new file mode 100644 index 0000000000..a1c5883afa --- /dev/null +++ b/includes/edit_area/reg_syntax/php.js @@ -0,0 +1,156 @@ +editAreaLoader.load_syntax["php"] = { + 'COMMENT_SINGLE' : {1 : '//', 2 : '#'} + ,'COMMENT_MULTI' : {'/*' : '*/'} + ,'QUOTEMARKS' : {1: "'", 2: '"'} + ,'KEYWORD_CASE_SENSITIVE' : false + ,'KEYWORDS' : { + 'statements' : [ + 'include', 'require', 'include_once', 'require_once', + 'for', 'foreach', 'as', 'if', 'elseif', 'else', 'while', 'do', 'endwhile', + 'endif', 'switch', 'case', 'endswitch', + 'return', 'break', 'continue' + ] + ,'reserved' : [ + '_GET', '_POST', '_SESSION', '_SERVER', '_FILES', '_ENV', '_COOKIE', '_REQUEST', + 'null', '__LINE__', '__FILE__', + 'false', '<?php', '?>', '<?', + '<script language', '</script>', + 'true', 'var', 'default', + 'function', 'class', 'new', '&new', 'this', + '__FUNCTION__', '__CLASS__', '__METHOD__', 'PHP_VERSION', + 'PHP_OS', 'DEFAULT_INCLUDE_PATH', 'PEAR_INSTALL_DIR', 'PEAR_EXTENSION_DIR', + 'PHP_EXTENSION_DIR', 'PHP_BINDIR', 'PHP_LIBDIR', 'PHP_DATADIR', 'PHP_SYSCONFDIR', + 'PHP_LOCALSTATEDIR', 'PHP_CONFIG_FILE_PATH', 'PHP_OUTPUT_HANDLER_START', 'PHP_OUTPUT_HANDLER_CONT', + 'PHP_OUTPUT_HANDLER_END', 'E_ERROR', 'E_WARNING', 'E_PARSE', 'E_NOTICE', + 'E_CORE_ERROR', 'E_CORE_WARNING', 'E_COMPILE_ERROR', 'E_COMPILE_WARNING', 'E_USER_ERROR', + 'E_USER_WARNING', 'E_USER_NOTICE', 'E_ALL' + + ] + ,'functions' : [ + 'func_num_args', 'func_get_arg', 'func_get_args', 'strlen', 'strcmp', 'strncmp', 'strcasecmp', 'strncasecmp', 'each', 'error_reporting', 'define', 'defined', + 'trigger_error', 'user_error', 'set_error_handler', 'restore_error_handler', 'get_declared_classes', 'get_loaded_extensions', + 'extension_loaded', 'get_extension_funcs', 'debug_backtrace', + 'constant', 'bin2hex', 'sleep', 'usleep', 'time', 'mktime', 'gmmktime', 'strftime', 'gmstrftime', 'strtotime', 'date', 'gmdate', 'getdate', 'localtime', 'checkdate', 'flush', 'wordwrap', 'htmlspecialchars', 'htmlentities', 'html_entity_decode', 'md5', 'md5_file', 'crc32', 'getimagesize', 'image_type_to_mime_type', 'phpinfo', 'phpversion', 'phpcredits', 'strnatcmp', 'strnatcasecmp', 'substr_count', 'strspn', 'strcspn', 'strtok', 'strtoupper', 'strtolower', 'strpos', 'strrpos', 'strrev', 'hebrev', 'hebrevc', 'nl2br', 'basename', 'dirname', 'pathinfo', 'stripslashes', 'stripcslashes', 'strstr', 'stristr', 'strrchr', 'str_shuffle', 'str_word_count', 'strcoll', 'substr', 'substr_replace', 'quotemeta', 'ucfirst', 'ucwords', 'strtr', 'addslashes', 'addcslashes', 'rtrim', 'str_replace', 'str_repeat', 'count_chars', 'chunk_split', 'trim', 'ltrim', 'strip_tags', 'similar_text', 'explode', 'implode', 'setlocale', 'localeconv', + 'parse_str', 'str_pad', 'chop', 'strchr', 'sprintf', 'printf', 'vprintf', 'vsprintf', 'sscanf', 'fscanf', 'parse_url', 'urlencode', 'urldecode', 'rawurlencode', 'rawurldecode', 'readlink', 'linkinfo', 'link', 'unlink', 'exec', 'system', 'escapeshellcmd', 'escapeshellarg', 'passthru', 'shell_exec', 'proc_open', 'proc_close', 'rand', 'srand', 'getrandmax', 'mt_rand', 'mt_srand', 'mt_getrandmax', 'base64_decode', 'base64_encode', 'abs', 'ceil', 'floor', 'round', 'is_finite', 'is_nan', 'is_infinite', 'bindec', 'hexdec', 'octdec', 'decbin', 'decoct', 'dechex', 'base_convert', 'number_format', 'fmod', 'ip2long', 'long2ip', 'getenv', 'putenv', 'getopt', 'microtime', 'gettimeofday', 'getrusage', 'uniqid', 'quoted_printable_decode', 'set_time_limit', 'get_cfg_var', 'magic_quotes_runtime', 'set_magic_quotes_runtime', 'get_magic_quotes_gpc', 'get_magic_quotes_runtime', + 'import_request_variables', 'error_log', 'serialize', 'unserialize', 'memory_get_usage', 'var_dump', 'var_export', 'debug_zval_dump', 'print_r','highlight_file', 'show_source', 'highlight_string', 'ini_get', 'ini_get_all', 'ini_set', 'ini_alter', 'ini_restore', 'get_include_path', 'set_include_path', 'restore_include_path', 'setcookie', 'header', 'headers_sent', 'connection_aborted', 'connection_status', 'ignore_user_abort', 'parse_ini_file', 'is_uploaded_file', 'move_uploaded_file', 'intval', 'floatval', 'doubleval', 'strval', 'gettype', 'settype', 'is_null', 'is_resource', 'is_bool', 'is_long', 'is_float', 'is_int', 'is_integer', 'is_double', 'is_real', 'is_numeric', 'is_string', 'is_array', 'is_object', 'is_scalar', + 'ereg', 'ereg_replace', 'eregi', 'eregi_replace', 'split', 'spliti', 'join', 'sql_regcase', 'dl', 'pclose', 'popen', 'readfile', 'rewind', 'rmdir', 'umask', 'fclose', 'feof', 'fgetc', 'fgets', 'fgetss', 'fread', 'fopen', 'fpassthru', 'ftruncate', 'fstat', 'fseek', 'ftell', 'fflush', 'fwrite', 'fputs', 'mkdir', 'rename', 'copy', 'tempnam', 'tmpfile', 'file', 'file_get_contents', 'stream_select', 'stream_context_create', 'stream_context_set_params', 'stream_context_set_option', 'stream_context_get_options', 'stream_filter_prepend', 'stream_filter_append', 'fgetcsv', 'flock', 'get_meta_tags', 'stream_set_write_buffer', 'set_file_buffer', 'set_socket_blocking', 'stream_set_blocking', 'socket_set_blocking', 'stream_get_meta_data', 'stream_register_wrapper', 'stream_wrapper_register', 'stream_set_timeout', 'socket_set_timeout', 'socket_get_status', 'realpath', 'fnmatch', 'fsockopen', 'pfsockopen', 'pack', 'unpack', 'get_browser', 'crypt', 'opendir', 'closedir', 'chdir', 'getcwd', 'rewinddir', 'readdir', 'dir', 'glob', 'fileatime', 'filectime', 'filegroup', 'fileinode', 'filemtime', 'fileowner', 'fileperms', 'filesize', 'filetype', 'file_exists', 'is_writable', 'is_writeable', 'is_readable', 'is_executable', 'is_file', 'is_dir', 'is_link', 'stat', 'lstat', 'chown', + 'touch', 'clearstatcache', 'mail', 'ob_start', 'ob_flush', 'ob_clean', 'ob_end_flush', 'ob_end_clean', 'ob_get_flush', 'ob_get_clean', 'ob_get_length', 'ob_get_level', 'ob_get_status', 'ob_get_contents', 'ob_implicit_flush', 'ob_list_handlers', 'ksort', 'krsort', 'natsort', 'natcasesort', 'asort', 'arsort', 'sort', 'rsort', 'usort', 'uasort', 'uksort', 'shuffle', 'array_walk', 'count', 'end', 'prev', 'next', 'reset', 'current', 'key', 'min', 'max', 'in_array', 'array_search', 'extract', 'compact', 'array_fill', 'range', 'array_multisort', 'array_push', 'array_pop', 'array_shift', 'array_unshift', 'array_splice', 'array_slice', 'array_merge', 'array_merge_recursive', 'array_keys', 'array_values', 'array_count_values', 'array_reverse', 'array_reduce', 'array_pad', 'array_flip', 'array_change_key_case', 'array_rand', 'array_unique', 'array_intersect', 'array_intersect_assoc', 'array_diff', 'array_diff_assoc', 'array_sum', 'array_filter', 'array_map', 'array_chunk', 'array_key_exists', 'pos', 'sizeof', 'key_exists', 'assert', 'assert_options', 'version_compare', 'ftok', 'str_rot13', 'aggregate', + 'session_name', 'session_module_name', 'session_save_path', 'session_id', 'session_regenerate_id', 'session_decode', 'session_register', 'session_unregister', 'session_is_registered', 'session_encode', + 'session_start', 'session_destroy', 'session_unset', 'session_set_save_handler', 'session_cache_limiter', 'session_cache_expire', 'session_set_cookie_params', 'session_get_cookie_params', 'session_write_close', 'preg_match', 'preg_match_all', 'preg_replace', 'preg_replace_callback', 'preg_split', 'preg_quote', 'preg_grep', 'overload', 'ctype_alnum', 'ctype_alpha', 'ctype_cntrl', 'ctype_digit', 'ctype_lower', 'ctype_graph', 'ctype_print', 'ctype_punct', 'ctype_space', 'ctype_upper', 'ctype_xdigit', 'virtual', 'apache_request_headers', 'apache_note', 'apache_lookup_uri', 'apache_child_terminate', 'apache_setenv', 'apache_response_headers', 'apache_get_version', 'getallheaders', 'mysql_connect', 'mysql_pconnect', 'mysql_close', 'mysql_select_db', 'mysql_create_db', 'mysql_drop_db', 'mysql_query', 'mysql_unbuffered_query', 'mysql_db_query', 'mysql_list_dbs', 'mysql_list_tables', 'mysql_list_fields', 'mysql_list_processes', 'mysql_error', 'mysql_errno', 'mysql_affected_rows', 'mysql_insert_id', 'mysql_result', 'mysql_num_rows', 'mysql_num_fields', 'mysql_fetch_row', 'mysql_fetch_array', 'mysql_fetch_assoc', 'mysql_fetch_object', 'mysql_data_seek', 'mysql_fetch_lengths', 'mysql_fetch_field', 'mysql_field_seek', 'mysql_free_result', 'mysql_field_name', 'mysql_field_table', 'mysql_field_len', 'mysql_field_type', 'mysql_field_flags', 'mysql_escape_string', 'mysql_real_escape_string', 'mysql_stat', + 'mysql_thread_id', 'mysql_client_encoding', 'mysql_get_client_info', 'mysql_get_host_info', 'mysql_get_proto_info', 'mysql_get_server_info', 'mysql_info', 'mysql', 'mysql_fieldname', 'mysql_fieldtable', 'mysql_fieldlen', 'mysql_fieldtype', 'mysql_fieldflags', 'mysql_selectdb', 'mysql_createdb', 'mysql_dropdb', 'mysql_freeresult', 'mysql_numfields', 'mysql_numrows', 'mysql_listdbs', 'mysql_listtables', 'mysql_listfields', 'mysql_db_name', 'mysql_dbname', 'mysql_tablename', 'mysql_table_name', 'pg_connect', 'pg_pconnect', 'pg_close', 'pg_connection_status', 'pg_connection_busy', 'pg_connection_reset', 'pg_host', 'pg_dbname', 'pg_port', 'pg_tty', 'pg_options', 'pg_ping', 'pg_query', 'pg_send_query', 'pg_cancel_query', 'pg_fetch_result', 'pg_fetch_row', 'pg_fetch_assoc', 'pg_fetch_array', 'pg_fetch_object', 'pg_fetch_all', 'pg_affected_rows', 'pg_get_result', 'pg_result_seek', 'pg_result_status', 'pg_free_result', 'pg_last_oid', 'pg_num_rows', 'pg_num_fields', 'pg_field_name', 'pg_field_num', 'pg_field_size', 'pg_field_type', 'pg_field_prtlen', 'pg_field_is_null', 'pg_get_notify', 'pg_get_pid', 'pg_result_error', 'pg_last_error', 'pg_last_notice', 'pg_put_line', 'pg_end_copy', 'pg_copy_to', 'pg_copy_from', + 'pg_trace', 'pg_untrace', 'pg_lo_create', 'pg_lo_unlink', 'pg_lo_open', 'pg_lo_close', 'pg_lo_read', 'pg_lo_write', 'pg_lo_read_all', 'pg_lo_import', 'pg_lo_export', 'pg_lo_seek', 'pg_lo_tell', 'pg_escape_string', 'pg_escape_bytea', 'pg_unescape_bytea', 'pg_client_encoding', 'pg_set_client_encoding', 'pg_meta_data', 'pg_convert', 'pg_insert', 'pg_update', 'pg_delete', 'pg_select', 'pg_exec', 'pg_getlastoid', 'pg_cmdtuples', 'pg_errormessage', 'pg_numrows', 'pg_numfields', 'pg_fieldname', 'pg_fieldsize', 'pg_fieldtype', 'pg_fieldnum', 'pg_fieldprtlen', 'pg_fieldisnull', 'pg_freeresult', 'pg_result', 'pg_loreadall', 'pg_locreate', 'pg_lounlink', 'pg_loopen', 'pg_loclose', 'pg_loread', 'pg_lowrite', 'pg_loimport', 'pg_loexport', + 'echo', 'print', 'global', 'static', 'exit', 'array', 'empty', 'eval', 'isset', 'unset', 'die' + + ] + } + ,'OPERATORS' :[ + '+', '-', '/', '*', '=', '<', '>', '%', '!', '&&', '||' + ] + ,'DELIMITERS' :[ + '(', ')', '[', ']', '{', '}' + ] + ,'REGEXPS' : { + // highlight all variables ($...) + 'variables' : { + 'search' : '()(\\$\\w+)()' + ,'class' : 'variables' + ,'modifiers' : 'g' + ,'execute' : 'before' // before or after + } + } + ,'STYLES' : { + 'COMMENTS': 'color: #AAAAAA;' + ,'QUOTESMARKS': 'color: #879EFA;' + ,'KEYWORDS' : { + 'reserved' : 'color: #48BDDF;' + ,'functions' : 'color: #0040FD;' + ,'statements' : 'color: #60CA00;' + } + ,'OPERATORS' : 'color: #FF00FF;' + ,'DELIMITERS' : 'color: #2B60FF;' + ,'REGEXPS' : { + 'variables' : 'color: #E0BD54;' + } + } + ,'AUTO_COMPLETION' : { + "default": { // the name of this definition group. It's posisble to have different rules inside the same definition file + "REGEXP": { "before_word": "[^a-zA-Z0-9_]|^" // \\s|\\.| + ,"possible_words_letters": "[a-zA-Z0-9_\$]+" + ,"letter_after_word_must_match": "[^a-zA-Z0-9_]|$" + ,"prefix_separator": "\\-\\>|\\:\\:" + } + ,"CASE_SENSITIVE": true + ,"MAX_TEXT_LENGTH": 100 // the maximum length of the text being analyzed before the cursor position + ,"KEYWORDS": { + '': [ // the prefix of thoses items + /** + * 0 : the keyword the user is typing + * 1 : (optionnal) the string inserted in code ("{@}" being the new position of the cursor, "§" beeing the equivalent to the value the typed string indicated if the previous ) + * If empty the keyword will be displayed + * 2 : (optionnal) the text that appear in the suggestion box (if empty, the string to insert will be displayed) + */ + ['$_POST'] + ,['$_GET'] + ,['$_SESSION'] + ,['$_SERVER'] + ,['$_FILES'] + ,['$_ENV'] + ,['$_COOKIE'] + ,['$_REQUEST'] + // magic methods + ,['__construct', '§( {@} )'] + ,['__destruct', '§( {@} )'] + ,['__sleep', '§( {@} )'] + ,['__wakeup', '§( {@} )'] + ,['__toString', '§( {@} )'] + // include + ,['include', '§ "{@}";'] + ,['include_once', '§ "{@}";'] + ,['require', '§ "{@}";'] + ,['require_once', '§ "{@}";'] + // statements + ,['for', '§( {@} )'] + ,['foreach', '§( {@} )'] + ,['if', '§( {@} )'] + ,['elseif', '§( {@} )'] + ,['while', '§( {@} )'] + ,['switch', '§( {@} )'] + ,['break'] + ,['case'] + ,['continue'] + ,['do'] + ,['else'] + ,['endif'] + ,['endswitch'] + ,['endwhile'] + ,['return'] + // function + ,['unset', '§( {@} )'] + ] + } + } + ,"live": { + + // class NAME: /class\W+([a-z]+)\W+/gi + // method: /^(public|private|protected)?\s*function\s+([a-z][a-z0-9\_]*)\s*(\([^\{]*\))/gmi + // static: /^(public|private|protected)?\s+static\s+(public|private|protected)?\s*function\s+([a-z][a-z0-9\_]*)\s*(\([^\{]*\))/gmi + // attributes: /(\$this\-\>|(?:var|public|protected|private)\W+\$)([a-z0-9\_]+)(?!\()\b/gi + // v1 : /(\$this\-\>|var\W+|public\W+|protected\W+|private\W+)([a-z0-9\_]+)\W*(=|;)/gi + // var type: /(\$(this\-\>)?[a-z0-9\_]+)\s*\=\s*new\s+([a-z0-9\_])+/gi + + + "REGEXP": { "before_word": "[^a-zA-Z0-9_]|^" // \\s|\\.| + ,"possible_words_letters": "[a-zA-Z0-9_\$]+" + ,"letter_after_word_must_match": "[^a-zA-Z0-9_]|$" + ,"prefix_separator": "\\-\\>" + } + ,"CASE_SENSITIVE": true + ,"MAX_TEXT_LENGTH": 100 // the maximum length of the text being analyzed before the cursor position + ,"KEYWORDS": { + '$this': [ // the prefix of thoses items + ['test'] + ] + } + } + } +}; diff --git a/includes/edit_area/reg_syntax/python.js b/includes/edit_area/reg_syntax/python.js new file mode 100644 index 0000000000..456b27e976 --- /dev/null +++ b/includes/edit_area/reg_syntax/python.js @@ -0,0 +1,144 @@ +/** + * Python syntax v 1.1 + * + * v1.1 by Andre Roberge (2006/12/27) + * +**/ +editAreaLoader.load_syntax["python"] = { + 'COMMENT_SINGLE' : {1 : '#'} + ,'COMMENT_MULTI' : {} + ,'QUOTEMARKS' : {1: "'", 2: '"'} + ,'KEYWORD_CASE_SENSITIVE' : true + ,'KEYWORDS' : { + /* + ** Set 1: reserved words + ** http://python.org/doc/current/ref/keywords.html + ** Note: 'as' and 'with' have been added starting with Python 2.5 + */ + 'reserved' : [ + 'and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', + 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', + 'import', 'is', 'in', 'lambda', 'not', 'or', 'pass', 'print', 'raise', + 'return', 'try', 'while', 'with', 'yield' + //the following are *almost* reserved; we'll treat them as such + , 'False', 'True', 'None' + ] + /* + ** Set 2: builtins + ** http://python.org/doc/current/lib/built-in-funcs.html + */ + ,'builtins' : [ + '__import__', 'abs', 'basestring', 'bool', 'callable', 'chr', 'classmethod', 'cmp', + 'compile', 'complex', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'execfile', + 'file', 'filter', 'float', 'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', + 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter', 'len', 'list', 'locals', + 'long', 'map', 'max', 'min', 'object', 'oct', 'open', 'ord', 'pow', 'property', 'range', + 'raw_input', 'reduce', 'reload', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice', + 'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'unichr', 'unicode', + 'vars', 'xrange', 'zip', + // Built-in constants: http://www.python.org/doc/2.4.1/lib/node35.html + //'False', 'True', 'None' have been included in 'reserved' + 'NotImplemented', 'Ellipsis', + // Built-in Exceptions: http://python.org/doc/current/lib/module-exceptions.html + 'Exception', 'StandardError', 'ArithmeticError', 'LookupError', 'EnvironmentError', + 'AssertionError', 'AttributeError', 'EOFError', 'FloatingPointError', 'IOError', + 'ImportError', 'IndexError', 'KeyError', 'KeyboardInterrupt', 'MemoryError', 'NameError', + 'NotImplementedError', 'OSError', 'OverflowError', 'ReferenceError', 'RuntimeError', + 'StopIteration', 'SyntaxError', 'SystemError', 'SystemExit', 'TypeError', + 'UnboundlocalError', 'UnicodeError', 'UnicodeEncodeError', 'UnicodeDecodeError', + 'UnicodeTranslateError', 'ValueError', 'WindowsError', 'ZeroDivisionError', 'Warning', + 'UserWarning', 'DeprecationWarning', 'PendingDeprecationWarning', 'SyntaxWarning', + 'RuntimeWarning', 'FutureWarning', + // we will include the string methods as well + // http://python.org/doc/current/lib/string-methods.html + 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', + 'find', 'index', 'isalnum', 'isaplpha', 'isdigit', 'islower', 'isspace', 'istitle', + 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'replace', 'rfind', 'rindex', 'rjust', + 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', + 'translate', 'upper', 'zfill' + ] + /* + ** Set 3: standard library + ** http://python.org/doc/current/lib/modindex.html + */ + ,'stdlib' : [ + '__builtin__', '__future__', '__main__', '_winreg', 'aifc', 'AL', 'al', 'anydbm', + 'array', 'asynchat', 'asyncore', 'atexit', 'audioop', 'base64', 'BaseHTTPServer', + 'Bastion', 'binascii', 'binhex', 'bisect', 'bsddb', 'bz2', 'calendar', 'cd', 'cgi', + 'CGIHTTPServer', 'cgitb', 'chunk', 'cmath', 'cmd', 'code', 'codecs', 'codeop', + 'collections', 'colorsys', 'commands', 'compileall', 'compiler', 'compiler', + 'ConfigParser', 'Cookie', 'cookielib', 'copy', 'copy_reg', 'cPickle', 'crypt', + 'cStringIO', 'csv', 'curses', 'datetime', 'dbhash', 'dbm', 'decimal', 'DEVICE', + 'difflib', 'dircache', 'dis', 'distutils', 'dl', 'doctest', 'DocXMLRPCServer', 'dumbdbm', + 'dummy_thread', 'dummy_threading', 'email', 'encodings', 'errno', 'exceptions', 'fcntl', + 'filecmp', 'fileinput', 'FL', 'fl', 'flp', 'fm', 'fnmatch', 'formatter', 'fpectl', + 'fpformat', 'ftplib', 'gc', 'gdbm', 'getopt', 'getpass', 'gettext', 'GL', 'gl', 'glob', + 'gopherlib', 'grp', 'gzip', 'heapq', 'hmac', 'hotshot', 'htmlentitydefs', 'htmllib', + 'HTMLParser', 'httplib', 'imageop', 'imaplib', 'imgfile', 'imghdr', 'imp', 'inspect', + 'itertools', 'jpeg', 'keyword', 'linecache', 'locale', 'logging', 'mailbox', 'mailcap', + 'marshal', 'math', 'md5', 'mhlib', 'mimetools', 'mimetypes', 'MimeWriter', 'mimify', + 'mmap', 'msvcrt', 'multifile', 'mutex', 'netrc', 'new', 'nis', 'nntplib', 'operator', + 'optparse', 'os', 'ossaudiodev', 'parser', 'pdb', 'pickle', 'pickletools', 'pipes', + 'pkgutil', 'platform', 'popen2', 'poplib', 'posix', 'posixfile', 'pprint', 'profile', + 'pstats', 'pty', 'pwd', 'py_compile', 'pyclbr', 'pydoc', 'Queue', 'quopri', 'random', + 're', 'readline', 'repr', 'resource', 'rexec', 'rfc822', 'rgbimg', 'rlcompleter', + 'robotparser', 'sched', 'ScrolledText', 'select', 'sets', 'sgmllib', 'sha', 'shelve', + 'shlex', 'shutil', 'signal', 'SimpleHTTPServer', 'SimpleXMLRPCServer', 'site', 'smtpd', + 'smtplib', 'sndhdr', 'socket', 'SocketServer', 'stat', 'statcache', 'statvfs', 'string', + 'StringIO', 'stringprep', 'struct', 'subprocess', 'sunau', 'SUNAUDIODEV', 'sunaudiodev', + 'symbol', 'sys', 'syslog', 'tabnanny', 'tarfile', 'telnetlib', 'tempfile', 'termios', + 'test', 'textwrap', 'thread', 'threading', 'time', 'timeit', 'Tix', 'Tkinter', 'token', + 'tokenize', 'traceback', 'tty', 'turtle', 'types', 'unicodedata', 'unittest', 'urllib2', + 'urllib', 'urlparse', 'user', 'UserDict', 'UserList', 'UserString', 'uu', 'warnings', + 'wave', 'weakref', 'webbrowser', 'whichdb', 'whrandom', 'winsound', 'xdrlib', 'xml', + 'xmllib', 'xmlrpclib', 'zipfile', 'zipimport', 'zlib' + + ] + /* + ** Set 4: special methods + ** http://python.org/doc/current/ref/specialnames.html + */ + ,'special' : [ + // Basic customization: http://python.org/doc/current/ref/customization.html + '__new__', '__init__', '__del__', '__repr__', '__str__', + '__lt__', '__le__', '__eq__', '__ne__', '__gt__', '__ge__', '__cmp__', '__rcmp__', + '__hash__', '__nonzero__', '__unicode__', '__dict__', + // Attribute access: http://python.org/doc/current/ref/attribute-access.html + '__setattr__', '__delattr__', '__getattr__', '__getattribute__', '__get__', '__set__', + '__delete__', '__slots__', + // Class creation, callable objects + '__metaclass__', '__call__', + // Container types: http://python.org/doc/current/ref/sequence-types.html + '__len__', '__getitem__', '__setitem__', '__delitem__', '__iter__', '__contains__', + '__getslice__', '__setslice__', '__delslice__', + // Numeric types: http://python.org/doc/current/ref/numeric-types.html + '__abs__','__add__','__and__','__coerce__','__div__','__divmod__','__float__', + '__hex__','__iadd__','__isub__','__imod__','__idiv__','__ipow__','__iand__', + '__ior__','__ixor__', '__ilshift__','__irshift__','__invert__','__int__', + '__long__','__lshift__', + '__mod__','__mul__','__neg__','__oct__','__or__','__pos__','__pow__', + '__radd__','__rdiv__','__rdivmod__','__rmod__','__rpow__','__rlshift__','__rrshift__', + '__rshift__','__rsub__','__rmul__','__repr__','__rand__','__rxor__','__ror__', + '__sub__','__xor__' + ] + } + ,'OPERATORS' :[ + '+', '-', '/', '*', '=', '<', '>', '%', '!', '&', ';', '?', '`', ':', ',' + ] + ,'DELIMITERS' :[ + '(', ')', '[', ']', '{', '}' + ] + ,'STYLES' : { + 'COMMENTS': 'color: #AAAAAA;' + ,'QUOTESMARKS': 'color: #660066;' + ,'KEYWORDS' : { + 'reserved' : 'color: #0000FF;' + ,'builtins' : 'color: #009900;' + ,'stdlib' : 'color: #009900;' + ,'special': 'color: #006666;' + } + ,'OPERATORS' : 'color: #993300;' + ,'DELIMITERS' : 'color: #993300;' + + } +}; diff --git a/includes/edit_area/reg_syntax/robotstxt.js b/includes/edit_area/reg_syntax/robotstxt.js new file mode 100644 index 0000000000..eab451d039 --- /dev/null +++ b/includes/edit_area/reg_syntax/robotstxt.js @@ -0,0 +1,24 @@ +editAreaLoader.load_syntax["robotstxt"] = { + 'COMMENT_SINGLE' : {1 : '#'}, + 'COMMENT_MULTI' : {}, + 'QUOTEMARKS' : [], + 'KEYWORD_CASE_SENSITIVE' : false, + 'KEYWORDS' : { + 'attributes' : ['User-agent', 'Disallow', 'Allow', 'Crawl-delay'], + 'values' : ['*'], + 'specials' : ['*'] + }, + 'OPERATORS' :[':'], + 'DELIMITERS' :[], + 'STYLES' : { + 'COMMENTS': 'color: #AAAAAA;', + 'QUOTESMARKS': 'color: #6381F8;', + 'KEYWORDS' : { + 'attributes' : 'color: #48BDDF;', + 'values' : 'color: #2B60FF;', + 'specials' : 'color: #FF0000;' + }, + 'OPERATORS' : 'color: #FF00FF;', + 'DELIMITERS' : 'color: #60CA00;' + } +}; diff --git a/includes/edit_area/reg_syntax/ruby.js b/includes/edit_area/reg_syntax/ruby.js new file mode 100644 index 0000000000..1f94ecc9ef --- /dev/null +++ b/includes/edit_area/reg_syntax/ruby.js @@ -0,0 +1,67 @@ +/** + * Ruby syntax v 1.0 + * + * v1.0 by Patrice De Saint Steban (2007/01/03) + * +**/ +editAreaLoader.load_syntax["ruby"] = { + 'COMMENT_SINGLE' : {1 : '#'} + ,'COMMENT_MULTI' : {} + ,'QUOTEMARKS' : {1: "'", 2: '"'} + ,'KEYWORD_CASE_SENSITIVE' : true + ,'KEYWORDS' : { + 'reserved' : [ + 'alias', 'and', 'BEGIN', 'begin', 'break', 'case', 'class', 'def', 'defined', 'do', 'else', + 'elsif', 'END', 'end', 'ensure', 'false', 'for', 'if', + 'in', 'module', 'next', 'not', 'or', 'redo', 'rescue', 'retry', + 'return', 'self', 'super', 'then', 'true', 'undef', 'unless', 'until', 'when', 'while', 'yield' + ] + } + ,'OPERATORS' :[ + '+', '-', '/', '*', '=', '<', '>', '%', '!', '&', ';', '?', '`', ':', ',' + ] + ,'DELIMITERS' :[ + '(', ')', '[', ']', '{', '}' + ] + ,'REGEXPS' : { + 'constants' : { + 'search' : '()([A-Z]\\w*)()' + ,'class' : 'constants' + ,'modifiers' : 'g' + ,'execute' : 'before' + } + ,'variables' : { + 'search' : '()([\$\@\%]+\\w+)()' + ,'class' : 'variables' + ,'modifiers' : 'g' + ,'execute' : 'before' + } + ,'numbers' : { + 'search' : '()(-?[0-9]+)()' + ,'class' : 'numbers' + ,'modifiers' : 'g' + ,'execute' : 'before' + } + ,'symbols' : { + 'search' : '()(:\\w+)()' + ,'class' : 'symbols' + ,'modifiers' : 'g' + ,'execute' : 'before' + } + } + ,'STYLES' : { + 'COMMENTS': 'color: #AAAAAA;' + ,'QUOTESMARKS': 'color: #660066;' + ,'KEYWORDS' : { + 'reserved' : 'font-weight: bold; color: #0000FF;' + } + ,'OPERATORS' : 'color: #993300;' + ,'DELIMITERS' : 'color: #993300;' + ,'REGEXPS' : { + 'variables' : 'color: #E0BD54;' + ,'numbers' : 'color: green;' + ,'constants' : 'color: #00AA00;' + ,'symbols' : 'color: #879EFA;' + } + } +}; diff --git a/includes/edit_area/reg_syntax/sql.js b/includes/edit_area/reg_syntax/sql.js new file mode 100644 index 0000000000..f4530a99c7 --- /dev/null +++ b/includes/edit_area/reg_syntax/sql.js @@ -0,0 +1,55 @@ +editAreaLoader.load_syntax["sql"] = { + 'COMMENT_SINGLE' : {1 : '--'} + ,'COMMENT_MULTI' : {'/*' : '*/'} + ,'QUOTEMARKS' : {1: "'", 2: '"', 3: '`'} + ,'KEYWORD_CASE_SENSITIVE' : false + ,'KEYWORDS' : { + 'statements' : [ + 'select', 'SELECT', 'where', 'order', 'by', + 'insert', 'from', 'update', 'grant', 'left join', 'right join', + 'union', 'group', 'having', 'limit', 'alter', 'LIKE','IN','CASE' + ] + ,'reserved' : [ + 'null', 'enum', 'int', 'boolean', 'add', 'varchar' + + ] + ,'functions' : [ + 'ABS','ACOS','ADDDATE','ADDTIME','AES_DECRYPT','AES_ENCRYPT','ASCII','ASIN','ATAN2 ATAN','ATAN','AVG','BENCHMARK','DISTINCT','BIN','BIT_AND','BIT_COUNT','BIT_LENGTH','BIT_OR','BIT_XOR','CAST','CEILING CEIL','CHAR_LENGTH','CHAR', +'CHARACTER_LENGTH','CHARSET','COALESCE','COERCIBILITY','COLLATION','COMPRESS','CONCAT_WS','CONCAT','CONNECTION_ID','CONV','CONVERT_TZ','COS','COT','COUNT','CRC32','CURDATE','CURRENT_DATE','CURRENT_TIME','CURRENT_TIMESTAMP','CURRENT_USER','CURTIME','DATABASE','DATE_ADD','DATE_FORMAT','DATE_SUB','DATE','DATEDIFF','DAY','DAYNAME','DAYOFMONTH', +'DAYOFWEEK','DAYOFYEAR','DECODE','DEFAULT','DEGREES','DES_DECRYPT','DES_ENCRYPT','ELT','ENCODE','ENCRYPT','EXP','EXPORT_SET','EXTRACT','FIELD','FIND_IN_SET','FLOOR','FORMAT','FOUND_ROWS','FROM_DAYS','FROM_UNIXTIME','GET_FORMAT','GET_LOCK','GREATEST','GROUP_CONCAT','HEX','HOUR','IF','IFNULL','INET_ATON','INET_NTOA', +'INSERT','INSTR','INTERVAL','IS_FREE_LOCK','IS_USED_LOCK','ISNULL','LAST_DAY','LAST_INSERT_ID','LCASE','LEAST','LEFT','LENGTH','LN','LOAD_FILE','LOCALTIME','LOCALTIMESTAMP','LOCATE','LOG10','LOG2','LOG','LOWER','LPAD','LTRIM','MAKE_SET','MAKEDATE','MAKETIME','MASTER_POS_WAIT','MAX','MD5','MICROSECOND', +'MID','MIN','MINUTE','MOD','MONTH','MONTHNAME','NOW','NULLIF','OCT','OCTET_LENGTH','OLD_PASSWORD','ORD','PASSWORD','PERIOD_ADD','PERIOD_DIFF','PI','POSITION','POW','POWER','PROCEDURE ANALYSE','QUARTER','QUOTE','RADIANS','RAND','RELEASE_LOCK','REPEAT','REPLACE','REVERSE','RIGHT','ROUND', +'RPAD','RTRIM','SEC_TO_TIME','SECOND','SESSION_USER','SHA1','SHA','SIGN','SIN','SOUNDEX','SOUNDS LIKE','SPACE','SQRT','STD','STDDEV','STR_TO_DATE','STRCMP','SUBDATE','SUBSTRING_INDEX','SUBSTRING','SUBSTR','SUBTIME','SUM','SYSDATE','SYSTEM_USER','TAN','TIME_FORMAT','TIME_TO_SEC','TIME','TIMEDIFF', +'TIMESTAMP','TO_DAYS','TRIM','TRUNCATE','UCASE','UNCOMPRESS','UNCOMPRESSED_LENGTH','UNHEX','UNIX_TIMESTAMP','UPPER','USER','UTC_DATE','UTC_TIME','UTC_TIMESTAMP','UUID','VALUES','VARIANCE','WEEK','WEEKDAY','WEEKOFYEAR','YEAR','YEARWEEK' + ] + } + ,'OPERATORS' :[ + 'AND','&&','BETWEEN','BINARY','&','|','^','/','DIV','<=>','=','>=','>','<<','>>','IS','NULL','<=','<','-','%','!=','<>','!','||','OR','+','REGEXP','RLIKE','XOR','~','*' + ] + ,'DELIMITERS' :[ + '(', ')', '[', ']', '{', '}' + ] + ,'REGEXPS' : { + // highlight all variables (@...) + 'variables' : { + 'search' : '()(\\@\\w+)()' + ,'class' : 'variables' + ,'modifiers' : 'g' + ,'execute' : 'before' // before or after + } + } + ,'STYLES' : { + 'COMMENTS': 'color: #AAAAAA;' + ,'QUOTESMARKS': 'color: #879EFA;' + ,'KEYWORDS' : { + 'reserved' : 'color: #48BDDF;' + ,'functions' : 'color: #0040FD;' + ,'statements' : 'color: #60CA00;' + } + ,'OPERATORS' : 'color: #FF00FF;' + ,'DELIMITERS' : 'color: #2B60FF;' + ,'REGEXPS' : { + 'variables' : 'color: #E0BD54;' + } + } +}; diff --git a/includes/edit_area/reg_syntax/tsql.js b/includes/edit_area/reg_syntax/tsql.js new file mode 100644 index 0000000000..0c5c9ee8ac --- /dev/null +++ b/includes/edit_area/reg_syntax/tsql.js @@ -0,0 +1,87 @@ +editAreaLoader.load_syntax["tsql"] = { + 'COMMENT_SINGLE' : {1 : '--'} + ,'COMMENT_MULTI' : {'/*' : '*/'} + ,'QUOTEMARKS' : {1: "'" } + ,'KEYWORD_CASE_SENSITIVE' : false + ,'KEYWORDS' : { + 'statements': [ + 'ADD', 'EXCEPT', 'PERCENT', 'EXEC', 'PLAN', 'ALTER', 'EXECUTE', 'PRECISION', + 'PRIMARY', 'EXIT', 'PRINT', 'AS', 'FETCH', 'PROC', 'ASC', + 'FILE', 'PROCEDURE', 'AUTHORIZATION', 'FILLFACTOR', 'PUBLIC', 'BACKUP', 'FOR', 'RAISERROR', + 'BEGIN', 'FOREIGN', 'READ', 'FREETEXT', 'READTEXT', 'BREAK', 'FREETEXTTABLE', + 'RECONFIGURE', 'BROWSE', 'FROM', 'REFERENCES', 'BULK', 'FULL', 'REPLICATION', 'BY', + 'FUNCTION', 'RESTORE', 'CASCADE', 'GOTO', 'RESTRICT', 'CASE', 'GRANT', 'RETURN', + 'CHECK', 'GROUP', 'REVOKE', 'CHECKPOINT', 'HAVING', 'RIGHT', 'CLOSE', 'HOLDLOCK', 'ROLLBACK', + 'CLUSTERED', 'IDENTITY', 'ROWCOUNT', 'IDENTITY_INSERT', 'ROWGUIDCOL', 'COLLATE', + 'IDENTITYCOL', 'RULE', 'COLUMN', 'IF', 'SAVE', 'COMMIT', 'SCHEMA', 'COMPUTE', 'INDEX', + 'SELECT', 'CONSTRAINT', 'CONTAINS', 'INSERT', 'SET', + 'CONTAINSTABLE', 'INTERSECT', 'SETUSER', 'CONTINUE', 'INTO', 'SHUTDOWN', 'SOME', + 'CREATE', 'STATISTICS', 'KEY', 'CURRENT', 'KILL', 'TABLE', + 'CURRENT_DATE', 'TEXTSIZE', 'CURRENT_TIME', 'THEN', 'LINENO', + 'TO', 'LOAD', 'TOP', 'CURSOR', 'NATIONAL', 'TRAN', 'DATABASE', 'NOCHECK', + 'TRANSACTION', 'DBCC', 'NONCLUSTERED', 'TRIGGER', 'DEALLOCATE', 'TRUNCATE', + 'DECLARE', 'TSEQUAL', 'DEFAULT', 'UNION', 'DELETE', 'OF', 'UNIQUE', + 'DENY', 'OFF', 'UPDATE', 'DESC', 'OFFSETS', 'UPDATETEXT', 'DISK', 'ON', 'USE', 'DISTINCT', 'OPEN', + 'DISTRIBUTED', 'OPENDATASOURCE', 'VALUES', 'DOUBLE', 'OPENQUERY', 'VARYING', 'DROP', + 'OPENROWSET', 'VIEW', 'DUMMY', 'OPENXML', 'WAITFOR', 'DUMP', 'OPTION', 'WHEN', 'ELSE', 'WHERE', + 'END', 'ORDER', 'WHILE', 'ERRLVL', 'WITH', 'ESCAPE', 'OVER', 'WRITETEXT' + ], + 'functions': [ + 'COALESCE', 'SESSION_USER', 'CONVERT', 'SYSTEM_USER', 'CURRENT_TIMESTAMP', 'CURRENT_USER', 'NULLIF', 'USER', + 'AVG', 'MIN', 'CHECKSUM', 'SUM', 'CHECKSUM_AGG', 'STDEV', 'COUNT', 'STDEVP', 'COUNT_BIG', 'VAR', 'GROUPING', 'VARP', 'MAX', + '@@DATEFIRST', '@@OPTIONS', '@@DBTS', '@@REMSERVER', '@@LANGID', '@@SERVERNAME', '@@LANGUAGE', '@@SERVICENAME', '@@LOCK_TIMEOUT', + '@@SPID', '@@MAX_CONNECTIONS', '@@TEXTSIZE', '@@MAX_PRECISION', '@@VERSION', '@@NESTLEVEL', + '@@CURSOR_ROWS', 'CURSOR_STATUS', '@@FETCH_STATUS', + 'DATEADD', 'DATEDIFF', 'DATENAME', 'DATEPART', 'DAY', 'GETDATE', 'GETUTCDATE', 'MONTH', 'YEAR', + 'ABS', 'DEGREES', 'RAND', 'ACOS', 'EXP', 'ROUND', 'ASIN', 'FLOOR', 'SIGN', 'ATAN', 'LOG', 'SIN', 'ATN2', 'LOG10', 'SQRT', + 'CEILING', 'PI ', 'SQUARE', 'COS', 'POWER', 'TAN', 'COT', 'RADIANS', + '@@PROCID', 'COL_LENGTH', 'FULLTEXTCATALOGPROPERTY', 'COL_NAME', 'FULLTEXTSERVICEPROPERTY', 'COLUMNPROPERTY', 'INDEX_COL', + 'DATABASEPROPERTY', 'INDEXKEY_PROPERTY', 'DATABASEPROPERTYEX', 'INDEXPROPERTY', 'DB_ID', 'OBJECT_ID', 'DB_NAME', 'OBJECT_NAME', + 'FILE_ID', 'OBJECTPROPERTY', 'OBJECTPROPERTYEX', 'FILE_NAME', 'SQL_VARIANT_PROPERTY', 'FILEGROUP_ID', 'FILEGROUP_NAME', + 'FILEGROUPPROPERTY', 'TYPEPROPERTY', 'FILEPROPERTY', + 'CURRENT_USER', 'SUSER_ID', 'SUSER_SID', 'IS_MEMBER', 'SUSER_SNAME', 'IS_SRVROLEMEMBER', 'PERMISSIONS', 'SYSTEM_USER', + 'SUSER_NAME', 'USER_ID', 'SESSION_USER', 'USER_NAME', 'ASCII', 'SOUNDEX', 'PATINDEX', 'SPACE', 'CHARINDEX', 'QUOTENAME', + 'STR', 'DIFFERENCE', 'REPLACE', 'STUFF', 'REPLICATE', 'SUBSTRING', 'LEN', 'REVERSE', 'UNICODE', 'LOWER', + 'UPPER', 'LTRIM', 'RTRIM', 'APP_NAME', 'CAST', 'CONVERT', 'COALESCE', 'COLLATIONPROPERTY', 'COLUMNS_UPDATED', 'CURRENT_TIMESTAMP', + 'CURRENT_USER', 'DATALENGTH', '@@ERROR', 'FORMATMESSAGE', 'GETANSINULL', 'HOST_ID', 'HOST_NAME', 'IDENT_CURRENT', 'IDENT_INCR', + 'IDENT_SEED', '@@IDENTITY', 'ISDATE', 'ISNULL', 'ISNUMERIC', 'NEWID', 'NULLIF', 'PARSENAME', '@@ROWCOUNT', + 'SCOPE_IDENTITY', 'SERVERPROPERTY', 'SESSIONPROPERTY', 'SESSION_USER', 'STATS_DATE', 'SYSTEM_USER', '@@TRANCOUNT', 'USER_NAME', + '@@CONNECTIONS', '@@PACK_RECEIVED', '@@CPU_BUSY', '@@PACK_SENT', '@@TIMETICKS', '@@IDLE', '@@TOTAL_ERRORS', '@@IO_BUSY', '@@TOTAL_READ', + '@@PACKET_ERRORS', '@@TOTAL_WRITE', 'PATINDEX', 'TEXTVALID', 'TEXTPTR' + ], + 'reserved': [ + 'RIGHT', 'INNER', 'IS', 'JOIN', 'CROSS', 'LEFT', 'NULL', 'OUTER' + ] + } + ,'OPERATORS' :[ + '+', '-', '*', '/', '%', '=', '&' ,'|', '^', '>', '<', '>=', '<=', '<>', '!=', '!<', '!>', 'ALL', 'AND', 'ANY', 'BETWEEN', 'EXISTS', 'IN', 'LIKE', 'NOT', 'OR', '~' + ] + ,'DELIMITERS' :[ + '(', ')', '[', ']', '{', '}' + ] + ,'REGEXPS' : { + // highlight all variables (@...) + 'variables' : { + 'search' : '()(\\@\\w+)()' + ,'class' : 'variables' + ,'modifiers' : 'g' + ,'execute' : 'before' // before or after + } + } + ,'STYLES' : { + 'COMMENTS': 'color: #008000;' + ,'QUOTESMARKS': 'color: #FF0000;' + ,'KEYWORDS' : { + 'reserved' : 'color: #808080;' + ,'functions' : 'color: #FF00FF;' + ,'statements' : 'color: #0000FF;' + } + ,'OPERATORS' : 'color: #808080;' + ,'DELIMITERS' : 'color: #FF8000;' + ,'REGEXPS' : { + 'variables' : 'color: #E0BD54;' + } + } +}; + + diff --git a/includes/edit_area/reg_syntax/vb.js b/includes/edit_area/reg_syntax/vb.js new file mode 100644 index 0000000000..18cc87cf78 --- /dev/null +++ b/includes/edit_area/reg_syntax/vb.js @@ -0,0 +1,52 @@ +editAreaLoader.load_syntax["vb"] = { + 'COMMENT_SINGLE' : {1 : "'"} + ,'COMMENT_MULTI' : { } + ,'QUOTEMARKS' : {1: '"'} + ,'KEYWORD_CASE_SENSITIVE' : false + ,'KEYWORDS' : { + 'statements' : [ + 'if','then','for','each','while','do','loop', + 'else','elseif','select','case','end select', + 'until','next','step','to','in','end if' + ] + ,'keywords' : [ + 'empty','isempty','nothing','null','isnull','true','false', + 'set','call', + 'sub','end sub','function','end function','exit','exit function', + 'dim','Mod','In','private','public','shared','const' + ] + + ,'functions' : [ + 'CDate','Date','DateAdd','DateDiff','DatePart','DateSerial','DateValue','Day','FormatDateTime', + 'Hour','IsDate','Minute','Month', + 'MonthName','Now','Second','Time','Timer','TimeSerial','TimeValue','Weekday','WeekdayName ','Year', + 'Asc','CBool','CByte','CCur','CDate','CDbl','Chr','CInt','CLng','CSng','CStr','Hex','Oct','FormatCurrency', + 'FormatDateTime','FormatNumber','FormatPercent','Abs','Atn','Cos','Exp','Hex','Int','Fix','Log','Oct', + 'Rnd','Sgn','Sin','Sqr','Tan', + 'Array','Filter','IsArray','Join','LBound','Split','UBound', + 'InStr','InStrRev','LCase','Left','Len','LTrim','RTrim','Trim','Mid','Replace','Right','Space','StrComp', + 'String','StrReverse','UCase', + 'CreateObject','Eval','GetLocale','GetObject','GetRef','InputBox','IsEmpty','IsNull','IsNumeric', + 'IsObject','LoadPicture','MsgBox','RGB','Round','ScriptEngine','ScriptEngineBuildVersion','ScriptEngineMajorVersion', + 'ScriptEngineMinorVersion','SetLocale','TypeName','VarType' + ] + } + ,'OPERATORS' :[ + '+', '-', '/', '*', '=', '<', '>', '!', '&' + ] + ,'DELIMITERS' :[ + '(', ')', '[', ']', '{', '}' + ] + ,'STYLES' : { + 'COMMENTS': 'color: #99CC00;' + ,'QUOTESMARKS': 'color: #333399;' + ,'KEYWORDS' : { + 'keywords' : 'color: #3366FF;' + ,'functions' : 'color: #0000FF;' + ,'statements' : 'color: #3366FF;' + } + ,'OPERATORS' : 'color: #FF0000;' + ,'DELIMITERS' : 'color: #0000FF;' + + } +}; diff --git a/includes/edit_area/reg_syntax/xml.js b/includes/edit_area/reg_syntax/xml.js new file mode 100644 index 0000000000..a043dd63ad --- /dev/null +++ b/includes/edit_area/reg_syntax/xml.js @@ -0,0 +1,56 @@ +/* +* last update: 2006-08-24 +*/ + +editAreaLoader.load_syntax["xml"] = { + 'COMMENT_SINGLE' : {} + ,'COMMENT_MULTI' : {''} + ,'QUOTEMARKS' : {1: "'", 2: '"'} + ,'KEYWORD_CASE_SENSITIVE' : false + ,'KEYWORDS' : { + } + ,'OPERATORS' :[ + ] + ,'DELIMITERS' :[ + ] + ,'REGEXPS' : { + 'xml' : { + 'search' : '()(<\\?[^>]*?\\?>)()' + ,'class' : 'xml' + ,'modifiers' : 'g' + ,'execute' : 'before' // before or after + } + ,'cdatas' : { + 'search' : '()()()' + ,'class' : 'cdata' + ,'modifiers' : 'g' + ,'execute' : 'before' // before or after + } + ,'tags' : { + 'search' : '(<)(/?[a-z][^ \r\n\t>]*)([^>]*>)' + ,'class' : 'tags' + ,'modifiers' : 'gi' + ,'execute' : 'before' // before or after + } + ,'attributes' : { + 'search' : '( |\n|\r|\t)([^ \r\n\t=]+)(=)' + ,'class' : 'attributes' + ,'modifiers' : 'g' + ,'execute' : 'before' // before or after + } + } + ,'STYLES' : { + 'COMMENTS': 'color: #AAAAAA;' + ,'QUOTESMARKS': 'color: #6381F8;' + ,'KEYWORDS' : { + } + ,'OPERATORS' : 'color: #E775F0;' + ,'DELIMITERS' : '' + ,'REGEXPS' : { + 'attributes': 'color: #B1AC41;' + ,'tags': 'color: #E62253;' + ,'xml': 'color: #8DCFB5;' + ,'cdata': 'color: #50B020;' + } + } +}; diff --git a/includes/email_address_validator.php b/includes/email_address_validator.php new file mode 100644 index 0000000000..40b3f02a77 --- /dev/null +++ b/includes/email_address_validator.php @@ -0,0 +1,181 @@ +check_email_address('test@example.org')) { + // Email address is technically valid + } + +*/ + +class EmailAddressValidator { + + /** + * Check email address validity + * @param strEmailAddress Email address to be checked + * @return True if email is valid, false if not + */ + public function check_email_address($strEmailAddress) { + + // If magic quotes is "on", email addresses with quote marks will + // fail validation because of added escape characters. Uncommenting + // the next three lines will allow for this issue. + //if (get_magic_quotes_gpc()) { + // $strEmailAddress = stripslashes($strEmailAddress); + //} + + // Control characters are not allowed + if (preg_match('/[\x00-\x1F\x7F-\xFF]/', $strEmailAddress)) { + return false; + } + + // Check email length - min 3 (a@a), max 256 + if (!$this->check_text_length($strEmailAddress, 3, 256)) { + return false; + } + + // Split it into sections using last instance of "@" + $intAtSymbol = strrpos($strEmailAddress, '@'); + if ($intAtSymbol === false) { + // No "@" symbol in email. + return false; + } + $arrEmailAddress[0] = substr($strEmailAddress, 0, $intAtSymbol); + $arrEmailAddress[1] = substr($strEmailAddress, $intAtSymbol + 1); + + // Count the "@" symbols. Only one is allowed, except where + // contained in quote marks in the local part. Quickest way to + // check this is to remove anything in quotes. We also remove + // characters escaped with backslash, and the backslash + // character. + $arrTempAddress[0] = preg_replace('/\./' + ,'' + ,$arrEmailAddress[0]); + $arrTempAddress[0] = preg_replace('/"[^"]+"/' + ,'' + ,$arrTempAddress[0]); + $arrTempAddress[1] = $arrEmailAddress[1]; + $strTempAddress = $arrTempAddress[0] . $arrTempAddress[1]; + // Then check - should be no "@" symbols. + if (strrpos($strTempAddress, '@') !== false) { + // "@" symbol found + return false; + } + + // Check local portion + if (!$this->check_local_portion($arrEmailAddress[0])) { + return false; + } + + // Check domain portion + if (!$this->check_domain_portion($arrEmailAddress[1])) { + return false; + } + + // If we're still here, all checks above passed. Email is valid. + return true; + + } + + /** + * Checks email section before "@" symbol for validity + * @param strLocalPortion Text to be checked + * @return True if local portion is valid, false if not + */ + protected function check_local_portion($strLocalPortion) { + // Local portion can only be from 1 to 64 characters, inclusive. + // Please note that servers are encouraged to accept longer local + // parts than 64 characters. + if (!$this->check_text_length($strLocalPortion, 1, 64)) { + return false; + } + // Local portion must be: + // 1) a dot-atom (strings separated by periods) + // 2) a quoted string + // 3) an obsolete format string (combination of the above) + $arrLocalPortion = explode('.', $strLocalPortion); + for ($i = 0, $max = sizeof($arrLocalPortion); $i < $max; $i++) { + if (!preg_match('.^(' + . '([A-Za-z0-9!#$%&\'*+/=?^_`{|}~-]' + . '[A-Za-z0-9!#$%&\'*+/=?^_`{|}~-]{0,63})' + .'|' + . '("[^\\\"]{0,62}")' + .')$.' + ,$arrLocalPortion[$i])) { + return false; + } + } + return true; + } + + /** + * Checks email section after "@" symbol for validity + * @param strDomainPortion Text to be checked + * @return True if domain portion is valid, false if not + */ + protected function check_domain_portion($strDomainPortion) { + // Total domain can only be from 1 to 255 characters, inclusive + if (!$this->check_text_length($strDomainPortion, 1, 255)) { + return false; + } + // Check if domain is IP, possibly enclosed in square brackets. + if (preg_match('/^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])' + .'(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}$/' + ,$strDomainPortion) || + preg_match('/^\[(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])' + .'(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}\]$/' + ,$strDomainPortion)) { + return true; + } else { + $arrDomainPortion = explode('.', $strDomainPortion); + if (sizeof($arrDomainPortion) < 2) { + return false; // Not enough parts to domain + } + for ($i = 0, $max = sizeof($arrDomainPortion); $i < $max; $i++) { + // Each portion must be between 1 and 63 characters, inclusive + if (!$this->check_text_length($arrDomainPortion[$i], 1, 63)) { + return false; + } + if (!preg_match('/^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|' + .'([A-Za-z0-9]+))$/', $arrDomainPortion[$i])) { + return false; + } + if ($i == $max - 1) { // TLD cannot be only numbers + if (strlen(preg_replace('/[0-9]/', '', $arrDomainPortion[$i])) <= 0) { + return false; + } + } + } + } + return true; + } + + /** + * Check given text length is between defined bounds + * @param strText Text to be checked + * @param intMinimum Minimum acceptable length + * @param intMaximum Maximum acceptable length + * @return True if string is within bounds (inclusive), false if not + */ + protected function check_text_length($strText, $intMinimum, $intMaximum) { + // Minimum and maximum are both inclusive + $intTextLength = strlen($strText); + if (($intTextLength < $intMinimum) || ($intTextLength > $intMaximum)) { + return false; + } else { + return true; + } + } + +} + +?> \ No newline at end of file diff --git a/includes/footer.php b/includes/footer.php new file mode 100644 index 0000000000..d06821ad38 --- /dev/null +++ b/includes/footer.php @@ -0,0 +1,101 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; + +//get the output from the buffer + $body = $content_from_db.ob_get_contents(); + ob_end_clean(); //clean the buffer + +//set a default template + if (strlen($_SESSION['domain']['template']['name']) == 0) { $_SESSION['domain']['template']['name'] = 'default'; } + +//set a default template + if (strlen($_SESSION["template_content"])==0) { //build template if session template has no length + $v_template_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes'; + if (strlen($template_rss_sub_category) > 0) { + //this template was assigned by the content manager + //get the contents of the template and save it to the template variable + $template_full_path = $v_template_path.'/'.$template_rss_sub_category.'/template.php'; + if (!file_exists($template_full_path)) { + $_SESSION['domain']['template']['name'] = 'default'; + $template_full_path = $v_template_path.'/default/template.php'; + } + $template = file_get_contents($template_full_path); + $_SESSION["template_content"] = $template; + } + else { + //get the contents of the template and save it to the template variable + $template_full_path = $v_template_path.'/'.$_SESSION['domain']['template']['name'].'/template.php'; + if (!file_exists($template_full_path)) { + $_SESSION['domain']['template']['name'] = 'default'; + $template_full_path = $v_template_path.'/default/template.php'; + } + $template = file_get_contents($template_full_path); + $_SESSION["template_content"] = $template; + } + } + +//start the output buffer + ob_start(); + $template = $_SESSION["template_content"]; + eval('?>' . $template . '", $custom_title, $template); // defined in each individual page + $output = str_replace ("", $custom_head, $output); // defined in each individual page + if (strlen($v_menu) > 0) { + $output = str_replace ("", $v_menu, $output); //defined in /includes/menu.php + } + else { + $output = str_replace ("", $_SESSION["menu"], $output); //defined in /includes/menu.php + } + $output = str_replace ("", PROJECT_PATH, $output); //defined in /includes/menu.php + + $pos = strrpos($output, ""); + if ($pos === false) { + $output = $body; //if tag not found just show the body + } + else { + //replace the body + $output = str_replace ("", $body, $output); + } + +//send the output to the browser + echo $output; + unset($output); + +//$statsauth = "a3az349x2bf3fdfa8dbt7x34fas5X"; +//require_once "stats/stat_sadd.php"; + +?> \ No newline at end of file diff --git a/includes/fpdf/font/courier.php b/includes/fpdf/font/courier.php new file mode 100644 index 0000000000..02525f589f --- /dev/null +++ b/includes/fpdf/font/courier.php @@ -0,0 +1,8 @@ + diff --git a/includes/fpdf/font/courierb.php b/includes/fpdf/font/courierb.php new file mode 100644 index 0000000000..f472063cca --- /dev/null +++ b/includes/fpdf/font/courierb.php @@ -0,0 +1,8 @@ + diff --git a/includes/fpdf/font/courierbi.php b/includes/fpdf/font/courierbi.php new file mode 100644 index 0000000000..6ce8501a66 --- /dev/null +++ b/includes/fpdf/font/courierbi.php @@ -0,0 +1,8 @@ + diff --git a/includes/fpdf/font/courieri.php b/includes/fpdf/font/courieri.php new file mode 100644 index 0000000000..320150a061 --- /dev/null +++ b/includes/fpdf/font/courieri.php @@ -0,0 +1,8 @@ + diff --git a/includes/fpdf/font/helvetica.php b/includes/fpdf/font/helvetica.php new file mode 100644 index 0000000000..891ea2511b --- /dev/null +++ b/includes/fpdf/font/helvetica.php @@ -0,0 +1,19 @@ +278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278, + chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584, + ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667, + 'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944, + 'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833, + 'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556, + chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, + chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333, + chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667, + chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722, + chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556, + chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500); +?> diff --git a/includes/fpdf/font/helveticab.php b/includes/fpdf/font/helveticab.php new file mode 100644 index 0000000000..6c9b972bee --- /dev/null +++ b/includes/fpdf/font/helveticab.php @@ -0,0 +1,19 @@ +278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278, + chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584, + ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722, + 'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944, + 'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889, + 'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556, + chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, + chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333, + chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722, + chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722, + chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611, + chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556); +?> diff --git a/includes/fpdf/font/helveticabi.php b/includes/fpdf/font/helveticabi.php new file mode 100644 index 0000000000..47203119be --- /dev/null +++ b/includes/fpdf/font/helveticabi.php @@ -0,0 +1,19 @@ +278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278, + chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>333,'"'=>474,'#'=>556,'$'=>556,'%'=>889,'&'=>722,'\''=>238,'('=>333,')'=>333,'*'=>389,'+'=>584, + ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>333,';'=>333,'<'=>584,'='=>584,'>'=>584,'?'=>611,'@'=>975,'A'=>722, + 'B'=>722,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>556,'K'=>722,'L'=>611,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944, + 'X'=>667,'Y'=>667,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>584,'_'=>556,'`'=>333,'a'=>556,'b'=>611,'c'=>556,'d'=>611,'e'=>556,'f'=>333,'g'=>611,'h'=>611,'i'=>278,'j'=>278,'k'=>556,'l'=>278,'m'=>889, + 'n'=>611,'o'=>611,'p'=>611,'q'=>611,'r'=>389,'s'=>556,'t'=>333,'u'=>611,'v'=>556,'w'=>778,'x'=>556,'y'=>556,'z'=>500,'{'=>389,'|'=>280,'}'=>389,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>278,chr(131)=>556, + chr(132)=>500,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>278,chr(146)=>278,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, + chr(154)=>556,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>280,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333, + chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>611,chr(182)=>556,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722, + chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722, + chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>556,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>611,chr(241)=>611, + chr(242)=>611,chr(243)=>611,chr(244)=>611,chr(245)=>611,chr(246)=>611,chr(247)=>584,chr(248)=>611,chr(249)=>611,chr(250)=>611,chr(251)=>611,chr(252)=>611,chr(253)=>556,chr(254)=>611,chr(255)=>556); +?> diff --git a/includes/fpdf/font/helveticai.php b/includes/fpdf/font/helveticai.php new file mode 100644 index 0000000000..25fb7949cd --- /dev/null +++ b/includes/fpdf/font/helveticai.php @@ -0,0 +1,19 @@ +278,chr(1)=>278,chr(2)=>278,chr(3)=>278,chr(4)=>278,chr(5)=>278,chr(6)=>278,chr(7)=>278,chr(8)=>278,chr(9)=>278,chr(10)=>278,chr(11)=>278,chr(12)=>278,chr(13)=>278,chr(14)=>278,chr(15)=>278,chr(16)=>278,chr(17)=>278,chr(18)=>278,chr(19)=>278,chr(20)=>278,chr(21)=>278, + chr(22)=>278,chr(23)=>278,chr(24)=>278,chr(25)=>278,chr(26)=>278,chr(27)=>278,chr(28)=>278,chr(29)=>278,chr(30)=>278,chr(31)=>278,' '=>278,'!'=>278,'"'=>355,'#'=>556,'$'=>556,'%'=>889,'&'=>667,'\''=>191,'('=>333,')'=>333,'*'=>389,'+'=>584, + ','=>278,'-'=>333,'.'=>278,'/'=>278,'0'=>556,'1'=>556,'2'=>556,'3'=>556,'4'=>556,'5'=>556,'6'=>556,'7'=>556,'8'=>556,'9'=>556,':'=>278,';'=>278,'<'=>584,'='=>584,'>'=>584,'?'=>556,'@'=>1015,'A'=>667, + 'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>722,'I'=>278,'J'=>500,'K'=>667,'L'=>556,'M'=>833,'N'=>722,'O'=>778,'P'=>667,'Q'=>778,'R'=>722,'S'=>667,'T'=>611,'U'=>722,'V'=>667,'W'=>944, + 'X'=>667,'Y'=>667,'Z'=>611,'['=>278,'\\'=>278,']'=>278,'^'=>469,'_'=>556,'`'=>333,'a'=>556,'b'=>556,'c'=>500,'d'=>556,'e'=>556,'f'=>278,'g'=>556,'h'=>556,'i'=>222,'j'=>222,'k'=>500,'l'=>222,'m'=>833, + 'n'=>556,'o'=>556,'p'=>556,'q'=>556,'r'=>333,'s'=>500,'t'=>278,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>500,'{'=>334,'|'=>260,'}'=>334,'~'=>584,chr(127)=>350,chr(128)=>556,chr(129)=>350,chr(130)=>222,chr(131)=>556, + chr(132)=>333,chr(133)=>1000,chr(134)=>556,chr(135)=>556,chr(136)=>333,chr(137)=>1000,chr(138)=>667,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>222,chr(146)=>222,chr(147)=>333,chr(148)=>333,chr(149)=>350,chr(150)=>556,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, + chr(154)=>500,chr(155)=>333,chr(156)=>944,chr(157)=>350,chr(158)=>500,chr(159)=>667,chr(160)=>278,chr(161)=>333,chr(162)=>556,chr(163)=>556,chr(164)=>556,chr(165)=>556,chr(166)=>260,chr(167)=>556,chr(168)=>333,chr(169)=>737,chr(170)=>370,chr(171)=>556,chr(172)=>584,chr(173)=>333,chr(174)=>737,chr(175)=>333, + chr(176)=>400,chr(177)=>584,chr(178)=>333,chr(179)=>333,chr(180)=>333,chr(181)=>556,chr(182)=>537,chr(183)=>278,chr(184)=>333,chr(185)=>333,chr(186)=>365,chr(187)=>556,chr(188)=>834,chr(189)=>834,chr(190)=>834,chr(191)=>611,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667, + chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>278,chr(205)=>278,chr(206)=>278,chr(207)=>278,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>584,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722, + chr(220)=>722,chr(221)=>667,chr(222)=>667,chr(223)=>611,chr(224)=>556,chr(225)=>556,chr(226)=>556,chr(227)=>556,chr(228)=>556,chr(229)=>556,chr(230)=>889,chr(231)=>500,chr(232)=>556,chr(233)=>556,chr(234)=>556,chr(235)=>556,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>556,chr(241)=>556, + chr(242)=>556,chr(243)=>556,chr(244)=>556,chr(245)=>556,chr(246)=>556,chr(247)=>584,chr(248)=>611,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500); +?> diff --git a/includes/fpdf/font/symbol.php b/includes/fpdf/font/symbol.php new file mode 100644 index 0000000000..a89f2954a9 --- /dev/null +++ b/includes/fpdf/font/symbol.php @@ -0,0 +1,19 @@ +250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250, + chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>713,'#'=>500,'$'=>549,'%'=>833,'&'=>778,'\''=>439,'('=>333,')'=>333,'*'=>500,'+'=>549, + ','=>250,'-'=>549,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>549,'='=>549,'>'=>549,'?'=>444,'@'=>549,'A'=>722, + 'B'=>667,'C'=>722,'D'=>612,'E'=>611,'F'=>763,'G'=>603,'H'=>722,'I'=>333,'J'=>631,'K'=>722,'L'=>686,'M'=>889,'N'=>722,'O'=>722,'P'=>768,'Q'=>741,'R'=>556,'S'=>592,'T'=>611,'U'=>690,'V'=>439,'W'=>768, + 'X'=>645,'Y'=>795,'Z'=>611,'['=>333,'\\'=>863,']'=>333,'^'=>658,'_'=>500,'`'=>500,'a'=>631,'b'=>549,'c'=>549,'d'=>494,'e'=>439,'f'=>521,'g'=>411,'h'=>603,'i'=>329,'j'=>603,'k'=>549,'l'=>549,'m'=>576, + 'n'=>521,'o'=>549,'p'=>549,'q'=>521,'r'=>549,'s'=>603,'t'=>439,'u'=>576,'v'=>713,'w'=>686,'x'=>493,'y'=>686,'z'=>494,'{'=>480,'|'=>200,'}'=>480,'~'=>549,chr(127)=>0,chr(128)=>0,chr(129)=>0,chr(130)=>0,chr(131)=>0, + chr(132)=>0,chr(133)=>0,chr(134)=>0,chr(135)=>0,chr(136)=>0,chr(137)=>0,chr(138)=>0,chr(139)=>0,chr(140)=>0,chr(141)=>0,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0, + chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>750,chr(161)=>620,chr(162)=>247,chr(163)=>549,chr(164)=>167,chr(165)=>713,chr(166)=>500,chr(167)=>753,chr(168)=>753,chr(169)=>753,chr(170)=>753,chr(171)=>1042,chr(172)=>987,chr(173)=>603,chr(174)=>987,chr(175)=>603, + chr(176)=>400,chr(177)=>549,chr(178)=>411,chr(179)=>549,chr(180)=>549,chr(181)=>713,chr(182)=>494,chr(183)=>460,chr(184)=>549,chr(185)=>549,chr(186)=>549,chr(187)=>549,chr(188)=>1000,chr(189)=>603,chr(190)=>1000,chr(191)=>658,chr(192)=>823,chr(193)=>686,chr(194)=>795,chr(195)=>987,chr(196)=>768,chr(197)=>768, + chr(198)=>823,chr(199)=>768,chr(200)=>768,chr(201)=>713,chr(202)=>713,chr(203)=>713,chr(204)=>713,chr(205)=>713,chr(206)=>713,chr(207)=>713,chr(208)=>768,chr(209)=>713,chr(210)=>790,chr(211)=>790,chr(212)=>890,chr(213)=>823,chr(214)=>549,chr(215)=>250,chr(216)=>713,chr(217)=>603,chr(218)=>603,chr(219)=>1042, + chr(220)=>987,chr(221)=>603,chr(222)=>987,chr(223)=>603,chr(224)=>494,chr(225)=>329,chr(226)=>790,chr(227)=>790,chr(228)=>786,chr(229)=>713,chr(230)=>384,chr(231)=>384,chr(232)=>384,chr(233)=>384,chr(234)=>384,chr(235)=>384,chr(236)=>494,chr(237)=>494,chr(238)=>494,chr(239)=>494,chr(240)=>0,chr(241)=>329, + chr(242)=>274,chr(243)=>686,chr(244)=>686,chr(245)=>686,chr(246)=>384,chr(247)=>384,chr(248)=>384,chr(249)=>384,chr(250)=>384,chr(251)=>384,chr(252)=>494,chr(253)=>494,chr(254)=>494,chr(255)=>0); +?> diff --git a/includes/fpdf/font/times.php b/includes/fpdf/font/times.php new file mode 100644 index 0000000000..57b9bce881 --- /dev/null +++ b/includes/fpdf/font/times.php @@ -0,0 +1,19 @@ +250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250, + chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>408,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>180,'('=>333,')'=>333,'*'=>500,'+'=>564, + ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>278,';'=>278,'<'=>564,'='=>564,'>'=>564,'?'=>444,'@'=>921,'A'=>722, + 'B'=>667,'C'=>667,'D'=>722,'E'=>611,'F'=>556,'G'=>722,'H'=>722,'I'=>333,'J'=>389,'K'=>722,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>556,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>722,'W'=>944, + 'X'=>722,'Y'=>722,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>469,'_'=>500,'`'=>333,'a'=>444,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778, + 'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>333,'s'=>389,'t'=>278,'u'=>500,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>480,'|'=>200,'}'=>480,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500, + chr(132)=>444,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>889,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>444,chr(148)=>444,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>980, + chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>200,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>564,chr(173)=>333,chr(174)=>760,chr(175)=>333, + chr(176)=>400,chr(177)=>564,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>453,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>444,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722, + chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>564,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722, + chr(220)=>722,chr(221)=>722,chr(222)=>556,chr(223)=>500,chr(224)=>444,chr(225)=>444,chr(226)=>444,chr(227)=>444,chr(228)=>444,chr(229)=>444,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500, + chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>564,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>500,chr(254)=>500,chr(255)=>500); +?> diff --git a/includes/fpdf/font/timesb.php b/includes/fpdf/font/timesb.php new file mode 100644 index 0000000000..6946b9ea4a --- /dev/null +++ b/includes/fpdf/font/timesb.php @@ -0,0 +1,19 @@ +250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250, + chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>555,'#'=>500,'$'=>500,'%'=>1000,'&'=>833,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570, + ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>930,'A'=>722, + 'B'=>667,'C'=>722,'D'=>722,'E'=>667,'F'=>611,'G'=>778,'H'=>778,'I'=>389,'J'=>500,'K'=>778,'L'=>667,'M'=>944,'N'=>722,'O'=>778,'P'=>611,'Q'=>778,'R'=>722,'S'=>556,'T'=>667,'U'=>722,'V'=>722,'W'=>1000, + 'X'=>722,'Y'=>722,'Z'=>667,'['=>333,'\\'=>278,']'=>333,'^'=>581,'_'=>500,'`'=>333,'a'=>500,'b'=>556,'c'=>444,'d'=>556,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>333,'k'=>556,'l'=>278,'m'=>833, + 'n'=>556,'o'=>500,'p'=>556,'q'=>556,'r'=>444,'s'=>389,'t'=>333,'u'=>556,'v'=>500,'w'=>722,'x'=>500,'y'=>500,'z'=>444,'{'=>394,'|'=>220,'}'=>394,'~'=>520,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500, + chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>1000,chr(141)=>350,chr(142)=>667,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, + chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>444,chr(159)=>722,chr(160)=>250,chr(161)=>333,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>300,chr(171)=>500,chr(172)=>570,chr(173)=>333,chr(174)=>747,chr(175)=>333, + chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>556,chr(182)=>540,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>330,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>722,chr(193)=>722,chr(194)=>722,chr(195)=>722,chr(196)=>722,chr(197)=>722, + chr(198)=>1000,chr(199)=>722,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>778,chr(211)=>778,chr(212)=>778,chr(213)=>778,chr(214)=>778,chr(215)=>570,chr(216)=>778,chr(217)=>722,chr(218)=>722,chr(219)=>722, + chr(220)=>722,chr(221)=>722,chr(222)=>611,chr(223)=>556,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556, + chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>500,chr(254)=>556,chr(255)=>500); +?> diff --git a/includes/fpdf/font/timesbi.php b/includes/fpdf/font/timesbi.php new file mode 100644 index 0000000000..cd5e5f1272 --- /dev/null +++ b/includes/fpdf/font/timesbi.php @@ -0,0 +1,19 @@ +250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250, + chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>389,'"'=>555,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570, + ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>832,'A'=>667, + 'B'=>667,'C'=>667,'D'=>722,'E'=>667,'F'=>667,'G'=>722,'H'=>778,'I'=>389,'J'=>500,'K'=>667,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>611,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>667,'W'=>889, + 'X'=>667,'Y'=>611,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>570,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778, + 'n'=>556,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>556,'v'=>444,'w'=>667,'x'=>500,'y'=>444,'z'=>389,'{'=>348,'|'=>220,'}'=>348,'~'=>570,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500, + chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, + chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>389,chr(159)=>611,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>266,chr(171)=>500,chr(172)=>606,chr(173)=>333,chr(174)=>747,chr(175)=>333, + chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>576,chr(182)=>500,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>300,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667, + chr(198)=>944,chr(199)=>667,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>570,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722, + chr(220)=>722,chr(221)=>611,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556, + chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>444,chr(254)=>500,chr(255)=>444); +?> diff --git a/includes/fpdf/font/timesi.php b/includes/fpdf/font/timesi.php new file mode 100644 index 0000000000..d6da2a99c7 --- /dev/null +++ b/includes/fpdf/font/timesi.php @@ -0,0 +1,19 @@ +250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250, + chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>333,'"'=>420,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>214,'('=>333,')'=>333,'*'=>500,'+'=>675, + ','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>675,'='=>675,'>'=>675,'?'=>500,'@'=>920,'A'=>611, + 'B'=>611,'C'=>667,'D'=>722,'E'=>611,'F'=>611,'G'=>722,'H'=>722,'I'=>333,'J'=>444,'K'=>667,'L'=>556,'M'=>833,'N'=>667,'O'=>722,'P'=>611,'Q'=>722,'R'=>611,'S'=>500,'T'=>556,'U'=>722,'V'=>611,'W'=>833, + 'X'=>611,'Y'=>556,'Z'=>556,'['=>389,'\\'=>278,']'=>389,'^'=>422,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>278,'g'=>500,'h'=>500,'i'=>278,'j'=>278,'k'=>444,'l'=>278,'m'=>722, + 'n'=>500,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>500,'v'=>444,'w'=>667,'x'=>444,'y'=>444,'z'=>389,'{'=>400,'|'=>275,'}'=>400,'~'=>541,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500, + chr(132)=>556,chr(133)=>889,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>500,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>556,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>556,chr(148)=>556,chr(149)=>350,chr(150)=>500,chr(151)=>889,chr(152)=>333,chr(153)=>980, + chr(154)=>389,chr(155)=>333,chr(156)=>667,chr(157)=>350,chr(158)=>389,chr(159)=>556,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>275,chr(167)=>500,chr(168)=>333,chr(169)=>760,chr(170)=>276,chr(171)=>500,chr(172)=>675,chr(173)=>333,chr(174)=>760,chr(175)=>333, + chr(176)=>400,chr(177)=>675,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>500,chr(182)=>523,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>310,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>611,chr(193)=>611,chr(194)=>611,chr(195)=>611,chr(196)=>611,chr(197)=>611, + chr(198)=>889,chr(199)=>667,chr(200)=>611,chr(201)=>611,chr(202)=>611,chr(203)=>611,chr(204)=>333,chr(205)=>333,chr(206)=>333,chr(207)=>333,chr(208)=>722,chr(209)=>667,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>675,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722, + chr(220)=>722,chr(221)=>556,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>667,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>500, + chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>675,chr(248)=>500,chr(249)=>500,chr(250)=>500,chr(251)=>500,chr(252)=>500,chr(253)=>444,chr(254)=>500,chr(255)=>444); +?> diff --git a/includes/fpdf/font/zapfdingbats.php b/includes/fpdf/font/zapfdingbats.php new file mode 100644 index 0000000000..8f7d49064d --- /dev/null +++ b/includes/fpdf/font/zapfdingbats.php @@ -0,0 +1,19 @@ +0,chr(1)=>0,chr(2)=>0,chr(3)=>0,chr(4)=>0,chr(5)=>0,chr(6)=>0,chr(7)=>0,chr(8)=>0,chr(9)=>0,chr(10)=>0,chr(11)=>0,chr(12)=>0,chr(13)=>0,chr(14)=>0,chr(15)=>0,chr(16)=>0,chr(17)=>0,chr(18)=>0,chr(19)=>0,chr(20)=>0,chr(21)=>0, + chr(22)=>0,chr(23)=>0,chr(24)=>0,chr(25)=>0,chr(26)=>0,chr(27)=>0,chr(28)=>0,chr(29)=>0,chr(30)=>0,chr(31)=>0,' '=>278,'!'=>974,'"'=>961,'#'=>974,'$'=>980,'%'=>719,'&'=>789,'\''=>790,'('=>791,')'=>690,'*'=>960,'+'=>939, + ','=>549,'-'=>855,'.'=>911,'/'=>933,'0'=>911,'1'=>945,'2'=>974,'3'=>755,'4'=>846,'5'=>762,'6'=>761,'7'=>571,'8'=>677,'9'=>763,':'=>760,';'=>759,'<'=>754,'='=>494,'>'=>552,'?'=>537,'@'=>577,'A'=>692, + 'B'=>786,'C'=>788,'D'=>788,'E'=>790,'F'=>793,'G'=>794,'H'=>816,'I'=>823,'J'=>789,'K'=>841,'L'=>823,'M'=>833,'N'=>816,'O'=>831,'P'=>923,'Q'=>744,'R'=>723,'S'=>749,'T'=>790,'U'=>792,'V'=>695,'W'=>776, + 'X'=>768,'Y'=>792,'Z'=>759,'['=>707,'\\'=>708,']'=>682,'^'=>701,'_'=>826,'`'=>815,'a'=>789,'b'=>789,'c'=>707,'d'=>687,'e'=>696,'f'=>689,'g'=>786,'h'=>787,'i'=>713,'j'=>791,'k'=>785,'l'=>791,'m'=>873, + 'n'=>761,'o'=>762,'p'=>762,'q'=>759,'r'=>759,'s'=>892,'t'=>892,'u'=>788,'v'=>784,'w'=>438,'x'=>138,'y'=>277,'z'=>415,'{'=>392,'|'=>392,'}'=>668,'~'=>668,chr(127)=>0,chr(128)=>390,chr(129)=>390,chr(130)=>317,chr(131)=>317, + chr(132)=>276,chr(133)=>276,chr(134)=>509,chr(135)=>509,chr(136)=>410,chr(137)=>410,chr(138)=>234,chr(139)=>234,chr(140)=>334,chr(141)=>334,chr(142)=>0,chr(143)=>0,chr(144)=>0,chr(145)=>0,chr(146)=>0,chr(147)=>0,chr(148)=>0,chr(149)=>0,chr(150)=>0,chr(151)=>0,chr(152)=>0,chr(153)=>0, + chr(154)=>0,chr(155)=>0,chr(156)=>0,chr(157)=>0,chr(158)=>0,chr(159)=>0,chr(160)=>0,chr(161)=>732,chr(162)=>544,chr(163)=>544,chr(164)=>910,chr(165)=>667,chr(166)=>760,chr(167)=>760,chr(168)=>776,chr(169)=>595,chr(170)=>694,chr(171)=>626,chr(172)=>788,chr(173)=>788,chr(174)=>788,chr(175)=>788, + chr(176)=>788,chr(177)=>788,chr(178)=>788,chr(179)=>788,chr(180)=>788,chr(181)=>788,chr(182)=>788,chr(183)=>788,chr(184)=>788,chr(185)=>788,chr(186)=>788,chr(187)=>788,chr(188)=>788,chr(189)=>788,chr(190)=>788,chr(191)=>788,chr(192)=>788,chr(193)=>788,chr(194)=>788,chr(195)=>788,chr(196)=>788,chr(197)=>788, + chr(198)=>788,chr(199)=>788,chr(200)=>788,chr(201)=>788,chr(202)=>788,chr(203)=>788,chr(204)=>788,chr(205)=>788,chr(206)=>788,chr(207)=>788,chr(208)=>788,chr(209)=>788,chr(210)=>788,chr(211)=>788,chr(212)=>894,chr(213)=>838,chr(214)=>1016,chr(215)=>458,chr(216)=>748,chr(217)=>924,chr(218)=>748,chr(219)=>918, + chr(220)=>927,chr(221)=>928,chr(222)=>928,chr(223)=>834,chr(224)=>873,chr(225)=>828,chr(226)=>924,chr(227)=>924,chr(228)=>917,chr(229)=>930,chr(230)=>931,chr(231)=>463,chr(232)=>883,chr(233)=>836,chr(234)=>836,chr(235)=>867,chr(236)=>867,chr(237)=>696,chr(238)=>696,chr(239)=>874,chr(240)=>0,chr(241)=>874, + chr(242)=>760,chr(243)=>946,chr(244)=>771,chr(245)=>865,chr(246)=>771,chr(247)=>888,chr(248)=>967,chr(249)=>888,chr(250)=>831,chr(251)=>873,chr(252)=>927,chr(253)=>970,chr(254)=>918,chr(255)=>0); +?> diff --git a/includes/fpdf/fpdf.php b/includes/fpdf/fpdf.php new file mode 100644 index 0000000000..308406ba64 --- /dev/null +++ b/includes/fpdf/fpdf.php @@ -0,0 +1,1804 @@ +_dochecks(); + // Initialization of properties + $this->page = 0; + $this->n = 2; + $this->buffer = ''; + $this->pages = array(); + $this->PageSizes = array(); + $this->state = 0; + $this->fonts = array(); + $this->FontFiles = array(); + $this->diffs = array(); + $this->images = array(); + $this->links = array(); + $this->InHeader = false; + $this->InFooter = false; + $this->lasth = 0; + $this->FontFamily = ''; + $this->FontStyle = ''; + $this->FontSizePt = 12; + $this->underline = false; + $this->DrawColor = '0 G'; + $this->FillColor = '0 g'; + $this->TextColor = '0 g'; + $this->ColorFlag = false; + $this->ws = 0; + // Font path + if(defined('FPDF_FONTPATH')) + { + $this->fontpath = FPDF_FONTPATH; + if(substr($this->fontpath,-1)!='/' && substr($this->fontpath,-1)!='\\') + $this->fontpath .= '/'; + } + elseif(is_dir(dirname(__FILE__).'/font')) + $this->fontpath = dirname(__FILE__).'/font/'; + else + $this->fontpath = ''; + // Core fonts + $this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats'); + // Scale factor + if($unit=='pt') + $this->k = 1; + elseif($unit=='mm') + $this->k = 72/25.4; + elseif($unit=='cm') + $this->k = 72/2.54; + elseif($unit=='in') + $this->k = 72; + else + $this->Error('Incorrect unit: '.$unit); + // Page sizes + $this->StdPageSizes = array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28), + 'letter'=>array(612,792), 'legal'=>array(612,1008)); + $size = $this->_getpagesize($size); + $this->DefPageSize = $size; + $this->CurPageSize = $size; + // Page orientation + $orientation = strtolower($orientation); + if($orientation=='p' || $orientation=='portrait') + { + $this->DefOrientation = 'P'; + $this->w = $size[0]; + $this->h = $size[1]; + } + elseif($orientation=='l' || $orientation=='landscape') + { + $this->DefOrientation = 'L'; + $this->w = $size[1]; + $this->h = $size[0]; + } + else + $this->Error('Incorrect orientation: '.$orientation); + $this->CurOrientation = $this->DefOrientation; + $this->wPt = $this->w*$this->k; + $this->hPt = $this->h*$this->k; + // Page margins (1 cm) + $margin = 28.35/$this->k; + $this->SetMargins($margin,$margin); + // Interior cell margin (1 mm) + $this->cMargin = $margin/10; + // Line width (0.2 mm) + $this->LineWidth = .567/$this->k; + // Automatic page break + $this->SetAutoPageBreak(true,2*$margin); + // Default display mode + $this->SetDisplayMode('default'); + // Enable compression + $this->SetCompression(true); + // Set default PDF version number + $this->PDFVersion = '1.3'; +} + +function SetMargins($left, $top, $right=null) +{ + // Set left, top and right margins + $this->lMargin = $left; + $this->tMargin = $top; + if($right===null) + $right = $left; + $this->rMargin = $right; +} + +function SetLeftMargin($margin) +{ + // Set left margin + $this->lMargin = $margin; + if($this->page>0 && $this->x<$margin) + $this->x = $margin; +} + +function SetTopMargin($margin) +{ + // Set top margin + $this->tMargin = $margin; +} + +function SetRightMargin($margin) +{ + // Set right margin + $this->rMargin = $margin; +} + +function SetAutoPageBreak($auto, $margin=0) +{ + // Set auto page break mode and triggering margin + $this->AutoPageBreak = $auto; + $this->bMargin = $margin; + $this->PageBreakTrigger = $this->h-$margin; +} + +function SetDisplayMode($zoom, $layout='default') +{ + // Set display mode in viewer + if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) + $this->ZoomMode = $zoom; + else + $this->Error('Incorrect zoom display mode: '.$zoom); + if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') + $this->LayoutMode = $layout; + else + $this->Error('Incorrect layout display mode: '.$layout); +} + +function SetCompression($compress) +{ + // Set page compression + if(function_exists('gzcompress')) + $this->compress = $compress; + else + $this->compress = false; +} + +function SetTitle($title, $isUTF8=false) +{ + // Title of document + if($isUTF8) + $title = $this->_UTF8toUTF16($title); + $this->title = $title; +} + +function SetSubject($subject, $isUTF8=false) +{ + // Subject of document + if($isUTF8) + $subject = $this->_UTF8toUTF16($subject); + $this->subject = $subject; +} + +function SetAuthor($author, $isUTF8=false) +{ + // Author of document + if($isUTF8) + $author = $this->_UTF8toUTF16($author); + $this->author = $author; +} + +function SetKeywords($keywords, $isUTF8=false) +{ + // Keywords of document + if($isUTF8) + $keywords = $this->_UTF8toUTF16($keywords); + $this->keywords = $keywords; +} + +function SetCreator($creator, $isUTF8=false) +{ + // Creator of document + if($isUTF8) + $creator = $this->_UTF8toUTF16($creator); + $this->creator = $creator; +} + +function AliasNbPages($alias='{nb}') +{ + // Define an alias for total number of pages + $this->AliasNbPages = $alias; +} + +function Error($msg) +{ + // Fatal error + die('FPDF error: '.$msg); +} + +function Open() +{ + // Begin document + $this->state = 1; +} + +function Close() +{ + // Terminate document + if($this->state==3) + return; + if($this->page==0) + $this->AddPage(); + // Page footer + $this->InFooter = true; + $this->Footer(); + $this->InFooter = false; + // Close page + $this->_endpage(); + // Close document + $this->_enddoc(); +} + +function AddPage($orientation='', $size='') +{ + // Start a new page + if($this->state==0) + $this->Open(); + $family = $this->FontFamily; + $style = $this->FontStyle.($this->underline ? 'U' : ''); + $fontsize = $this->FontSizePt; + $lw = $this->LineWidth; + $dc = $this->DrawColor; + $fc = $this->FillColor; + $tc = $this->TextColor; + $cf = $this->ColorFlag; + if($this->page>0) + { + // Page footer + $this->InFooter = true; + $this->Footer(); + $this->InFooter = false; + // Close page + $this->_endpage(); + } + // Start new page + $this->_beginpage($orientation,$size); + // Set line cap style to square + $this->_out('2 J'); + // Set line width + $this->LineWidth = $lw; + $this->_out(sprintf('%.2F w',$lw*$this->k)); + // Set font + if($family) + $this->SetFont($family,$style,$fontsize); + // Set colors + $this->DrawColor = $dc; + if($dc!='0 G') + $this->_out($dc); + $this->FillColor = $fc; + if($fc!='0 g') + $this->_out($fc); + $this->TextColor = $tc; + $this->ColorFlag = $cf; + // Page header + $this->InHeader = true; + $this->Header(); + $this->InHeader = false; + // Restore line width + if($this->LineWidth!=$lw) + { + $this->LineWidth = $lw; + $this->_out(sprintf('%.2F w',$lw*$this->k)); + } + // Restore font + if($family) + $this->SetFont($family,$style,$fontsize); + // Restore colors + if($this->DrawColor!=$dc) + { + $this->DrawColor = $dc; + $this->_out($dc); + } + if($this->FillColor!=$fc) + { + $this->FillColor = $fc; + $this->_out($fc); + } + $this->TextColor = $tc; + $this->ColorFlag = $cf; +} + +function Header() +{ + // To be implemented in your own inherited class +} + +function Footer() +{ + // To be implemented in your own inherited class +} + +function PageNo() +{ + // Get current page number + return $this->page; +} + +function SetDrawColor($r, $g=null, $b=null) +{ + // Set color for all stroking operations + if(($r==0 && $g==0 && $b==0) || $g===null) + $this->DrawColor = sprintf('%.3F G',$r/255); + else + $this->DrawColor = sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255); + if($this->page>0) + $this->_out($this->DrawColor); +} + +function SetFillColor($r, $g=null, $b=null) +{ + // Set color for all filling operations + if(($r==0 && $g==0 && $b==0) || $g===null) + $this->FillColor = sprintf('%.3F g',$r/255); + else + $this->FillColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); + $this->ColorFlag = ($this->FillColor!=$this->TextColor); + if($this->page>0) + $this->_out($this->FillColor); +} + +function SetTextColor($r, $g=null, $b=null) +{ + // Set color for text + if(($r==0 && $g==0 && $b==0) || $g===null) + $this->TextColor = sprintf('%.3F g',$r/255); + else + $this->TextColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); + $this->ColorFlag = ($this->FillColor!=$this->TextColor); +} + +function GetStringWidth($s) +{ + // Get width of a string in the current font + $s = (string)$s; + $cw = &$this->CurrentFont['cw']; + $w = 0; + $l = strlen($s); + for($i=0;$i<$l;$i++) + $w += $cw[$s[$i]]; + return $w*$this->FontSize/1000; +} + +function SetLineWidth($width) +{ + // Set line width + $this->LineWidth = $width; + if($this->page>0) + $this->_out(sprintf('%.2F w',$width*$this->k)); +} + +function Line($x1, $y1, $x2, $y2) +{ + // Draw a line + $this->_out(sprintf('%.2F %.2F m %.2F %.2F l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k)); +} + +function Rect($x, $y, $w, $h, $style='') +{ + // Draw a rectangle + if($style=='F') + $op = 'f'; + elseif($style=='FD' || $style=='DF') + $op = 'B'; + else + $op = 'S'; + $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op)); +} + +function AddFont($family, $style='', $file='') +{ + // Add a TrueType, OpenType or Type1 font + $family = strtolower($family); + if($file=='') + $file = str_replace(' ','',$family).strtolower($style).'.php'; + $style = strtoupper($style); + if($style=='IB') + $style = 'BI'; + $fontkey = $family.$style; + if(isset($this->fonts[$fontkey])) + return; + $info = $this->_loadfont($file); + $info['i'] = count($this->fonts)+1; + if(!empty($info['diff'])) + { + // Search existing encodings + $n = array_search($info['diff'],$this->diffs); + if(!$n) + { + $n = count($this->diffs)+1; + $this->diffs[$n] = $info['diff']; + } + $info['diffn'] = $n; + } + if(!empty($info['file'])) + { + // Embedded font + if($info['type']=='TrueType') + $this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']); + else + $this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']); + } + $this->fonts[$fontkey] = $info; +} + +function SetFont($family, $style='', $size=0) +{ + // Select a font; size given in points + if($family=='') + $family = $this->FontFamily; + else + $family = strtolower($family); + $style = strtoupper($style); + if(strpos($style,'U')!==false) + { + $this->underline = true; + $style = str_replace('U','',$style); + } + else + $this->underline = false; + if($style=='IB') + $style = 'BI'; + if($size==0) + $size = $this->FontSizePt; + // Test if font is already selected + if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) + return; + // Test if font is already loaded + $fontkey = $family.$style; + if(!isset($this->fonts[$fontkey])) + { + // Test if one of the core fonts + if($family=='arial') + $family = 'helvetica'; + if(in_array($family,$this->CoreFonts)) + { + if($family=='symbol' || $family=='zapfdingbats') + $style = ''; + $fontkey = $family.$style; + if(!isset($this->fonts[$fontkey])) + $this->AddFont($family,$style); + } + else + $this->Error('Undefined font: '.$family.' '.$style); + } + // Select it + $this->FontFamily = $family; + $this->FontStyle = $style; + $this->FontSizePt = $size; + $this->FontSize = $size/$this->k; + $this->CurrentFont = &$this->fonts[$fontkey]; + if($this->page>0) + $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); +} + +function SetFontSize($size) +{ + // Set font size in points + if($this->FontSizePt==$size) + return; + $this->FontSizePt = $size; + $this->FontSize = $size/$this->k; + if($this->page>0) + $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); +} + +function AddLink() +{ + // Create a new internal link + $n = count($this->links)+1; + $this->links[$n] = array(0, 0); + return $n; +} + +function SetLink($link, $y=0, $page=-1) +{ + // Set destination of internal link + if($y==-1) + $y = $this->y; + if($page==-1) + $page = $this->page; + $this->links[$link] = array($page, $y); +} + +function Link($x, $y, $w, $h, $link) +{ + // Put a link on the page + $this->PageLinks[$this->page][] = array($x*$this->k, $this->hPt-$y*$this->k, $w*$this->k, $h*$this->k, $link); +} + +function Text($x, $y, $txt) +{ + // Output a string + $s = sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); + if($this->underline && $txt!='') + $s .= ' '.$this->_dounderline($x,$y,$txt); + if($this->ColorFlag) + $s = 'q '.$this->TextColor.' '.$s.' Q'; + $this->_out($s); +} + +function AcceptPageBreak() +{ + // Accept automatic page break or not + return $this->AutoPageBreak; +} + +function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') +{ + // Output a cell + $k = $this->k; + if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) + { + // Automatic page break + $x = $this->x; + $ws = $this->ws; + if($ws>0) + { + $this->ws = 0; + $this->_out('0 Tw'); + } + $this->AddPage($this->CurOrientation,$this->CurPageSize); + $this->x = $x; + if($ws>0) + { + $this->ws = $ws; + $this->_out(sprintf('%.3F Tw',$ws*$k)); + } + } + if($w==0) + $w = $this->w-$this->rMargin-$this->x; + $s = ''; + if($fill || $border==1) + { + if($fill) + $op = ($border==1) ? 'B' : 'f'; + else + $op = 'S'; + $s = sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); + } + if(is_string($border)) + { + $x = $this->x; + $y = $this->y; + if(strpos($border,'L')!==false) + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); + if(strpos($border,'T')!==false) + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); + if(strpos($border,'R')!==false) + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); + if(strpos($border,'B')!==false) + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); + } + if($txt!=='') + { + if($align=='R') + $dx = $w-$this->cMargin-$this->GetStringWidth($txt); + elseif($align=='C') + $dx = ($w-$this->GetStringWidth($txt))/2; + else + $dx = $this->cMargin; + if($this->ColorFlag) + $s .= 'q '.$this->TextColor.' '; + $txt2 = str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt))); + $s .= sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2); + if($this->underline) + $s .= ' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); + if($this->ColorFlag) + $s .= ' Q'; + if($link) + $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link); + } + if($s) + $this->_out($s); + $this->lasth = $h; + if($ln>0) + { + // Go to next line + $this->y += $h; + if($ln==1) + $this->x = $this->lMargin; + } + else + $this->x += $w; +} + +function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false) +{ + // Output text with automatic or explicit line breaks + $cw = &$this->CurrentFont['cw']; + if($w==0) + $w = $this->w-$this->rMargin-$this->x; + $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; + $s = str_replace("\r",'',$txt); + $nb = strlen($s); + if($nb>0 && $s[$nb-1]=="\n") + $nb--; + $b = 0; + if($border) + { + if($border==1) + { + $border = 'LTRB'; + $b = 'LRT'; + $b2 = 'LR'; + } + else + { + $b2 = ''; + if(strpos($border,'L')!==false) + $b2 .= 'L'; + if(strpos($border,'R')!==false) + $b2 .= 'R'; + $b = (strpos($border,'T')!==false) ? $b2.'T' : $b2; + } + } + $sep = -1; + $i = 0; + $j = 0; + $l = 0; + $ns = 0; + $nl = 1; + while($i<$nb) + { + // Get next character + $c = $s[$i]; + if($c=="\n") + { + // Explicit line break + if($this->ws>0) + { + $this->ws = 0; + $this->_out('0 Tw'); + } + $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); + $i++; + $sep = -1; + $j = $i; + $l = 0; + $ns = 0; + $nl++; + if($border && $nl==2) + $b = $b2; + continue; + } + if($c==' ') + { + $sep = $i; + $ls = $l; + $ns++; + } + $l += $cw[$c]; + if($l>$wmax) + { + // Automatic line break + if($sep==-1) + { + if($i==$j) + $i++; + if($this->ws>0) + { + $this->ws = 0; + $this->_out('0 Tw'); + } + $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); + } + else + { + if($align=='J') + { + $this->ws = ($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0; + $this->_out(sprintf('%.3F Tw',$this->ws*$this->k)); + } + $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill); + $i = $sep+1; + } + $sep = -1; + $j = $i; + $l = 0; + $ns = 0; + $nl++; + if($border && $nl==2) + $b = $b2; + } + else + $i++; + } + // Last chunk + if($this->ws>0) + { + $this->ws = 0; + $this->_out('0 Tw'); + } + if($border && strpos($border,'B')!==false) + $b .= 'B'; + $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); + $this->x = $this->lMargin; +} + +function Write($h, $txt, $link='') +{ + // Output text in flowing mode + $cw = &$this->CurrentFont['cw']; + $w = $this->w-$this->rMargin-$this->x; + $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; + $s = str_replace("\r",'',$txt); + $nb = strlen($s); + $sep = -1; + $i = 0; + $j = 0; + $l = 0; + $nl = 1; + while($i<$nb) + { + // Get next character + $c = $s[$i]; + if($c=="\n") + { + // Explicit line break + $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); + $i++; + $sep = -1; + $j = $i; + $l = 0; + if($nl==1) + { + $this->x = $this->lMargin; + $w = $this->w-$this->rMargin-$this->x; + $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; + } + $nl++; + continue; + } + if($c==' ') + $sep = $i; + $l += $cw[$c]; + if($l>$wmax) + { + // Automatic line break + if($sep==-1) + { + if($this->x>$this->lMargin) + { + // Move to next line + $this->x = $this->lMargin; + $this->y += $h; + $w = $this->w-$this->rMargin-$this->x; + $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; + $i++; + $nl++; + continue; + } + if($i==$j) + $i++; + $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); + } + else + { + $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link); + $i = $sep+1; + } + $sep = -1; + $j = $i; + $l = 0; + if($nl==1) + { + $this->x = $this->lMargin; + $w = $this->w-$this->rMargin-$this->x; + $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; + } + $nl++; + } + else + $i++; + } + // Last chunk + if($i!=$j) + $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',0,$link); +} + +function Ln($h=null) +{ + // Line feed; default value is last cell height + $this->x = $this->lMargin; + if($h===null) + $this->y += $this->lasth; + else + $this->y += $h; +} + +function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='') +{ + // Put an image on the page + if(!isset($this->images[$file])) + { + // First use of this image, get info + if($type=='') + { + $pos = strrpos($file,'.'); + if(!$pos) + $this->Error('Image file has no extension and no type was specified: '.$file); + $type = substr($file,$pos+1); + } + $type = strtolower($type); + if($type=='jpeg') + $type = 'jpg'; + $mtd = '_parse'.$type; + if(!method_exists($this,$mtd)) + $this->Error('Unsupported image type: '.$type); + $info = $this->$mtd($file); + $info['i'] = count($this->images)+1; + $this->images[$file] = $info; + } + else + $info = $this->images[$file]; + + // Automatic width and height calculation if needed + if($w==0 && $h==0) + { + // Put image at 96 dpi + $w = -96; + $h = -96; + } + if($w<0) + $w = -$info['w']*72/$w/$this->k; + if($h<0) + $h = -$info['h']*72/$h/$this->k; + if($w==0) + $w = $h*$info['w']/$info['h']; + if($h==0) + $h = $w*$info['h']/$info['w']; + + // Flowing mode + if($y===null) + { + if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) + { + // Automatic page break + $x2 = $this->x; + $this->AddPage($this->CurOrientation,$this->CurPageSize); + $this->x = $x2; + } + $y = $this->y; + $this->y += $h; + } + + if($x===null) + $x = $this->x; + $this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i'])); + if($link) + $this->Link($x,$y,$w,$h,$link); +} + +function GetX() +{ + // Get x position + return $this->x; +} + +function SetX($x) +{ + // Set x position + if($x>=0) + $this->x = $x; + else + $this->x = $this->w+$x; +} + +function GetY() +{ + // Get y position + return $this->y; +} + +function SetY($y) +{ + // Set y position and reset x + $this->x = $this->lMargin; + if($y>=0) + $this->y = $y; + else + $this->y = $this->h+$y; +} + +function SetXY($x, $y) +{ + // Set x and y positions + $this->SetY($y); + $this->SetX($x); +} + +function Output($name='', $dest='') +{ + // Output PDF to some destination + if($this->state<3) + $this->Close(); + $dest = strtoupper($dest); + if($dest=='') + { + if($name=='') + { + $name = 'doc.pdf'; + $dest = 'I'; + } + else + $dest = 'F'; + } + switch($dest) + { + case 'I': + // Send to standard output + $this->_checkoutput(); + if(PHP_SAPI!='cli') + { + // We send to a browser + header('Content-Type: application/pdf'); + header('Content-Disposition: inline; filename="'.$name.'"'); + header('Cache-Control: private, max-age=0, must-revalidate'); + header('Pragma: public'); + } + echo $this->buffer; + break; + case 'D': + // Download file + $this->_checkoutput(); + header('Content-Type: application/x-download'); + header('Content-Disposition: attachment; filename="'.$name.'"'); + header('Cache-Control: private, max-age=0, must-revalidate'); + header('Pragma: public'); + echo $this->buffer; + break; + case 'F': + // Save to local file + $f = fopen($name,'wb'); + if(!$f) + $this->Error('Unable to create output file: '.$name); + fwrite($f,$this->buffer,strlen($this->buffer)); + fclose($f); + break; + case 'S': + // Return as a string + return $this->buffer; + default: + $this->Error('Incorrect output destination: '.$dest); + } + return ''; +} + +/******************************************************************************* +* * +* Protected methods * +* * +*******************************************************************************/ +function _dochecks() +{ + // Check availability of %F + if(sprintf('%.1F',1.0)!='1.0') + $this->Error('This version of PHP is not supported'); + // Check mbstring overloading + if(ini_get('mbstring.func_overload') & 2) + $this->Error('mbstring overloading must be disabled'); + // Ensure runtime magic quotes are disabled + if(get_magic_quotes_runtime()) + @set_magic_quotes_runtime(0); +} + +function _checkoutput() +{ + if(PHP_SAPI!='cli') + { + if(headers_sent($file,$line)) + $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)"); + } + if(ob_get_length()) + { + // The output buffer is not empty + if(preg_match('/^(\xEF\xBB\xBF)?\s*$/',ob_get_contents())) + { + // It contains only a UTF-8 BOM and/or whitespace, let's clean it + ob_clean(); + } + else + $this->Error("Some data has already been output, can't send PDF file"); + } +} + +function _getpagesize($size) +{ + if(is_string($size)) + { + $size = strtolower($size); + if(!isset($this->StdPageSizes[$size])) + $this->Error('Unknown page size: '.$size); + $a = $this->StdPageSizes[$size]; + return array($a[0]/$this->k, $a[1]/$this->k); + } + else + { + if($size[0]>$size[1]) + return array($size[1], $size[0]); + else + return $size; + } +} + +function _beginpage($orientation, $size) +{ + $this->page++; + $this->pages[$this->page] = ''; + $this->state = 2; + $this->x = $this->lMargin; + $this->y = $this->tMargin; + $this->FontFamily = ''; + // Check page size and orientation + if($orientation=='') + $orientation = $this->DefOrientation; + else + $orientation = strtoupper($orientation[0]); + if($size=='') + $size = $this->DefPageSize; + else + $size = $this->_getpagesize($size); + if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1]) + { + // New size or orientation + if($orientation=='P') + { + $this->w = $size[0]; + $this->h = $size[1]; + } + else + { + $this->w = $size[1]; + $this->h = $size[0]; + } + $this->wPt = $this->w*$this->k; + $this->hPt = $this->h*$this->k; + $this->PageBreakTrigger = $this->h-$this->bMargin; + $this->CurOrientation = $orientation; + $this->CurPageSize = $size; + } + if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1]) + $this->PageSizes[$this->page] = array($this->wPt, $this->hPt); +} + +function _endpage() +{ + $this->state = 1; +} + +function _loadfont($font) +{ + // Load a font definition file from the font directory + include($this->fontpath.$font); + $a = get_defined_vars(); + if(!isset($a['name'])) + $this->Error('Could not include font definition file'); + return $a; +} + +function _escape($s) +{ + // Escape special characters in strings + $s = str_replace('\\','\\\\',$s); + $s = str_replace('(','\\(',$s); + $s = str_replace(')','\\)',$s); + $s = str_replace("\r",'\\r',$s); + return $s; +} + +function _textstring($s) +{ + // Format a text string + return '('.$this->_escape($s).')'; +} + +function _UTF8toUTF16($s) +{ + // Convert UTF-8 to UTF-16BE with BOM + $res = "\xFE\xFF"; + $nb = strlen($s); + $i = 0; + while($i<$nb) + { + $c1 = ord($s[$i++]); + if($c1>=224) + { + // 3-byte character + $c2 = ord($s[$i++]); + $c3 = ord($s[$i++]); + $res .= chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2)); + $res .= chr((($c2 & 0x03)<<6) + ($c3 & 0x3F)); + } + elseif($c1>=192) + { + // 2-byte character + $c2 = ord($s[$i++]); + $res .= chr(($c1 & 0x1C)>>2); + $res .= chr((($c1 & 0x03)<<6) + ($c2 & 0x3F)); + } + else + { + // Single-byte character + $res .= "\0".chr($c1); + } + } + return $res; +} + +function _dounderline($x, $y, $txt) +{ + // Underline text + $up = $this->CurrentFont['up']; + $ut = $this->CurrentFont['ut']; + $w = $this->GetStringWidth($txt)+$this->ws*substr_count($txt,' '); + return sprintf('%.2F %.2F %.2F %.2F re f',$x*$this->k,($this->h-($y-$up/1000*$this->FontSize))*$this->k,$w*$this->k,-$ut/1000*$this->FontSizePt); +} + +function _parsejpg($file) +{ + // Extract info from a JPEG file + $a = getimagesize($file); + if(!$a) + $this->Error('Missing or incorrect image file: '.$file); + if($a[2]!=2) + $this->Error('Not a JPEG file: '.$file); + if(!isset($a['channels']) || $a['channels']==3) + $colspace = 'DeviceRGB'; + elseif($a['channels']==4) + $colspace = 'DeviceCMYK'; + else + $colspace = 'DeviceGray'; + $bpc = isset($a['bits']) ? $a['bits'] : 8; + $data = file_get_contents($file); + return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data); +} + +function _parsepng($file) +{ + // Extract info from a PNG file + $f = fopen($file,'rb'); + if(!$f) + $this->Error('Can\'t open image file: '.$file); + $info = $this->_parsepngstream($f,$file); + fclose($f); + return $info; +} + +function _parsepngstream($f, $file) +{ + // Check signature + if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) + $this->Error('Not a PNG file: '.$file); + + // Read header chunk + $this->_readstream($f,4); + if($this->_readstream($f,4)!='IHDR') + $this->Error('Incorrect PNG file: '.$file); + $w = $this->_readint($f); + $h = $this->_readint($f); + $bpc = ord($this->_readstream($f,1)); + if($bpc>8) + $this->Error('16-bit depth not supported: '.$file); + $ct = ord($this->_readstream($f,1)); + if($ct==0 || $ct==4) + $colspace = 'DeviceGray'; + elseif($ct==2 || $ct==6) + $colspace = 'DeviceRGB'; + elseif($ct==3) + $colspace = 'Indexed'; + else + $this->Error('Unknown color type: '.$file); + if(ord($this->_readstream($f,1))!=0) + $this->Error('Unknown compression method: '.$file); + if(ord($this->_readstream($f,1))!=0) + $this->Error('Unknown filter method: '.$file); + if(ord($this->_readstream($f,1))!=0) + $this->Error('Interlacing not supported: '.$file); + $this->_readstream($f,4); + $dp = '/Predictor 15 /Colors '.($colspace=='DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w; + + // Scan chunks looking for palette, transparency and image data + $pal = ''; + $trns = ''; + $data = ''; + do + { + $n = $this->_readint($f); + $type = $this->_readstream($f,4); + if($type=='PLTE') + { + // Read palette + $pal = $this->_readstream($f,$n); + $this->_readstream($f,4); + } + elseif($type=='tRNS') + { + // Read transparency info + $t = $this->_readstream($f,$n); + if($ct==0) + $trns = array(ord(substr($t,1,1))); + elseif($ct==2) + $trns = array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); + else + { + $pos = strpos($t,chr(0)); + if($pos!==false) + $trns = array($pos); + } + $this->_readstream($f,4); + } + elseif($type=='IDAT') + { + // Read image data block + $data .= $this->_readstream($f,$n); + $this->_readstream($f,4); + } + elseif($type=='IEND') + break; + else + $this->_readstream($f,$n+4); + } + while($n); + + if($colspace=='Indexed' && empty($pal)) + $this->Error('Missing palette in '.$file); + $info = array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'dp'=>$dp, 'pal'=>$pal, 'trns'=>$trns); + if($ct>=4) + { + // Extract alpha channel + if(!function_exists('gzuncompress')) + $this->Error('Zlib not available, can\'t handle alpha channel: '.$file); + $data = gzuncompress($data); + $color = ''; + $alpha = ''; + if($ct==4) + { + // Gray image + $len = 2*$w; + for($i=0;$i<$h;$i++) + { + $pos = (1+$len)*$i; + $color .= $data[$pos]; + $alpha .= $data[$pos]; + $line = substr($data,$pos+1,$len); + $color .= preg_replace('/(.)./s','$1',$line); + $alpha .= preg_replace('/.(.)/s','$1',$line); + } + } + else + { + // RGB image + $len = 4*$w; + for($i=0;$i<$h;$i++) + { + $pos = (1+$len)*$i; + $color .= $data[$pos]; + $alpha .= $data[$pos]; + $line = substr($data,$pos+1,$len); + $color .= preg_replace('/(.{3})./s','$1',$line); + $alpha .= preg_replace('/.{3}(.)/s','$1',$line); + } + } + unset($data); + $data = gzcompress($color); + $info['smask'] = gzcompress($alpha); + if($this->PDFVersion<'1.4') + $this->PDFVersion = '1.4'; + } + $info['data'] = $data; + return $info; +} + +function _readstream($f, $n) +{ + // Read n bytes from stream + $res = ''; + while($n>0 && !feof($f)) + { + $s = fread($f,$n); + if($s===false) + $this->Error('Error while reading stream'); + $n -= strlen($s); + $res .= $s; + } + if($n>0) + $this->Error('Unexpected end of stream'); + return $res; +} + +function _readint($f) +{ + // Read a 4-byte integer from stream + $a = unpack('Ni',$this->_readstream($f,4)); + return $a['i']; +} + +function _parsegif($file) +{ + // Extract info from a GIF file (via PNG conversion) + if(!function_exists('imagepng')) + $this->Error('GD extension is required for GIF support'); + if(!function_exists('imagecreatefromgif')) + $this->Error('GD has no GIF read support'); + $im = imagecreatefromgif($file); + if(!$im) + $this->Error('Missing or incorrect image file: '.$file); + imageinterlace($im,0); + $f = @fopen('php://temp','rb+'); + if($f) + { + // Perform conversion in memory + ob_start(); + imagepng($im); + $data = ob_get_clean(); + imagedestroy($im); + fwrite($f,$data); + rewind($f); + $info = $this->_parsepngstream($f,$file); + fclose($f); + } + else + { + // Use temporary file + $tmp = tempnam('.','gif'); + if(!$tmp) + $this->Error('Unable to create a temporary file'); + if(!imagepng($im,$tmp)) + $this->Error('Error while saving to temporary file'); + imagedestroy($im); + $info = $this->_parsepng($tmp); + unlink($tmp); + } + return $info; +} + +function _newobj() +{ + // Begin a new object + $this->n++; + $this->offsets[$this->n] = strlen($this->buffer); + $this->_out($this->n.' 0 obj'); +} + +function _putstream($s) +{ + $this->_out('stream'); + $this->_out($s); + $this->_out('endstream'); +} + +function _out($s) +{ + // Add a line to the document + if($this->state==2) + $this->pages[$this->page] .= $s."\n"; + else + $this->buffer .= $s."\n"; +} + +function _putpages() +{ + $nb = $this->page; + if(!empty($this->AliasNbPages)) + { + // Replace number of pages + for($n=1;$n<=$nb;$n++) + $this->pages[$n] = str_replace($this->AliasNbPages,$nb,$this->pages[$n]); + } + if($this->DefOrientation=='P') + { + $wPt = $this->DefPageSize[0]*$this->k; + $hPt = $this->DefPageSize[1]*$this->k; + } + else + { + $wPt = $this->DefPageSize[1]*$this->k; + $hPt = $this->DefPageSize[0]*$this->k; + } + $filter = ($this->compress) ? '/Filter /FlateDecode ' : ''; + for($n=1;$n<=$nb;$n++) + { + // Page + $this->_newobj(); + $this->_out('<_out('/Parent 1 0 R'); + if(isset($this->PageSizes[$n])) + $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageSizes[$n][0],$this->PageSizes[$n][1])); + $this->_out('/Resources 2 0 R'); + if(isset($this->PageLinks[$n])) + { + // Links + $annots = '/Annots ['; + foreach($this->PageLinks[$n] as $pl) + { + $rect = sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]); + $annots .= '<_textstring($pl[4]).'>>>>'; + else + { + $l = $this->links[$pl[4]]; + $h = isset($this->PageSizes[$l[0]]) ? $this->PageSizes[$l[0]][1] : $hPt; + $annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',1+2*$l[0],$h-$l[1]*$this->k); + } + } + $this->_out($annots.']'); + } + if($this->PDFVersion>'1.3') + $this->_out('/Group <>'); + $this->_out('/Contents '.($this->n+1).' 0 R>>'); + $this->_out('endobj'); + // Page content + $p = ($this->compress) ? gzcompress($this->pages[$n]) : $this->pages[$n]; + $this->_newobj(); + $this->_out('<<'.$filter.'/Length '.strlen($p).'>>'); + $this->_putstream($p); + $this->_out('endobj'); + } + // Pages root + $this->offsets[1] = strlen($this->buffer); + $this->_out('1 0 obj'); + $this->_out('<_out($kids.']'); + $this->_out('/Count '.$nb); + $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]',$wPt,$hPt)); + $this->_out('>>'); + $this->_out('endobj'); +} + +function _putfonts() +{ + $nf = $this->n; + foreach($this->diffs as $diff) + { + // Encodings + $this->_newobj(); + $this->_out('<>'); + $this->_out('endobj'); + } + foreach($this->FontFiles as $file=>$info) + { + // Font file embedding + $this->_newobj(); + $this->FontFiles[$file]['n'] = $this->n; + $font = file_get_contents($this->fontpath.$file,true); + if(!$font) + $this->Error('Font file not found: '.$file); + $compressed = (substr($file,-2)=='.z'); + if(!$compressed && isset($info['length2'])) + $font = substr($font,6,$info['length1']).substr($font,6+$info['length1']+6,$info['length2']); + $this->_out('<_out('/Filter /FlateDecode'); + $this->_out('/Length1 '.$info['length1']); + if(isset($info['length2'])) + $this->_out('/Length2 '.$info['length2'].' /Length3 0'); + $this->_out('>>'); + $this->_putstream($font); + $this->_out('endobj'); + } + foreach($this->fonts as $k=>$font) + { + // Font objects + $this->fonts[$k]['n'] = $this->n+1; + $type = $font['type']; + $name = $font['name']; + if($type=='Core') + { + // Core font + $this->_newobj(); + $this->_out('<_out('/BaseFont /'.$name); + $this->_out('/Subtype /Type1'); + if($name!='Symbol' && $name!='ZapfDingbats') + $this->_out('/Encoding /WinAnsiEncoding'); + $this->_out('>>'); + $this->_out('endobj'); + } + elseif($type=='Type1' || $type=='TrueType') + { + // Additional Type1 or TrueType/OpenType font + $this->_newobj(); + $this->_out('<_out('/BaseFont /'.$name); + $this->_out('/Subtype /'.$type); + $this->_out('/FirstChar 32 /LastChar 255'); + $this->_out('/Widths '.($this->n+1).' 0 R'); + $this->_out('/FontDescriptor '.($this->n+2).' 0 R'); + if(isset($font['diffn'])) + $this->_out('/Encoding '.($nf+$font['diffn']).' 0 R'); + else + $this->_out('/Encoding /WinAnsiEncoding'); + $this->_out('>>'); + $this->_out('endobj'); + // Widths + $this->_newobj(); + $cw = &$font['cw']; + $s = '['; + for($i=32;$i<=255;$i++) + $s .= $cw[chr($i)].' '; + $this->_out($s.']'); + $this->_out('endobj'); + // Descriptor + $this->_newobj(); + $s = '<$v) + $s .= ' /'.$k.' '.$v; + if(!empty($font['file'])) + $s .= ' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R'; + $this->_out($s.'>>'); + $this->_out('endobj'); + } + else + { + // Allow for additional types + $mtd = '_put'.strtolower($type); + if(!method_exists($this,$mtd)) + $this->Error('Unsupported font type: '.$type); + $this->$mtd($font); + } + } +} + +function _putimages() +{ + foreach(array_keys($this->images) as $file) + { + $this->_putimage($this->images[$file]); + unset($this->images[$file]['data']); + unset($this->images[$file]['smask']); + } +} + +function _putimage(&$info) +{ + $this->_newobj(); + $info['n'] = $this->n; + $this->_out('<_out('/Subtype /Image'); + $this->_out('/Width '.$info['w']); + $this->_out('/Height '.$info['h']); + if($info['cs']=='Indexed') + $this->_out('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]'); + else + { + $this->_out('/ColorSpace /'.$info['cs']); + if($info['cs']=='DeviceCMYK') + $this->_out('/Decode [1 0 1 0 1 0 1 0]'); + } + $this->_out('/BitsPerComponent '.$info['bpc']); + if(isset($info['f'])) + $this->_out('/Filter /'.$info['f']); + if(isset($info['dp'])) + $this->_out('/DecodeParms <<'.$info['dp'].'>>'); + if(isset($info['trns']) && is_array($info['trns'])) + { + $trns = ''; + for($i=0;$i_out('/Mask ['.$trns.']'); + } + if(isset($info['smask'])) + $this->_out('/SMask '.($this->n+1).' 0 R'); + $this->_out('/Length '.strlen($info['data']).'>>'); + $this->_putstream($info['data']); + $this->_out('endobj'); + // Soft mask + if(isset($info['smask'])) + { + $dp = '/Predictor 15 /Colors 1 /BitsPerComponent 8 /Columns '.$info['w']; + $smask = array('w'=>$info['w'], 'h'=>$info['h'], 'cs'=>'DeviceGray', 'bpc'=>8, 'f'=>$info['f'], 'dp'=>$dp, 'data'=>$info['smask']); + $this->_putimage($smask); + } + // Palette + if($info['cs']=='Indexed') + { + $filter = ($this->compress) ? '/Filter /FlateDecode ' : ''; + $pal = ($this->compress) ? gzcompress($info['pal']) : $info['pal']; + $this->_newobj(); + $this->_out('<<'.$filter.'/Length '.strlen($pal).'>>'); + $this->_putstream($pal); + $this->_out('endobj'); + } +} + +function _putxobjectdict() +{ + foreach($this->images as $image) + $this->_out('/I'.$image['i'].' '.$image['n'].' 0 R'); +} + +function _putresourcedict() +{ + $this->_out('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); + $this->_out('/Font <<'); + foreach($this->fonts as $font) + $this->_out('/F'.$font['i'].' '.$font['n'].' 0 R'); + $this->_out('>>'); + $this->_out('/XObject <<'); + $this->_putxobjectdict(); + $this->_out('>>'); +} + +function _putresources() +{ + $this->_putfonts(); + $this->_putimages(); + // Resource dictionary + $this->offsets[2] = strlen($this->buffer); + $this->_out('2 0 obj'); + $this->_out('<<'); + $this->_putresourcedict(); + $this->_out('>>'); + $this->_out('endobj'); +} + +function _putinfo() +{ + $this->_out('/Producer '.$this->_textstring('FPDF '.FPDF_VERSION)); + if(!empty($this->title)) + $this->_out('/Title '.$this->_textstring($this->title)); + if(!empty($this->subject)) + $this->_out('/Subject '.$this->_textstring($this->subject)); + if(!empty($this->author)) + $this->_out('/Author '.$this->_textstring($this->author)); + if(!empty($this->keywords)) + $this->_out('/Keywords '.$this->_textstring($this->keywords)); + if(!empty($this->creator)) + $this->_out('/Creator '.$this->_textstring($this->creator)); + $this->_out('/CreationDate '.$this->_textstring('D:'.@date('YmdHis'))); +} + +function _putcatalog() +{ + $this->_out('/Type /Catalog'); + $this->_out('/Pages 1 0 R'); + if($this->ZoomMode=='fullpage') + $this->_out('/OpenAction [3 0 R /Fit]'); + elseif($this->ZoomMode=='fullwidth') + $this->_out('/OpenAction [3 0 R /FitH null]'); + elseif($this->ZoomMode=='real') + $this->_out('/OpenAction [3 0 R /XYZ null null 1]'); + elseif(!is_string($this->ZoomMode)) + $this->_out('/OpenAction [3 0 R /XYZ null null '.sprintf('%.2F',$this->ZoomMode/100).']'); + if($this->LayoutMode=='single') + $this->_out('/PageLayout /SinglePage'); + elseif($this->LayoutMode=='continuous') + $this->_out('/PageLayout /OneColumn'); + elseif($this->LayoutMode=='two') + $this->_out('/PageLayout /TwoColumnLeft'); +} + +function _putheader() +{ + $this->_out('%PDF-'.$this->PDFVersion); +} + +function _puttrailer() +{ + $this->_out('/Size '.($this->n+1)); + $this->_out('/Root '.$this->n.' 0 R'); + $this->_out('/Info '.($this->n-1).' 0 R'); +} + +function _enddoc() +{ + $this->_putheader(); + $this->_putpages(); + $this->_putresources(); + // Info + $this->_newobj(); + $this->_out('<<'); + $this->_putinfo(); + $this->_out('>>'); + $this->_out('endobj'); + // Catalog + $this->_newobj(); + $this->_out('<<'); + $this->_putcatalog(); + $this->_out('>>'); + $this->_out('endobj'); + // Cross-ref + $o = strlen($this->buffer); + $this->_out('xref'); + $this->_out('0 '.($this->n+1)); + $this->_out('0000000000 65535 f '); + for($i=1;$i<=$this->n;$i++) + $this->_out(sprintf('%010d 00000 n ',$this->offsets[$i])); + // Trailer + $this->_out('trailer'); + $this->_out('<<'); + $this->_puttrailer(); + $this->_out('>>'); + $this->_out('startxref'); + $this->_out($o); + $this->_out('%%EOF'); + $this->state = 3; +} +// End of class +} + +// Handle special IE contype request +if(isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT']=='contype') +{ + header('Content-Type: application/pdf'); + exit; +} + +?> diff --git a/includes/header.php b/includes/header.php new file mode 100644 index 0000000000..57df501098 --- /dev/null +++ b/includes/header.php @@ -0,0 +1,137 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; + +//if reloadxml then run the command + if (isset($_SESSION["reload_xml"])) { + if (strlen($_SESSION["reload_xml"]) > 0) { + if ($_SESSION['apply_settings'] == "true") { + //show the apply settings prompt + } + else { + //create the event socket connection + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + //reload the access control list this also runs reloadxml + $response = event_socket_request($fp, 'api reloadxml'); + $_SESSION["reload_xml"] = ''; + unset($_SESSION["reload_xml"]); + usleep(500); + //clear the apply settings reminder + $_SESSION["reload_xml"] = false; + } + } + } + +//set a default template + if (!isset($_SESSION['domain']['template']['name'])) { $_SESSION['domain']['template']['name'] = 'default'; } + +//set a default template + $v_template_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/themes'; + if (!isset($_SESSION['domain']['template']['name'])) { + //get the contents of the template and save it to the template variable + $template_full_path = $v_template_path.'/'.$_SESSION['domain']['template']['name'].'/template.php'; + if (!file_exists($template_full_path)) { + $_SESSION['domain']['template']['name'] = 'default'; + } + } + +//start the output buffer + include $v_template_path.'/'.$_SESSION['domain']['template']['name'].'/config.php'; + +//start the output buffer + ob_start(); + +// get the content + if (isset($content)) { + $content = $_GET["c"]; //link + } + else { + $content = ''; + } + +//get the parent id + $sql = ""; + $sql .= "select * from v_menu_items "; + $sql .= "where menu_uuid = '".$_SESSION['domain']['menu']['uuid']."' "; + $sql .= "and menu_item_link = '".$_SERVER["SCRIPT_NAME"]."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $_SESSION["menu_item_parent_uuid"] = $row["menu_item_parent_uuid"]; + break; + } + unset($result); + +//get the content + $sql = ""; + $sql .= "select * from v_rss "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and rss_category = 'content' "; + if (strlen($content) == 0) { + $sql .= "and rss_link = '".$_SERVER["PHP_SELF"]."' "; + } + else { + $sql .= "and rss_link = '".$content."' "; + } + $sql .= "and length(rss_del_date) = 0 "; + $sql .= "or domain_uuid = '$domain_uuid' "; + $sql .= "and rss_category = 'content' "; + if (strlen($content) == 0) { + $sql .= "and rss_link = '".$_SERVER["PHP_SELF"]."' "; + } + else { + $sql .= "and rss_link = '".$content."' "; + } + $sql .= "and rss_del_date is null "; + $sql .= "order by rss_order asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + + $customtitle = ''; + foreach($result as $row) { + $template_rss_sub_category = $row[rss_sub_category]; + if (strlen($row[rss_group]) == 0) { + //content is public + $content_from_db = &$row[rss_description]; + $customtitle = $row[rss_title]; + } + else { + if (if_group($row[rss_group])) { //viewable only to designated group + $content_from_db = &$row[rss_description]; + $customtitle = $row[rss_title]; + } + } + } //end foreach + unset($sql, $result, $row_count); + +//start the output buffer + ob_start(); + +?> \ No newline at end of file diff --git a/includes/install/autoload_configs/cdr_csv.conf.xml b/includes/install/autoload_configs/cdr_csv.conf.xml new file mode 100644 index 0000000000..a44f21b1cd --- /dev/null +++ b/includes/install/autoload_configs/cdr_csv.conf.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/includes/install/dialplan/default.xml b/includes/install/dialplan/default.xml new file mode 100644 index 0000000000..eb5ed17267 --- /dev/null +++ b/includes/install/dialplan/default.xml @@ -0,0 +1,832 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/install/htdocs/license.txt b/includes/install/htdocs/license.txt new file mode 100644 index 0000000000..2111a50a1f --- /dev/null +++ b/includes/install/htdocs/license.txt @@ -0,0 +1,10 @@ +Copyright (c) 2005, Fabricio Zuardi +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/includes/install/htdocs/slim.swf b/includes/install/htdocs/slim.swf new file mode 100644 index 0000000000..24b36c9daf Binary files /dev/null and b/includes/install/htdocs/slim.swf differ diff --git a/includes/install/htdocs/slimtest.htm b/includes/install/htdocs/slimtest.htm new file mode 100644 index 0000000000..f1536d7ca0 --- /dev/null +++ b/includes/install/htdocs/slimtest.htm @@ -0,0 +1,23 @@ +

    + You can find more infos about slim.swf here: +

    +

    + http://musicplayer.sourceforge.net/#documentation +

    +

    +
    + Please remember that you should record your MP3s at 11Khz for slim.swf to play correctly + + A quick example follows: +

    + + + + + + + +

    + Remember that if this is not working for you, you should most probably point the song_url GET parameter to a real MP3 file that should be reachable through the web server. +

    diff --git a/includes/install/lang/en/en.xml b/includes/install/lang/en/en.xml new file mode 100644 index 0000000000..0b12c7b698 --- /dev/null +++ b/includes/install/lang/en/en.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/includes/install/lang/en/wakeup/sounds.xml b/includes/install/lang/en/wakeup/sounds.xml new file mode 100644 index 0000000000..8c41736405 --- /dev/null +++ b/includes/install/lang/en/wakeup/sounds.xml @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/install/scripts/call_broadcast_originate.js b/includes/install/scripts/call_broadcast_originate.js new file mode 100644 index 0000000000..a87f7115c4 --- /dev/null +++ b/includes/install/scripts/call_broadcast_originate.js @@ -0,0 +1,80 @@ +include("config.js"); + //var sounds_dir + //var admin_pin + //var tmp_dir + //var recordings_dir + +var sipuri = argv[0]; +var recording = argv[1]; +var caller_id_name = argv[2]; +var caller_id_number = argv[3]; +var call_timeout = argv[4]; +var call_count_var_name = argv[5]; +var tmp_sipuri; + +caller_id_name = caller_id_name.replace("+", " "); +console_log( "info", "sipuri: "+sipuri+"\n" ); +console_log( "info", "recording: "+recording+"\n" ); +console_log( "info", "caller_id_name: "+caller_id_name+"\n" ); +console_log( "info", "caller_id_number: "+caller_id_number+"\n" ); +console_log( "info", "call_timeout: "+call_timeout+"\n" ); +console_log( "info", "call_count_var_name: "+call_count_var_name+"\n" ); + + + +//function on_hangup(hup_session, how) +//{ +// console_log("err", how + " HOOK" + " name: " + hup_session.name + " cause: " + hup_session.cause + "\n"); +// //exit here would end the script so you could cleanup and just be done +// exit(); +//} + +function originate (sipuri, recording, caller_id_name, caller_id_number, call_timeout, count_var_name) { + + var dtmf = new Object(); + var cid; + dtmf.digits = ""; + cid = ",origination_caller_id_name="+caller_id_name+",origination_caller_id_number="+caller_id_number; + + new_session = new Session("{ignore_early_media=true,hangup_after_bridge=false,call_timeout="+call_timeout+""+cid+"}"+sipuri); + //new_session = new Session(sipuri); + +//new_session.execute("set", "api_after_bridge=reloadxml"); +//set the on_hangup function to be called when this session is hungup +//new_session.setHangupHook(on_hangup); +//result = new_session.setAutoHangup(true); + + //console_log( "info", "followme: new_session uuid "+new_session.uuid+"\n" ); + //console_log( "info", "followme: no dtmf detected\n" ); + + digitmaxlength = 1; + while (new_session.ready()) { + if (recording.length > 0) { + //new_session.streamFile( recordings_dir+"/"+recording); + new_session.execute("playback",recordings_dir+"/"+recording); + //new_session.hangup("NORMAL_CLEARING"); + } + break; + } + + var hangup_cause = new_session.getVariable("bridge_hangup_cause"); + console_log( "info", "hangup cause: "+hangup_cause+"\n" ); + var count = getGlobalVariable(call_count_var_name); + setGlobalVariable(call_count_var_name, (parseInt(count)-1)); + console_log( "info", "action: hangup, count: "+count+"\n" ); + +} + +sipuri_array = sipuri.split(","); +for (i = 0; i < sipuri_array.length; i++){ + //var count = getGlobalVariable(call_count_var_name); + //setGlobalVariable(call_count_var_name, (parseInt(count)+1)); + + tmp_sipuri = sipuri_array[i]; + console_log("info", "tmp_sipuri: "+tmp_sipuri); + result = originate (tmp_sipuri, recording, caller_id_name, caller_id_number, call_timeout, call_count_var_name); + if (result) { + break; + } +} +exit(); diff --git a/includes/install/scripts/call_forward.lua b/includes/install/scripts/call_forward.lua new file mode 100644 index 0000000000..b39fc28306 --- /dev/null +++ b/includes/install/scripts/call_forward.lua @@ -0,0 +1,127 @@ +-- +-- FusionPBX +-- Version: MPL 1.1 +-- +-- The contents of this file are subject to the Mozilla Public License Version +-- 1.1 (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- http://www.mozilla.org/MPL/ +-- +-- Software distributed under the License is distributed on an "AS IS" basis, +-- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +-- for the specific language governing rights and limitations under the +-- License. +-- +-- The Original Code is FusionPBX +-- +-- The Initial Developer of the Original Code is +-- Mark J Crane +-- Copyright (C) 2010 +-- the Initial Developer. All Rights Reserved. +-- +-- Contributor(s): +-- Mark J Crane + +pin_number = ""; +max_tries = "3"; +digit_timeout = "3000"; + +function file_exists(fname) + local f = io.open(fname, "r") + if (f and f:read()) then return true end +end + +if ( session:ready() ) then + session:answer(); + --session:execute("info", ""); + extension = session:getVariable("user_name"); + pin_number = session:getVariable("pin_number"); + sounds_dir = session:getVariable("sounds_dir"); + dialplan_default_dir = session:getVariable("dialplan_default_dir"); + call_forward_number = session:getVariable("call_forward_number"); + extension_required = session:getVariable("extension_required"); + context = session:getVariable("context"); + if (not context ) then context = 'default'; end + + --set the sounds path for the language, dialect and voice + default_language = session:getVariable("default_language"); + default_dialect = session:getVariable("default_dialect"); + default_voice = session:getVariable("default_voice"); + if (not default_language) then default_language = 'en'; end + if (not default_dialect) then default_dialect = 'us'; end + if (not default_voice) then default_voice = 'callie'; end + + --if the pin number is provided then require it + if (pin_number) then + min_digits = string.len(pin_number); + max_digits = string.len(pin_number)+1; + digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/please_enter_the_pin_number.wav", "", "\\d+"); + if (digits == pin_number) then + --pin is correct + else + session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/your_pin_number_is_incorect_goodbye.wav"); + session:hangup("NORMAL_CLEARING"); + return; + end + end + + --if extension_requires is true then get the extension number + if (extension_required) then + if (extension_required == "true") then + extension = session:playAndGetDigits(3, 6, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/please_enter_the_extension_number.wav", "", "\\d+"); + end + end + + + if (file_exists(dialplan_default_dir.."/000_call_forward_"..extension..".xml")) then + --file exists + + --remove the call forward dialplan entry + os.remove (dialplan_default_dir.."/000_call_forward_"..extension..".xml"); + + --stream file + session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/call_forward_has_been_deleted.wav"); + + --wait for the file to be written before proceeding + session:sleep(1000); + + else + --file does not exist + + dtmf = ""; --clear dtmf digits to prepare for next dtmf request + if (call_forward_number) then + -- do nothing + else + -- get the call forward number + call_forward_number = session:playAndGetDigits(3, 15, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/please_enter_the_phone_number.wav", "", "\\d+"); + end + if (string.len(call_forward_number) > 0) then + --write the xml file + xml = "\n"; + xml = xml .. " \n"; + xml = xml .. " \n"; + xml = xml .. " \n"; + xml = xml .. "\n"; + session:execute("log", xml); + local file = assert(io.open(dialplan_default_dir.."/000_call_forward_"..extension..".xml", "w")); + file:write(xml); + file:close(); + + --wait for the file to be written before proceeding + --session:sleep(20000); + + --stream file + session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/call_forward_has_been_set.wav"); + end + end + + --reloadxml + api = freeswitch.API(); + reply = api:executeString("reloadxml"); + + --wait for the file to be written before proceeding + session:sleep(1000); + + session:hangup(); + +end \ No newline at end of file diff --git a/includes/install/scripts/disa.lua b/includes/install/scripts/disa.lua new file mode 100644 index 0000000000..85fe8e8e31 --- /dev/null +++ b/includes/install/scripts/disa.lua @@ -0,0 +1,156 @@ +-- +-- FusionPBX +-- Version: MPL 1.1 +-- +-- The contents of this file are subject to the Mozilla Public License Version +-- 1.1 (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- http://www.mozilla.org/MPL/ +-- +-- Software distributed under the License is distributed on an "AS IS" basis, +-- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +-- for the specific language governing rights and limitations under the +-- License. +-- +-- The Original Code is FusionPBX +-- +-- The Initial Developer of the Original Code is +-- Mark J Crane +-- Copyright (C) 2010 +-- the Initial Developer. All Rights Reserved. +-- +-- Contributor(s): +-- Mark J Crane + +predefined_destination = ""; +max_tries = "3"; +digit_timeout = "5000"; + +function trim (s) + return (string.gsub(s, "^%s*(.-)%s*$", "%1")) +end + +function explode ( seperator, str ) + local pos, arr = 0, {} + for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found + table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider + pos = sp + 1 -- jump past current divider + end + table.insert( arr, string.sub( str, pos ) ) -- attach chars right of last divider + return arr +end + +if ( session:ready() ) then + session:answer( ); + pin_number = session:getVariable("pin_number"); + sounds_dir = session:getVariable("sounds_dir"); + caller_id_name = session:getVariable("caller_id_name"); + caller_id_number = session:getVariable("caller_id_number"); + predefined_destination = session:getVariable("predefined_destination"); + digit_min_length = session:getVariable("digit_min_length"); + digit_max_length = session:getVariable("digit_max_length"); + gateway = session:getVariable("gateway"); + context = session:getVariable("context"); + + --set the sounds path for the language, dialect and voice + default_language = session:getVariable("default_language"); + default_dialect = session:getVariable("default_dialect"); + default_voice = session:getVariable("default_voice"); + if (not default_language) then default_language = 'en'; end + if (not default_dialect) then default_dialect = 'us'; end + if (not default_voice) then default_voice = 'callie'; end + + --set defaults + if (digit_min_length) then + --do nothing + else + digit_min_length = "2"; + end + + if (digit_max_length) then + --do nothing + else + digit_max_length = "11"; + end + + --if the pin number is provided then require it + if (pin_number) then + min_digits = string.len(pin_number); + max_digits = string.len(pin_number)+1; + digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-please_enter_pin_followed_by_pound.wav", "", "\\d+"); + if (digits == pin_number) then + --pin is correct + else + session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-pin_or_extension_is-invalid.wav"); + session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-im_sorry.wav"); + session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/voicemail/vm-goodbye.wav"); + + session:hangup("NORMAL_CLEARING"); + return; + end + end + + --if a predefined_destination is provided then set the number to the predefined_destination + if (predefined_destination) then + destination_number = predefined_destination; + else + dtmf = ""; --clear dtmf digits to prepare for next dtmf request + destination_number = session:playAndGetDigits(digit_min_length, digit_max_length, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-enter_destination_telephone_number.wav", "", "\\d+"); + --if (string.len(destination_number) == 10) then destination_number = "1"..destination_number; end + end + + --set the caller id anme and number + if (string.len(destination_number) < 7) then + if (caller_id_name) then + --caller id name provided do nothing + else + caller_id_number = session:getVariable("effective_caller_id_name"); + end + if (caller_id_number) then + --caller id number provided do nothing + else + caller_id_number = session:getVariable("effective_caller_id_number"); + end + else + if (caller_id_name) then + --caller id name provided do nothing + else + caller_id_number = session:getVariable("outbound_caller_id_name"); + end + if (caller_id_number) then + --caller id number provided do nothing + else + caller_id_number = session:getVariable("outbound_caller_id_number"); + end + end + + --transfer or bridge the call + if (string.len(destination_number) < 7) then + --local call + session:execute("transfer", destination_number .. " XML " .. context); + else + --remote call + if (gateway) then + gateway_table = explode(",",gateway); + for index,value in pairs(gateway_table) do + session:execute("bridge", "{continue_on_fail=true,hangup_after_bridge=true,origination_caller_id_name="..caller_id_name..",origination_caller_id_number="..caller_id_number.."}sofia/gateway/"..value.."/"..destination_number); + end + else + session:execute("set", "effective_caller_id_name="..caller_id_name); + session:execute("set", "effective_caller_id_number="..caller_id_number); + session:execute("transfer", destination_number .. " XML " .. context); + end + end + + --alternate method + --local session2 = freeswitch.Session("{ignore_early_media=true}sofia/gateway/flowroute.com/"..destination_number); + --t1 = os.date('*t'); + --call_start_time = os.time(t1); + --freeswitch.bridge(session, session2); +end + +--function HangupHook(s, status, arg) + --session:execute("info", ""); + --freeswitch.consoleLog("NOTICE", "HangupHook: " .. status .. "\n"); +--end +--session:setHangupHook("HangupHook", ""); diff --git a/includes/install/scripts/eavesdrop.lua b/includes/install/scripts/eavesdrop.lua new file mode 100644 index 0000000000..1cb5535c1f --- /dev/null +++ b/includes/install/scripts/eavesdrop.lua @@ -0,0 +1,101 @@ +-- +-- FusionPBX +-- Version: MPL 1.1 +-- +-- The contents of this file are subject to the Mozilla Public License Version +-- 1.1 (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- http://www.mozilla.org/MPL/ +-- +-- Software distributed under the License is distributed on an "AS IS" basis, +-- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +-- for the specific language governing rights and limitations under the +-- License. +-- +-- The Original Code is FusionPBX +-- +-- The Initial Developer of the Original Code is +-- Mark J Crane +-- Copyright (C) 2010 +-- the Initial Developer. All Rights Reserved. +-- +-- Contributor(s): +-- Mark J Crane + +max_tries = "3"; +digit_timeout = "5000"; + +extension = argv[1]; + +--database + --connect to the database + --local dbh = freeswitch.Dbh("dsn","user","pass"); -- when using ODBC + local dbh = freeswitch.Dbh("core:core"); -- when using sqlite + + --exits the script if we didn't connect properly + assert(dbh:connected()); + +if ( session:ready() ) then + session:answer( ); + pin_number = session:getVariable("pin_number"); + sounds_dir = session:getVariable("sounds_dir"); + domain_name = session:getVariable("domain_name"); + + --set the sounds path for the language, dialect and voice + default_language = session:getVariable("default_language"); + default_dialect = session:getVariable("default_dialect"); + default_voice = session:getVariable("default_voice"); + if (not default_language) then default_language = 'en'; end + if (not default_dialect) then default_dialect = 'us'; end + if (not default_voice) then default_voice = 'callie'; end + + --set defaults + if (digit_min_length) then + --do nothing + else + digit_min_length = "2"; + end + + if (digit_max_length) then + --do nothing + else + digit_max_length = "11"; + end + + --if the pin number is provided then require it + if (pin_number) then + min_digits = string.len(pin_number); + max_digits = string.len(pin_number)+1; + digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/please_enter_the_pin_number.wav", "", "\\d+"); + if (digits == pin_number) then + --pin is correct + else + session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/your_pin_number_is_incorect_goodbye.wav"); + session:hangup("NORMAL_CLEARING"); + return; + end + end + + --check the database to get the uuid + --eavesdrop + sql = "select uuid from channels where presence_id = '"..extension.."@"..domain_name.."' "; + dbh:query(sql, function(result) + for key, val in pairs(result) do + freeswitch.consoleLog("NOTICE", "result "..key.." "..val.."\n"); + end + uuid = result.uuid; + end); + +end + +--eavesdrop + if (uuid) then + session:execute("eavesdrop", uuid); --call barge + end + +--notes + --originate a call + --cmd = "originate user/1007@voip.example.com &eavesdrop("..uuid..")"; + --cmd = "uuid_bridge "..caller_uuid.." "..uuid; + --api = freeswitch.API(); + --result = api:executeString(cmd); diff --git a/includes/install/scripts/fax_retry.lua b/includes/install/scripts/fax_retry.lua new file mode 100644 index 0000000000..578d74e281 --- /dev/null +++ b/includes/install/scripts/fax_retry.lua @@ -0,0 +1,70 @@ +--set default variables + fax_retry_sleep = 10; + fax_retry_limit = 3; + +-- show all channel variables + --dat = env:serialize() + --freeswitch.consoleLog("INFO","info:\n" .. dat .. "\n") + +-- example channel variables relating to fax + --variable_fax_success: 0 + --variable_fax_result_code: 49 + --variable_fax_result_text: The%20call%20dropped%20prematurely + --variable_fax_ecm_used: off + --variable_fax_local_station_id: SpanDSP%20Fax%20Ident + --variable_fax_document_transferred_pages: 0 + --variable_fax_document_total_pages: 0 + --variable_fax_image_resolution: 0x0 + --variable_fax_image_size: 0 + --variable_fax_bad_rows: 0 + --variable_fax_transfer_rate: 14400 + +-- set channel variables to lua variables + uuid = env:getHeader("uuid"); + fax_success = env:getHeader("fax_success"); + fax_result_text = env:getHeader("fax_result_text"); + fax_ecm_used = env:getHeader("fax_ecm_used"); + fax_retry_attempts = tonumber(env:getHeader("fax_retry_attempts")); + fax_retry_limit = tonumber(env:getHeader("fax_retry_limit")); + fax_retry_sleep = tonumber(env:getHeader("fax_retry_sleep")); + fax_uri = env:getHeader("fax_uri"); + fax_file = env:getHeader("fax_file"); + fax_extension_number = env:getHeader("fax_extension_number"); + origination_caller_id_name = env:getHeader("origination_caller_id_name"); + origination_caller_id_number = env:getHeader("origination_caller_id_number"); + +--set default values + if (not origination_caller_id_name) then + origination_caller_id_name = '000000000000000'; + end + if (not origination_caller_id_number) then + origination_caller_id_number = '000000000000000'; + end + +-- send the selected variables to the console + freeswitch.consoleLog("INFO","fax_success: '" .. fax_success .. "'\n"); + freeswitch.consoleLog("INFO","fax_result_text: '" .. fax_result_text .. "'\n"); + freeswitch.consoleLog("INFO","fax_file: '" .. fax_file .. "'\n"); + freeswitch.consoleLog("INFO","uuid: '" .. uuid .. "'\n"); + freeswitch.consoleLog("INFO","fax_ecm_used: '" .. fax_ecm_used .. "'\n"); + freeswitch.consoleLog("INFO","fax_retry_attempts: " .. fax_retry_attempts.. "\n"); + freeswitch.consoleLog("INFO","fax_retry_limit: " .. fax_retry_limit.. "\n"); + freeswitch.consoleLog("INFO","fax_retry_sleep: " .. fax_retry_sleep.. "\n"); + freeswitch.consoleLog("INFO","fax_uri: '" .. fax_uri.. "'\n"); + freeswitch.consoleLog("INFO","origination_caller_id_name: " .. origination_caller_id_name .. "\n"); + freeswitch.consoleLog("INFO","origination_caller_id_number: " .. origination_caller_id_number .. "\n"); + +-- if the fax failed then try again + if (fax_success == "0") then + if (fax_retry_attempts < fax_retry_limit) then + -- sleep + freeswitch.msleep(fax_retry_sleep * 1000); + --increment the retry attempts + fax_retry_attempts = fax_retry_attempts + 1; + cmd = "originate {origination_caller_id_name='"..origination_caller_id_name.. "',origination_caller_id_number="..origination_caller_id_number..",fax_uri="..fax_uri..",fax_retry_attempts="..fax_retry_attempts..",fax_retry_limit="..fax_retry_limit..",fax_retry_sleep="..fax_retry_sleep..",fax_verbose=true,fax_file='"..fax_file.."',fax_use_ecm=off,api_hangup_hook='lua fax_retry.lua'}"..fax_uri.." &txfax('"..fax_file.."')"; + --cmd = "sofia/internal/"..fax_number.."@"..domain_name.." &txfax('"..fax_file.."') XML default "; + freeswitch.consoleLog("INFO","retry cmd: " .. cmd .. "\n"); + api = freeswitch.API(); + reply = api:executeString(cmd); + end + end diff --git a/includes/install/scripts/fifo_member.lua b/includes/install/scripts/fifo_member.lua new file mode 100644 index 0000000000..69b5847498 --- /dev/null +++ b/includes/install/scripts/fifo_member.lua @@ -0,0 +1,99 @@ +-- +-- FusionPBX +-- Version: MPL 1.1 +-- +-- The contents of this file are subject to the Mozilla Public License Version +-- 1.1 (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- http://www.mozilla.org/MPL/ +-- +-- Software distributed under the License is distributed on an "AS IS" basis, +-- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +-- for the specific language governing rights and limitations under the +-- License. +-- +-- The Original Code is FusionPBX +-- +-- The Initial Developer of the Original Code is +-- Mark J Crane +-- Copyright (C) 2010 +-- All Rights Reserved. +-- +-- Contributor(s): +-- Mark J Crane + +sounds_dir = ""; +recordings_dir = ""; +pin_number = ""; +max_tries = "3"; +digit_timeout = "3000"; + + +if ( session:ready() ) then + session:answer(); + --session:execute("info", ""); + user_name = session:getVariable("user_name"); + pin_number = session:getVariable("pin_number"); + sounds_dir = session:getVariable("sounds_dir"); + queue_name = session:getVariable("queue_name"); + fifo_simo = session:getVariable("fifo_simo"); + fifo_timeout = session:getVariable("fifo_timeout"); + fifo_lag = session:getVariable("fifo_lag"); + + --pin_number = "1234"; --for testing + --queue_name = "5900@voip.fusionpbx.com"; + --fifo_simo = 1; + --fifo_timeout = 10; + --fifo_lag = 10; + + if (pin_number) then + digits = session:playAndGetDigits(3, 8, 3, digit_timeout, "#", sounds_dir.."/custom/please_enter_the_pin_number.wav", "", "\\d+"); + if (digits == pin_number) then + --pin is correct + + --press 1 to login and 2 to logout + menu_selection = session:playAndGetDigits(1, 1, max_tries, digit_timeout, "#", sounds_dir.."/custom/please_enter_the_phone_number.wav", "", "\\d+"); + freeswitch.consoleLog("NOTICE", "menu_selection: "..menu_selection.."\n"); + if (menu_selection == "1") then + session:execute("set", "fifo_member_add_result=${fifo_member(add "..queue_name.." {fifo_member_wait=nowait}user/"..user_name.." "..fifo_simo.." "..fifo_timeout.." "..fifo_lag.."} )"); --simo timeout lag + fifo_member_add_result = session:getVariable("fifo_member_add_result"); + freeswitch.consoleLog("NOTICE", "fifo_member_add_result: "..fifo_member_add_result.."\n"); + session:streamFile("ivr/ivr-you_are_now_logged_in.wav"); + end + if (menu_selection == "2") then + session:execute("set", "fifo_member_del_result=${fifo_member(del "..queue_name.." {fifo_member_wait=nowait}user/"..user_name.."} )"); + session:streamFile("ivr/ivr-you_are_now_logged_out.wav"); + end + + --wait for the file to be written before proceeding + -- session:sleep(1000); + + session:hangup(); + + else + session:streamFile(sounds_dir.."/custom/your_pin_number_is_incorect_goodbye.wav"); + end + else + + --pin number is not required + + --press 1 to login and 2 to logout + menu_selection = session:playAndGetDigits(1, 1, max_tries, digit_timeout, "#", sounds_dir.."/custom/please_enter_the_phone_number.wav", "", "\\d+"); + freeswitch.consoleLog("NOTICE", "menu_selection: "..menu_selection.."\n"); + if (menu_selection == "1") then + session:execute("set", "fifo_member_add_result=${fifo_member(add "..queue_name.." {fifo_member_wait=nowait}user/"..user_name.." "..fifo_simo.." "..fifo_timeout.." "..fifo_lag.."} )"); --simo timeout lag + fifo_member_add_result = session:getVariable("fifo_member_add_result"); + freeswitch.consoleLog("NOTICE", "fifo_member_add_result: "..fifo_member_add_result.."\n"); + session:streamFile("ivr/ivr-you_are_now_logged_in.wav"); + end + if (menu_selection == "2") then + session:execute("set", "fifo_member_del_result=${fifo_member(del "..queue_name.." {fifo_member_wait=nowait}user/"..user_name.."} )"); + session:streamFile("ivr/ivr-you_are_now_logged_out.wav"); + end + + --wait for the file to be written before proceeding + -- session:sleep(1000); + + session:hangup(); + end +end \ No newline at end of file diff --git a/includes/install/scripts/huntgroup_originate.lua b/includes/install/scripts/huntgroup_originate.lua new file mode 100644 index 0000000000..74d375107a --- /dev/null +++ b/includes/install/scripts/huntgroup_originate.lua @@ -0,0 +1,108 @@ +--get the argv values + domain_name = argv[1]; + uuid = argv[2]; + sipuri = argv[3]; + extension = argv[4]; + caller_id_name = argv[5]; + caller_id_number = argv[6]; + caller_announce = argv[7]; + +--variable preparation + tmp_sipuri = ''; + caller_id_name = string.gsub(caller_id_name, "+", " "); + +function explode ( seperator, str ) + local pos, arr = 0, {} + for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found + table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider + pos = sp + 1 -- jump past current divider + end + table.insert( arr, string.sub( str, pos ) ) -- attach chars right of last divider + return arr +end + +function originate (domain_name, session, sipuri, extension, caller_announce, caller_id_name, caller_id_number) + + cid = ",origination_caller_id_name="..caller_id_name..",origination_caller_id_number="..caller_id_number; + local new_session = freeswitch.Session("{ignore_early_media=true"..cid.."}"..sipuri); + new_session:execute("set", "call_timeout=60"); + new_session:execute("sleep", "1000"); + + --if the session is not ready wait longer + if ( new_session:ready() ) then + --do nothing + else + new_session:execute("sleep", "1000"); + end + + if ( new_session:ready() ) then + --get the session id + uuid = new_session:getVariable("uuid"); + --set the sounds path for the language, dialect and voice + default_language = new_session:getVariable("default_language"); + default_dialect = new_session:getVariable("default_dialect"); + default_voice = new_session:getVariable("default_voice"); + if (not default_language) then default_language = 'en'; end + if (not default_dialect) then default_dialect = 'us'; end + if (not default_voice) then default_voice = 'callie'; end + + --caller announce + if (caller_announce) then + new_session:streamFile(caller_announce); + end + + --set the sounds directory + sounds_dir = new_session:getVariable("sounds_dir"); + + --check the fifo status if it is empty hangup the call + api = freeswitch.API(); + cmd = "fifo count "..extension.."@"..domain_name; + result = api:executeString(cmd); + --freeswitch.consoleLog("notice", "result " .. result .. "\n"); + result_table = explode(":",result); + if (result_table[3] == "0") then + --session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/your_pin_number_is_incorect_goodbye.wav"); + new_session:hangup("NORMAL_CLEARING"); + return; + end + + --prompt user for action + dtmf_digits = new_session:playAndGetDigits(1, 1, 2, 3000, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/8000/press_1_to_accept_2_to_reject_or_3_for_voicemail.wav", "", "\\d+"); + freeswitch.consoleLog("NOTICE", "followme: "..dtmf_digits.."\n"); + + if ( dtmf_digits == "1" ) then + freeswitch.consoleLog("NOTICE", "followme: call accepted\n"); + freeswitch.consoleLog("NOTICE", extension.."@"..domain_name.." out nowait\n"); + new_session:execute("fifo", extension.."@"..domain_name.." out nowait"); + return true; + end + if ( dtmf_digits == "2" ) then + freeswitch.consoleLog("NOTICE", "followme: call rejected\n"); + new_session:hangup(); + return false; + end + if ( dtmf_digits == "3" ) then + freeswitch.consoleLog("NOTICE", "followme: call sent to voicemail\n"); + cmd = "uuid_transfer "..uuid.." *99"..extension; + api = freeswitch.API(); + reply = api:executeString(cmd); + return true; + end + if ( dtmf_digits == "" ) then + freeswitch.consoleLog("NOTICE", "followme: no dtmf detected\n"); + return false; + end + else + freeswitch.consoleLog("err", "followme: session not ready\n"); + end +end + +sipuri_table = explode(",",sipuri); +for index,tmp_sip_uri in pairs(sipuri_table) do + freeswitch.consoleLog("NOTICE", "sip_uri: "..tmp_sip_uri.."\n"); + result = originate (domain_name, session, tmp_sip_uri, extension, caller_announce, caller_id_name, caller_id_number); + if (result) then + break; + --exit; + end +end diff --git a/includes/install/scripts/intercept.lua b/includes/install/scripts/intercept.lua new file mode 100644 index 0000000000..a3e9479338 --- /dev/null +++ b/includes/install/scripts/intercept.lua @@ -0,0 +1,100 @@ +-- +-- FusionPBX +-- Version: MPL 1.1 +-- +-- The contents of this file are subject to the Mozilla Public License Version +-- 1.1 (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- http://www.mozilla.org/MPL/ +-- +-- Software distributed under the License is distributed on an "AS IS" basis, +-- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +-- for the specific language governing rights and limitations under the +-- License. +-- +-- The Original Code is FusionPBX +-- +-- The Initial Developer of the Original Code is +-- Mark J Crane +-- Copyright (C) 2010 +-- the Initial Developer. All Rights Reserved. +-- +-- Contributor(s): +-- Mark J Crane + +max_tries = "3"; +digit_timeout = "5000"; + +extension = argv[1]; + +--database + --connect to the database + --local dbh = freeswitch.Dbh("dsn","user","pass"); -- when using ODBC + local dbh = freeswitch.Dbh("core:core"); -- when using sqlite + + --exits the script if we didn't connect properly + assert(dbh:connected()); + +if ( session:ready() ) then + session:answer( ); + pin_number = session:getVariable("pin_number"); + sounds_dir = session:getVariable("sounds_dir"); + domain_name = session:getVariable("domain_name"); + + --set the sounds path for the language, dialect and voice + default_language = session:getVariable("default_language"); + default_dialect = session:getVariable("default_dialect"); + default_voice = session:getVariable("default_voice"); + if (not default_language) then default_language = 'en'; end + if (not default_dialect) then default_dialect = 'us'; end + if (not default_voice) then default_voice = 'callie'; end + + --set defaults + if (digit_min_length) then + --do nothing + else + digit_min_length = "2"; + end + + if (digit_max_length) then + --do nothing + else + digit_max_length = "11"; + end + + --if the pin number is provided then require it + if (pin_number) then + min_digits = string.len(pin_number); + max_digits = string.len(pin_number)+1; + digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/please_enter_the_pin_number.wav", "", "\\d+"); + if (digits == pin_number) then + --pin is correct + else + session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/your_pin_number_is_incorect_goodbye.wav"); + session:hangup("NORMAL_CLEARING"); + return; + end + end + + --check the database to get the uuid + --intercept + sql = "select call_uuid as uuid from channels where presence_id = '"..extension.."@"..domain_name.."' and callstate = 'RINGING' "; + dbh:query(sql, function(result) + for key, val in pairs(result) do + freeswitch.consoleLog("NOTICE", "result "..key.." "..val.."\n"); + end + uuid = result.uuid; + end); + +end + +--intercept a call that is ringing + if (uuid) then + session:execute("intercept", uuid); + end + +--notes + --originate a call + --cmd = "originate user/1007@voip.example.com &intercept("..uuid..")"; + --api = freeswitch.API(); + --result = api:executeString(cmd); diff --git a/includes/install/scripts/originate.js b/includes/install/scripts/originate.js new file mode 100644 index 0000000000..85b1bfa276 --- /dev/null +++ b/includes/install/scripts/originate.js @@ -0,0 +1,43 @@ +include("config.js"); + //var sounds_dir + //var admin_pin + //var tmp_dir + +var sipuri = argv[0]; +var caller_id_name = argv[1]; +var caller_id_number = argv[2]; +var tmp_sipuri; + +caller_id_name = caller_id_name.replace("+", " "); +//console_log( "info", "caller_announce: "+caller_announce+"\n" ); + +function originate (sipuri, caller_id_name, caller_id_number) { + + var dtmf = new Object(); + var cid; + dtmf.digits = ""; + cid = ",origination_caller_id_name="+caller_id_name+",origination_caller_id_number="+caller_id_number; + + new_session = new Session("{ignore_early_media=true"+cid+"}"+sipuri); + new_session.execute("set", "call_timeout=30"); + + if ( new_session.ready() ) { + new_session.streamFile( sounds_dir+"/custom/press_1_to_accept_2_to_reject_or_3_for_voicemail.wav"); + digitmaxlength = 1; + while (new_session.ready()) { + //console_log( "info", "originate succeeded\n" ); + } + + } +} + +sipuri_array = sipuri.split(","); +for (i = 0; i < sipuri_array.length; i++){ + tmp_sipuri = sipuri_array[i]; + console_log("info", "tmp_sipuri: "+tmp_sipuri); + result = originate (tmp_sipuri, caller_id_name, caller_id_number); + if (result) { + break; + exit; + } +} \ No newline at end of file diff --git a/includes/install/scripts/page.lua b/includes/install/scripts/page.lua new file mode 100644 index 0000000000..f12aade889 --- /dev/null +++ b/includes/install/scripts/page.lua @@ -0,0 +1,138 @@ +-- page.lua +-- Part of FusionPBX +-- Copyright (C) 2010 Mark J Crane +-- All rights reserved. +-- +-- Redistribution and use in source and binary forms, with or without +-- modification, are permitted provided that the following conditions are met: +-- +-- 1. Redistributions of source code must retain the above copyright notice, +-- this list of conditions and the following disclaimer. +-- +-- 2. Redistributions in binary form must reproduce the above copyright +-- notice, this list of conditions and the following disclaimer in the +-- documentation and/or other materials provided with the distribution. +-- +-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +-- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +-- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +-- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +-- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +-- POSSIBILITY OF SUCH DAMAGE. + +pin_number = ""; +max_tries = "3"; +digit_timeout = "3000"; + +function trim (s) + return (string.gsub(s, "^%s*(.-)%s*$", "%1")) +end + +function explode ( seperator, str ) + local pos, arr = 0, {} + for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found + table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider + pos = sp + 1 -- jump past current divider + end + table.insert( arr, string.sub( str, pos ) ) -- attach chars right of last divider + return arr +end + +if ( session:ready() ) then + session:answer(); + --get the dialplan variables and set them as local variables + destination_number = session:getVariable("destination_number"); + pin_number = session:getVariable("pin_number"); + domain_name = session:getVariable("domain_name"); + sounds_dir = session:getVariable("sounds_dir"); + extension_list = session:getVariable("extension_list"); + caller_id_name = session:getVariable("caller_id_name"); + caller_id_number = session:getVariable("caller_id_number"); + extension_table = explode(",",extension_list); + sip_from_user = session:getVariable("sip_from_user"); + + --set the sounds path for the language, dialect and voice + default_language = session:getVariable("default_language"); + default_dialect = session:getVariable("default_dialect"); + default_voice = session:getVariable("default_voice"); + if (not default_language) then default_language = 'en'; end + if (not default_dialect) then default_dialect = 'us'; end + if (not default_voice) then default_voice = 'callie'; end + + if (caller_id_name) then + --caller id name provided do nothing + else + effective_caller_id_name = session:getVariable("effective_caller_id_name"); + caller_id_number = effective_caller_id_name; + end + + if (caller_id_number) then + --caller id number provided do nothing + else + effective_caller_id_number = session:getVariable("effective_caller_id_number"); + caller_id_number = effective_caller_id_number; + end + + --if the pin number is provided then require it + if (pin_number) then + min_digits = string.len(pin_number); + max_digits = string.len(pin_number)+1; + digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/please_enter_the_pin_number.wav", "", "\\d+"); + if (digits == pin_number) then + --pin is correct + else + session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/your_pin_number_is_incorect_goodbye.wav"); + session:hangup("NORMAL_CLEARING"); + return; + end + end + + api = freeswitch.API(); + for index,value in pairs(extension_table) do + if (string.find(value, "-") == nill) then + value = value..'-'..value; + end + sub_table = explode("-",value); + for extension=sub_table[1],sub_table[2] do + --extension_exists = "username_exists id "..extension.."@"..domain_name; + --reply = trim(api:executeString(extension_exists)); + --if (reply == "true") then + extension_status = "show channels like "..extension.."@"; + reply = trim(api:executeString(extension_status)); + if (reply == "0 total.") then + --freeswitch.consoleLog("NOTICE", "extension "..extension.." available\n"); + if (extension == tonumber(sip_from_user)) then + --this extension is the caller that initated the page + else + --originate the call + cmd_string = "bgapi originate {sip_auto_answer=true,hangup_after_bridge=false,origination_caller_id_name='"..caller_id_name.."',origination_caller_id_number="..caller_id_number.."}user/"..extension.."@"..domain_name.." conference:page-"..destination_number.."@page+flags{mute} inline"; + api:executeString(cmd_string); + end + --freeswitch.consoleLog("NOTICE", "cmd_string "..cmd_string.."\n"); + else + --look inside the reply to check for the correct domain_name + if string.find(reply, domain_name) then + --found: extension number is busy + else + --not found + if (extension == tonumber(sip_from_user)) then + --this extension is the caller that initated the page + else + --originate the call + cmd_string = "bgapi originate {sip_auto_answer=true,hangup_after_bridge=false,origination_caller_id_name='"..caller_id_name.."',origination_caller_id_number="..caller_id_number.."}user/"..extension.."@"..domain_name.." conference:page-"..destination_number.."@page+flags{mute} inline"; + api:executeString(cmd_string); + end + end + end + --end + end + end + + --send main call to the conference room + session:execute("conference", "page-"..destination_number.."@page+flags{endconf}"); + +end \ No newline at end of file diff --git a/includes/install/scripts/park.lua b/includes/install/scripts/park.lua new file mode 100644 index 0000000000..61fba64800 --- /dev/null +++ b/includes/install/scripts/park.lua @@ -0,0 +1,229 @@ +--example usage + --basic + --condition destination_number 5900 + --action set park_extension=5901 + --advanced + --condition destination_number ^59(\d{2})$ + --action set park_extension=$1 + --additional settings + --action set park_range=5 + --action set park_direction=in (in/out/both) + --action set park_announce=true (not implemented yet) + --action set park_timeout_seconds=30 (not implemented yet) + --action set park_timeout_extension=1001 (not implemented yet) + --action set park_music=$${hold_music} + --action lua park.lua + +--connect to the database + --ODBC - data source name + --local dbh = freeswitch.Dbh("name","user","pass"); + --FreeSWITCH core db + local dbh = freeswitch.Dbh("core:park"); + +--get the session variables + sounds_dir = session:getVariable("sounds_dir"); + park_direction = session:getVariable("park_direction"); + uuid = session:getVariable("uuid"); + domain_name = session:getVariable("domain_name"); + park_extension = session:getVariable("park_extension"); + park_range = session:getVariable("park_range"); + park_announce = session:getVariable("park_announce"); + park_timeout_type = session:getVariable("park_timeout_type"); + park_timeout_destination = session:getVariable("park_timeout_destination"); + park_timeout_seconds = session:getVariable("park_timeout_seconds"); + park_music = session:getVariable("park_music"); + +--add the explode function + function explode ( seperator, str ) + local pos, arr = 0, {} + for st, sp in function() return string.find( str, seperator, pos, true ) end do -- for each divider found + table.insert( arr, string.sub( str, pos, st-1 ) ) -- attach chars left of current divider + pos = sp + 1 -- jump past current divider + end + table.insert( arr, string.sub( str, pos ) ) -- attach chars right of last divider + return arr + end + +--add the trim function + function trim(s) + return s:gsub("^%s+", ""):gsub("%s+$", "") + end + +--if park_timeout_seconds is not defined set the timeout to 5 minutes + if (not park_timeout_seconds) then + park_timeout_seconds = 300; + end + +--if park_timeout_type is not defined set to transfer + if (not park_timeout_type) then + park_timeout_type = "transfer"; + end + +--prepare the api + api = freeswitch.API(); + +--answer the call + session:answer(); + +--database + --exits the script if we didn't connect properly + assert(dbh:connected()); + + --create the table if it doesn't exist + --pgsql + dbh:test_reactive("SELECT * FROM park", "", "CREATE TABLE park (id SERIAL, lot TEXT, domain TEXT, uuid TEXT, CONSTRAINT park_pk PRIMARY KEY(id))"); + --sqlite + dbh:test_reactive("SELECT * FROM park", "", "CREATE TABLE park (id INTEGER PRIMARY KEY, lot TEXT, domain TEXT, uuid TEXT)"); + --mysql + dbh:test_reactive("SELECT * FROM park", "", "CREATE TABLE park (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, lot TEXT, domain TEXT, uuid TEXT)"); + + --if park_range is defined then loop through the range to find an available parking lot + if (park_range) then + park_extension_start = park_extension; + park_extension_end = ((park_extension+park_range)-1); + extension = park_extension_start; + while true do + --exit the loop at the end of the range + if (tonumber(extension) > park_extension_end) then + break; + end + --check the database for an available slot + lot_status = "available"; + sql = "SELECT count(*) as count FROM park WHERE lot = '"..extension.."' and domain = '"..domain_name.."' "; + dbh:query(sql, function(result) + --for key, val in pairs(result) do + -- freeswitch.consoleLog("NOTICE", "parking result "..key.." "..val.."\n"); + --end + count = result.count; + end); + --if count is 0 then the parking lot is available end the loop + if (count == "0") then + lot_status = "available"; + park_extension = ""..extension; + break; + end + --increment the value + extension = extension + 1; + end + end + + --check the database to see if the slot is available or unavailable + lot_status = "available"; + sql = "SELECT id, lot, uuid FROM park WHERE lot = '"..park_extension.."' and domain = '"..domain_name.."' "; + dbh:query(sql, function(row) + lot_uuid = row.uuid; + lot_status = "unavailable"; + end); + + --if park direction is set to out then unpark by bridging it to the caller + if (park_direction == "out") then + if (lot_uuid) then + --set the park status + cmd = "uuid_setvar "..lot_uuid.." park_status unparked"; + result = trim(api:executeString(cmd)); + freeswitch.consoleLog("NOTICE", "Park Status: unparked "..park_extension.."\n"); + --unpark the call with bridge + cmd = "uuid_bridge "..uuid.." "..lot_uuid; + result = trim(api:executeString(cmd)); + end + else + --check if the uuid_exists, if it does not exist then delete the uuid from the db and set presence to terminated + if (lot_uuid) then + cmd = "uuid_exists "..lot_uuid; + result = trim(api:executeString(cmd)); + if (result == "false") then + --set presence out + event = freeswitch.Event("PRESENCE_IN"); + event:addHeader("proto", "sip"); + event:addHeader("event_type", "presence"); + event:addHeader("alt_event_type", "dialog"); + event:addHeader("Presence-Call-Direction", "outbound"); + event:addHeader("state", "Active (1 waiting)"); + event:addHeader("from", park_extension.."@"..domain_name); + event:addHeader("login", park_extension.."@"..domain_name); + event:addHeader("unique-id", lot_uuid); + event:addHeader("answer-state", "terminated"); + event:fire(); + + --delete from the database + dbh:query("DELETE from park WHERE lot = '"..park_extension.."' and domain = '"..domain_name.."' "); + --freeswitch.consoleLog("NOTICE", "Park - Affected rows: " .. dbh:affected_rows() .. "\n"); + + --set the status to available + lot_status = "available"; + end + end + + --check if the parking lot is available, if it is then add it to the db, set presenence to confirmed and park the call + if (lot_status == "available") then + --park the call + cmd = "uuid_park "..uuid; + result = trim(api:executeString(cmd)); + if (park_music) then + cmd = "uuid_broadcast "..uuid.." "..park_music.." aleg"; + result = trim(api:executeString(cmd)); + end + + --set the park status + cmd = "uuid_setvar "..uuid.." park_status parked"; + result = trim(api:executeString(cmd)); + freeswitch.consoleLog("NOTICE", "Park Status: parked "..park_extension.."\n"); + + --add to the database + dbh:query("INSERT INTO park (lot, domain, uuid) VALUES('"..park_extension.."', '"..domain_name.."', '"..uuid.."')"); + + --set presence in + event = freeswitch.Event("PRESENCE_IN"); + event:addHeader("proto", "sip"); --park + event:addHeader("login", park_extension.."@"..domain_name); + event:addHeader("from", park_extension.."@"..domain_name); + event:addHeader("status", "Active (1 waiting)"); + event:addHeader("rpid", "unknown"); + event:addHeader("event_type", "presence"); + event:addHeader("alt_event_type", "dialog"); + event:addHeader("event_count", "1"); + event:addHeader("unique-id", uuid); + --event:addHeader("Presence-Call-Direction", "outbound") + event:addHeader("answer-state", "confirmed"); + event:fire(); + + else + --bridge the current call to the call that is parked + --set the presence to terminated + event = freeswitch.Event("PRESENCE_IN"); + event:addHeader("proto", "sip"); + event:addHeader("event_type", "presence"); + event:addHeader("alt_event_type", "dialog"); + event:addHeader("Presence-Call-Direction", "outbound"); + --event:addHeader("state", "Active (1 waiting)"); + event:addHeader("from", park_extension.."@"..domain_name); + event:addHeader("login", park_extension.."@"..domain_name); + event:addHeader("unique-id", uuid); + event:addHeader("answer-state", "terminated"); + event:fire(); + + --delete the lot from the database + dbh:query("DELETE from park WHERE lot = '"..park_extension.."' and domain = '"..domain_name.."' "); + --freeswitch.consoleLog("NOTICE", "Park 200- Affected rows: " .. dbh:affected_rows() .. "\n"); + + --set the park status + cmd = "uuid_setvar "..lot_uuid.." park_status unparked"; + result = trim(api:executeString(cmd)); + freeswitch.consoleLog("NOTICE", "Park Status: unparked "..park_extension.."\n"); + + --connect the calls + cmd = "uuid_bridge "..uuid.." "..lot_uuid; + result = trim(api:executeString(cmd)); + end + + --continue running when the session ends + session:setAutoHangup(false); + + --start the fifo monitor on its own so that it doesn't block the script execution + api = freeswitch.API(); + cmd = "luarun park_monitor.lua "..uuid.." "..domain_name.." "..park_extension.." "..park_timeout_type.." "..park_timeout_seconds.." "..park_timeout_destination; + result = api:executeString(cmd); + end + +--close the database connection + dbh:release(); diff --git a/includes/install/scripts/park_monitor.lua b/includes/install/scripts/park_monitor.lua new file mode 100644 index 0000000000..bac696c243 --- /dev/null +++ b/includes/install/scripts/park_monitor.lua @@ -0,0 +1,149 @@ +--park_monitor.lua + --Date: 4 Oct. 2011 + --Description: + --if the call has been answered + --then send presence terminate, and delete from the database + +--connect to the database + --ODBC - data source name + --local dbh = freeswitch.Dbh("name","user","pass"); + --FreeSWITCH core db + local dbh = freeswitch.Dbh("core:park"); + +--get the argv values + script_name = argv[0]; + uuid = argv[1]; + domain_name = argv[2]; + park_extension = argv[3]; + park_timeout_type = argv[4]; + park_timeout_seconds = argv[5]; + park_timeout_destination = argv[6]; + +--prepare the api + api = freeswitch.API(); + +--add a trim function + function trim (s) + return (string.gsub(s, "^%s*(.-)%s*$", "%1")) + end + +--monitor the parking lot if the call has hungup send a terminated event, and delete from the db + x = 0 + while true do + --sleep a moment to prevent using unecessary resources + freeswitch.msleep(1000); + + if (api:executeString("uuid_exists "..uuid) == "false") then + --set the presence to terminated + event = freeswitch.Event("PRESENCE_IN"); + event:addHeader("proto", "sip"); + event:addHeader("event_type", "presence"); + event:addHeader("alt_event_type", "dialog"); + event:addHeader("Presence-Call-Direction", "outbound"); + event:addHeader("state", "Active (1 waiting)"); + event:addHeader("from", park_extension.."@"..domain_name); + event:addHeader("login", park_extension.."@"..domain_name); + event:addHeader("unique-id", uuid); + event:addHeader("answer-state", "terminated"); + event:fire(); + + --set the park status + cmd = "uuid_setvar "..uuid.." park_status cancelled"; + result = trim(api:executeString(cmd)); + freeswitch.consoleLog("NOTICE", "Park Status: cancelled\n"); + + --delete the lot from the database + dbh:query("DELETE from park WHERE lot = '"..park_extension.."' and domain = '"..domain_name.."' "); + + + --end the loop + break; + else + cmd = "uuid_getvar "..uuid.." park_status"; + result = trim(api:executeString(cmd)); + --freeswitch.consoleLog("notice", "" .. result .. "\n"); + if (result == "parked") then --_undef_ + --set presence in + event = freeswitch.Event("PRESENCE_IN"); + event:addHeader("proto", "sip"); --park + event:addHeader("login", park_extension.."@"..domain_name); + event:addHeader("from", park_extension.."@"..domain_name); + event:addHeader("status", "Active (1 waiting)"); + event:addHeader("rpid", "unknown"); + event:addHeader("event_type", "presence"); + event:addHeader("alt_event_type", "dialog"); + event:addHeader("event_count", "1"); + event:addHeader("unique-id", uuid); + --event:addHeader("Presence-Call-Direction", "outbound") + event:addHeader("answer-state", "confirmed"); + event:fire(); + else + --set the presence to terminated + event = freeswitch.Event("PRESENCE_IN"); + event:addHeader("proto", "sip"); + event:addHeader("event_type", "presence"); + event:addHeader("alt_event_type", "dialog"); + event:addHeader("Presence-Call-Direction", "outbound"); + event:addHeader("state", "Active (1 waiting)"); + event:addHeader("from", park_extension.."@"..domain_name); + event:addHeader("login", park_extension.."@"..domain_name); + event:addHeader("unique-id", uuid); + event:addHeader("answer-state", "terminated"); + event:fire(); + + --delete the lot from the database + dbh:query("DELETE from park WHERE lot = '"..park_extension.."' and domain = '"..domain_name.."' "); + --freeswitch.consoleLog("NOTICE", "Affected rows: park ext "..park_extension.." " .. dbh:affected_rows() .. "\n"); + + --set the park status + cmd = "uuid_setvar "..uuid.." park_status unparked"; + result = trim(api:executeString(cmd)); + freeswitch.consoleLog("NOTICE", "Park Status: unparked "..park_extension.."\n"); + + --end the loop + break; + end + end + + --limit the monitor to watching 60 seconds + x = x + 1; + if (x > tonumber(park_timeout_seconds)) then + --set the presence to terminated + event = freeswitch.Event("PRESENCE_IN"); + event:addHeader("proto", "sip"); + event:addHeader("event_type", "presence"); + event:addHeader("alt_event_type", "dialog"); + event:addHeader("Presence-Call-Direction", "outbound"); + event:addHeader("state", "Active (1 waiting)"); + event:addHeader("from", park_extension.."@"..domain_name); + event:addHeader("login", park_extension.."@"..domain_name); + event:addHeader("unique-id", uuid); + event:addHeader("answer-state", "terminated"); + event:fire(); + + --delete the lot from the database + dbh:query("DELETE from park WHERE lot = '"..park_extension.."' and domain = '"..domain_name.."' "); + + --set the park status + cmd = "uuid_setvar "..uuid.." park_status timeout"; + result = trim(api:executeString(cmd)); + freeswitch.consoleLog("NOTICE", "Park Status: timeout\n"); + + --end the loop + break; + end + + end + + --if the timeout was reached transfer the call + cmd = "uuid_getvar "..uuid.." park_status"; + park_status = trim(api:executeString(cmd)); + if (park_timeout_type == "transfer" and park_status == "timeout") then + --set the park status + cmd = "uuid_setvar "..uuid.." park_status unparked"; + result = trim(api:executeString(cmd)); + freeswitch.consoleLog("NOTICE", "Park Status: unparked\n"); + --transfer the call when it has timed out + cmd = "uuid_transfer "..uuid.." "..park_timeout_destination; + result = trim(api:executeString(cmd)); + end diff --git a/includes/install/scripts/pin_number.lua b/includes/install/scripts/pin_number.lua new file mode 100644 index 0000000000..d28f51b745 --- /dev/null +++ b/includes/install/scripts/pin_number.lua @@ -0,0 +1,54 @@ +-- +-- FusionPBX +-- Version: MPL 1.1 +-- +-- The contents of this file are subject to the Mozilla Public License Version +-- 1.1 (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- http://www.mozilla.org/MPL/ +-- +-- Software distributed under the License is distributed on an "AS IS" basis, +-- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +-- for the specific language governing rights and limitations under the +-- License. +-- +-- The Original Code is FusionPBX +-- +-- The Initial Developer of the Original Code is +-- Mark J Crane +-- Copyright (C) 2010 +-- the Initial Developer. All Rights Reserved. +-- +-- Contributor(s): +-- Mark J Crane + +max_tries = "3"; +digit_timeout = "5000"; + +if ( session:ready() ) then + session:answer( ); + pin_number = session:getVariable("pin_number"); + sounds_dir = session:getVariable("sounds_dir"); + + --set the sounds path for the language, dialect and voice + default_language = session:getVariable("default_language"); + default_dialect = session:getVariable("default_dialect"); + default_voice = session:getVariable("default_voice"); + if (not default_language) then default_language = 'en'; end + if (not default_dialect) then default_dialect = 'us'; end + if (not default_voice) then default_voice = 'callie'; end + + --if the pin number is provided then require it + if (pin_number) then + min_digits = string.len(pin_number); + max_digits = string.len(pin_number)+1; + digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/please_enter_the_pin_number.wav", "", "\\d+"); + if (digits == pin_number) then + --pin is correct + else + session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/your_pin_number_is_incorect_goodbye.wav"); + session:hangup("NORMAL_CLEARING"); + return; + end + end +end diff --git a/includes/install/scripts/recordings.lua b/includes/install/scripts/recordings.lua new file mode 100644 index 0000000000..c678139e3a --- /dev/null +++ b/includes/install/scripts/recordings.lua @@ -0,0 +1,162 @@ +-- +-- FusionPBX +-- Version: MPL 1.1 +-- +-- The contents of this file are subject to the Mozilla Public License Version +-- 1.1 (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- http://www.mozilla.org/MPL/ +-- +-- Software distributed under the License is distributed on an "AS IS" basis, +-- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +-- for the specific language governing rights and limitations under the +-- License. +-- +-- The Original Code is FusionPBX +-- +-- The Initial Developer of the Original Code is +-- Mark J Crane +-- Copyright (C) 2010 +-- the Initial Developer. All Rights Reserved. +-- +-- Contributor(s): +-- Mark J Crane + +pin_number = ""; +max_tries = "3"; +digit_timeout = "3000"; +sounds_dir = ""; +recordings_dir = ""; +file_name = ""; +recording_number = ""; +recording_slots = ""; +recording_prefix = ""; + +--dtmf call back function detects the "#" and ends the call + function onInput(s, type, obj) + if (type == "dtmf" and obj['digit'] == '#') then + return "break"; + end + end + +--start the recording + function begin_record(session, sounds_dir, recordings_dir) + + --set the sounds path for the language, dialect and voice + default_language = session:getVariable("default_language"); + default_dialect = session:getVariable("default_dialect"); + default_voice = session:getVariable("default_voice"); + if (not default_language) then default_language = 'en'; end + if (not default_dialect) then default_dialect = 'us'; end + if (not default_voice) then default_voice = 'callie'; end + recording_slots = session:getVariable("recording_slots"); + recording_prefix = session:getVariable("recording_prefix"); + recording_name = session:getVariable("recording_name"); + + --select the recording number + if (recording_slots) then + min_digits = 1; + max_digits = 20; + recording_number = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/please_enter_the_recording_number.wav", "", "\\d+"); + recording_name = recording_prefix..recording_number..".wav"; + end + + --set the default recording name if one was not provided + if (recording_name) then + --recording name is provided do nothing + else + --set a default recording_name + recording_name = "temp_"..session:get_uuid()..".wav"; + end + + --prompt for the recording + session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/begin_recording.wav"); + session:execute("set", "playback_terminators=#"); + + --begin recording + session:execute("record", recordings_dir.."/"..recording_name.." 180 200"); + + --preview the recording + session:streamFile(recordings_dir.."/"..recording_name); + + --approve the recording, to save the recording press 1 to re-record press 2 + min_digits="0" max_digits="1" max_tries = "1"; digit_timeout = "100"; + digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "voicemail/vm-save_recording.wav", "", "\\d+"); + + if (string.len(digits) == 0) then + min_digits="0" max_digits="1" max_tries = "1"; digit_timeout = "100"; + digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "voicemail/vm-press.wav", "", "\\d+"); + end + + if (string.len(digits) == 0) then + min_digits="0" max_digits="1" max_tries = "1"; digit_timeout = "100"; + digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "digits/1.wav", "", "\\d+"); + end + + if (string.len(digits) == 0) then + min_digits="0" max_digits="1" max_tries = "1"; digit_timeout = "100"; + digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "voicemail/vm-rerecord.wav", "", "\\d+"); + end + + if (string.len(digits) == 0) then + min_digits="0" max_digits="1" max_tries = "1"; digit_timeout = "100"; + digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "voicemail/vm-press.wav", "", "\\d+"); + end + + if (string.len(digits) == 0) then + min_digits="1" max_digits="1" max_tries = "1"; digit_timeout = "5000"; + digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "digits/2.wav", "", "\\d+"); + end + + if (digits == "1") then + --recording saved, hangup + session:streamFile("voicemail/vm-saved.wav"); + return; + elseif (digits == "2") then + --delete the old recording + os.remove (recordings_dir.."/"..recording_name); + --session:execute("system", "rm "..); + --make a new recording + begin_record(session, sounds_dir, recordings_dir); + else + --recording saved, hangup + session:streamFile("voicemail/vm-saved.wav"); + return; + end + end + +if ( session:ready() ) then + session:answer(); + + --get the dialplan variables and set them as local variables + pin_number = session:getVariable("pin_number"); + sounds_dir = session:getVariable("sounds_dir"); + recordings_dir = session:getVariable("recordings_dir"); + + --set the sounds path for the language, dialect and voice + default_language = session:getVariable("default_language"); + default_dialect = session:getVariable("default_dialect"); + default_voice = session:getVariable("default_voice"); + if (not default_language) then default_language = 'en'; end + if (not default_dialect) then default_dialect = 'us'; end + if (not default_voice) then default_voice = 'callie'; end + + --if the pin number is provided then require it + if (pin_number) then + min_digits = string.len(pin_number); + max_digits = string.len(pin_number)+1; + digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/please_enter_the_pin_number.wav", "", "\\d+"); + if (digits == pin_number) then + --pin is correct + else + session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/your_pin_number_is_incorect_goodbye.wav"); + session:hangup("NORMAL_CLEARING"); + return; + end + end + + --start recording + begin_record(session, sounds_dir, recordings_dir); + + session:hangup(); +end diff --git a/includes/install/scripts/ring_group.lua b/includes/install/scripts/ring_group.lua new file mode 100644 index 0000000000..09109eb41e --- /dev/null +++ b/includes/install/scripts/ring_group.lua @@ -0,0 +1,98 @@ +-- intercom.lua +-- Part of FusionPBX +-- Copyright (C) 2010 Mark J Crane +-- All rights reserved. +-- +-- Redistribution and use in source and binary forms, with or without +-- modification, are permitted provided that the following conditions are met: +-- +-- 1. Redistributions of source code must retain the above copyright notice, +-- this list of conditions and the following disclaimer. +-- +-- 2. Redistributions in binary form must reproduce the above copyright +-- notice, this list of conditions and the following disclaimer in the +-- documentation and/or other materials provided with the distribution. +-- +-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +-- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +-- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +-- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +-- OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +-- POSSIBILITY OF SUCH DAMAGE. + +--include the lua script + scripts_dir = string.sub(debug.getinfo(1).source,2,string.len(debug.getinfo(1).source)-(string.len(argv[0])+1)); + include = assert(loadfile(scripts_dir .. "/resources/config.lua")); + include(); + +--connect to the database + --ODBC - data source name + if (dsn_name) then + dbh = freeswitch.Dbh(dsn_name,dsn_username,dsn_password); + end + --FreeSWITCH core db handler + if (db_type == "sqlite") then + dbh = freeswitch.Dbh("core:"..db_path.."/"..db_name); + end + +--get the variables + domain_name = session:getVariable("domain_name"); + ring_group_uuid = session:getVariable("ring_group_uuid"); + +--get the extension list + sql = + [[ SELECT g.ring_group_extension_uuid, e.extension_uuid, e.extension, + r.ring_group_strategy, r.ring_group_timeout_sec, r.ring_group_timeout_app, r.ring_group_timeout_data + FROM v_ring_groups as r, v_ring_group_extensions as g, v_extensions as e + where g.ring_group_uuid = r.ring_group_uuid + and g.ring_group_uuid = ']]..ring_group_uuid..[[' + and e.extension_uuid = g.extension_uuid + and r.ring_group_enabled = 'true' + order by e.extension asc ]] + --freeswitch.consoleLog("notice", "SQL:" .. sql .. "\n"); + app_data = ""; + + x = 0; + dbh:query(sql, function(row) + ring_group_timeout_sec = row.ring_group_timeout_sec; + ring_group_timeout_app = row.ring_group_timeout_app; + ring_group_timeout_data = row.ring_group_timeout_data; + if (row.ring_group_strategy == "sequence") then + delimiter = "|"; + end + if (row.ring_group_strategy == "simultaneous") then + delimiter = ","; + end + if (x == 0) then + app_data = "[leg_timeout="..ring_group_timeout_sec.."]user/" .. row.extension .. "@" .. domain_name; + else + app_data = app_data .. delimiter .. "[leg_timeout="..ring_group_timeout_sec.."]user/" .. row.extension .. "@" .. domain_name; + end + x = x + 1; + end); + +--close the database connection + dbh:release(); + +--app_data + --freeswitch.consoleLog("notice", "Debug:\n" .. app_data .. "\n"); + +--session actions + if (session:ready()) then + session:answer(); + session:execute("set", "hangup_after_bridge=true"); + session:execute("set", "continue_on_fail=true"); + session:execute("bridge", app_data); + session:execute(ring_group_timeout_app, ring_group_timeout_data); + end + +--actions + --ACTIONS = {} + --table.insert(ACTIONS, {"set", "hangup_after_bridge=true"}); + --table.insert(ACTIONS, {"set", "continue_on_fail=true"}); + --table.insert(ACTIONS, {"bridge", app_data}); + --table.insert(ACTIONS, {ring_group_timeout_app, ring_group_timeout_data}); diff --git a/includes/install/scripts/roku.lua b/includes/install/scripts/roku.lua new file mode 100644 index 0000000000..310fbf3f3a --- /dev/null +++ b/includes/install/scripts/roku.lua @@ -0,0 +1,91 @@ +-- +-- FusionPBX +-- Version: MPL 1.1 +-- +-- The contents of this file are subject to the Mozilla Public License Version +-- 1.1 (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- http://www.mozilla.org/MPL/ +-- +-- Software distributed under the License is distributed on an "AS IS" basis, +-- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +-- for the specific language governing rights and limitations under the +-- License. +-- +-- The Original Code is FusionPBX +-- +-- The Initial Developer of the Original Code is +-- Mark J Crane +-- Copyright (C) 2010 +-- the Initial Developer. All Rights Reserved. +-- +-- Contributor(s): +-- Mark J Crane + +predefined_destination = ""; +max_tries = "3"; +digit_timeout = "5000"; +port = "8080"; + +if ( session:ready() ) then + session:answer( ); + pin_number = session:getVariable("pin_number"); + sounds_dir = session:getVariable("sounds_dir"); + host = session:getVariable("host"); + + --set the sounds path for the language, dialect and voice + default_language = session:getVariable("default_language"); + default_dialect = session:getVariable("default_dialect"); + default_voice = session:getVariable("default_voice"); + if (default_language) then else default_language = 'en'; end + if (default_dialect) then else default_dialect = 'us'; end + if (default_voice) then else default_voice = 'callie'; end + + digitmaxlength = 0; + timeoutpin = 7500; + timeouttransfer = 7500; + + --if the pin number is provided then require it + if (pin_number) then + min_digits = string.len(pin_number); + max_digits = string.len(pin_number)+1; + digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/please_enter_the_pin_number.wav", "", "\\d+"); + if (digits == pin_number) then + --pin is correct + digits = ""; + else + session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/your_pin_number_is_incorect_goodbye.wav"); + session:hangup("NORMAL_CLEARING"); + return; + end + end + + if (session:ready()) then + session:answer(); + min_digits = 1; + max_digits = 1; + digitmaxlength = 1; + digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/custom/please_enter_the_phone_number.wav", "", "\\d+"); + + x = 0; + while (session:ready() == true) do + if (string.len(digits) == 0) then + --getDigits(length, terminators, timeout, digit_timeout, abs_timeout) + digits = session:getDigits(1, "#", 40000); + end + if (string.len(digits) > 0) then + --press star to exit + if (digits == "*") then + break; + end + --send the command to php + session:execute("system","/usr/local/bin/php /usr/local/www/fusionpbx/mod/roku/roku.php "..digits.." "..host.." "..port); + end + digits = ""; + if (x > 17500) then + break; + end + end + session:hangup("NORMAL_CLEARING"); + end +end \ No newline at end of file diff --git a/includes/install/scripts/wakeup.lua b/includes/install/scripts/wakeup.lua new file mode 100644 index 0000000000..ec14e7cf89 --- /dev/null +++ b/includes/install/scripts/wakeup.lua @@ -0,0 +1,203 @@ +-- +-- FusionPBX +-- Version: MPL 1.1 +-- +-- The contents of this file are subject to the Mozilla Public License Version +-- 1.1 (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- http://www.mozilla.org/MPL/ +-- +-- Software distributed under the License is distributed on an "AS IS" basis, +-- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +-- for the specific language governing rights and limitations under the +-- License. +-- +-- The Original Code is FusionPBX +-- +-- The Initial Developer of the Original Code is +-- Mark J Crane +-- Copyright (C) 2010 +-- the Initial Developer. All Rights Reserved. +-- +-- Contributor(s): +-- Mark J Crane + +--get the argv values + script_name = argv[0]; + domain_name = argv[1]; + wakeup_number = argv[2]; + +--add the trim function + function trim(s) + return s:gsub("^%s+", ""):gsub("%s+$", "") + end + +--add is_numeric + function is_numeric(text) + if type(text)~="string" and type(text)~="number" then return false end + return tonumber(text) and true or false + end + +--set the default values for the variables + pin_number = ""; + max_tries = "3"; + digit_timeout = "3000"; + sounds_dir = ""; + extension_type = ""; --number,caller_id_number,prompt + extension_number = ""; + +if (wakeup_number) then + --begin the wakeup call + if ( session:ready() ) then + --prepare the api object + api = freeswitch.API(); + + --set session settings + session:answer(); + session:setAutoHangup(false); + + --wakeup confirm press 1 to 3 + min_digits = 1; + max_digits = 1; + digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:wakeup-call", "", "\\d+"); + + --reschedule the call for snooze + if (digits == "2") then + freeswitch.consoleLog("NOTICE", "wakeup call: snooze selected - rescheduled the call\n"); + api = freeswitch.API(); + caller_id_name = "wakeup call"; + caller_id_number = wakeup_number; + sched_api_time = "600"; + cmd_string = "sched_api +"..sched_api_time.." wakeup-call-"..wakeup_number.." originate {hangup_after_bridge=false,origination_caller_id_name='"..caller_id_name.."',origination_caller_id_number="..caller_id_number.."}user/"..wakeup_number.."@"..domain_name.." &lua('wakeup.lua "..domain_name.." "..wakeup_number.."') "; + freeswitch.consoleLog("NOTICE", "wakeup: "..cmd_string.."\n"); + reply = api:executeString(cmd_string); + end + end +else + --prompt for the wakeup call information + + if ( session:ready() ) then + session:answer(); + session:setAutoHangup(false); + + --get the dialplan variables and set them as local variables + sounds_dir = session:getVariable("sounds_dir"); + domain_name = session:getVariable("domain_name"); + extension_number = session:getVariable("extension_number"); + extension_type = session:getVariable("extension_type"); + time_zone_offset = session:getVariable("time_zone_offset"); + sip_number_alias = session:getVariable("sip_number_alias"); + sip_from_user = session:getVariable("sip_from_user"); + if (is_numeric(sip_number_alias)) then + wakeup_number = sip_number_alias; + else + wakeup_number = sip_from_user; + end + + --get the extension number + if (extension_type == "prompt") then + min_digits = 1; + max_digits = 11; + wakeup_time = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:wakeup-get-extension", "", "\\d+"); + end + + --get the wakeup time + min_digits = 4; + max_digits = 4; + wakeup_time = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:wakeup-greeting", "", "\\d+"); + freeswitch.consoleLog("NOTICE", "wakeup time: "..wakeup_time.."\n"); + + --get the current time + current_hours = tonumber(os.date("%H")); + current_minutes = tonumber(os.date("%M")); + current_seconds = tonumber(os.date("%S")); + + --adjust the time zone offset + if (time_zone_offset) then + current_hours = time_zone_offset + current_hours; + if (current_hours < 0) then + current_hours = current_hours + 24; + end + if (current_hours > 23) then + current_hours = current_hours - 24; + end + end + + --show the current hours minutes and seconds to the log + --freeswitch.consoleLog("NOTICE", "Hours: " .. current_hours .. "\n"); + --freeswitch.consoleLog("NOTICE", "Mins: " .. current_minutes .. "\n"); + --freeswitch.consoleLog("NOTICE", "Seconds: " .. current_seconds .. "\n"); + + --prepare the current time + current_time = (current_hours * 100) + current_minutes; + + --get the wakeup hours and minutes + wakeup_hours = string.sub(wakeup_time, 1, 2); + wakeup_minutes = string.sub(wakeup_time, 3); + + --show the wakeup time, hours, and minutes to the log + --freeswitch.consoleLog("NOTICE", "wakeup_time "..wakeup_time.."\n"); + --freeswitch.consoleLog("NOTICE", "wakeup_hours "..wakeup_hours.."\n"); + --freeswitch.consoleLog("NOTICE", "wakeup_minutes "..wakeup_minutes.."\n"); + + --convert the time, hours and minutes to numbers + wakeup_time = tonumber(wakeup_time); + wakeup_hours = tonumber(wakeup_hours); + wakeup_minutes = tonumber(wakeup_minutes); + if (current_time > wakeup_time) then + --get the current_time_in_seconds + current_time_in_seconds = (current_hours * 3600) + (current_minutes * 60); + --freeswitch.consoleLog("NOTICE", "sched_api_time = ("..current_hours.." * 3600) + ("..current_minutes.." * 60)\n"); + --get the seconds until midnight + seconds_until_midnight = (24 * 3600) - current_time_in_seconds; + --freeswitch.consoleLog("NOTICE", "sched_api_time = (24 * 3600) - "..current_time_in_seconds.."\n"); + --get the wakeup_time_in_seconds + wakeup_time_in_seconds = (wakeup_hours * 3600) + (wakeup_minutes * 60); + --freeswitch.consoleLog("NOTICE", "sched_api_time = ("..wakeup_hours.." * 3600) + ("..wakeup_minutes.." * 60)\n"); + --add the seconds_until_midnight to the wakeup_time_in_seconds + sched_api_time = wakeup_time_in_seconds + seconds_until_midnight; + --freeswitch.consoleLog("NOTICE", "sched_api_time = "..wakeup_time_in_seconds.." + "..seconds_until_midnight.."\n"); + else + --get the current_time_in_seconds + current_time_in_seconds = (current_hours * 3600) + (current_minutes * 60); + --freeswitch.consoleLog("NOTICE", "current_time_in_seconds = ("..current_hours.." * 3600) + ("..current_minutes.." * 60);\n"); + --get the wakeup_time_in_seconds + wakeup_time_in_seconds = (wakeup_hours * 3600) + (wakeup_minutes * 60); + --freeswitch.consoleLog("NOTICE", "wakeup_time_in_seconds = ("..wakeup_hours.." * 3600) + ("..wakeup_minutes.." * 60);\n"); + --subtract the current time from wakeup_time_in_seconds + sched_api_time = wakeup_time_in_seconds - current_time_in_seconds; + --freeswitch.consoleLog("NOTICE", "sched_api_time = "..wakeup_time_in_seconds.." - "..current_time_in_seconds.."\n"); + end + --freeswitch.consoleLog("NOTICE", "sched_api_time "..sched_api_time.."\n"); + + --wakeup call has been scheduled + session:streamFile("phrase:wakeup-scheduled"); + session:say(wakeup_time, "en", "number", "ITERATED"); + + --wakeup confirm press 1 to 3 + min_digits = 1; + max_digits = 1; + wakeup_accept = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:wakeup-accept", "", "\\d+"); + --accept + if (wakeup_accept == "1") then + --send a message to the console + freeswitch.consoleLog("NOTICE", "wakeup: accepted\n"); + --schedule the wakeup call + caller_id_name = "wakeup call"; + caller_id_number = wakeup_number; + cmd_string = "sched_api +"..sched_api_time.." wakeup-call-"..wakeup_number.." originate {hangup_after_bridge=false,origination_caller_id_name='"..caller_id_name.."',origination_caller_id_number="..caller_id_number.."}user/"..wakeup_number.."@"..domain_name.." &lua('wakeup.lua "..domain_name.." "..wakeup_number.."') "; + freeswitch.consoleLog("NOTICE", "wakeup: "..cmd_string.."\n"); + api = freeswitch.API(); + reply = api:executeString(cmd_string); + --hangup + session:hangup(); + end + --cancel + if (wakeup_accept == "2") then + --send a message to the console + freeswitch.consoleLog("NOTICE", "wakeup: cancelled\n"); + --hangup + session:hangup(); + end + end +end \ No newline at end of file diff --git a/includes/install/sounds/en/us/callie/custom/16000/4.wav b/includes/install/sounds/en/us/callie/custom/16000/4.wav new file mode 100644 index 0000000000..696b20ec98 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/4.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/a.wav b/includes/install/sounds/en/us/callie/custom/16000/a.wav new file mode 100644 index 0000000000..14137b3a43 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/a.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/accept.wav b/includes/install/sounds/en/us/callie/custom/16000/accept.wav new file mode 100644 index 0000000000..5cec9cedd0 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/accept.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/and.wav b/includes/install/sounds/en/us/callie/custom/16000/and.wav new file mode 100644 index 0000000000..3245d35cab Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/and.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/been.wav b/includes/install/sounds/en/us/callie/custom/16000/been.wav new file mode 100644 index 0000000000..1e5d709dd0 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/been.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/begin.wav b/includes/install/sounds/en/us/callie/custom/16000/begin.wav new file mode 100644 index 0000000000..cc8571670b Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/begin.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/begin_recording.wav b/includes/install/sounds/en/us/callie/custom/16000/begin_recording.wav new file mode 100644 index 0000000000..9ec5fd95e6 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/begin_recording.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/call.wav b/includes/install/sounds/en/us/callie/custom/16000/call.wav new file mode 100644 index 0000000000..d2d07cd938 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/call.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/call_forward_has_been_deleted.wav b/includes/install/sounds/en/us/callie/custom/16000/call_forward_has_been_deleted.wav new file mode 100644 index 0000000000..7833436289 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/call_forward_has_been_deleted.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/call_forward_has_been_set.wav b/includes/install/sounds/en/us/callie/custom/16000/call_forward_has_been_set.wav new file mode 100644 index 0000000000..f6477e1f82 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/call_forward_has_been_set.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/calling.wav b/includes/install/sounds/en/us/callie/custom/16000/calling.wav new file mode 100644 index 0000000000..4970bbd267 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/calling.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/cancel.wav b/includes/install/sounds/en/us/callie/custom/16000/cancel.wav new file mode 100644 index 0000000000..ee465f99c9 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/cancel.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/delete.wav b/includes/install/sounds/en/us/callie/custom/16000/delete.wav new file mode 100644 index 0000000000..0484d530a5 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/delete.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/digit.wav b/includes/install/sounds/en/us/callie/custom/16000/digit.wav new file mode 100644 index 0000000000..720f5d4494 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/digit.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/digits.wav b/includes/install/sounds/en/us/callie/custom/16000/digits.wav new file mode 100644 index 0000000000..6cd7a654f7 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/digits.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/enter.wav b/includes/install/sounds/en/us/callie/custom/16000/enter.wav new file mode 100644 index 0000000000..3e7022b94e Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/enter.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/exit.wav b/includes/install/sounds/en/us/callie/custom/16000/exit.wav new file mode 100644 index 0000000000..7175ab8a3b Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/exit.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/extension.wav b/includes/install/sounds/en/us/callie/custom/16000/extension.wav new file mode 100644 index 0000000000..2a11139f89 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/extension.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/followme_menu.wav b/includes/install/sounds/en/us/callie/custom/16000/followme_menu.wav new file mode 100644 index 0000000000..1414b2c862 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/followme_menu.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/for.wav b/includes/install/sounds/en/us/callie/custom/16000/for.wav new file mode 100644 index 0000000000..696b20ec98 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/for.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/forward.wav b/includes/install/sounds/en/us/callie/custom/16000/forward.wav new file mode 100644 index 0000000000..2f25e71eca Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/forward.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/goodbye.wav b/includes/install/sounds/en/us/callie/custom/16000/goodbye.wav new file mode 100644 index 0000000000..8370de1f1e Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/goodbye.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/has.wav b/includes/install/sounds/en/us/callie/custom/16000/has.wav new file mode 100644 index 0000000000..f3f6aaead2 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/has.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/hours.wav b/includes/install/sounds/en/us/callie/custom/16000/hours.wav new file mode 100644 index 0000000000..f26174f353 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/hours.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/incorrect.wav b/includes/install/sounds/en/us/callie/custom/16000/incorrect.wav new file mode 100644 index 0000000000..fa6c360c23 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/incorrect.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/is.wav b/includes/install/sounds/en/us/callie/custom/16000/is.wav new file mode 100644 index 0000000000..724bc65412 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/is.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/m.wav b/includes/install/sounds/en/us/callie/custom/16000/m.wav new file mode 100644 index 0000000000..80679aefbb Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/m.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/minutes.wav b/includes/install/sounds/en/us/callie/custom/16000/minutes.wav new file mode 100644 index 0000000000..583d442888 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/minutes.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/name.wav b/includes/install/sounds/en/us/callie/custom/16000/name.wav new file mode 100644 index 0000000000..09b8081a26 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/name.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/new.wav b/includes/install/sounds/en/us/callie/custom/16000/new.wav new file mode 100644 index 0000000000..26857c8dc2 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/new.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/now.wav b/includes/install/sounds/en/us/callie/custom/16000/now.wav new file mode 100644 index 0000000000..8309ab1e67 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/now.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/number.wav b/includes/install/sounds/en/us/callie/custom/16000/number.wav new file mode 100644 index 0000000000..a5097ca53b Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/number.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/or.wav b/includes/install/sounds/en/us/callie/custom/16000/or.wav new file mode 100644 index 0000000000..9ead188e39 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/or.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/p.wav b/includes/install/sounds/en/us/callie/custom/16000/p.wav new file mode 100644 index 0000000000..96a4c64973 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/p.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/pin.wav b/includes/install/sounds/en/us/callie/custom/16000/pin.wav new file mode 100644 index 0000000000..1797a5fbd9 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/pin.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/please.wav b/includes/install/sounds/en/us/callie/custom/16000/please.wav new file mode 100644 index 0000000000..493c2c61e2 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/please.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/please_enter_the_extension_number.wav b/includes/install/sounds/en/us/callie/custom/16000/please_enter_the_extension_number.wav new file mode 100644 index 0000000000..f8cfe9f7ae Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/please_enter_the_extension_number.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/please_enter_the_phone_number.wav b/includes/install/sounds/en/us/callie/custom/16000/please_enter_the_phone_number.wav new file mode 100644 index 0000000000..cb9f087422 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/please_enter_the_phone_number.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/please_enter_the_pin_number.wav b/includes/install/sounds/en/us/callie/custom/16000/please_enter_the_pin_number.wav new file mode 100644 index 0000000000..8c47cb4f53 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/please_enter_the_pin_number.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/please_enter_the_recording_number.wav b/includes/install/sounds/en/us/callie/custom/16000/please_enter_the_recording_number.wav new file mode 100644 index 0000000000..bf3864cfe7 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/please_enter_the_recording_number.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/please_enter_your_pin_number.wav b/includes/install/sounds/en/us/callie/custom/16000/please_enter_your_pin_number.wav new file mode 100644 index 0000000000..24a881c9ee Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/please_enter_your_pin_number.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/please_say_your_name_and_reason_for_calling.wav b/includes/install/sounds/en/us/callie/custom/16000/please_say_your_name_and_reason_for_calling.wav new file mode 100644 index 0000000000..1f716203b7 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/please_say_your_name_and_reason_for_calling.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/press.wav b/includes/install/sounds/en/us/callie/custom/16000/press.wav new file mode 100644 index 0000000000..f67b0818be Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/press.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/press_1_to_accept_2_to_reject_or_3_for_voicemail.wav b/includes/install/sounds/en/us/callie/custom/16000/press_1_to_accept_2_to_reject_or_3_for_voicemail.wav new file mode 100644 index 0000000000..395c79bbcc Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/press_1_to_accept_2_to_reject_or_3_for_voicemail.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/press_1_to_accept_this_call.wav b/includes/install/sounds/en/us/callie/custom/16000/press_1_to_accept_this_call.wav new file mode 100644 index 0000000000..7fc252ffa0 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/press_1_to_accept_this_call.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/reason.wav b/includes/install/sounds/en/us/callie/custom/16000/reason.wav new file mode 100644 index 0000000000..717136a58d Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/reason.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/recording.wav b/includes/install/sounds/en/us/callie/custom/16000/recording.wav new file mode 100644 index 0000000000..bd64c72dae Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/recording.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/reject.wav b/includes/install/sounds/en/us/callie/custom/16000/reject.wav new file mode 100644 index 0000000000..40e1a562aa Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/reject.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/say.wav b/includes/install/sounds/en/us/callie/custom/16000/say.wav new file mode 100644 index 0000000000..1f02f44d00 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/say.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/schedule.wav b/includes/install/sounds/en/us/callie/custom/16000/schedule.wav new file mode 100644 index 0000000000..eccf353f9a Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/schedule.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/scheduled.wav b/includes/install/sounds/en/us/callie/custom/16000/scheduled.wav new file mode 100644 index 0000000000..b84ea80a7b Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/scheduled.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/set.wav b/includes/install/sounds/en/us/callie/custom/16000/set.wav new file mode 100644 index 0000000000..815640109f Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/set.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/snooze.wav b/includes/install/sounds/en/us/callie/custom/16000/snooze.wav new file mode 100644 index 0000000000..19ad1c21a7 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/snooze.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/the.wav b/includes/install/sounds/en/us/callie/custom/16000/the.wav new file mode 100644 index 0000000000..353e3be634 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/the.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/this.wav b/includes/install/sounds/en/us/callie/custom/16000/this.wav new file mode 100644 index 0000000000..16571aa861 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/this.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/time.wav b/includes/install/sounds/en/us/callie/custom/16000/time.wav new file mode 100644 index 0000000000..cf2255e2c6 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/time.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/to.wav b/includes/install/sounds/en/us/callie/custom/16000/to.wav new file mode 100644 index 0000000000..f82981b6ba Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/to.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/voicemail.wav b/includes/install/sounds/en/us/callie/custom/16000/voicemail.wav new file mode 100644 index 0000000000..53c6eb2d88 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/voicemail.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/wakeup.wav b/includes/install/sounds/en/us/callie/custom/16000/wakeup.wav new file mode 100644 index 0000000000..94d0e57853 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/wakeup.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/your.wav b/includes/install/sounds/en/us/callie/custom/16000/your.wav new file mode 100644 index 0000000000..a8e9f7f2bb Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/your.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/16000/your_pin_number_is_incorect_goodbye.wav b/includes/install/sounds/en/us/callie/custom/16000/your_pin_number_is_incorect_goodbye.wav new file mode 100644 index 0000000000..80d49558a5 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/16000/your_pin_number_is_incorect_goodbye.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/4.wav b/includes/install/sounds/en/us/callie/custom/8000/4.wav new file mode 100644 index 0000000000..5560e35476 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/4.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/a.wav b/includes/install/sounds/en/us/callie/custom/8000/a.wav new file mode 100644 index 0000000000..75b6a753ff Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/a.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/accept.wav b/includes/install/sounds/en/us/callie/custom/8000/accept.wav new file mode 100644 index 0000000000..32f638d5c3 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/accept.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/and.wav b/includes/install/sounds/en/us/callie/custom/8000/and.wav new file mode 100644 index 0000000000..14a353ac1b Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/and.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/been.wav b/includes/install/sounds/en/us/callie/custom/8000/been.wav new file mode 100644 index 0000000000..77776b7d45 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/been.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/begin.wav b/includes/install/sounds/en/us/callie/custom/8000/begin.wav new file mode 100644 index 0000000000..836a715a3b Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/begin.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/begin_recording.wav b/includes/install/sounds/en/us/callie/custom/8000/begin_recording.wav new file mode 100644 index 0000000000..9e4992ca6a Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/begin_recording.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/call.wav b/includes/install/sounds/en/us/callie/custom/8000/call.wav new file mode 100644 index 0000000000..d0d48e2540 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/call.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/call_forward_has_been_deleted.wav b/includes/install/sounds/en/us/callie/custom/8000/call_forward_has_been_deleted.wav new file mode 100644 index 0000000000..ebe6ed362c Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/call_forward_has_been_deleted.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/call_forward_has_been_set.wav b/includes/install/sounds/en/us/callie/custom/8000/call_forward_has_been_set.wav new file mode 100644 index 0000000000..5826285220 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/call_forward_has_been_set.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/calling.wav b/includes/install/sounds/en/us/callie/custom/8000/calling.wav new file mode 100644 index 0000000000..4df57486a0 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/calling.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/cancel.wav b/includes/install/sounds/en/us/callie/custom/8000/cancel.wav new file mode 100644 index 0000000000..d94f97b757 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/cancel.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/delete.wav b/includes/install/sounds/en/us/callie/custom/8000/delete.wav new file mode 100644 index 0000000000..5d3fc7d632 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/delete.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/digit.wav b/includes/install/sounds/en/us/callie/custom/8000/digit.wav new file mode 100644 index 0000000000..2d0e84334d Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/digit.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/digits.wav b/includes/install/sounds/en/us/callie/custom/8000/digits.wav new file mode 100644 index 0000000000..75b61f002a Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/digits.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/enter.wav b/includes/install/sounds/en/us/callie/custom/8000/enter.wav new file mode 100644 index 0000000000..e081477481 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/enter.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/exit.wav b/includes/install/sounds/en/us/callie/custom/8000/exit.wav new file mode 100644 index 0000000000..495ace50d6 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/exit.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/extension.wav b/includes/install/sounds/en/us/callie/custom/8000/extension.wav new file mode 100644 index 0000000000..4f86bdbf3f Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/extension.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/followme_menu.wav b/includes/install/sounds/en/us/callie/custom/8000/followme_menu.wav new file mode 100644 index 0000000000..1c44517882 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/followme_menu.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/for.wav b/includes/install/sounds/en/us/callie/custom/8000/for.wav new file mode 100644 index 0000000000..5560e35476 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/for.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/forward.wav b/includes/install/sounds/en/us/callie/custom/8000/forward.wav new file mode 100644 index 0000000000..b62b2d9614 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/forward.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/goodbye.wav b/includes/install/sounds/en/us/callie/custom/8000/goodbye.wav new file mode 100644 index 0000000000..70a62f8fc1 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/goodbye.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/has.wav b/includes/install/sounds/en/us/callie/custom/8000/has.wav new file mode 100644 index 0000000000..800332da1f Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/has.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/hours.wav b/includes/install/sounds/en/us/callie/custom/8000/hours.wav new file mode 100644 index 0000000000..828a4c919b Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/hours.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/incorrect.wav b/includes/install/sounds/en/us/callie/custom/8000/incorrect.wav new file mode 100644 index 0000000000..d6d73612c1 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/incorrect.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/is.wav b/includes/install/sounds/en/us/callie/custom/8000/is.wav new file mode 100644 index 0000000000..23a03929c8 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/is.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/m.wav b/includes/install/sounds/en/us/callie/custom/8000/m.wav new file mode 100644 index 0000000000..afb1213a81 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/m.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/minutes.wav b/includes/install/sounds/en/us/callie/custom/8000/minutes.wav new file mode 100644 index 0000000000..6d12402c56 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/minutes.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/name.wav b/includes/install/sounds/en/us/callie/custom/8000/name.wav new file mode 100644 index 0000000000..bfb8998ff3 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/name.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/new.wav b/includes/install/sounds/en/us/callie/custom/8000/new.wav new file mode 100644 index 0000000000..a4db8fc34c Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/new.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/now.wav b/includes/install/sounds/en/us/callie/custom/8000/now.wav new file mode 100644 index 0000000000..ebd9d924d9 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/now.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/number.wav b/includes/install/sounds/en/us/callie/custom/8000/number.wav new file mode 100644 index 0000000000..c23932c897 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/number.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/or.wav b/includes/install/sounds/en/us/callie/custom/8000/or.wav new file mode 100644 index 0000000000..dd64e41490 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/or.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/p.wav b/includes/install/sounds/en/us/callie/custom/8000/p.wav new file mode 100644 index 0000000000..021fbf9278 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/p.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/pin.wav b/includes/install/sounds/en/us/callie/custom/8000/pin.wav new file mode 100644 index 0000000000..0fa00e3969 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/pin.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/please.wav b/includes/install/sounds/en/us/callie/custom/8000/please.wav new file mode 100644 index 0000000000..790b16aae9 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/please.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/please_enter_the_extension_number.wav b/includes/install/sounds/en/us/callie/custom/8000/please_enter_the_extension_number.wav new file mode 100644 index 0000000000..d9384b0fef Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/please_enter_the_extension_number.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/please_enter_the_phone_number.wav b/includes/install/sounds/en/us/callie/custom/8000/please_enter_the_phone_number.wav new file mode 100644 index 0000000000..9cb4057bdf Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/please_enter_the_phone_number.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/please_enter_the_pin_number.wav b/includes/install/sounds/en/us/callie/custom/8000/please_enter_the_pin_number.wav new file mode 100644 index 0000000000..107728a5a8 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/please_enter_the_pin_number.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/please_enter_the_recording_number.wav b/includes/install/sounds/en/us/callie/custom/8000/please_enter_the_recording_number.wav new file mode 100644 index 0000000000..0a25273c9b Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/please_enter_the_recording_number.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/please_enter_your_pin_number.wav b/includes/install/sounds/en/us/callie/custom/8000/please_enter_your_pin_number.wav new file mode 100644 index 0000000000..46263917a3 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/please_enter_your_pin_number.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/please_say_your_name_and_reason_for_calling.wav b/includes/install/sounds/en/us/callie/custom/8000/please_say_your_name_and_reason_for_calling.wav new file mode 100644 index 0000000000..325a879d84 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/please_say_your_name_and_reason_for_calling.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/press.wav b/includes/install/sounds/en/us/callie/custom/8000/press.wav new file mode 100644 index 0000000000..0d62767f40 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/press.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/press_1_to_accept_2_to_reject_or_3_for_voicemail.wav b/includes/install/sounds/en/us/callie/custom/8000/press_1_to_accept_2_to_reject_or_3_for_voicemail.wav new file mode 100644 index 0000000000..9c01616a9d Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/press_1_to_accept_2_to_reject_or_3_for_voicemail.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/press_1_to_accept_this_call.wav b/includes/install/sounds/en/us/callie/custom/8000/press_1_to_accept_this_call.wav new file mode 100644 index 0000000000..fa79822fe1 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/press_1_to_accept_this_call.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/reason.wav b/includes/install/sounds/en/us/callie/custom/8000/reason.wav new file mode 100644 index 0000000000..d779883341 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/reason.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/recording.wav b/includes/install/sounds/en/us/callie/custom/8000/recording.wav new file mode 100644 index 0000000000..badf1372d6 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/recording.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/reject.wav b/includes/install/sounds/en/us/callie/custom/8000/reject.wav new file mode 100644 index 0000000000..9844ae1dd7 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/reject.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/say.wav b/includes/install/sounds/en/us/callie/custom/8000/say.wav new file mode 100644 index 0000000000..d3415e7421 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/say.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/schedule.wav b/includes/install/sounds/en/us/callie/custom/8000/schedule.wav new file mode 100644 index 0000000000..a4ab3819c7 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/schedule.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/scheduled.wav b/includes/install/sounds/en/us/callie/custom/8000/scheduled.wav new file mode 100644 index 0000000000..49cf0fb083 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/scheduled.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/set.wav b/includes/install/sounds/en/us/callie/custom/8000/set.wav new file mode 100644 index 0000000000..b6be954c59 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/set.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/snooze.wav b/includes/install/sounds/en/us/callie/custom/8000/snooze.wav new file mode 100644 index 0000000000..e4e5072bb7 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/snooze.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/the.wav b/includes/install/sounds/en/us/callie/custom/8000/the.wav new file mode 100644 index 0000000000..4e4a28ca55 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/the.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/this.wav b/includes/install/sounds/en/us/callie/custom/8000/this.wav new file mode 100644 index 0000000000..66301fa462 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/this.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/time.wav b/includes/install/sounds/en/us/callie/custom/8000/time.wav new file mode 100644 index 0000000000..ec5bee904f Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/time.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/to.wav b/includes/install/sounds/en/us/callie/custom/8000/to.wav new file mode 100644 index 0000000000..7b26105f36 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/to.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/voicemail.wav b/includes/install/sounds/en/us/callie/custom/8000/voicemail.wav new file mode 100644 index 0000000000..dccb29a16e Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/voicemail.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/wakeup.wav b/includes/install/sounds/en/us/callie/custom/8000/wakeup.wav new file mode 100644 index 0000000000..b5cb91622d Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/wakeup.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/your.wav b/includes/install/sounds/en/us/callie/custom/8000/your.wav new file mode 100644 index 0000000000..d401310b62 Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/your.wav differ diff --git a/includes/install/sounds/en/us/callie/custom/8000/your_pin_number_is_incorect_goodbye.wav b/includes/install/sounds/en/us/callie/custom/8000/your_pin_number_is_incorect_goodbye.wav new file mode 100644 index 0000000000..5683bb8e4d Binary files /dev/null and b/includes/install/sounds/en/us/callie/custom/8000/your_pin_number_is_incorect_goodbye.wav differ diff --git a/includes/install/source.xml b/includes/install/source.xml new file mode 100644 index 0000000000..218b6aaf4d --- /dev/null +++ b/includes/install/source.xml @@ -0,0 +1,5063 @@ + + + file + /.htaccess + Mon, 05 Jul 2010 17:59:19 GMT + 792e4a892be4096d965a4660fcc0bdc9 + 332 + + + directory + /core + + + + + + directory + /core/backup + + + + + + file + /core/backup/backup.php + Sat, 06 Feb 2010 18:10:09 GMT + 946fa5976d2b29ae1e585d9894098069 + 1630 + + + file + /core/backup/backupandrestore.php + Sat, 06 Feb 2010 18:10:09 GMT + e848f428bd5455fa58472c39b68d62d6 + 2941 + + + file + /core/backup/root.php + Sat, 06 Feb 2010 18:10:09 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + directory + /core/menu + + + + + + file + /core/menu/index.php + Sat, 01 May 2010 08:12:06 GMT + 24c7f43397fb1ff8e8cc1aba16a7db5c + 10321 + + + file + /core/menu/menu.php + Sat, 01 May 2010 08:11:22 GMT + 54b00234bc20f257a6f0e1123071c8ce + 10415 + + + file + /core/menu/menu_delete.php + Sun, 23 May 2010 06:16:08 GMT + 5767c2426cc87c6bf213d713ea953d0b + 1578 + + + file + /core/menu/menu_edit.php + Sun, 23 May 2010 06:18:11 GMT + 90a282b8dbd0f820dd106a347c3dd56e + 12103 + + + file + /core/menu/menu_list.php + Sat, 01 May 2010 08:12:06 GMT + 6b2020cb1e9878503698f2741b34d9fa + 12725 + + + file + /core/menu/menu_move_down.php + Sun, 23 May 2010 06:18:11 GMT + 003c88d77ce6fa13a9f20d32feed7faa + 2982 + + + file + /core/menu/menu_move_up.php + Sun, 23 May 2010 06:18:42 GMT + 23e0080e62ba268612113c43de5253d7 + 2504 + + + file + /core/menu/menu_restore_default.php + Sun, 23 May 2010 06:19:04 GMT + 119127e0ef2e342326fb98847f78666a + 4393 + + + file + /core/menu/root.php + Sat, 06 Feb 2010 18:05:21 GMT + d399882b4822a07f0f4745cc41e1af1a + 1911 + + + directory + /core/settings + + + + + + file + /core/settings/root.php + Sat, 06 Feb 2010 18:02:36 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /core/settings/v_settings.php + Sat, 01 May 2010 08:03:57 GMT + ba867fd1a54a476feaf27bdc7f554120 + 5629 + + + file + /core/settings/v_settings_delete.php + Sat, 01 May 2010 08:03:57 GMT + 76069f395e160be17b1a3acac98ef602 + 1500 + + + file + /core/settings/v_settings_edit.php + Sat, 28 Aug 2010 18:49:56 GMT + 4b6a77eba20cd866ef3bf58cf8ed06a2 + 21008 + + + directory + /core/status + + + + + + file + /core/status/root.php + Sat, 06 Feb 2010 18:02:14 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /core/status/cmd.php + Sat, 06 Feb 2010 18:02:13 GMT + 2305b689a2e50df316552fca238c371d + 1786 + + + file + /core/status/v_status.php + Fri, 27 Aug 2010 23:20:26 GMT + be0a01baea7e3f1b044965c6733ba95e + 20672 + + + file + /core/status/v_status_registrations.php + Thu, 01 Jul 2010 20:26:06 GMT + 88d4549190d71d3c7085a054fb3c1c92 + 5011 + + + directory + /core/system_settings + + + + + + file + /core/system_settings/root.php + Sat, 06 Feb 2010 18:01:24 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /core/system_settings/v_system_settings.php + Sun, 15 Aug 2010 07:25:30 GMT + 82fd3f709bb619c9671b5aa848d98a83 + 6329 + + + file + /core/system_settings/v_system_settings_default.php + Mon, 30 Aug 2010 22:52:07 GMT + d4587f85de8bd9749effe554aaadef03 + 5790 + + + file + /core/system_settings/v_system_settings_delete.php + Sun, 15 Aug 2010 07:25:06 GMT + ff127bdb0d6793660fad7f0d22d1d57b + 1564 + + + file + /core/system_settings/v_system_settings_edit.php + Sun, 15 Aug 2010 07:24:54 GMT + ba9989d7c88fea789ea6e0bfa23953c9 + 28525 + + + directory + /core/upgrade + + + + + + file + /core/upgrade/root.php + Tue, 20 Oct 2009 18:13:40 GMT + 1d66d2f0f6ca694fc5d98c5b0e94e05b + 1091 + + + file + /core/upgrade/upgrade.php + Sun, 07 Mar 2010 04:05:23 GMT + efef8f062ab1103a56db3d610ac4b364 + 1591 + + + file + /core/upgrade/upgrade_schema.php + Fri, 01 Oct 2010 08:52:39 GMT + df3dc29315af014411644de0c5658b06 + 1655 + + + file + /core/upgrade/upgrade_svn.php + Thu, 09 Sep 2010 06:11:54 GMT + f0c7192b55c864260bbf3d5dc2549a2e + 7549 + + + file + /core/upgrade/upgrade_xml.php + Tue, 20 Jul 2010 02:17:47 GMT + 7bf91067097b7938f8f220355f51d5d6 + 3590 + + + directory + /core/users + + + + + + file + /core/users/groupadd.php + Sat, 06 Feb 2010 17:54:25 GMT + c70e80108d447d56a8b196cb442d2f4a + 3430 + + + file + /core/users/groupdelete.php + Sat, 06 Feb 2010 17:54:21 GMT + 0e321232aafc985247378f961309daf8 + 1510 + + + file + /core/users/grouplist.php + Sat, 06 Feb 2010 17:54:17 GMT + a03418af9922b3929f73c67fb49fe54a + 4852 + + + file + /core/users/groupmemberadd.php + Sat, 06 Feb 2010 17:53:40 GMT + ec2a900ab96a94a5d3f4dac68b45ef35 + 2378 + + + file + /core/users/groupmemberdelete.php + Sat, 06 Feb 2010 17:53:33 GMT + 9a627b38c57a78add544f7c19945a0eb + 2183 + + + file + /core/users/groupmembers.php + Sat, 06 Feb 2010 17:54:53 GMT + 122456196393dc1983f4c3b4c60353a0 + 4679 + + + file + /core/users/index.php + Sat, 06 Feb 2010 17:54:49 GMT + 9e0a8c8ef7c0af5cdec0afb0d16f65c9 + 1450 + + + file + /core/users/root.php + Sat, 06 Feb 2010 17:54:45 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /core/users/signup.php + Sun, 23 May 2010 06:22:02 GMT + 8a7b40722027520c4bfe7022934c3ef8 + 23160 + + + file + /core/users/useradd.php + Sat, 06 Feb 2010 17:54:38 GMT + 40b087a82e163a8cf2ffeb5492c99d49 + 6637 + + + file + /core/users/userdelete.php + Sat, 06 Feb 2010 17:54:34 GMT + d38aa19c7900f7b104ae656fb008e20a + 2626 + + + file + /core/users/userlist.php + Sat, 06 Feb 2010 17:54:32 GMT + 7aa313b5674fa527c479d73bbd0cde86 + 8989 + + + file + /core/users/usersupdate.php + Sat, 11 Sep 2010 16:59:21 GMT + d054a42ee31abcbd9d0099b88a5ee9c8 + 24995 + + + directory + /images + + + + + + file + /images/background_cell_active.gif + Fri, 21 May 2010 08:53:03 GMT + 0bf1471ae70a9b4e3818f7bd44ae1afb + 128 + + + file + /images/background_cell_conference.gif + Fri, 21 May 2010 08:53:03 GMT + 3b0736071002f93929130eb10d9d1869 + 128 + + + file + /images/background_cell_fifo.gif + Fri, 21 May 2010 08:53:02 GMT + 684692e2901f1105f42b99a6d0482d0b + 128 + + + file + /images/background_cell_light.gif + Fri, 21 May 2010 08:53:03 GMT + 204131d7b2e940853a07b97c788ed475 + 149 + + + file + /images/blank.gif + Fri, 21 May 2010 08:53:03 GMT + 56398e76be6355ad5999b262208a17c9 + 49 + + + file + /images/icon_cal.gif + Fri, 21 May 2010 08:52:38 GMT + 9c6f557f2ab2e04f6c3f4c2d6a8f40e9 + 646 + + + file + /images/icon_e.gif + Fri, 21 May 2010 08:53:02 GMT + e6b0a46279a319f635306e0238b2ec68 + 1106 + + + file + /images/icon_plus.gif + Fri, 21 May 2010 08:53:02 GMT + 5ac12528061cade8421f8f73eb766a11 + 1100 + + + file + /images/icon_up.gif + Fri, 21 May 2010 08:53:02 GMT + 4653b9b36eff66d412a8c962c574923b + 1116 + + + file + /images/icon_view.gif + Fri, 21 May 2010 08:53:03 GMT + 23624c848a869a3d4eb7f16f9f3f135f + 1109 + + + file + /images/icon_x.gif + Fri, 21 May 2010 08:53:02 GMT + c53fdfed01f3bb048ad3bbbf10692ebe + 1111 + + + directory + /includes + + + + + + file + /includes/calendar_lw_layers.js + Tue, 08 Dec 2009 02:25:03 GMT + 320abdf3709d06879886397b51c1a7eb + 4834 + + + file + /includes/calendar_lw_menu.js + Tue, 08 Dec 2009 02:25:03 GMT + 025630a5fc20907369decafc96234945 + 8367 + + + file + /includes/calendar_popcalendar.js + Tue, 08 Dec 2009 02:25:03 GMT + dec43c74fe649175a666a8df31d3b868 + 23043 + + + directory + /includes/captcha + + + + + + directory + /includes/captcha/fonts + + + + + + file + /includes/captcha/fonts/hanshand.ttf + Tue, 08 Dec 2009 02:24:54 GMT + 5abafb3678ef53ce7298c9e253a0a2b4 + 53424 + + + file + /includes/captcha/fonts/ROUGD.TTF + Tue, 08 Dec 2009 02:24:54 GMT + 58dcf2f5d780c90a9d45284cde4eb4d1 + 65036 + + + file + /includes/captcha/fonts/Zebra.ttf + Tue, 08 Dec 2009 02:24:54 GMT + 47b48b6778cf0b3e1a70e28fe4c2c7cb + 82064 + + + file + /includes/captcha/img.php + Sat, 06 Feb 2010 18:19:35 GMT + 6eb82ef732e3f02a50c0e885562dcbf4 + 3290 + + + file + /includes/captcha/root.php + Sat, 06 Feb 2010 18:19:35 GMT + d399882b4822a07f0f4745cc41e1af1a + 1911 + + + file + /includes/checkauth.php + Sun, 05 Sep 2010 06:44:52 GMT + 8f5f75bae7abe72ddfe0283d9f05935f + 4660 + + + file + /includes/checkstring.php + Sat, 06 Feb 2010 18:17:07 GMT + 276485fdbdbc49ed2d0ccc1fbc912109 + 955 + + + file + /includes/class.phpmailer.php + Tue, 08 Dec 2009 02:25:03 GMT + d80cf8d4005ee4334f445e91402b6b17 + 56086 + + + file + /includes/class.smtp.php + Tue, 08 Dec 2009 02:25:03 GMT + d2be32bec43171954dc9bd328ab63dac + 31376 + + + file + /includes/class_vcard.php + Tue, 08 Jun 2010 00:32:38 GMT + 720e638a94af0dbb374d746a42ef46de + 6073 + + + file + /includes/config.php.dist + Sat, 06 Feb 2010 18:18:53 GMT + 7af7ffbb69ddc8585810c5cd0def1379 + 2381 + + + file + /includes/directory.php + Tue, 23 Mar 2010 10:05:56 GMT + 101e7bddf1e063aead84d9bc68fdd8f8 + 12927 + + + file + /includes/download.php + Sat, 06 Feb 2010 18:18:53 GMT + 31d2bf32511a4651914330577269ccac + 1052 + + + directory + /includes/edit_area + + + + + + file + /includes/edit_area/edit_area_full.gz + Tue, 08 Dec 2009 02:24:53 GMT + 8c924f9b2bc2bc0ac2919cbbffb24fa2 + 29125 + + + file + /includes/edit_area/edit_area_full.js + Tue, 08 Dec 2009 02:24:53 GMT + 58b9669d5903765b99ca4adac8e9b9f5 + 114587 + + + directory + /includes/edit_area/images + + + + + + file + /includes/edit_area/images/autocompletion.gif + Tue, 08 Dec 2009 02:24:53 GMT + a49a7f9395b32bcf6aa8e143e17c03ff + 359 + + + file + /includes/edit_area/images/close.gif + Tue, 08 Dec 2009 02:24:53 GMT + 6cc9d27bdda91ad192a4326a653ba566 + 102 + + + file + /includes/edit_area/images/fullscreen.gif + Tue, 08 Dec 2009 02:24:53 GMT + 88d0dd1d465c2989dc04cb8f4473f6b9 + 198 + + + file + /includes/edit_area/images/go_to_line.gif + Tue, 08 Dec 2009 02:24:53 GMT + 05aa7fa3c6c720595bb3ead7366bbe07 + 1053 + + + file + /includes/edit_area/images/help.gif + Tue, 08 Dec 2009 02:24:53 GMT + 4cd4a5d2cdcd74c8aeced17813afd6ea + 295 + + + file + /includes/edit_area/images/highlight.gif + Tue, 08 Dec 2009 02:24:53 GMT + 96382d6d24bb8a1b228586b323e72fb4 + 256 + + + file + /includes/edit_area/images/load.gif + Tue, 08 Dec 2009 02:24:53 GMT + 203725593d5c7412fc51aa603434f96f + 1041 + + + file + /includes/edit_area/images/move.gif + Tue, 08 Dec 2009 02:24:53 GMT + 0da84ad6a24533d4335cef8255101edc + 257 + + + file + /includes/edit_area/images/newdocument.gif + Tue, 08 Dec 2009 02:24:53 GMT + 24b01aa27845c551f24a186a92cbc94e + 170 + + + file + /includes/edit_area/images/opacity.png + Tue, 08 Dec 2009 02:24:53 GMT + 7f1c7b1ff1f3e04828540f6ffdde46c2 + 147 + + + file + /includes/edit_area/images/processing.gif + Tue, 08 Dec 2009 02:24:53 GMT + 40418383947fe6335056fce05abe44a2 + 825 + + + file + /includes/edit_area/images/redo.gif + Tue, 08 Dec 2009 02:24:53 GMT + c2b3b80e20aa7f50ec45acb999373425 + 169 + + + file + /includes/edit_area/images/reset_highlight.gif + Tue, 08 Dec 2009 02:24:53 GMT + e9c387cc80f33b14447b628df1906639 + 168 + + + file + /includes/edit_area/images/save.gif + Tue, 08 Dec 2009 02:24:53 GMT + 2392d13d22fec22e69add07becf83e20 + 285 + + + file + /includes/edit_area/images/search.gif + Tue, 08 Dec 2009 02:24:53 GMT + 791e640ca1b345a84084eb611004de98 + 191 + + + file + /includes/edit_area/images/smooth_selection.gif + Tue, 08 Dec 2009 02:24:53 GMT + e6a384f19aef7c0fb2f2e0ee0bdc72e0 + 174 + + + file + /includes/edit_area/images/spacer.gif + Tue, 08 Dec 2009 02:24:53 GMT + 12bf9e19374920de3146a64775f46a5e + 43 + + + file + /includes/edit_area/images/statusbar_resize.gif + Tue, 08 Dec 2009 02:24:53 GMT + 1b952cd23844b834e0a307db3c803626 + 79 + + + file + /includes/edit_area/images/undo.gif + Tue, 08 Dec 2009 02:24:53 GMT + 7883b9e1f9bf0b860e77b904e1941591 + 175 + + + file + /includes/edit_area/images/word_wrap.gif + Tue, 08 Dec 2009 02:24:53 GMT + 47bd30f6fe667d34f37230b01544595a + 951 + + + directory + /includes/edit_area/langs + + + + + + file + /includes/edit_area/langs/bg.js + Tue, 08 Dec 2009 02:24:53 GMT + 33949d475debd38862a6c8a6a5934fb6 + 3132 + + + file + /includes/edit_area/langs/cs.js + Tue, 08 Dec 2009 02:24:53 GMT + a7ac795809ed32a3e42c5fe7ad5ca204 + 2202 + + + file + /includes/edit_area/langs/de.js + Tue, 08 Dec 2009 02:24:53 GMT + 2855b486c898565e93a4124aaf31b48d + 2244 + + + file + /includes/edit_area/langs/dk.js + Tue, 08 Dec 2009 02:24:53 GMT + cdda9d4383c055093c78d3ab4d8c71c5 + 2123 + + + file + /includes/edit_area/langs/en.js + Tue, 08 Dec 2009 02:24:53 GMT + a9941aeea2f8286991a4f2abe3d0367d + 1969 + + + file + /includes/edit_area/langs/eo.js + Tue, 08 Dec 2009 02:24:53 GMT + 97ee39c2f4861273de5ed1fb2280b8ae + 2282 + + + file + /includes/edit_area/langs/es.js + Tue, 08 Dec 2009 02:24:53 GMT + 877c2f5a72984003da94b082b0fa04ab + 2146 + + + file + /includes/edit_area/langs/fi.js + Tue, 08 Dec 2009 02:24:53 GMT + effce5cfeb1b273543d1def9226ce843 + 2126 + + + file + /includes/edit_area/langs/fr.js + Tue, 08 Dec 2009 02:24:53 GMT + e26b41e7407e91bb66e05abb7e9c0533 + 2413 + + + file + /includes/edit_area/langs/hr.js + Tue, 08 Dec 2009 02:24:53 GMT + 8179b813bea428c74c5d289aeb119a74 + 1985 + + + file + /includes/edit_area/langs/it.js + Tue, 08 Dec 2009 02:24:53 GMT + b937185e999b70255d161d15453a1cdf + 2113 + + + file + /includes/edit_area/langs/ja.js + Tue, 08 Dec 2009 02:24:53 GMT + a96e8fad9b9fef10138fb5be3f9b8b1a + 2171 + + + file + /includes/edit_area/langs/mk.js + Tue, 08 Dec 2009 02:24:53 GMT + 15acec0d9d4bee76f9f7fd90bc74f91e + 2817 + + + file + /includes/edit_area/langs/nl.js + Tue, 08 Dec 2009 02:24:53 GMT + 74b7565272926811078e12f746e2242a + 2034 + + + file + /includes/edit_area/langs/pl.js + Tue, 08 Dec 2009 02:24:53 GMT + 39ff6ff5981cc6730b6ee2832f47f556 + 2106 + + + file + /includes/edit_area/langs/pt.js + Tue, 08 Dec 2009 02:24:53 GMT + 6589eeeb1f79d896acfa7ab9dd5a7d97 + 1937 + + + file + /includes/edit_area/langs/ru.js + Tue, 08 Dec 2009 02:24:53 GMT + f9f79e8730db7701c4ec4eb612c815d9 + 2919 + + + file + /includes/edit_area/langs/sk.js + Tue, 08 Dec 2009 02:24:53 GMT + a664ffc9e05ddd7c8341645839ddeccf + 2211 + + + file + /includes/edit_area/langs/zh.js + Tue, 08 Dec 2009 02:24:53 GMT + 4f844bc3cde7edaf03ee66aefaabb40d + 2025 + + + directory + /includes/edit_area/plugins + + + + + + directory + /includes/edit_area/plugins/charmap + + + + + + file + /includes/edit_area/plugins/charmap/charmap.js + Tue, 08 Dec 2009 02:24:52 GMT + 15d5626b8375004c217dec10ce1346a4 + 2807 + + + directory + /includes/edit_area/plugins/charmap/css + + + + + + file + /includes/edit_area/plugins/charmap/css/charmap.css + Tue, 08 Dec 2009 02:24:52 GMT + 84eed9f0eaf34e71f528444d0fbd729c + 953 + + + directory + /includes/edit_area/plugins/charmap/images + + + + + + file + /includes/edit_area/plugins/charmap/images/charmap.gif + Tue, 08 Dec 2009 02:24:52 GMT + 948c608cfe393168642e3946097eba3d + 245 + + + directory + /includes/edit_area/plugins/charmap/jscripts + + + + + + file + /includes/edit_area/plugins/charmap/jscripts/map.js + Tue, 08 Dec 2009 02:24:52 GMT + 071107a09c753f3d2e88d0b99aa61820 + 11846 + + + directory + /includes/edit_area/plugins/charmap/langs + + + + + + file + /includes/edit_area/plugins/charmap/langs/bg.js + Tue, 08 Dec 2009 02:24:52 GMT + a4c60ccea1575a77c43c964ab1d78a62 + 396 + + + file + /includes/edit_area/plugins/charmap/langs/cs.js + Tue, 08 Dec 2009 02:24:52 GMT + d578b06a1b41e5da773ddb688d98bdd9 + 187 + + + file + /includes/edit_area/plugins/charmap/langs/de.js + Tue, 08 Dec 2009 02:24:52 GMT + b93418619c8678c6505c023b1072b80b + 192 + + + file + /includes/edit_area/plugins/charmap/langs/dk.js + Tue, 08 Dec 2009 02:24:52 GMT + e6395e180e9b9bd87a7e96cf745b101e + 187 + + + file + /includes/edit_area/plugins/charmap/langs/en.js + Tue, 08 Dec 2009 02:24:52 GMT + 17a20a2e46b7de8d7fa5370a9bf6b294 + 187 + + + file + /includes/edit_area/plugins/charmap/langs/eo.js + Tue, 08 Dec 2009 02:24:52 GMT + 0cc471de01b7ad207df32c450682cd3d + 175 + + + file + /includes/edit_area/plugins/charmap/langs/es.js + Tue, 08 Dec 2009 02:24:52 GMT + ea43e35253952cc33c85d3fe7c9bb27b + 187 + + + file + /includes/edit_area/plugins/charmap/langs/fr.js + Tue, 08 Dec 2009 02:24:52 GMT + 96c4acb5f590d7b403d3b0e319dfb349 + 194 + + + file + /includes/edit_area/plugins/charmap/langs/hr.js + Tue, 08 Dec 2009 02:24:52 GMT + 578178183db00474dfa660f616db86ae + 191 + + + file + /includes/edit_area/plugins/charmap/langs/it.js + Tue, 08 Dec 2009 02:24:52 GMT + 433ac140154e12f5423b226c6ed8e148 + 189 + + + file + /includes/edit_area/plugins/charmap/langs/ja.js + Tue, 08 Dec 2009 02:24:52 GMT + fc17e42e8ce2ac676f885d332244cbaa + 187 + + + file + /includes/edit_area/plugins/charmap/langs/mk.js + Tue, 08 Dec 2009 02:24:52 GMT + 4cc7a175a342f413101db66013f09900 + 188 + + + file + /includes/edit_area/plugins/charmap/langs/nl.js + Tue, 08 Dec 2009 02:24:52 GMT + 0e717e403d8c8f53e4376c3b4e09d6fd + 190 + + + file + /includes/edit_area/plugins/charmap/langs/pl.js + Tue, 08 Dec 2009 02:24:52 GMT + 52627faf46a7b1f8b8f5110358d224cf + 192 + + + file + /includes/edit_area/plugins/charmap/langs/pt.js + Tue, 08 Dec 2009 02:24:52 GMT + 9828da57868e6192b5c921400ab87d1f + 187 + + + file + /includes/edit_area/plugins/charmap/langs/ru.js + Tue, 08 Dec 2009 02:24:52 GMT + 67e1426c248ee6fe6274ee2fed23df22 + 275 + + + file + /includes/edit_area/plugins/charmap/langs/sk.js + Tue, 08 Dec 2009 02:24:52 GMT + 3da0f484cce154d5a8f06572ac5a8461 + 194 + + + file + /includes/edit_area/plugins/charmap/langs/zh.js + Tue, 08 Dec 2009 02:24:52 GMT + 50f6ecf19890d2cd305357ca9679684c + 169 + + + file + /includes/edit_area/plugins/charmap/popup.html + Tue, 08 Dec 2009 02:24:52 GMT + 7d97c56e6f29a3cdaacb934793133188 + 782 + + + directory + /includes/edit_area/plugins/test + + + + + + directory + /includes/edit_area/plugins/test/css + + + + + + file + /includes/edit_area/plugins/test/css/test.css + Tue, 08 Dec 2009 02:24:52 GMT + c6d48fc50bb974b20bec7731e312f5de + 53 + + + directory + /includes/edit_area/plugins/test/images + + + + + + file + /includes/edit_area/plugins/test/images/test.gif + Tue, 08 Dec 2009 02:24:52 GMT + 6036655a01df362267183a8b23fead10 + 87 + + + directory + /includes/edit_area/plugins/test/langs + + + + + + file + /includes/edit_area/plugins/test/langs/bg.js + Tue, 08 Dec 2009 02:24:51 GMT + d7123a41255600449aec9fc1f301c147 + 244 + + + file + /includes/edit_area/plugins/test/langs/cs.js + Tue, 08 Dec 2009 02:24:51 GMT + 1cefb4fd6e169dfe1950c35b4aff1eba + 84 + + + file + /includes/edit_area/plugins/test/langs/de.js + Tue, 08 Dec 2009 02:24:51 GMT + 7a7675c982dd18be1ced114aa70daafb + 92 + + + file + /includes/edit_area/plugins/test/langs/dk.js + Tue, 08 Dec 2009 02:24:51 GMT + 488f8af5a93283499dfebe551fb7f4ed + 84 + + + file + /includes/edit_area/plugins/test/langs/en.js + Tue, 08 Dec 2009 02:24:51 GMT + acb2b331564a8dc553302aa46d5f5d36 + 84 + + + file + /includes/edit_area/plugins/test/langs/eo.js + Tue, 08 Dec 2009 02:24:51 GMT + a010b4aa33bb848a8b16793910eb05ac + 89 + + + file + /includes/edit_area/plugins/test/langs/es.js + Tue, 08 Dec 2009 02:24:51 GMT + 687fba1e66bc7ef6cec32cb208e2b1d7 + 84 + + + file + /includes/edit_area/plugins/test/langs/fr.js + Tue, 08 Dec 2009 02:24:51 GMT + 7091caec9d5c627073e728ab74a3a5bd + 88 + + + file + /includes/edit_area/plugins/test/langs/hr.js + Tue, 08 Dec 2009 02:24:51 GMT + 152f29d20c99cb7d337f0f369dd71ceb + 86 + + + file + /includes/edit_area/plugins/test/langs/it.js + Tue, 08 Dec 2009 02:24:51 GMT + 7de5456ada17577d4fcbbfc619324662 + 92 + + + file + /includes/edit_area/plugins/test/langs/ja.js + Tue, 08 Dec 2009 02:24:51 GMT + 5ccb36b44757fc4e514498c4f447577c + 84 + + + file + /includes/edit_area/plugins/test/langs/mk.js + Tue, 08 Dec 2009 02:24:51 GMT + 7a5f9fbf31ac0783d92fcaed1f1c8295 + 84 + + + file + /includes/edit_area/plugins/test/langs/nl.js + Tue, 08 Dec 2009 02:24:51 GMT + 4b3627381f170e533d9eb767487f33d3 + 84 + + + file + /includes/edit_area/plugins/test/langs/pl.js + Tue, 08 Dec 2009 02:24:51 GMT + 255f97808244326878b647cecb64aebc + 78 + + + file + /includes/edit_area/plugins/test/langs/pt.js + Tue, 08 Dec 2009 02:24:51 GMT + dcbf418e8f05db1ef7b13cbc8e03782b + 84 + + + file + /includes/edit_area/plugins/test/langs/ru.js + Tue, 08 Dec 2009 02:24:51 GMT + 37a504c426450b8e738f7ebbd3ee7587 + 119 + + + file + /includes/edit_area/plugins/test/langs/sk.js + Tue, 08 Dec 2009 02:24:51 GMT + 1e7b4e0b10b36b9d63edc4d6bfeea172 + 92 + + + file + /includes/edit_area/plugins/test/langs/zh.js + Tue, 08 Dec 2009 02:24:51 GMT + 0a68369b57f733e07b1eb10c1c238d95 + 87 + + + file + /includes/edit_area/plugins/test/test.js + Tue, 08 Dec 2009 02:24:52 GMT + 8559ea076cd3f47bac8540f91369e7c6 + 3695 + + + file + /includes/edit_area/plugins/test/test2.js + Tue, 08 Dec 2009 02:24:52 GMT + 9bef02a43a1bd789ec6534f20fbbfc5d + 47 + + + directory + /includes/edit_area/reg_syntax + + + + + + file + /includes/edit_area/reg_syntax/basic.js + Tue, 08 Dec 2009 02:24:53 GMT + 68e21d612e33473e6326c1e72df6421e + 2650 + + + file + /includes/edit_area/reg_syntax/brainfuck.js + Tue, 08 Dec 2009 02:24:53 GMT + 6514a6685ea2b819c610f050b4c36a32 + 907 + + + file + /includes/edit_area/reg_syntax/c.js + Tue, 08 Dec 2009 02:24:53 GMT + 8668c7d1d3f4c1fae0fe5e46ef2b1fe9 + 1648 + + + file + /includes/edit_area/reg_syntax/coldfusion.js + Tue, 08 Dec 2009 02:24:53 GMT + 389c9d5f2cbab70de8109b549d6f103d + 5934 + + + file + /includes/edit_area/reg_syntax/cpp.js + Tue, 08 Dec 2009 02:24:53 GMT + 4af61c486401e028b44874169d6bda35 + 1853 + + + file + /includes/edit_area/reg_syntax/css.js + Tue, 08 Dec 2009 02:24:53 GMT + 33d561ba22a917c3279fb31a4a760551 + 4972 + + + file + /includes/edit_area/reg_syntax/html.js + Tue, 08 Dec 2009 02:24:53 GMT + b0f62d2507c072a89e51e60270f911d7 + 1116 + + + file + /includes/edit_area/reg_syntax/java.js + Tue, 08 Dec 2009 02:24:53 GMT + 548e6e6ff4547cbec9b38f1f09b49f95 + 1667 + + + file + /includes/edit_area/reg_syntax/js.js + Tue, 08 Dec 2009 02:24:53 GMT + 2d77b33a886e435004e11a1835f4b6f9 + 4368 + + + file + /includes/edit_area/reg_syntax/pas.js + Tue, 08 Dec 2009 02:24:53 GMT + 34dabdc2dc2df0c5a8865ad6f3f3688e + 3292 + + + file + /includes/edit_area/reg_syntax/perl.js + Tue, 08 Dec 2009 02:24:53 GMT + e01cf02194bff0a6c3565b2b93399887 + 3166 + + + file + /includes/edit_area/reg_syntax/php.js + Tue, 08 Dec 2009 02:24:53 GMT + d0048d0d4a51f0e2fb359169f62828d3 + 14135 + + + file + /includes/edit_area/reg_syntax/python.js + Tue, 08 Dec 2009 02:24:53 GMT + 776815baeec98159e3f1f6ae6a4d70c0 + 7897 + + + file + /includes/edit_area/reg_syntax/robotstxt.js + Tue, 08 Dec 2009 02:24:53 GMT + f24de940202b28b84d393703cf73fd7e + 634 + + + file + /includes/edit_area/reg_syntax/ruby.js + Tue, 08 Dec 2009 02:24:53 GMT + cf881ed977dc8dcc5683c186a55e566f + 1732 + + + file + /includes/edit_area/reg_syntax/sql.js + Tue, 08 Dec 2009 02:24:53 GMT + 1696ab1abdc071d299af651defdaea4f + 3384 + + + file + /includes/edit_area/reg_syntax/tsql.js + Tue, 08 Dec 2009 02:24:53 GMT + fef976fba89b77c46191eb3d9288e7c1 + 5211 + + + file + /includes/edit_area/reg_syntax/vb.js + Tue, 08 Dec 2009 02:24:53 GMT + 1614b162371030dd3372c80bbc40084c + 2196 + + + file + /includes/edit_area/reg_syntax/xml.js + Tue, 08 Dec 2009 02:24:53 GMT + 5fda1c26de462cbdf74ef0c185bcb8d8 + 1264 + + + file + /includes/footer.php + Thu, 09 Sep 2010 04:19:23 GMT + 7c0bc2cfa1fc969dbd2a578ceb4ba700 + 4820 + + + file + /includes/getcontent.php + Sat, 06 Feb 2010 18:18:53 GMT + c8c28473f6285fabb6ea4543c157e7b6 + 1874 + + + file + /includes/header.php + Sat, 06 Feb 2010 18:18:53 GMT + 4eac32156e9dfc3adac6c33c134ddc5e + 1458 + + + directory + /includes/install + + + + + + directory + /includes/install/autoload_configs + + + + + + file + /includes/install/autoload_configs/cdr_csv.conf.xml + Tue, 08 Dec 2009 02:24:56 GMT + 8b824abf2cc66031ffa9f8d51e4d2b44 + 2463 + + + directory + /includes/install/dialplan + + + + + + file + /includes/install/dialplan/default.xml + Wed, 11 Aug 2010 13:51:49 GMT + 156993963dc7b2c2112eaee26021b4d8 + 33866 + + + directory + /includes/install/htdocs + + + + + + file + /includes/install/htdocs/license.txt + Tue, 08 Dec 2009 02:24:56 GMT + e477142260885b28359224de461f8bed + 1492 + + + file + /includes/install/htdocs/slim.swf + Tue, 08 Dec 2009 02:24:56 GMT + 6da31effb6edadd3c7d55d3dc3877d00 + 56327 + + + file + /includes/install/htdocs/slimtest.htm + Tue, 08 Dec 2009 02:24:56 GMT + f11e41bdc8a118ea03b32fa4d9b2eb5c + 789 + + + directory + /includes/install/scripts + + + + + + file + /includes/install/scripts/call_broadcast_originate.js + Fri, 12 Mar 2010 01:03:35 GMT + c88b59e727795ecd439696fad076c00a + 2784 + + + file + /includes/install/scripts/call_forward_basic.lua + Sat, 21 Aug 2010 16:40:31 GMT + 75055a5e981fb90ad16d678449853c15 + 6941 + + + file + /includes/install/scripts/disa.lua + Sat, 28 Aug 2010 07:27:50 GMT + e9d0a9f5368cf132bf74ade7044b2556 + 5818 + + + file + /includes/install/scripts/huntgroup_originate.js + Tue, 06 Jul 2010 07:11:16 GMT + 2fcbbcee41cdab48515456f24f707e3d + 2417 + + + file + /includes/install/scripts/intercom.lua + Sat, 02 Oct 2010 21:29:15 GMT + 470c734e4cc5b1bf18a47a4ada28015c + 5057 + + + file + /includes/install/scripts/originate.js + Tue, 06 Jul 2010 07:11:58 GMT + c20d8be185c08e665ce763ca1bd20595 + 1152 + + + file + /includes/install/scripts/recordings.lua + Sat, 18 Sep 2010 23:31:58 GMT + 1b462d10b8d7b93ed0b14c4a2e63c562 + 5618 + + + file + /includes/install/scripts/roku.lua + Thu, 09 Sep 2010 22:29:29 GMT + 88a5b268bd9b45587f0d41e612217db3 + 3338 + + + directory + /includes/install/sounds + + + + + + directory + /includes/install/sounds/custom + + + + + + directory + /includes/install/sounds/custom/16000 + + + + + + file + /includes/install/sounds/custom/16000/begin_recording.wav + Tue, 06 Jul 2010 07:27:24 GMT + bbf95551bbdbc5316b4f73ea805b770b + 77156 + + + file + /includes/install/sounds/custom/16000/call_forward_has_been_deleted.wav + Tue, 06 Jul 2010 07:27:59 GMT + aa9eb7ba0d8d02639bdfeee379c364d6 + 114092 + + + file + /includes/install/sounds/custom/16000/call_forward_has_been_set.wav + Tue, 06 Jul 2010 07:28:21 GMT + 7321c5225cff0bcc45bbb22cc8afc8b1 + 123164 + + + file + /includes/install/sounds/custom/16000/followme_menu.wav + Tue, 06 Jul 2010 07:33:02 GMT + bfb5873ad6c52af49589ad861a325e8d + 248228 + + + file + /includes/install/sounds/custom/16000/please_enter_the_extension_number.wav + Tue, 06 Jul 2010 07:26:53 GMT + feebc69643e05097154681293147ac8b + 128996 + + + file + /includes/install/sounds/custom/16000/please_enter_the_phone_number.wav + Tue, 06 Jul 2010 07:29:15 GMT + 422e2520cc768e7bd5aa7c9fe2044d1a + 105668 + + + file + /includes/install/sounds/custom/16000/please_enter_the_pin_number.wav + Tue, 06 Jul 2010 07:29:42 GMT + b9c2800746b860c1ff60f4690a2b3f00 + 109556 + + + file + /includes/install/sounds/custom/16000/please_enter_your_pin_number.wav + Tue, 06 Jul 2010 07:30:07 GMT + 8c563af0f07284a00df7a37c64e95cc4 + 112148 + + + file + /includes/install/sounds/custom/16000/please_say_your_name_and_reason_for_calling.wav + Tue, 06 Jul 2010 07:30:35 GMT + 0410a0ca15c77c68d4bd359b6624e2b1 + 143252 + + + file + /includes/install/sounds/custom/16000/press_1_to_accept_2_to_reject_or_3_for_voicemail.wav + Tue, 06 Jul 2010 07:31:08 GMT + 07f2ceb86d16823a4df1874c8d507ffc + 223604 + + + file + /includes/install/sounds/custom/16000/your_pin_number_is_incorect_goodbye.wav + Tue, 06 Jul 2010 07:31:46 GMT + ccae9539f0bf07171782a88170f77bc8 + 143252 + + + directory + /includes/install/sounds/custom/8000 + + + + + + file + /includes/install/sounds/custom/8000/begin_recording.wav + Tue, 08 Dec 2009 02:25:02 GMT + 55b24f8fcf30d59da9cf9176329b702c + 19480 + + + file + /includes/install/sounds/custom/8000/call_forward_has_been_deleted.wav + Tue, 08 Dec 2009 02:25:02 GMT + b04be640cff8a9a5a609880ad48b2e11 + 28668 + + + file + /includes/install/sounds/custom/8000/call_forward_has_been_set.wav + Tue, 08 Dec 2009 02:25:02 GMT + 6b7cfd2e67f488db89e9e3b454fdaa61 + 30976 + + + file + /includes/install/sounds/custom/8000/followme_menu.wav + Tue, 08 Dec 2009 02:25:02 GMT + 6d207d938e1eff410ecbe42bc89d1b86 + 66860 + + + file + /includes/install/sounds/custom/8000/please_enter_the_extension_number.wav + Tue, 08 Dec 2009 02:25:02 GMT + 7094ea33f7319b94eab72ebcab621ea4 + 32360 + + + file + /includes/install/sounds/custom/8000/please_enter_the_phone_number.wav + Tue, 08 Dec 2009 02:25:02 GMT + 641f6b17ff5cf538c0937aa17b178adc + 26552 + + + file + /includes/install/sounds/custom/8000/please_enter_the_pin_number.wav + Tue, 08 Dec 2009 02:25:02 GMT + 82759320121a88f7a6d6bdd7eecfca5b + 27504 + + + file + /includes/install/sounds/custom/8000/please_enter_your_pin_number.wav + Tue, 08 Dec 2009 02:25:02 GMT + 63d1b5fa350a0e2b6ead3220b6b3b061 + 28212 + + + file + /includes/install/sounds/custom/8000/please_say_your_name_and_reason_for_calling.wav + Tue, 08 Dec 2009 02:25:02 GMT + 7fcbd940088c0a423d60d10909fa64c7 + 35860 + + + file + /includes/install/sounds/custom/8000/press_1_to_accept_2_to_reject_or_3_for_voicemail.wav + Tue, 08 Dec 2009 02:25:02 GMT + b24a2008ac97127a22c5b1a81c768f06 + 68104 + + + file + /includes/install/sounds/custom/8000/your_pin_number_is_incorect_goodbye.wav + Tue, 08 Dec 2009 02:25:02 GMT + 6c3d7230382ecaf5110335d41e609549 + 43420 + + + file + /includes/install/source.xml + Thu, 09 Sep 2010 05:07:14 GMT + f4e6de980c77dd44fc860d6899bf7f2e + 146914 + + + directory + /includes/install/sql + + + + + + file + /includes/install/sql/mysql.sql + Sat, 18 Sep 2010 20:09:43 GMT + 916e8fe7f7477f196cb724ec2da1ca94 + 41951 + + + file + /includes/install/sql/pgsql.sql + Sat, 18 Sep 2010 20:09:50 GMT + 201eb1f2001c9839dbd005de6e764722 + 42761 + + + file + /includes/install/sql/sqlite.sql + Sat, 18 Sep 2010 20:08:35 GMT + 02662b3efdeb52cb09ba47203984c8d2 + 41728 + + + file + /includes/lib_cdr.php + Sat, 06 Feb 2010 18:18:53 GMT + 83d550d6c159fb6db6d0d6605f8ed5ee + 3111 + + + file + /includes/lib_functions.php + Thu, 23 Sep 2010 10:36:46 GMT + 28ba5b89a5660e0734239d4439a60e98 + 20444 + + + file + /includes/lib_install_copy.php + Tue, 21 Sep 2010 16:40:39 GMT + 6db91d8c03136b915d65371b801311d0 + 10391 + + + file + /includes/lib_pdo.php + Thu, 23 Sep 2010 08:11:46 GMT + 2a66473313ff282fc45b0328ccfa6feb + 8465 + + + file + /includes/lib_php.php + Tue, 09 Mar 2010 23:56:52 GMT + 3ba8c2dfb9a069de73dbcacfdbf99273 + 3770 + + + file + /includes/lib_schema.php + Fri, 01 Oct 2010 15:46:30 GMT + 90340704c5af4240884aa6bd76ed0de1 + 11343 + + + file + /includes/lib_switch.php + Wed, 22 Sep 2010 15:30:03 GMT + a96c4f73ee5321da9786b9f940e835d3 + 217716 + + + file + /includes/lib_system_settings_default.php + Mon, 30 Aug 2010 22:04:47 GMT + 0062ee7b9fd7d1ea021ef03ada2e799c + 8733 + + + file + /includes/menu.php + Sun, 18 Apr 2010 02:58:04 GMT + 8825aef61e2df6e755579ab750a52e6b + 9533 + + + file + /includes/menu_list.php + Sun, 18 Apr 2010 03:03:28 GMT + 5d695dfe5ee9b84b3fb3ac394aad120c + 10495 + + + file + /includes/paging.php + Sat, 06 Feb 2010 18:17:54 GMT + 6130c7876f557bf9762376363fcee359 + 3467 + + + file + /includes/persistform.php + Sat, 06 Feb 2010 18:17:54 GMT + e2d36087c696746e62bc3d28367d05b5 + 1571 + + + file + /includes/persistformvar.php + Sat, 06 Feb 2010 18:17:54 GMT + 7be4848bfd70ceff231ccc0f6f896778 + 1605 + + + directory + /includes/pop3 + + + + + + file + /includes/pop3/mime_parser.php + Fri, 09 Apr 2010 00:01:37 GMT + 9f6694873f9785bb3f0f640a417dbd8f + 77658 + + + file + /includes/pop3/parse_message.php + Sun, 01 Feb 2009 16:33:42 GMT + e9108d04e271950c5711cda9b7ab88dd + 2589 + + + file + /includes/pop3/pop3.php + Sun, 01 Feb 2009 16:33:42 GMT + db16cec54c4ac61b749e35689c9c9787 + 23819 + + + file + /includes/pop3/rfc822_addresses.php + Fri, 09 Apr 2010 00:01:37 GMT + 5a4310adf2b11f5154531ad5d6c68b0f + 20122 + + + directory + /includes/templates/provision + + + + + + directory + /includes/templates/provision/aastra + + + + + + directory + /includes/templates/provision/aastra/675x + + + + + + file + /includes/templates/provision/aastra/675x/{v_mac}.cfg + Thu, 19 Aug 2010 07:41:58 GMT + dabe18bd088393a798ce77e09d4e84c7 + 3697 + + + directory + /includes/templates/provision/cisco + + + + + + directory + /includes/templates/provision/cisco/7940 + + + + + + directory + /includes/templates/provision/cisco/7960 + + + + + + directory + /includes/templates/provision/grandstream + + + + + + directory + /includes/templates/provision/linksys + + + + + + directory + /includes/templates/provision/linksys/spa942 + + + + + + file + /includes/templates/provision/linksys/spa942/{v_mac}.xml + Mon, 05 Jul 2010 17:58:03 GMT + 826df81f528099612f785bb68ca542f8 + 1364 + + + directory + /includes/templates/provision/polycom + + + + + + directory + /includes/templates/provision/snom + + + + + + directory + /includes/templates/provision/snom/820 + + + + + + file + /includes/templates/provision/snom/820/{v_mac}.xml + Sun, 27 Jun 2010 10:02:56 GMT + 46c1aa2b3da420cd26fd7b361bcd3360 + 2373 + + + directory + /includes/templates/provision/yealink + + + + + + file + /includes/root.php + Sat, 06 Feb 2010 18:17:54 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /includes/securedownload.php + Sat, 06 Feb 2010 18:17:54 GMT + 5fd41baaed351b0f27c6774b64ee8096 + 2941 + + + file + /includes/upload.php + Sat, 06 Feb 2010 18:17:54 GMT + 64d6abe31bcfa5d107d4f8b9eb9581d3 + 1705 + + + file + /includes/cmd.php + Sat, 06 Feb 2010 18:17:54 GMT + 3041c90a77039729bb041c0679a0c80e + 1788 + + + file + /includes/v_dialplan_entry_exists.php + Sat, 06 Feb 2010 18:17:54 GMT + 38f66218cc0ca9faa16a81bb7bdf3027 + 4093 + + + file + /includes/wysiwyg.php + Sat, 06 Feb 2010 18:17:17 GMT + 951c322cd95551458a036020407add07 + 7093 + + + file + /index.php + Thu, 23 Sep 2010 10:37:11 GMT + 3a4264b33e02dc3d8cf804f845e0bbd7 + 11206 + + + file + /install.php + Thu, 23 Sep 2010 08:43:41 GMT + 0fb3b6e5b3b51f763949eb54b97c5f29 + 54107 + + + file + /licenses.php + Mon, 21 Jun 2010 23:56:08 GMT + bdc853e1bb9d26b93cbc9fb5ec39bbef + 3476 + + + file + /login.php + Thu, 29 Jul 2010 03:05:07 GMT + c9fc2ebbbe95518fbeb3144afa78fae2 + 2558 + + + file + /logout.php + Sat, 06 Feb 2010 18:12:33 GMT + 4c47ffae19cabefbdd41b5fa9626059b + 1015 + + + directory + /mod + + + + + + directory + /mod/auto_attendant + + + + + + file + /mod/auto_attendant/root.php + Sat, 06 Feb 2010 18:30:59 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/auto_attendant/v_auto_attendant.php + Mon, 22 Feb 2010 23:04:56 GMT + 0c777740aca5f973cf4ca418c56c7c4a + 6376 + + + file + /mod/auto_attendant/v_auto_attendant_delete.php + Sat, 06 Feb 2010 18:31:00 GMT + 1438343375ffcc1d364acbc13180a670 + 2995 + + + file + /mod/auto_attendant/v_auto_attendant_edit.php + Sat, 28 Aug 2010 18:49:38 GMT + 0ce8cf0a49722d42e22c21314469cc8a + 31690 + + + file + /mod/auto_attendant/v_auto_attendant_options_delete.php + Sat, 06 Feb 2010 18:30:59 GMT + 17c1ee1f30ab48c4129012ded718c3f3 + 1790 + + + file + /mod/auto_attendant/v_auto_attendant_options_edit.php + Sat, 28 Aug 2010 18:49:30 GMT + 2418d4d58f7a2a2ffab01708100e6b92 + 13141 + + + directory + /mod/calls_active + + + + + + file + /mod/calls_active/root.php + Tue, 20 Oct 2009 18:13:40 GMT + 1d66d2f0f6ca694fc5d98c5b0e94e05b + 1091 + + + file + /mod/calls_active/v_calls_active.php + Sat, 10 Apr 2010 02:36:26 GMT + 3de488dfe1ae12f7588db2f738934089 + 5325 + + + file + /mod/calls_active/v_calls_active_assigned_extensions_inc.php + Sun, 22 Aug 2010 08:51:29 GMT + a0d720d60f75b2a16c4ee8823cd8db1d + 11664 + + + file + /mod/calls_active/v_calls_active_extensions.php + Mon, 30 Aug 2010 18:05:51 GMT + bc748bd109faf4bb24dc6fbf0499dd60 + 7747 + + + file + /mod/calls_active/v_calls_active_extensions_inc.php + Fri, 27 Aug 2010 23:54:49 GMT + d650fb5ec6a51c455aa8e6c33c1781a1 + 16404 + + + file + /mod/calls_active/v_calls_active_inc.php + Thu, 27 May 2010 22:59:34 GMT + 6995c9e3c2a184612eee1115a9364e37 + 14295 + + + file + /mod/calls_active/v_calls_exec.php + Sat, 18 Sep 2010 21:19:42 GMT + dd5ed8421d87d8b10b290e2e3190c412 + 5186 + + + directory + /mod/call_broadcast + + + + + + file + /mod/call_broadcast/root.php + Fri, 12 Feb 2010 06:43:53 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/call_broadcast/v_call_broadcast.php + Fri, 03 Sep 2010 08:06:49 GMT + e3091908fd30670bc8031e70f3c62875 + 5710 + + + file + /mod/call_broadcast/v_call_broadcast_delete.php + Fri, 12 Feb 2010 06:43:52 GMT + 3e34c7486be6c4723141c9bf613ac614 + 1524 + + + file + /mod/call_broadcast/v_call_broadcast_edit.php + Fri, 03 Sep 2010 08:07:01 GMT + 7934aa16d6978744d1fd6f0770e48a8d + 18426 + + + file + /mod/call_broadcast/v_call_broadcast_send.php + Fri, 25 Jun 2010 04:12:52 GMT + a40a6e6829bb0c62b2c2fbeaebb7c104 + 13138 + + + directory + /mod/call_forward + + + + + + file + /mod/call_forward/root.php + Sat, 06 Feb 2010 18:31:36 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/call_forward/v_call_forward.php + Sun, 19 Sep 2010 03:39:37 GMT + cd8f2129b853ab739e8060d3ffe7e43c + 8278 + + + file + /mod/call_forward/v_call_forward_add.php + Thu, 15 Jul 2010 08:58:36 GMT + a3138810902b87fe1c38599813dbf816 + 26761 + + + file + /mod/call_forward/v_call_forward_delete.php + Sat, 06 Feb 2010 18:31:37 GMT + 9a8dd600b6467a831b6344a4da359a89 + 1825 + + + file + /mod/call_forward/v_call_forward_details_delete.php + Sat, 06 Feb 2010 18:31:36 GMT + e7e9864c56887d50ca37e861b55faaf3 + 1742 + + + file + /mod/call_forward/v_call_forward_details_edit.php + Sun, 23 May 2010 06:24:56 GMT + 150a27be5f1325dd1fc82f4350288cac + 16253 + + + file + /mod/call_forward/v_call_forward_edit.php + Sat, 28 Aug 2010 18:49:11 GMT + 45f94c9284cf075e6d8614ab7936b9a2 + 19401 + + + directory + /mod/cdr + + + + + + file + /mod/cdr/root.php + Sat, 06 Feb 2010 18:09:39 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/cdr/v_cdr.php + Sun, 29 Aug 2010 04:35:01 GMT + acdcd298d1926225ca8f0c39b9b7b34c + 18036 + + + file + /mod/cdr/v_cdr_csv.php + Sun, 29 Aug 2010 04:35:31 GMT + 3a021e1cdcbd9940cc74261838c52b5b + 6104 + + + file + /mod/cdr/v_cdr_edit.php + Sat, 28 Aug 2010 18:49:02 GMT + 51cb63bc7bce086f045af86c0bb4faf2 + 17414 + + + file + /mod/cdr/v_cdr_import.php + Sun, 23 May 2010 06:23:48 GMT + 73ef6714bb4a115430664c0e82447c81 + 3248 + + + file + /mod/cdr/v_cdr_search.php + Tue, 06 Jul 2010 22:02:44 GMT + 425fe4561ac66de5bf3d595307bdd5bc + 5811 + + + directory + /mod/click_to_call + + + + + + file + /mod/click_to_call/click_to_call.php + Tue, 04 May 2010 02:47:08 GMT + a81e4afd3294f387865ae30a08bba761 + 5398 + + + file + /mod/click_to_call/root.php + Thu, 11 Mar 2010 10:21:32 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + directory + /mod/conferences + + + + + + file + /mod/conferences/root.php + Sat, 06 Feb 2010 18:30:24 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/conferences/v_conferences.php + Sat, 18 Sep 2010 18:41:56 GMT + ae89b09587aae22ca8a047769ba34add + 8971 + + + file + /mod/conferences/v_conferences_delete.php + Sat, 06 Feb 2010 18:30:23 GMT + 4ef8cc1ea94058b0319f364024033eac + 1824 + + + file + /mod/conferences/v_conferences_details_delete.php + Sat, 06 Feb 2010 18:30:23 GMT + 7188d5fb3a4e7bb692ae107d993bdc87 + 1741 + + + file + /mod/conferences/v_conferences_details_edit.php + Sun, 23 May 2010 06:25:30 GMT + 2b519d42e181fd784b4a125c6c1d2d2f + 16274 + + + file + /mod/conferences/v_conferences_edit.php + Sat, 18 Sep 2010 18:41:15 GMT + 3f0b47f93758ff1e26c5fb169cfaf98a + 21403 + + + file + /mod/conferences/v_conferences_edit_advanced.php + Thu, 15 Jul 2010 22:20:31 GMT + 4276f5bcd02bebfd87c9d8ed9e5f15ee + 18909 + + + directory + /mod/conferences_active + + + + + + file + /mod/conferences_active/root.php + Tue, 20 Oct 2009 18:13:40 GMT + 1d66d2f0f6ca694fc5d98c5b0e94e05b + 1091 + + + file + /mod/conferences_active/v_conferences_active.php + Thu, 11 Feb 2010 18:35:26 GMT + 4e4e0c721682df1d6e0c95eb1e60c967 + 3537 + + + file + /mod/conferences_active/v_conferences_active_inc.php + Thu, 11 Feb 2010 20:41:22 GMT + 7f0bf3a18c3fed1540ca2b33baaf2fc4 + 3284 + + + file + /mod/conferences_active/v_conference_exec.php + Thu, 13 May 2010 11:16:52 GMT + bf5bcab7e8abf841491058acf55ae60a + 4027 + + + file + /mod/conferences_active/v_conference_interactive.php + Thu, 11 Feb 2010 18:36:17 GMT + b233603ea73fea87488b7da81e39c2c6 + 4164 + + + file + /mod/conferences_active/v_conference_interactive_inc.php + Thu, 13 May 2010 10:58:29 GMT + 68214114f8ddd7127aa1c27f16f4f93d + 7970 + + + directory + /mod/contacts + + + + + + file + /mod/contacts/root.php + Sat, 06 Feb 2010 18:29:43 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/contacts/users.php + Fri, 03 Sep 2010 07:40:48 GMT + 11a9edefb97be120ae6a1315ca8a207a + 6905 + + + file + /mod/contacts/users_delete.php + Sat, 06 Feb 2010 18:29:43 GMT + 5ef460395fc017831c06720cc3a25092 + 1531 + + + file + /mod/contacts/users_edit.php + Sat, 28 Aug 2010 18:48:55 GMT + cafb237d4d3944e326f5a82b5ab8888f + 42268 + + + file + /mod/contacts/users_vcard.php + Tue, 08 Jun 2010 05:37:43 GMT + 4b84fc5b607f5501dcd56d433bd430c8 + 4354 + + + directory + /mod/content + + + + + + file + /mod/content/index.php + Sat, 06 Feb 2010 18:07:33 GMT + 0d5bda44b8b09c0db174bab3e3544674 + 1233 + + + file + /mod/content/root.php + Sat, 06 Feb 2010 18:07:29 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/content/rss.css + Tue, 08 Dec 2009 02:25:06 GMT + a3f96f1ba9be618ea2154531627e80f8 + 694 + + + file + /mod/content/rss.php + Sat, 06 Feb 2010 18:09:06 GMT + aa0d12cd56d15f9e1f5da159444c8a27 + 7682 + + + file + /mod/content/rssadd.php + Sun, 23 May 2010 06:26:22 GMT + 202ce21c18632c09e9bf02e19552f7a3 + 10477 + + + file + /mod/content/rsscontent.php + Sat, 06 Feb 2010 18:08:59 GMT + 228dae7777d58771f221f00b32018653 + 2012 + + + file + /mod/content/rssdelete.php + Sun, 23 May 2010 06:43:08 GMT + b0cc4c8cc2d85c2923ffdf27fe9918d5 + 1679 + + + file + /mod/content/rsslist.php + Wed, 24 Feb 2010 16:13:54 GMT + 2649f7eecd704336e7525eed5a043b06 + 8186 + + + file + /mod/content/rssmovedown.php + Sun, 23 May 2010 06:26:48 GMT + 59a6c22433a88901a30001e4b1b594c9 + 2675 + + + file + /mod/content/rssmoveup.php + Sun, 23 May 2010 06:27:00 GMT + 629bc473f58cc7fca44aee0559372d8d + 2198 + + + file + /mod/content/rsssearch.php + Sat, 06 Feb 2010 18:08:42 GMT + f55e6c830fb6925129351c05f5e2ab39 + 10682 + + + file + /mod/content/rsssubadd.php + Sun, 23 May 2010 06:56:28 GMT + e499313ab65420dd3476cc4a2a395102 + 5087 + + + file + /mod/content/rsssubcategoryadd.php + Sun, 23 May 2010 06:58:00 GMT + 474155551f4694d33fa0959948fe1dbf + 3334 + + + file + /mod/content/rsssubcategorylist.php + Sat, 06 Feb 2010 18:08:18 GMT + 8ac2d1a519a64aeceaf3cc2e36c12eb2 + 6260 + + + file + /mod/content/rsssubcategoryupdate.php + Sat, 06 Feb 2010 18:08:12 GMT + 3df7a52702ac43ef0503d8e0ad7e39c0 + 4137 + + + file + /mod/content/rsssubdelete.php + Sun, 23 May 2010 06:43:26 GMT + 8b60324d6755d64357d034b35c727c85 + 1692 + + + file + /mod/content/rsssublist.php + Sat, 06 Feb 2010 18:08:04 GMT + 639203a208621a400d7bc04917660a1c + 14992 + + + file + /mod/content/rsssubsearch.php + Sat, 06 Feb 2010 18:08:00 GMT + 19203a2e993a429b7dded8a2c724d4a7 + 10203 + + + file + /mod/content/rsssubupdate.php + Sat, 06 Feb 2010 18:07:49 GMT + 02a9263e38177e0c6302b2a084328fa5 + 6956 + + + file + /mod/content/rssupdate.php + Sun, 05 Sep 2010 07:29:15 GMT + e618ee07c766a86767d138edefc6b388 + 14159 + + + directory + /mod/dialplan + + + + + + file + /mod/dialplan/root.php + Sat, 06 Feb 2010 18:07:05 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/dialplan/v_dialplans.php + Sat, 01 May 2010 07:58:21 GMT + a3be48af0b44ecfefa947281feaa8585 + 4431 + + + file + /mod/dialplan/v_dialplans.php + Tue, 04 May 2010 01:28:42 GMT + b1a0d09a3c629c9c70183cd92a1889f8 + 6568 + + + file + /mod/dialplan/dialplan_add.php + Sat, 14 Aug 2010 07:01:10 GMT + 3d234f0355ce2c1b332ce504260d568e + 26489 + + + file + /mod/dialplan/v_dialplan_delete.php + Sat, 01 May 2010 19:07:25 GMT + 70c98ad23504a24fa38c13c6ca8ee0b6 + 1830 + + + file + /mod/dialplan/v_dialplan_details_delete.php + Tue, 04 May 2010 01:29:47 GMT + a731a9a1e8963c1a1aecd5f3bd0eafb2 + 1747 + + + file + /mod/dialplan/v_dialplan_details_edit.php + Sun, 23 May 2010 06:27:22 GMT + fb41795185cfbec6470d738ef5a924e7 + 16312 + + + file + /mod/dialplan/v_dialplan_edit.php + Sat, 28 Aug 2010 18:50:00 GMT + f5421ef8b178c5af04abab3f8c7adfd5 + 19521 + + + directory + /mod/dialplan_outbound + + + + + + file + /mod/dialplan_outbound/root.php + Thu, 15 Jul 2010 22:20:31 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/dialplan_outbound/v_dialplan_outbound.php + Thu, 02 Sep 2010 08:17:36 GMT + 14b0b555ae6840a52d67f8f0e0363f57 + 8088 + + + file + /mod/dialplan_outbound/v_dialplan_outbound_add.php + Fri, 03 Sep 2010 06:57:37 GMT + 27c70472cc21e12e6816a970bdabe237 + 23379 + + + file + /mod/dialplan_outbound/v_dialplan_outbound_delete.php + Thu, 02 Sep 2010 08:03:59 GMT + 14fb4d0b98d3583c6d24daeb46fd3939 + 1830 + + + file + /mod/dialplan_outbound/v_dialplan_outbound_details_delete.php + Thu, 02 Sep 2010 08:03:58 GMT + 6b9b76c12378bb24d087fbc839f7c8b2 + 1747 + + + file + /mod/dialplan_outbound/v_dialplan_outbound_details_edit.php + Fri, 03 Sep 2010 01:18:55 GMT + c65c6eaaa48a9e490e13993143dd4182 + 16160 + + + file + /mod/dialplan_outbound/v_dialplan_outbound_edit.php + Thu, 02 Sep 2010 08:19:22 GMT + c6c0e2b04090844b31535f58e70ff8c1 + 18988 + + + directory + /mod/exec + + + + + + file + /mod/exec/root.php + Sat, 06 Feb 2010 18:29:14 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/exec/v_exec.php + Sat, 10 Apr 2010 02:34:16 GMT + 8e33fb266adfaa5e267be76ab9c1c1a1 + 7190 + + + directory + /mod/extensions + + + + + + file + /mod/extensions/root.php + Sat, 06 Feb 2010 18:06:15 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/extensions/v_extensions.php + Thu, 05 Aug 2010 15:52:26 GMT + 3ef63d4f5b1cf9c304ee40ee4ceb37b7 + 5813 + + + file + /mod/extensions/v_extensions_delete.php + Sat, 06 Feb 2010 18:06:15 GMT + da29fa8196cbf0be474eba43be84b68a + 1586 + + + file + /mod/extensions/v_extensions_edit.php + Tue, 07 Sep 2010 12:02:49 GMT + 7d50119a307ef438bd50d8922f6d2554 + 32017 + + + directory + /mod/fax + + + + + + file + /mod/fax/root.php + Sat, 06 Feb 2010 18:28:52 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/fax/v_fax.php + Tue, 29 Jun 2010 06:48:29 GMT + 5812644d3d5a2c44771bdf9cf8a02e3f + 5489 + + + file + /mod/fax/v_fax_delete.php + Tue, 29 Jun 2010 06:47:47 GMT + e688ce09274ddd3b2b7fc3413080fbae + 1503 + + + file + /mod/fax/v_fax_edit.php + Mon, 12 Jul 2010 16:04:27 GMT + 5b42f88134c8511277aeacf1c154e8ed + 29625 + + + directory + /mod/features + + + + + + file + /mod/features/root.php + Sat, 06 Feb 2010 18:28:15 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/features/v_features.php + Wed, 24 Feb 2010 07:36:30 GMT + 3d5c49ea8ba3b39e56729c67597f87f5 + 5671 + + + directory + /mod/fifo + + + + + + file + /mod/fifo/root.php + Sat, 10 Jul 2010 02:32:26 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/fifo/v_fifo.php + Tue, 13 Jul 2010 05:57:16 GMT + 37d054a855d6d6d65ca03413be62e2ad + 7927 + + + file + /mod/fifo/v_fifo_add.php + Sun, 11 Jul 2010 08:50:43 GMT + 3b09db9d886ca744edc2ac82ce8f5689 + 17738 + + + file + /mod/fifo/v_fifo_delete.php + Sat, 10 Jul 2010 20:05:27 GMT + dd5b28101578f84f8e14a477d21a1055 + 1743 + + + file + /mod/fifo/v_fifo_details_delete.php + Sat, 10 Jul 2010 20:05:51 GMT + f2369ffb533c13aed30361c10c58ed71 + 1660 + + + file + /mod/fifo/v_fifo_details_edit.php + Sun, 11 Jul 2010 08:48:06 GMT + 24557188a309771fbee717079f594b9c + 15795 + + + file + /mod/fifo/v_fifo_edit.php + Sat, 28 Aug 2010 18:50:00 GMT + 6d7d1b70627dc32f720e65b4496f496a + 18819 + + + directory + /mod/fifo_list + + + + + + file + /mod/fifo_list/root.php + Thu, 10 Jun 2010 19:58:45 GMT + 1d66d2f0f6ca694fc5d98c5b0e94e05b + 1091 + + + file + /mod/fifo_list/v_fifo_exec.php + Sun, 11 Jul 2010 07:59:59 GMT + 15a1ae96460c7965bdb21db9665aff4b + 3506 + + + file + /mod/fifo_list/v_fifo_interactive.php + Sun, 11 Jul 2010 08:59:23 GMT + 492de8f176feaf5d9987d1bb70e36337 + 4080 + + + file + /mod/fifo_list/v_fifo_interactive_inc.php + Sun, 11 Jul 2010 08:08:25 GMT + db385fbafa904bf27cf617b2d519e087 + 7276 + + + file + /mod/fifo_list/v_fifo_list.php + Sun, 11 Jul 2010 07:59:59 GMT + f9aa241ce14e776a225fd2529498999e + 3444 + + + file + /mod/fifo_list/v_fifo_list_inc.php + Sun, 11 Jul 2010 07:59:59 GMT + 7ba0f1332da558afd04babd75d535abb + 3727 + + + directory + /mod/gateways + + + + + + file + /mod/gateways/root.php + Sat, 06 Feb 2010 18:05:48 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/gateways/v_gateways.php + Sat, 06 Feb 2010 18:05:49 GMT + f547f19c3bce7a9f87c09923afc9f210 + 6683 + + + file + /mod/gateways/v_gateways_delete.php + Sat, 06 Feb 2010 18:05:49 GMT + d4eadbdaa260723a8c51ad80fda630bc + 2631 + + + file + /mod/gateways/v_gateways_edit.php + Tue, 07 Sep 2010 12:10:16 GMT + d61af79d667e6042fbc080c24888c5ea + 34506 + + + directory + /mod/grammar_edit + + + + + + file + /mod/grammar_edit/clipadd.php + Sun, 23 May 2010 06:37:09 GMT + 28549f6f91b0d869877e1a6b0af23966 + 3269 + + + file + /mod/grammar_edit/clipdelete.php + Sat, 06 Feb 2010 18:34:44 GMT + 2c02de8b37ce5c23ecf21c9c8da581d9 + 1412 + + + file + /mod/grammar_edit/cliplist.php + Sat, 06 Feb 2010 18:34:44 GMT + d8d2ce5f33d43bbd3a3e63176115ae23 + 12754 + + + file + /mod/grammar_edit/clipoptions.php + Sat, 06 Feb 2010 18:34:44 GMT + 3bde522624cbb5345d3ad1fdc42ef140 + 3100 + + + file + /mod/grammar_edit/clipoptionslist.php + Sat, 06 Feb 2010 18:34:44 GMT + 0c8f8b95aee81315c786f7cdc8929d2f + 10761 + + + file + /mod/grammar_edit/clipsearch.php + Sat, 06 Feb 2010 18:34:44 GMT + 82a54406083514f6f2ce0cce35abeda3 + 6481 + + + file + /mod/grammar_edit/clipupdate.php + Sat, 06 Feb 2010 18:34:43 GMT + 30210d0c7a4526edc2066b7e7d244365 + 4337 + + + file + /mod/grammar_edit/filedelete.php + Sat, 06 Feb 2010 18:34:43 GMT + 810c5c9aef088f4d75896c10a917639e + 2201 + + + file + /mod/grammar_edit/filelist.php + Sat, 28 Aug 2010 21:22:17 GMT + f8ff3663039278539ce36d7b7abacb89 + 8690 + + + file + /mod/grammar_edit/filenew.php + Sat, 06 Feb 2010 18:34:43 GMT + 33042b92b0173e15a6f543ee0bccc8e2 + 2311 + + + file + /mod/grammar_edit/fileoptions.php + Sat, 06 Feb 2010 18:34:43 GMT + 5b79c7987f6cb1b4d2f8f2a17702dbb5 + 4000 + + + file + /mod/grammar_edit/fileoptionslist.php + Sat, 06 Feb 2010 18:34:43 GMT + 0cbb547a0fd10ac3485d51125e6adfa3 + 14064 + + + file + /mod/grammar_edit/fileread.php + Sat, 06 Feb 2010 18:34:43 GMT + 87311164928514f501d66acf3e977af5 + 1213 + + + file + /mod/grammar_edit/filerename.php + Sat, 06 Feb 2010 18:34:43 GMT + 3b5a76994b03f24d4dc03032f6ddfb7b + 2688 + + + file + /mod/grammar_edit/filesave.php + Sat, 06 Feb 2010 18:34:43 GMT + f22c7667f8480711d35e974f742c830c + 1302 + + + file + /mod/grammar_edit/folderdelete.php + Sat, 06 Feb 2010 18:34:43 GMT + 8b171129783c2e6f5fba0d43c5652880 + 1198 + + + file + /mod/grammar_edit/foldernew.php + Sat, 06 Feb 2010 18:34:43 GMT + 4f130ae369199f4c8b5e06e3269a4f45 + 2199 + + + file + /mod/grammar_edit/footer.php + Sat, 06 Feb 2010 18:34:43 GMT + 48b9b9266e8e74b4ae39a4249a8e37c8 + 1188 + + + file + /mod/grammar_edit/header.php + Sat, 06 Feb 2010 18:34:43 GMT + 745a04241d9d3d90d3c7fb886f02c767 + 2818 + + + directory + /mod/grammar_edit/images + + + + + + file + /mod/grammar_edit/images/file.gif + Tue, 08 Dec 2009 02:24:00 GMT + f5ddae5e4e5eb50e1841b543dc9efd0e + 96 + + + file + /mod/grammar_edit/images/file.png + Tue, 08 Dec 2009 02:24:00 GMT + b0b89b853c4514d1a79429365cdf0cb2 + 434 + + + file + /mod/grammar_edit/images/folder.gif + Tue, 08 Dec 2009 02:24:00 GMT + 33d8e89f825441b036df0ea0a4d7c86b + 585 + + + file + /mod/grammar_edit/images/gear.png + Tue, 08 Dec 2009 02:24:00 GMT + 91a6abc4126bc211a6ffe69a1f3fdbc8 + 822 + + + file + /mod/grammar_edit/images/leaf.gif + Tue, 08 Dec 2009 02:24:00 GMT + 33d8e89f825441b036df0ea0a4d7c86b + 585 + + + file + /mod/grammar_edit/images/minus.gif + Tue, 08 Dec 2009 02:24:00 GMT + 813b2a3203fad9b56dc006e90996dba8 + 124 + + + file + /mod/grammar_edit/images/plus.gif + Tue, 08 Dec 2009 02:24:00 GMT + 6e6b599e843efe688bc76a2e19ebeced + 129 + + + file + /mod/grammar_edit/images/program.gif + Tue, 08 Dec 2009 02:24:00 GMT + 738187dc01e9c8a83723362935ef372c + 61 + + + directory + /mod/grammar_edit/images/thumbnails + + + + + + file + /mod/grammar_edit/images/thumbnails/cliplibrary.png + Tue, 08 Dec 2009 02:24:00 GMT + 3b5ec9a7a870c46784047083bbcfd67a + 20544 + + + file + /mod/grammar_edit/images/thumbnails/filemanagement.png + Tue, 08 Dec 2009 02:24:00 GMT + 8ba2a3f2d1f05c2acba6ed8fafbc49f4 + 23105 + + + file + /mod/grammar_edit/images/thumbnails/phpeditor.png + Tue, 08 Dec 2009 02:24:00 GMT + 08f4a12c81a3f87af7de6139cc8a8669 + 98754 + + + file + /mod/grammar_edit/index.php + Wed, 25 Aug 2010 23:44:39 GMT + 94d97486f8c00d1c8130610735a6ad7f + 9363 + + + file + /mod/grammar_edit/list.php + Sat, 06 Feb 2010 18:34:44 GMT + e93ae1b29d085e0457f1e3ed62531c67 + 4290 + + + file + /mod/grammar_edit/readme.txt + Tue, 08 Dec 2009 02:24:01 GMT + 53dd94e0899a6dbd9d36075ff8dcb7ba + 126 + + + file + /mod/grammar_edit/root.php + Sat, 06 Feb 2010 18:34:44 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + directory + /mod/hardware_phones + + + + + + file + /mod/hardware_phones/root.php + Thu, 10 Jun 2010 20:00:21 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/hardware_phones/v_hardware_phones.php + Fri, 03 Sep 2010 08:02:08 GMT + a676e69b7f5987c31a40c9d8df23faff + 6359 + + + file + /mod/hardware_phones/v_hardware_phones_delete.php + Sun, 27 Jun 2010 06:30:20 GMT + 1bd7ad3207de513e79156d1cf1f08aa3 + 1455 + + + file + /mod/hardware_phones/v_hardware_phones_edit.php + Fri, 03 Sep 2010 08:01:58 GMT + dcd35aef9aa1f400e8ab8f3e8e968a09 + 11595 + + + directory + /mod/hunt_group + + + + + + file + /mod/hunt_group/root.php + Sat, 06 Feb 2010 18:27:40 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/hunt_group/v_hunt_group.php + Sat, 06 Feb 2010 18:27:40 GMT + dd31575678eeef367523efe610389df2 + 6331 + + + file + /mod/hunt_group/v_hunt_group_delete.php + Sat, 06 Feb 2010 18:27:40 GMT + db7cfdf2736ccf71d0b18ccff6740fd3 + 3816 + + + file + /mod/hunt_group/v_hunt_group_destinations_delete.php + Sat, 06 Feb 2010 18:27:40 GMT + 408af55b503108fdad2a8b7ccd9e0fa9 + 1738 + + + file + /mod/hunt_group/v_hunt_group_destinations_edit.php + Sat, 28 Aug 2010 18:50:00 GMT + 3ba620fa342c3e78e8cd1cf99b9f1151 + 11601 + + + file + /mod/hunt_group/v_hunt_group_edit.php + Sat, 28 Aug 2010 18:50:00 GMT + dd5cf744b0c218700eb51d6ee41efe3a + 21107 + + + directory + /mod/ivr_menu + + + + + + file + /mod/ivr_menu/root.php + Thu, 11 Mar 2010 10:22:41 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/ivr_menu/v_ivr_menu.php + Fri, 03 Sep 2010 07:49:29 GMT + 5f679960ef59816a6044a034489dc9e4 + 5436 + + + file + /mod/ivr_menu/v_ivr_menu_delete.php + Wed, 12 May 2010 23:27:21 GMT + 3ab15f0aa7f7b82a3feae85b3d937ca5 + 2155 + + + file + /mod/ivr_menu/v_ivr_menu_edit.php + Fri, 03 Sep 2010 07:53:28 GMT + e654a1a75e9ba94d498ec31cf68e00f8 + 28623 + + + file + /mod/ivr_menu/v_ivr_menu_options.php + Fri, 01 Oct 2010 02:14:39 GMT + ac7f17b3e58a9f7de9cc4db487e03dab + 6713 + + + file + /mod/ivr_menu/v_ivr_menu_options_delete.php + Tue, 11 May 2010 07:53:27 GMT + 117e8011fbd9389f47393cd24d8c742c + 851 + + + file + /mod/ivr_menu/v_ivr_menu_options_edit.php + Fri, 03 Sep 2010 07:52:33 GMT + 61681b8ad6dd0c9817aa67006eebb784 + 11774 + + + directory + /mod/modules + + + + + + file + /mod/modules/root.php + Sat, 06 Feb 2010 18:04:36 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/modules/v_modules.php + Sat, 01 May 2010 08:04:43 GMT + bf50f66f71171a4981b3c9073526bcd1 + 7316 + + + file + /mod/modules/v_modules_delete.php + Sat, 01 May 2010 08:04:43 GMT + f54ff1eabd51b61e3159b9b68a7dc32a + 1518 + + + file + /mod/modules/v_modules_edit.php + Sat, 28 Aug 2010 18:48:19 GMT + 676584f0be83463da930015eba88390a + 10006 + + + directory + /mod/php_edit + + + + + + file + /mod/php_edit/clipadd.php + Sun, 23 May 2010 06:29:55 GMT + 53478170a6f1dfbeefd843aac38320cd + 3556 + + + file + /mod/php_edit/clipdelete.php + Sat, 06 Feb 2010 18:36:27 GMT + 2c02de8b37ce5c23ecf21c9c8da581d9 + 1412 + + + file + /mod/php_edit/cliplist.php + Sat, 06 Feb 2010 18:36:27 GMT + d8d2ce5f33d43bbd3a3e63176115ae23 + 12754 + + + file + /mod/php_edit/clipoptions.php + Sat, 06 Feb 2010 18:36:27 GMT + 3bde522624cbb5345d3ad1fdc42ef140 + 3100 + + + file + /mod/php_edit/clipoptionslist.php + Sat, 06 Feb 2010 18:36:27 GMT + 0c8f8b95aee81315c786f7cdc8929d2f + 10761 + + + file + /mod/php_edit/clipsearch.php + Sat, 06 Feb 2010 18:36:27 GMT + 82a54406083514f6f2ce0cce35abeda3 + 6481 + + + file + /mod/php_edit/clipupdate.php + Sat, 06 Feb 2010 18:36:27 GMT + 83d6d740fa4f3a5c23207dc2a4598a75 + 4346 + + + file + /mod/php_edit/filedelete.php + Sat, 06 Feb 2010 18:36:26 GMT + 810c5c9aef088f4d75896c10a917639e + 2201 + + + file + /mod/php_edit/filelist.php + Tue, 20 Jul 2010 01:36:53 GMT + 72c204d299a4369a620dc14b2e5da449 + 13665 + + + file + /mod/php_edit/filenew.php + Sat, 06 Feb 2010 18:36:26 GMT + 33042b92b0173e15a6f543ee0bccc8e2 + 2311 + + + file + /mod/php_edit/fileoptions.php + Sat, 06 Feb 2010 18:36:26 GMT + 5b79c7987f6cb1b4d2f8f2a17702dbb5 + 4000 + + + file + /mod/php_edit/fileoptionslist.php + Sat, 06 Feb 2010 18:36:26 GMT + c55b42c2c00d2dbad6df12a60595fa56 + 14073 + + + file + /mod/php_edit/fileread.php + Sat, 06 Feb 2010 18:36:26 GMT + 87311164928514f501d66acf3e977af5 + 1213 + + + file + /mod/php_edit/filerename.php + Sat, 06 Feb 2010 18:36:26 GMT + 3b5a76994b03f24d4dc03032f6ddfb7b + 2688 + + + file + /mod/php_edit/filesave.php + Sat, 06 Feb 2010 18:36:27 GMT + f22c7667f8480711d35e974f742c830c + 1302 + + + file + /mod/php_edit/folderdelete.php + Sat, 06 Feb 2010 18:36:27 GMT + 8b171129783c2e6f5fba0d43c5652880 + 1198 + + + file + /mod/php_edit/foldernew.php + Sat, 06 Feb 2010 18:36:27 GMT + 4f130ae369199f4c8b5e06e3269a4f45 + 2199 + + + file + /mod/php_edit/footer.php + Sat, 06 Feb 2010 18:36:26 GMT + 48b9b9266e8e74b4ae39a4249a8e37c8 + 1188 + + + file + /mod/php_edit/header.php + Sat, 06 Feb 2010 18:36:26 GMT + 745a04241d9d3d90d3c7fb886f02c767 + 2818 + + + directory + /mod/php_edit/images + + + + + + file + /mod/php_edit/images/file.gif + Tue, 08 Dec 2009 02:24:03 GMT + f5ddae5e4e5eb50e1841b543dc9efd0e + 96 + + + file + /mod/php_edit/images/file.png + Tue, 08 Dec 2009 02:24:03 GMT + b0b89b853c4514d1a79429365cdf0cb2 + 434 + + + file + /mod/php_edit/images/folder.gif + Tue, 08 Dec 2009 02:24:03 GMT + 33d8e89f825441b036df0ea0a4d7c86b + 585 + + + file + /mod/php_edit/images/gear.png + Tue, 08 Dec 2009 02:24:03 GMT + 91a6abc4126bc211a6ffe69a1f3fdbc8 + 822 + + + file + /mod/php_edit/images/leaf.gif + Tue, 08 Dec 2009 02:24:03 GMT + 33d8e89f825441b036df0ea0a4d7c86b + 585 + + + file + /mod/php_edit/images/minus.gif + Tue, 08 Dec 2009 02:24:03 GMT + 813b2a3203fad9b56dc006e90996dba8 + 124 + + + file + /mod/php_edit/images/plus.gif + Tue, 08 Dec 2009 02:24:03 GMT + 6e6b599e843efe688bc76a2e19ebeced + 129 + + + file + /mod/php_edit/images/program.gif + Tue, 08 Dec 2009 02:24:03 GMT + 738187dc01e9c8a83723362935ef372c + 61 + + + directory + /mod/php_edit/images/thumbnails + + + + + + file + /mod/php_edit/images/thumbnails/cliplibrary.png + Tue, 08 Dec 2009 02:24:03 GMT + 3b5ec9a7a870c46784047083bbcfd67a + 20544 + + + file + /mod/php_edit/images/thumbnails/filemanagement.png + Tue, 08 Dec 2009 02:24:03 GMT + 8ba2a3f2d1f05c2acba6ed8fafbc49f4 + 23105 + + + file + /mod/php_edit/images/thumbnails/phpeditor.png + Tue, 08 Dec 2009 02:24:03 GMT + 08f4a12c81a3f87af7de6139cc8a8669 + 98754 + + + file + /mod/php_edit/index.php + Wed, 25 Aug 2010 23:43:37 GMT + 987a801e927bf2f992c5f39b66567441 + 9457 + + + file + /mod/php_edit/list.php + Sat, 06 Feb 2010 18:36:26 GMT + e93ae1b29d085e0457f1e3ed62531c67 + 4290 + + + file + /mod/php_edit/readme.txt + Tue, 08 Dec 2009 02:24:03 GMT + 53dd94e0899a6dbd9d36075ff8dcb7ba + 126 + + + file + /mod/php_edit/root.php + Sat, 06 Feb 2010 18:36:26 GMT + d399882b4822a07f0f4745cc41e1af1a + 1911 + + + directory + /mod/php_service + + + + + + file + /mod/php_service/root.php + Fri, 07 May 2010 19:29:25 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/php_service/v_php_service.php + Fri, 03 Sep 2010 07:44:27 GMT + 4743d414d982a2afb7691eeafd97b38e + 6347 + + + file + /mod/php_service/v_php_service_delete.php + Wed, 16 Jun 2010 02:52:45 GMT + fdc6723647587389507911ce528e57fd + 1388 + + + file + /mod/php_service/v_php_service_edit.php + Mon, 12 Jul 2010 15:21:42 GMT + b269ac27f41bcfda1b4c0e11acb7f4f1 + 17518 + + + directory + /mod/profiles + + + + + + file + /mod/profiles/root.php + Sat, 06 Feb 2010 18:04:00 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/profiles/v_profiles.php + Mon, 30 Aug 2010 18:11:47 GMT + d8095fea4c9e2f0454cdfe0a9ff4bc75 + 6143 + + + file + /mod/profiles/v_profile_edit.php + Sat, 01 May 2010 08:07:29 GMT + a686d9b5c036aea94fae303405bdff34 + 3478 + + + directory + /mod/provision + + + + + + file + /mod/provision/index.php + Sat, 21 Aug 2010 00:28:36 GMT + 6e338d6199a5cec02dfbf988b603f29d + 15673 + + + file + /mod/provision/root.php + Thu, 11 Mar 2010 10:21:27 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + directory + /mod/public_includes + + + + + + file + /mod/public_includes/root.php + Sat, 06 Feb 2010 18:03:20 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/public_includes/v_public.php + Thu, 08 Jul 2010 22:07:24 GMT + f220ba931a587ce1f235f8807a72555e + 17034 + + + file + /mod/public_includes/v_public_add.php + Sat, 14 Aug 2010 07:04:05 GMT + ad75b8f2fe06a7e38cf0e161aa5814a3 + 26225 + + + file + /mod/public_includes/v_public_delete.php + Sat, 06 Feb 2010 18:03:20 GMT + 48aac49ab1fc7d95e1acf1186559abe6 + 2769 + + + file + /mod/public_includes/v_public_details_delete.php + Sat, 06 Feb 2010 18:03:20 GMT + 73c0fae3464189c82a535680d9d84ccf + 1761 + + + file + /mod/public_includes/v_public_details_edit.php + Sat, 28 Aug 2010 18:48:10 GMT + 7b7d55d8f0b815db485d435448c8a73b + 22746 + + + file + /mod/public_includes/v_public_edit.php + Sat, 28 Aug 2010 18:46:38 GMT + 9a8ed8625f859d394891d150012dbf64 + 19939 + + + directory + /mod/recordings + + + + + + file + /mod/recordings/root.php + Sat, 06 Feb 2010 18:27:00 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/recordings/slim.swf + Tue, 08 Dec 2009 02:24:04 GMT + 6da31effb6edadd3c7d55d3dc3877d00 + 56327 + + + file + /mod/recordings/v_recordings.php + Fri, 13 Aug 2010 09:57:49 GMT + fe57be200d70bf00adc7130d3661b299 + 16500 + + + file + /mod/recordings/v_recordings_delete.php + Sat, 06 Feb 2010 18:27:00 GMT + c87891cc3cc8a5e0668b11dde72e6328 + 2034 + + + file + /mod/recordings/v_recordings_edit.php + Sat, 28 Aug 2010 18:46:48 GMT + a8d03f1ba6930416cd153124caffd06a + 8618 + + + file + /mod/recordings/v_recordings_play.php + Thu, 01 Jul 2010 17:04:06 GMT + 34682e3658f3663880af26d42bce5882 + 2463 + + + directory + /mod/roku + + + + + + file + /mod/roku/roku.php + Mon, 30 Aug 2010 18:13:21 GMT + 43f3c848ae6907d85e81562a97a1d26a + 2159 + + + directory + /mod/script_edit + + + + + + file + /mod/script_edit/clipadd.php + Sun, 23 May 2010 06:36:04 GMT + 5405ec84debf977805d9a00b8fa4ab75 + 3326 + + + file + /mod/script_edit/clipdelete.php + Sat, 06 Feb 2010 18:26:19 GMT + 2c02de8b37ce5c23ecf21c9c8da581d9 + 1412 + + + file + /mod/script_edit/cliplist.php + Sat, 06 Feb 2010 18:26:19 GMT + d8d2ce5f33d43bbd3a3e63176115ae23 + 12754 + + + file + /mod/script_edit/clipoptions.php + Sat, 06 Feb 2010 18:26:19 GMT + 3bde522624cbb5345d3ad1fdc42ef140 + 3100 + + + file + /mod/script_edit/clipoptionslist.php + Sat, 06 Feb 2010 18:25:02 GMT + 0c8f8b95aee81315c786f7cdc8929d2f + 10761 + + + file + /mod/script_edit/clipsearch.php + Sat, 06 Feb 2010 18:24:57 GMT + 82a54406083514f6f2ce0cce35abeda3 + 6481 + + + file + /mod/script_edit/clipupdate.php + Sat, 06 Feb 2010 18:26:18 GMT + 8fc3a552fee934be35697d6b32c4943d + 4232 + + + file + /mod/script_edit/filedelete.php + Sat, 06 Feb 2010 18:26:18 GMT + 810c5c9aef088f4d75896c10a917639e + 2201 + + + file + /mod/script_edit/filelist.php + Tue, 20 Jul 2010 01:39:55 GMT + e15865ce541b06a53fb5737c9e4c521b + 13866 + + + file + /mod/script_edit/filenew.php + Sat, 06 Feb 2010 18:26:18 GMT + 33042b92b0173e15a6f543ee0bccc8e2 + 2311 + + + file + /mod/script_edit/fileoptions.php + Sat, 06 Feb 2010 18:26:18 GMT + 5b79c7987f6cb1b4d2f8f2a17702dbb5 + 4000 + + + file + /mod/script_edit/fileoptionslist.php + Sat, 06 Feb 2010 18:26:18 GMT + 23f7f613bb6b8092557a4f2880421359 + 14059 + + + file + /mod/script_edit/fileread.php + Sat, 06 Feb 2010 18:26:18 GMT + 87311164928514f501d66acf3e977af5 + 1213 + + + file + /mod/script_edit/filerename.php + Sat, 06 Feb 2010 18:26:18 GMT + 3b5a76994b03f24d4dc03032f6ddfb7b + 2688 + + + file + /mod/script_edit/filesave.php + Sat, 06 Feb 2010 18:26:20 GMT + f22c7667f8480711d35e974f742c830c + 1302 + + + file + /mod/script_edit/folderdelete.php + Sat, 06 Feb 2010 18:26:19 GMT + 8b171129783c2e6f5fba0d43c5652880 + 1198 + + + file + /mod/script_edit/foldernew.php + Sat, 06 Feb 2010 18:26:19 GMT + 4f130ae369199f4c8b5e06e3269a4f45 + 2199 + + + file + /mod/script_edit/footer.php + Sat, 06 Feb 2010 18:26:19 GMT + 48b9b9266e8e74b4ae39a4249a8e37c8 + 1188 + + + file + /mod/script_edit/header.php + Sat, 06 Feb 2010 18:26:19 GMT + 745a04241d9d3d90d3c7fb886f02c767 + 2818 + + + directory + /mod/script_edit/images + + + + + + file + /mod/script_edit/images/file.gif + Tue, 08 Dec 2009 02:24:09 GMT + f5ddae5e4e5eb50e1841b543dc9efd0e + 96 + + + file + /mod/script_edit/images/file.png + Tue, 08 Dec 2009 02:24:09 GMT + b0b89b853c4514d1a79429365cdf0cb2 + 434 + + + file + /mod/script_edit/images/folder.gif + Tue, 08 Dec 2009 02:24:09 GMT + 33d8e89f825441b036df0ea0a4d7c86b + 585 + + + file + /mod/script_edit/images/gear.png + Tue, 08 Dec 2009 02:24:09 GMT + 91a6abc4126bc211a6ffe69a1f3fdbc8 + 822 + + + file + /mod/script_edit/images/leaf.gif + Tue, 08 Dec 2009 02:24:09 GMT + 33d8e89f825441b036df0ea0a4d7c86b + 585 + + + file + /mod/script_edit/images/minus.gif + Tue, 08 Dec 2009 02:24:09 GMT + 813b2a3203fad9b56dc006e90996dba8 + 124 + + + file + /mod/script_edit/images/plus.gif + Tue, 08 Dec 2009 02:24:09 GMT + 6e6b599e843efe688bc76a2e19ebeced + 129 + + + file + /mod/script_edit/images/program.gif + Tue, 08 Dec 2009 02:24:09 GMT + 738187dc01e9c8a83723362935ef372c + 61 + + + directory + /mod/script_edit/images/thumbnails + + + + + + file + /mod/script_edit/images/thumbnails/cliplibrary.png + Tue, 08 Dec 2009 02:24:09 GMT + 3b5ec9a7a870c46784047083bbcfd67a + 20544 + + + file + /mod/script_edit/images/thumbnails/filemanagement.png + Tue, 08 Dec 2009 02:24:09 GMT + 8ba2a3f2d1f05c2acba6ed8fafbc49f4 + 23105 + + + file + /mod/script_edit/images/thumbnails/phpeditor.png + Tue, 08 Dec 2009 02:24:09 GMT + 08f4a12c81a3f87af7de6139cc8a8669 + 98754 + + + file + /mod/script_edit/index.php + Wed, 25 Aug 2010 23:42:59 GMT + 94d97486f8c00d1c8130610735a6ad7f + 9363 + + + file + /mod/script_edit/list.php + Sat, 06 Feb 2010 18:26:19 GMT + e93ae1b29d085e0457f1e3ed62531c67 + 4290 + + + file + /mod/script_edit/readme.txt + Tue, 08 Dec 2009 02:24:09 GMT + 53dd94e0899a6dbd9d36075ff8dcb7ba + 126 + + + file + /mod/script_edit/root.php + Sat, 06 Feb 2010 18:26:19 GMT + d399882b4822a07f0f4745cc41e1af1a + 1911 + + + directory + /mod/soft_phone + + + + + + file + /mod/soft_phone/root.php + Sat, 06 Feb 2010 18:24:36 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/soft_phone/v_softphone.php + Sat, 06 Feb 2010 18:24:36 GMT + 5cefe5eef350cb0d3582e50440d4a21f + 10475 + + + directory + /mod/sql_query + + + + + + file + /mod/sql_query/root.php + Thu, 11 Mar 2010 10:21:34 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/sql_query/v_sql_query.php + Fri, 09 Jul 2010 02:54:39 GMT + 0c7c208202e52f2b1b3050fe9482b9e7 + 4143 + + + file + /mod/sql_query/v_sql_query_result.php + Thu, 05 Aug 2010 06:01:23 GMT + d9fac6d0d25b33d339bf7bfed553e7bf + 4055 + + + directory + /mod/templates + + + + + + file + /mod/templates/root.php + Sat, 06 Feb 2010 18:00:35 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/templates/templates.php + Thu, 11 Mar 2010 10:04:45 GMT + 220314b2ccf5c6dab1824010e4797e97 + 5632 + + + file + /mod/templates/templates_delete.php + Sat, 06 Feb 2010 18:00:25 GMT + e2ae034aa17a21d33bbb4be026effa05 + 1531 + + + file + /mod/templates/templates_edit.php + Sat, 28 Aug 2010 18:47:00 GMT + ec38cddfd390e51098fd68e95f87cd9b + 12129 + + + file + /mod/templates/template_restore_default.php + Sun, 23 May 2010 06:31:50 GMT + 31708bdb97cec760f1f0d2c033553169 + 4095 + + + directory + /mod/time_conditions + + + + + + file + /mod/time_conditions/root.php + Sat, 10 Jul 2010 02:32:54 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/time_conditions/v_dialplans.php + Wed, 14 Jul 2010 19:37:55 GMT + ecfbc50b3b4036755c675715d4e75ec0 + 9358 + + + file + /mod/time_conditions/dialplan_add.php + Thu, 15 Jul 2010 05:48:51 GMT + 88d76764c52f555967dd8009149da61a + 41649 + + + file + /mod/time_conditions/v_dialplan_delete.php + Sat, 10 Jul 2010 02:32:54 GMT + 70c98ad23504a24fa38c13c6ca8ee0b6 + 1830 + + + file + /mod/time_conditions/v_dialplan_details_delete.php + Sat, 10 Jul 2010 02:32:55 GMT + a731a9a1e8963c1a1aecd5f3bd0eafb2 + 1747 + + + file + /mod/time_conditions/v_dialplan_details_edit.php + Tue, 13 Jul 2010 20:36:08 GMT + 9bd82d87d238bdb52d1cfb0ed2d74954 + 16305 + + + file + /mod/time_conditions/v_dialplan_edit.php + Sat, 28 Aug 2010 18:47:14 GMT + 90dd319e7f235af7703119d79ea83976 + 19568 + + + directory + /mod/users + + + + + + file + /mod/users/root.php + Sat, 06 Feb 2010 18:23:29 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/users/signup.php + Mon, 06 Sep 2010 10:37:59 GMT + 57cf8747a968e149e1b6ba5e0512777d + 23220 + + + file + /mod/users/usersupdate.php + Sat, 11 Sep 2010 16:52:29 GMT + 592fc38cdf16f7ee96b4140f91eca1cb + 24822 + + + directory + /mod/users_bulk_add + + + + + + file + /mod/users_bulk_add/root.php + Sun, 27 Jun 2010 10:16:02 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/users_bulk_add/v_users_bulk_add.php + Thu, 15 Jul 2010 20:25:55 GMT + ca0ef8933e738cb4fe5031b8fd490f6b + 6836 + + + directory + /mod/vars + + + + + + file + /mod/vars/root.php + Sat, 06 Feb 2010 17:52:31 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/vars/v_vars.php + Sat, 01 May 2010 08:06:02 GMT + 75c63ebf17ffe1ee74ac40d9ae53513c + 7887 + + + file + /mod/vars/v_vars.textarea.php + Sat, 01 May 2010 08:06:02 GMT + 2d73130196e06c933427fcc8afd4330e + 4538 + + + file + /mod/vars/v_vars_delete.php + Sat, 01 May 2010 08:06:27 GMT + a16822bccc972ec3ab6b54167daa16b1 + 1513 + + + file + /mod/vars/v_vars_edit.php + Sat, 28 Aug 2010 18:47:29 GMT + 02566ad6528146c536e8874e6a5b1cce + 13731 + + + directory + /mod/voicemail_msgs + + + + + + file + /mod/voicemail_msgs/root.php + Sat, 06 Feb 2010 18:23:06 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/voicemail_msgs/v_voicemail_msgs.php + Wed, 19 May 2010 20:31:23 GMT + 78422b1c8d6033ef33428e7af054909c + 12024 + + + file + /mod/voicemail_msgs/v_voicemail_msgs_delete.php + Sat, 06 Feb 2010 18:23:07 GMT + eea93a77f04c7ebe80c852705f396187 + 2565 + + + file + /mod/voicemail_msgs/v_voicemail_msgs_password.php + Sat, 28 Aug 2010 18:47:37 GMT + fe73ce8b6bdbf9ac2bdc88f7a54c21ec + 14622 + + + file + /mod/voicemail_msgs/v_voicemail_msgs_play.php + Sat, 06 Feb 2010 18:23:06 GMT + d38415afee911511f94092304a4193ff + 2370 + + + directory + /mod/voicemail_status + + + + + + file + /mod/voicemail_status/root.php + Sat, 06 Feb 2010 18:22:38 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/voicemail_status/v_voicemail.php + Wed, 19 May 2010 19:38:36 GMT + 2c91f3e2ef57976b11cbe1887847a1a6 + 6734 + + + file + /mod/voicemail_status/v_voicemail_prefs_delete.php + Sat, 06 Feb 2010 18:22:38 GMT + 296e463b9f94802ac9878bd648cc2fb0 + 1923 + + + directory + /mod/xml_cdr + + + + + + file + /mod/xml_cdr/root.php + Fri, 07 May 2010 19:30:10 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /mod/xml_cdr/xml_cdr.php + Sun, 29 Aug 2010 04:31:18 GMT + 5d0e850ce9af15f86937e76a518afea6 + 21108 + + + file + /mod/xml_cdr/v_xml_cdr_csv.php + Sun, 29 Aug 2010 04:36:52 GMT + 6e487492870ec7b858b98e943aa44dad + 5973 + + + file + /mod/xml_cdr/v_xml_cdr_delete.php + Wed, 04 Aug 2010 19:26:51 GMT + de136c983ae66ade089f09116b08fcb0 + 730 + + + file + /mod/xml_cdr/v_xml_cdr_details.php + Sun, 08 Aug 2010 09:45:46 GMT + 2c7fe2f7f8840762def3c67bc41ea70a + 16342 + + + file + /mod/xml_cdr/v_xml_cdr_edit.php + Wed, 04 Aug 2010 19:29:59 GMT + 5773cc956021af6461db226fb091684d + 22717 + + + file + /mod/xml_cdr/v_xml_cdr_import.php + Fri, 01 Oct 2010 08:01:28 GMT + c123f3f87335e8a1eb37f53b6fa18c3e + 9322 + + + file + /mod/xml_cdr/v_xml_cdr_search.php + Fri, 01 Oct 2010 02:25:52 GMT + 19a6723d640d78293e46f5d019cf2fd9 + 5823 + + + directory + /mod/xml_edit + + + + + + file + /mod/xml_edit/clipadd.php + Sun, 23 May 2010 06:32:53 GMT + 7f5d8e8b6ebbe0273a3832963dbc685e + 3273 + + + file + /mod/xml_edit/clipdelete.php + Sat, 01 May 2010 08:14:18 GMT + 10a7d1018e22a91efdcd9403e24e8f82 + 1471 + + + file + /mod/xml_edit/cliplist.php + Sat, 01 May 2010 08:14:29 GMT + 88fc145a96531a17b0a429be4f839172 + 13098 + + + file + /mod/xml_edit/clipoptions.php + Sat, 01 May 2010 08:14:37 GMT + a335e9b42c5628fd78bfacce500eb04b + 3155 + + + file + /mod/xml_edit/clipoptionslist.php + Sat, 01 May 2010 08:14:43 GMT + 7176b2b795fb5d35162f92b1e8c7d48c + 10766 + + + file + /mod/xml_edit/clipsearch.php + Sat, 01 May 2010 08:14:48 GMT + 75cb211af71a2a55d2cd1b888ee1b6bb + 6668 + + + file + /mod/xml_edit/clipupdate.php + Sat, 01 May 2010 08:14:56 GMT + f6703d96f2f70e860ea502392da08ea6 + 4487 + + + file + /mod/xml_edit/filedelete.php + Sat, 01 May 2010 08:16:09 GMT + 7eec5a5d505d48a0abfed9ce89319c6c + 2268 + + + file + /mod/xml_edit/filelist.php + Mon, 30 Aug 2010 18:02:07 GMT + 1c16a71a83e33eb728b467293122483b + 13970 + + + file + /mod/xml_edit/filenew.php + Sat, 01 May 2010 08:16:01 GMT + cf1ee352afd87e915084872884455cde + 2403 + + + file + /mod/xml_edit/fileoptions.php + Sat, 01 May 2010 08:15:55 GMT + 8b068ea59428f211d68839ae3e3c49ea + 4083 + + + file + /mod/xml_edit/fileoptionslist.php + Sat, 01 May 2010 08:15:47 GMT + 3d3f9c4d64bed6d739f9d07a0c234be7 + 14085 + + + file + /mod/xml_edit/fileread.php + Sat, 01 May 2010 08:15:42 GMT + 386914139a8d09c9a31a5bae48a32262 + 1467 + + + file + /mod/xml_edit/filerename.php + Sat, 01 May 2010 08:15:37 GMT + 99760910d1d1ec202a9d76497dcfee54 + 2796 + + + file + /mod/xml_edit/filesave.php + Sat, 01 May 2010 08:15:33 GMT + d133f7e7a237f9eb1c3232b411a7f4ea + 1358 + + + file + /mod/xml_edit/folderdelete.php + Sat, 01 May 2010 08:15:28 GMT + ff98014304dce09f69c0b82ed02f33d3 + 1203 + + + file + /mod/xml_edit/foldernew.php + Sat, 01 May 2010 08:15:23 GMT + 3e1a29cc68dd691032c68b0e2b6adc47 + 2213 + + + file + /mod/xml_edit/footer.php + Sat, 06 Feb 2010 18:22:01 GMT + 9559d67fa5d8024d8213e58ebd02a06c + 1200 + + + file + /mod/xml_edit/header.php + Sat, 06 Feb 2010 18:22:01 GMT + 745a04241d9d3d90d3c7fb886f02c767 + 2818 + + + directory + /mod/xml_edit/images + + + + + + file + /mod/xml_edit/images/file.gif + Tue, 08 Dec 2009 02:24:06 GMT + f5ddae5e4e5eb50e1841b543dc9efd0e + 96 + + + file + /mod/xml_edit/images/file.png + Tue, 08 Dec 2009 02:24:06 GMT + b0b89b853c4514d1a79429365cdf0cb2 + 434 + + + file + /mod/xml_edit/images/folder.gif + Tue, 08 Dec 2009 02:24:06 GMT + 33d8e89f825441b036df0ea0a4d7c86b + 585 + + + file + /mod/xml_edit/images/gear.png + Tue, 08 Dec 2009 02:24:06 GMT + 91a6abc4126bc211a6ffe69a1f3fdbc8 + 822 + + + file + /mod/xml_edit/images/leaf.gif + Tue, 08 Dec 2009 02:24:06 GMT + 33d8e89f825441b036df0ea0a4d7c86b + 585 + + + file + /mod/xml_edit/images/minus.gif + Tue, 08 Dec 2009 02:24:06 GMT + 813b2a3203fad9b56dc006e90996dba8 + 124 + + + file + /mod/xml_edit/images/plus.gif + Tue, 08 Dec 2009 02:24:06 GMT + 6e6b599e843efe688bc76a2e19ebeced + 129 + + + file + /mod/xml_edit/images/program.gif + Tue, 08 Dec 2009 02:24:06 GMT + 738187dc01e9c8a83723362935ef372c + 61 + + + directory + /mod/xml_edit/images/thumbnails + + + + + + file + /mod/xml_edit/images/thumbnails/cliplibrary.png + Tue, 08 Dec 2009 02:24:06 GMT + 3b5ec9a7a870c46784047083bbcfd67a + 20544 + + + file + /mod/xml_edit/images/thumbnails/filemanagement.png + Tue, 08 Dec 2009 02:24:06 GMT + 8ba2a3f2d1f05c2acba6ed8fafbc49f4 + 23105 + + + file + /mod/xml_edit/images/thumbnails/phpeditor.png + Tue, 08 Dec 2009 02:24:06 GMT + 08f4a12c81a3f87af7de6139cc8a8669 + 98754 + + + file + /mod/xml_edit/index.php + Wed, 25 Aug 2010 23:40:51 GMT + d5200344babc8a1ff687ad8cb564fa70 + 9475 + + + file + /mod/xml_edit/list.php + Sat, 01 May 2010 08:13:55 GMT + 7bfa6f4b5ce517356c17a6841270e261 + 4392 + + + file + /mod/xml_edit/readme.txt + Tue, 08 Dec 2009 02:24:07 GMT + 53dd94e0899a6dbd9d36075ff8dcb7ba + 126 + + + file + /mod/xml_edit/root.php + Sat, 06 Feb 2010 18:22:01 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /root.php + Sat, 06 Feb 2010 18:12:33 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + directory + /secure + + + + + + file + /secure/.htaccess + Tue, 29 Jun 2010 08:34:20 GMT + d3e3f4f1861877f7e035cb8876ba8d18 + 60 + + + file + /secure/class.phpmailer.php + Tue, 29 Jun 2010 08:34:19 GMT + d80cf8d4005ee4334f445e91402b6b17 + 56086 + + + file + /secure/class.smtp.php + Tue, 29 Jun 2010 08:34:20 GMT + d2be32bec43171954dc9bd328ab63dac + 31376 + + + file + /secure/fax_to_email.php + Tue, 07 Sep 2010 06:35:18 GMT + 176d1835e583ba73f29894b5b7ce98e5 + 8381 + + + file + /secure/htaccess.tmp + Tue, 29 Jun 2010 08:34:20 GMT + d3e3f4f1861877f7e035cb8876ba8d18 + 60 + + + file + /secure/index.php + Tue, 29 Jun 2010 08:34:20 GMT + 02c874c2cb149f783e14b0867246f2a4 + 940 + + + file + /secure/root.php + Tue, 29 Jun 2010 08:34:19 GMT + a20aca300a3c9c1cdd724971dba4626d + 1913 + + + file + /secure/v_config_cli.php + Tue, 29 Jun 2010 08:34:19 GMT + 6e1e710fe517b4a624d0fad75313d1bb + 1109 + + + file + /secure/v_mailto.php + Tue, 29 Jun 2010 08:34:19 GMT + 9d33605176da0905309c7f62f58d9eb4 + 7230 + + + directory + /themes + + + + + + directory + /themes/default + + + + + + file + /themes/default/background.gif + Tue, 08 Dec 2009 02:24:10 GMT + 519582841753eaec7ceccd815f576b11 + 128 + + + file + /themes/default/background_black.png + Sat, 04 Sep 2010 23:40:30 GMT + e99b62c13995e4d2082d7e2cb509336f + 322 + + + file + /themes/default/background_cell.gif + Wed, 24 Feb 2010 03:39:51 GMT + b5dc189db0c5688ffbb85131d8983eae + 128 + + + file + /themes/default/background_cell.png + Wed, 24 Feb 2010 03:57:49 GMT + 38bdb2a91cf5bf2c5c957362d4978fff + 135 + + + file + /themes/default/background_head.png + Wed, 24 Feb 2010 03:13:59 GMT + e0ec4552445b04ddce3efad334707a03 + 339 + + + file + /themes/default/background_th.png + Thu, 15 Jul 2010 22:21:35 GMT + f312bb56f3f1c40047420ba07e411aa2 + 324 + + + file + /themes/default/background_th_blue.png + Thu, 15 Jul 2010 22:21:35 GMT + f312bb56f3f1c40047420ba07e411aa2 + 324 + + + file + /themes/default/blank.gif + Tue, 08 Dec 2009 02:24:10 GMT + 56398e76be6355ad5999b262208a17c9 + 49 + + + file + /themes/default/logo.png + Fri, 19 Feb 2010 22:21:10 GMT + e45f2d2b34a95646df5e16393857278d + 14978 + + + file + /themes/default/menu_background.jpg + Wed, 24 Feb 2010 02:24:57 GMT + a0c9ea4b1e3456316d5e521b9841518a + 1124 + + + file + /themes/default/template.php + Sun, 05 Sep 2010 00:03:16 GMT + 313eb46074ee2f98cea99cfc3855dd05 + 7735 + + + directory + /themes/horizontal + + + + + + file + /themes/horizontal/background.jpg + Wed, 24 Feb 2010 02:24:57 GMT + a0c9ea4b1e3456316d5e521b9841518a + 1124 + + + file + /themes/horizontal/background_cell.gif + Wed, 24 Feb 2010 03:39:51 GMT + b5dc189db0c5688ffbb85131d8983eae + 128 + + + file + /themes/horizontal/background_head.png + Wed, 24 Feb 2010 03:13:59 GMT + e0ec4552445b04ddce3efad334707a03 + 339 + + + file + /themes/horizontal/background_th.png + Wed, 24 Feb 2010 06:21:09 GMT + f312bb56f3f1c40047420ba07e411aa2 + 324 + + + file + /themes/horizontal/background_th_blue.png + Thu, 15 Jul 2010 22:21:35 GMT + f312bb56f3f1c40047420ba07e411aa2 + 324 + + + file + /themes/horizontal/background_th_purple.png + Wed, 24 Feb 2010 06:03:21 GMT + 1e2480358b52c6c5714c236724dbae3f + 310 + + + file + /themes/horizontal/blank.gif + Tue, 08 Dec 2009 02:24:10 GMT + 56398e76be6355ad5999b262208a17c9 + 49 + + + file + /themes/horizontal/logo.png + Fri, 19 Feb 2010 22:21:10 GMT + e45f2d2b34a95646df5e16393857278d + 14978 + + + file + /themes/horizontal/template.php + Sun, 05 Sep 2010 00:37:03 GMT + b97ed9148e7489e48f3eb557f544a449 + 8686 + + \ No newline at end of file diff --git a/includes/install/sql/mysql.sql b/includes/install/sql/mysql.sql new file mode 100644 index 0000000000..d2ba34d170 --- /dev/null +++ b/includes/install/sql/mysql.sql @@ -0,0 +1 @@ +INSERT INTO v_settings (numbering_plan, event_socket_ip_address, event_socket_port, event_socket_password, xml_rpc_http_port, xml_rpc_auth_realm, xml_rpc_auth_user, xml_rpc_auth_pass, admin_pin, smtp_host, smtp_secure, smtp_auth, smtp_username, smtp_password, smtp_from, smtp_from_name, mod_shout_decoder, mod_shout_volume) VALUES ('US','127.0.0.1',8021,'ClueCon',8787,'localhost','xmlrpc','7e4d3i',1234,'','none','','','','','Voicemail','i386',0.3); \ No newline at end of file diff --git a/includes/install/sql/pgsql.sql b/includes/install/sql/pgsql.sql new file mode 100644 index 0000000000..2f66737e92 --- /dev/null +++ b/includes/install/sql/pgsql.sql @@ -0,0 +1,9 @@ +--BEGIN TRANSACTION; +INSERT INTO v_settings (numbering_plan, event_socket_ip_address, event_socket_port, event_socket_password, xml_rpc_http_port, xml_rpc_auth_realm, xml_rpc_auth_user, xml_rpc_auth_pass, admin_pin, smtp_host, smtp_secure, smtp_auth, smtp_username, smtp_password, smtp_from, smtp_from_name, mod_shout_decoder, mod_shout_volume) VALUES ('US','127.0.0.1',8021,'ClueCon',8787,'localhost','xmlrpc','7e4d3i',1234,'','none','','','','','Voicemail','i386',0.3); +CREATE INDEX index_billsec ON v_xml_cdr(billsec); +CREATE INDEX index_caller_id_name ON v_xml_cdr(caller_id_name); +CREATE INDEX index_destination_number ON v_xml_cdr(destination_number); +CREATE INDEX index_duration ON v_xml_cdr(duration); +CREATE INDEX index_hangup_cause ON v_xml_cdr(hangup_cause); +CREATE INDEX index_start_stamp ON v_xml_cdr(start_stamp); +--COMMIT; diff --git a/includes/install/sql/sqlite.sql b/includes/install/sql/sqlite.sql new file mode 100644 index 0000000000..e1d207635f --- /dev/null +++ b/includes/install/sql/sqlite.sql @@ -0,0 +1,9 @@ +--BEGIN TRANSACTION; +INSERT INTO v_settings (numbering_plan, event_socket_ip_address, event_socket_port, event_socket_password, xml_rpc_http_port, xml_rpc_auth_realm, xml_rpc_auth_user, xml_rpc_auth_pass, admin_pin, smtp_host, smtp_secure, smtp_auth, smtp_username, smtp_password, smtp_from, smtp_from_name, mod_shout_decoder, mod_shout_volume) VALUES ('US','127.0.0.1',8021,'ClueCon',8787,'localhost','xmlrpc','7e4d3i',1234,'','none','','','','','Voicemail','i386',0.3); +CREATE INDEX index_billsec ON v_xml_cdr(billsec ASC); +CREATE INDEX index_caller_id_name ON v_xml_cdr(caller_id_name ASC); +CREATE INDEX index_destination_number ON v_xml_cdr(destination_number ASC); +CREATE INDEX index_duration ON v_xml_cdr(duration ASC); +CREATE INDEX index_hangup_cause ON v_xml_cdr(hangup_cause ASC); +CREATE INDEX index_start_stamp ON v_xml_cdr(start_stamp ASC); +--COMMIT; diff --git a/includes/jquery/flot/excanvas.min.js b/includes/jquery/flot/excanvas.min.js new file mode 100644 index 0000000000..12c74f7bea --- /dev/null +++ b/includes/jquery/flot/excanvas.min.js @@ -0,0 +1 @@ +if(!document.createElement("canvas").getContext){(function(){var z=Math;var K=z.round;var J=z.sin;var U=z.cos;var b=z.abs;var k=z.sqrt;var D=10;var F=D/2;function T(){return this.context_||(this.context_=new W(this))}var O=Array.prototype.slice;function G(i,j,m){var Z=O.call(arguments,2);return function(){return i.apply(j,Z.concat(O.call(arguments)))}}function AD(Z){return String(Z).replace(/&/g,"&").replace(/"/g,""")}function r(i){if(!i.namespaces.g_vml_){i.namespaces.add("g_vml_","urn:schemas-microsoft-com:vml","#default#VML")}if(!i.namespaces.g_o_){i.namespaces.add("g_o_","urn:schemas-microsoft-com:office:office","#default#VML")}if(!i.styleSheets.ex_canvas_){var Z=i.createStyleSheet();Z.owningElement.id="ex_canvas_";Z.cssText="canvas{display:inline-block;overflow:hidden;text-align:left;width:300px;height:150px}"}}r(document);var E={init:function(Z){if(/MSIE/.test(navigator.userAgent)&&!window.opera){var i=Z||document;i.createElement("canvas");i.attachEvent("onreadystatechange",G(this.init_,this,i))}},init_:function(m){var j=m.getElementsByTagName("canvas");for(var Z=0;Z1){j--}if(6*j<1){return i+(Z-i)*6*j}else{if(2*j<1){return Z}else{if(3*j<2){return i+(Z-i)*(2/3-j)*6}else{return i}}}}function Y(Z){var AE,p=1;Z=String(Z);if(Z.charAt(0)=="#"){AE=Z}else{if(/^rgb/.test(Z)){var m=g(Z);var AE="#",AF;for(var j=0;j<3;j++){if(m[j].indexOf("%")!=-1){AF=Math.floor(C(m[j])*255)}else{AF=Number(m[j])}AE+=I[N(AF,0,255)]}p=m[3]}else{if(/^hsl/.test(Z)){var m=g(Z);AE=c(m);p=m[3]}else{AE=B[Z]||Z}}}return{color:AE,alpha:p}}var L={style:"normal",variant:"normal",weight:"normal",size:10,family:"sans-serif"};var f={};function X(Z){if(f[Z]){return f[Z]}var m=document.createElement("div");var j=m.style;try{j.font=Z}catch(i){}return f[Z]={style:j.fontStyle||L.style,variant:j.fontVariant||L.variant,weight:j.fontWeight||L.weight,size:j.fontSize||L.size,family:j.fontFamily||L.family}}function P(j,i){var Z={};for(var AF in j){Z[AF]=j[AF]}var AE=parseFloat(i.currentStyle.fontSize),m=parseFloat(j.size);if(typeof j.size=="number"){Z.size=j.size}else{if(j.size.indexOf("px")!=-1){Z.size=m}else{if(j.size.indexOf("em")!=-1){Z.size=AE*m}else{if(j.size.indexOf("%")!=-1){Z.size=(AE/100)*m}else{if(j.size.indexOf("pt")!=-1){Z.size=m/0.75}else{Z.size=AE}}}}}Z.size*=0.981;return Z}function AA(Z){return Z.style+" "+Z.variant+" "+Z.weight+" "+Z.size+"px "+Z.family}function t(Z){switch(Z){case"butt":return"flat";case"round":return"round";case"square":default:return"square"}}function W(i){this.m_=V();this.mStack_=[];this.aStack_=[];this.currentPath_=[];this.strokeStyle="#000";this.fillStyle="#000";this.lineWidth=1;this.lineJoin="miter";this.lineCap="butt";this.miterLimit=D*1;this.globalAlpha=1;this.font="10px sans-serif";this.textAlign="left";this.textBaseline="alphabetic";this.canvas=i;var Z=i.ownerDocument.createElement("div");Z.style.width=i.clientWidth+"px";Z.style.height=i.clientHeight+"px";Z.style.overflow="hidden";Z.style.position="absolute";i.appendChild(Z);this.element_=Z;this.arcScaleX_=1;this.arcScaleY_=1;this.lineScale_=1}var M=W.prototype;M.clearRect=function(){if(this.textMeasureEl_){this.textMeasureEl_.removeNode(true);this.textMeasureEl_=null}this.element_.innerHTML=""};M.beginPath=function(){this.currentPath_=[]};M.moveTo=function(i,Z){var j=this.getCoords_(i,Z);this.currentPath_.push({type:"moveTo",x:j.x,y:j.y});this.currentX_=j.x;this.currentY_=j.y};M.lineTo=function(i,Z){var j=this.getCoords_(i,Z);this.currentPath_.push({type:"lineTo",x:j.x,y:j.y});this.currentX_=j.x;this.currentY_=j.y};M.bezierCurveTo=function(j,i,AI,AH,AG,AE){var Z=this.getCoords_(AG,AE);var AF=this.getCoords_(j,i);var m=this.getCoords_(AI,AH);e(this,AF,m,Z)};function e(Z,m,j,i){Z.currentPath_.push({type:"bezierCurveTo",cp1x:m.x,cp1y:m.y,cp2x:j.x,cp2y:j.y,x:i.x,y:i.y});Z.currentX_=i.x;Z.currentY_=i.y}M.quadraticCurveTo=function(AG,j,i,Z){var AF=this.getCoords_(AG,j);var AE=this.getCoords_(i,Z);var AH={x:this.currentX_+2/3*(AF.x-this.currentX_),y:this.currentY_+2/3*(AF.y-this.currentY_)};var m={x:AH.x+(AE.x-this.currentX_)/3,y:AH.y+(AE.y-this.currentY_)/3};e(this,AH,m,AE)};M.arc=function(AJ,AH,AI,AE,i,j){AI*=D;var AN=j?"at":"wa";var AK=AJ+U(AE)*AI-F;var AM=AH+J(AE)*AI-F;var Z=AJ+U(i)*AI-F;var AL=AH+J(i)*AI-F;if(AK==Z&&!j){AK+=0.125}var m=this.getCoords_(AJ,AH);var AG=this.getCoords_(AK,AM);var AF=this.getCoords_(Z,AL);this.currentPath_.push({type:AN,x:m.x,y:m.y,radius:AI,xStart:AG.x,yStart:AG.y,xEnd:AF.x,yEnd:AF.y})};M.rect=function(j,i,Z,m){this.moveTo(j,i);this.lineTo(j+Z,i);this.lineTo(j+Z,i+m);this.lineTo(j,i+m);this.closePath()};M.strokeRect=function(j,i,Z,m){var p=this.currentPath_;this.beginPath();this.moveTo(j,i);this.lineTo(j+Z,i);this.lineTo(j+Z,i+m);this.lineTo(j,i+m);this.closePath();this.stroke();this.currentPath_=p};M.fillRect=function(j,i,Z,m){var p=this.currentPath_;this.beginPath();this.moveTo(j,i);this.lineTo(j+Z,i);this.lineTo(j+Z,i+m);this.lineTo(j,i+m);this.closePath();this.fill();this.currentPath_=p};M.createLinearGradient=function(i,m,Z,j){var p=new v("gradient");p.x0_=i;p.y0_=m;p.x1_=Z;p.y1_=j;return p};M.createRadialGradient=function(m,AE,j,i,p,Z){var AF=new v("gradientradial");AF.x0_=m;AF.y0_=AE;AF.r0_=j;AF.x1_=i;AF.y1_=p;AF.r1_=Z;return AF};M.drawImage=function(AO,j){var AH,AF,AJ,AV,AM,AK,AQ,AX;var AI=AO.runtimeStyle.width;var AN=AO.runtimeStyle.height;AO.runtimeStyle.width="auto";AO.runtimeStyle.height="auto";var AG=AO.width;var AT=AO.height;AO.runtimeStyle.width=AI;AO.runtimeStyle.height=AN;if(arguments.length==3){AH=arguments[1];AF=arguments[2];AM=AK=0;AQ=AJ=AG;AX=AV=AT}else{if(arguments.length==5){AH=arguments[1];AF=arguments[2];AJ=arguments[3];AV=arguments[4];AM=AK=0;AQ=AG;AX=AT}else{if(arguments.length==9){AM=arguments[1];AK=arguments[2];AQ=arguments[3];AX=arguments[4];AH=arguments[5];AF=arguments[6];AJ=arguments[7];AV=arguments[8]}else{throw Error("Invalid number of arguments")}}}var AW=this.getCoords_(AH,AF);var m=AQ/2;var i=AX/2;var AU=[];var Z=10;var AE=10;AU.push(" ','","");this.element_.insertAdjacentHTML("BeforeEnd",AU.join(""))};M.stroke=function(AM){var m=10;var AN=10;var AE=5000;var AG={x:null,y:null};var AL={x:null,y:null};for(var AH=0;AHAL.x){AL.x=Z.x}if(AG.y==null||Z.yAL.y){AL.y=Z.y}}}AK.push(' ">');if(!AM){R(this,AK)}else{a(this,AK,AG,AL)}AK.push("");this.element_.insertAdjacentHTML("beforeEnd",AK.join(""))}};function R(j,AE){var i=Y(j.strokeStyle);var m=i.color;var p=i.alpha*j.globalAlpha;var Z=j.lineScale_*j.lineWidth;if(Z<1){p*=Z}AE.push("')}function a(AO,AG,Ah,AP){var AH=AO.fillStyle;var AY=AO.arcScaleX_;var AX=AO.arcScaleY_;var Z=AP.x-Ah.x;var m=AP.y-Ah.y;if(AH instanceof v){var AL=0;var Ac={x:0,y:0};var AU=0;var AK=1;if(AH.type_=="gradient"){var AJ=AH.x0_/AY;var j=AH.y0_/AX;var AI=AH.x1_/AY;var Aj=AH.y1_/AX;var Ag=AO.getCoords_(AJ,j);var Af=AO.getCoords_(AI,Aj);var AE=Af.x-Ag.x;var p=Af.y-Ag.y;AL=Math.atan2(AE,p)*180/Math.PI;if(AL<0){AL+=360}if(AL<0.000001){AL=0}}else{var Ag=AO.getCoords_(AH.x0_,AH.y0_);Ac={x:(Ag.x-Ah.x)/Z,y:(Ag.y-Ah.y)/m};Z/=AY*D;m/=AX*D;var Aa=z.max(Z,m);AU=2*AH.r0_/Aa;AK=2*AH.r1_/Aa-AU}var AS=AH.colors_;AS.sort(function(Ak,i){return Ak.offset-i.offset});var AN=AS.length;var AR=AS[0].color;var AQ=AS[AN-1].color;var AW=AS[0].alpha*AO.globalAlpha;var AV=AS[AN-1].alpha*AO.globalAlpha;var Ab=[];for(var Ae=0;Ae')}else{if(AH instanceof u){if(Z&&m){var AF=-Ah.x;var AZ=-Ah.y;AG.push("')}}else{var Ai=Y(AO.fillStyle);var AT=Ai.color;var Ad=Ai.alpha*AO.globalAlpha;AG.push('')}}}M.fill=function(){this.stroke(true)};M.closePath=function(){this.currentPath_.push({type:"close"})};M.getCoords_=function(j,i){var Z=this.m_;return{x:D*(j*Z[0][0]+i*Z[1][0]+Z[2][0])-F,y:D*(j*Z[0][1]+i*Z[1][1]+Z[2][1])-F}};M.save=function(){var Z={};Q(this,Z);this.aStack_.push(Z);this.mStack_.push(this.m_);this.m_=d(V(),this.m_)};M.restore=function(){if(this.aStack_.length){Q(this.aStack_.pop(),this);this.m_=this.mStack_.pop()}};function H(Z){return isFinite(Z[0][0])&&isFinite(Z[0][1])&&isFinite(Z[1][0])&&isFinite(Z[1][1])&&isFinite(Z[2][0])&&isFinite(Z[2][1])}function y(i,Z,j){if(!H(Z)){return }i.m_=Z;if(j){var p=Z[0][0]*Z[1][1]-Z[0][1]*Z[1][0];i.lineScale_=k(b(p))}}M.translate=function(j,i){var Z=[[1,0,0],[0,1,0],[j,i,1]];y(this,d(Z,this.m_),false)};M.rotate=function(i){var m=U(i);var j=J(i);var Z=[[m,j,0],[-j,m,0],[0,0,1]];y(this,d(Z,this.m_),false)};M.scale=function(j,i){this.arcScaleX_*=j;this.arcScaleY_*=i;var Z=[[j,0,0],[0,i,0],[0,0,1]];y(this,d(Z,this.m_),true)};M.transform=function(p,m,AF,AE,i,Z){var j=[[p,m,0],[AF,AE,0],[i,Z,1]];y(this,d(j,this.m_),true)};M.setTransform=function(AE,p,AG,AF,j,i){var Z=[[AE,p,0],[AG,AF,0],[j,i,1]];y(this,Z,true)};M.drawText_=function(AK,AI,AH,AN,AG){var AM=this.m_,AQ=1000,i=0,AP=AQ,AF={x:0,y:0},AE=[];var Z=P(X(this.font),this.element_);var j=AA(Z);var AR=this.element_.currentStyle;var p=this.textAlign.toLowerCase();switch(p){case"left":case"center":case"right":break;case"end":p=AR.direction=="ltr"?"right":"left";break;case"start":p=AR.direction=="rtl"?"right":"left";break;default:p="left"}switch(this.textBaseline){case"hanging":case"top":AF.y=Z.size/1.75;break;case"middle":break;default:case null:case"alphabetic":case"ideographic":case"bottom":AF.y=-Z.size/2.25;break}switch(p){case"right":i=AQ;AP=0.05;break;case"center":i=AP=AQ/2;break}var AO=this.getCoords_(AI+AF.x,AH+AF.y);AE.push('');if(AG){R(this,AE)}else{a(this,AE,{x:-i,y:0},{x:AP,y:Z.size})}var AL=AM[0][0].toFixed(3)+","+AM[1][0].toFixed(3)+","+AM[0][1].toFixed(3)+","+AM[1][1].toFixed(3)+",0,0";var AJ=K(AO.x/D)+","+K(AO.y/D);AE.push('','','');this.element_.insertAdjacentHTML("beforeEnd",AE.join(""))};M.fillText=function(j,Z,m,i){this.drawText_(j,Z,m,i,false)};M.strokeText=function(j,Z,m,i){this.drawText_(j,Z,m,i,true)};M.measureText=function(j){if(!this.textMeasureEl_){var Z='';this.element_.insertAdjacentHTML("beforeEnd",Z);this.textMeasureEl_=this.element_.lastChild}var i=this.element_.ownerDocument;this.textMeasureEl_.innerHTML="";this.textMeasureEl_.style.font=this.font;this.textMeasureEl_.appendChild(i.createTextNode(j));return{width:this.textMeasureEl_.offsetWidth}};M.clip=function(){};M.arcTo=function(){};M.createPattern=function(i,Z){return new u(i,Z)};function v(Z){this.type_=Z;this.x0_=0;this.y0_=0;this.r0_=0;this.x1_=0;this.y1_=0;this.r1_=0;this.colors_=[]}v.prototype.addColorStop=function(i,Z){Z=Y(Z);this.colors_.push({offset:i,color:Z.color,alpha:Z.alpha})};function u(i,Z){q(i);switch(Z){case"repeat":case null:case"":this.repetition_="repeat";break;case"repeat-x":case"repeat-y":case"no-repeat":this.repetition_=Z;break;default:n("SYNTAX_ERR")}this.src_=i.src;this.width_=i.width;this.height_=i.height}function n(Z){throw new o(Z)}function q(Z){if(!Z||Z.nodeType!=1||Z.tagName!="IMG"){n("TYPE_MISMATCH_ERR")}if(Z.readyState!="complete"){n("INVALID_STATE_ERR")}}function o(Z){this.code=this[Z];this.message=Z+": DOM Exception "+this.code}var x=o.prototype=new Error;x.INDEX_SIZE_ERR=1;x.DOMSTRING_SIZE_ERR=2;x.HIERARCHY_REQUEST_ERR=3;x.WRONG_DOCUMENT_ERR=4;x.INVALID_CHARACTER_ERR=5;x.NO_DATA_ALLOWED_ERR=6;x.NO_MODIFICATION_ALLOWED_ERR=7;x.NOT_FOUND_ERR=8;x.NOT_SUPPORTED_ERR=9;x.INUSE_ATTRIBUTE_ERR=10;x.INVALID_STATE_ERR=11;x.SYNTAX_ERR=12;x.INVALID_MODIFICATION_ERR=13;x.NAMESPACE_ERR=14;x.INVALID_ACCESS_ERR=15;x.VALIDATION_ERR=16;x.TYPE_MISMATCH_ERR=17;G_vmlCanvasManager=E;CanvasRenderingContext2D=W;CanvasGradient=v;CanvasPattern=u;DOMException=o})()}; \ No newline at end of file diff --git a/includes/jquery/flot/jquery.flot.js b/includes/jquery/flot/jquery.flot.js new file mode 100644 index 0000000000..aabc544e9a --- /dev/null +++ b/includes/jquery/flot/jquery.flot.js @@ -0,0 +1,2599 @@ +/*! Javascript plotting library for jQuery, v. 0.7. + * + * Released under the MIT license by IOLA, December 2007. + * + */ + +// first an inline dependency, jquery.colorhelpers.js, we inline it here +// for convenience + +/* Plugin for jQuery for working with colors. + * + * Version 1.1. + * + * Inspiration from jQuery color animation plugin by John Resig. + * + * Released under the MIT license by Ole Laursen, October 2009. + * + * Examples: + * + * $.color.parse("#fff").scale('rgb', 0.25).add('a', -0.5).toString() + * var c = $.color.extract($("#mydiv"), 'background-color'); + * console.log(c.r, c.g, c.b, c.a); + * $.color.make(100, 50, 25, 0.4).toString() // returns "rgba(100,50,25,0.4)" + * + * Note that .scale() and .add() return the same modified object + * instead of making a new one. + * + * V. 1.1: Fix error handling so e.g. parsing an empty string does + * produce a color rather than just crashing. + */ +(function(B){B.color={};B.color.make=function(F,E,C,D){var G={};G.r=F||0;G.g=E||0;G.b=C||0;G.a=D!=null?D:1;G.add=function(J,I){for(var H=0;H=1){return"rgb("+[G.r,G.g,G.b].join(",")+")"}else{return"rgba("+[G.r,G.g,G.b,G.a].join(",")+")"}};G.normalize=function(){function H(J,K,I){return KI?I:K)}G.r=H(0,parseInt(G.r),255);G.g=H(0,parseInt(G.g),255);G.b=H(0,parseInt(G.b),255);G.a=H(0,G.a,1);return G};G.clone=function(){return B.color.make(G.r,G.b,G.g,G.a)};return G.normalize()};B.color.extract=function(D,C){var E;do{E=D.css(C).toLowerCase();if(E!=""&&E!="transparent"){break}D=D.parent()}while(!B.nodeName(D.get(0),"body"));if(E=="rgba(0, 0, 0, 0)"){E="transparent"}return B.color.parse(E)};B.color.parse=function(F){var E,C=B.color.make;if(E=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(F)){return C(parseInt(E[1],10),parseInt(E[2],10),parseInt(E[3],10))}if(E=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(F)){return C(parseInt(E[1],10),parseInt(E[2],10),parseInt(E[3],10),parseFloat(E[4]))}if(E=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(F)){return C(parseFloat(E[1])*2.55,parseFloat(E[2])*2.55,parseFloat(E[3])*2.55)}if(E=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(F)){return C(parseFloat(E[1])*2.55,parseFloat(E[2])*2.55,parseFloat(E[3])*2.55,parseFloat(E[4]))}if(E=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(F)){return C(parseInt(E[1],16),parseInt(E[2],16),parseInt(E[3],16))}if(E=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(F)){return C(parseInt(E[1]+E[1],16),parseInt(E[2]+E[2],16),parseInt(E[3]+E[3],16))}var D=B.trim(F).toLowerCase();if(D=="transparent"){return C(255,255,255,0)}else{E=A[D]||[0,0,0];return C(E[0],E[1],E[2])}};var A={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]}})(jQuery); + +// the actual Flot code +(function($) { + function Plot(placeholder, data_, options_, plugins) { + // data is on the form: + // [ series1, series2 ... ] + // where series is either just the data as [ [x1, y1], [x2, y2], ... ] + // or { data: [ [x1, y1], [x2, y2], ... ], label: "some label", ... } + + var series = [], + options = { + // the color theme used for graphs + colors: ["#edc240", "#afd8f8", "#cb4b4b", "#4da74d", "#9440ed"], + legend: { + show: true, + noColumns: 1, // number of colums in legend table + labelFormatter: null, // fn: string -> string + labelBoxBorderColor: "#ccc", // border color for the little label boxes + container: null, // container (as jQuery object) to put legend in, null means default on top of graph + position: "ne", // position of default legend container within plot + margin: 5, // distance from grid edge to default legend container within plot + backgroundColor: null, // null means auto-detect + backgroundOpacity: 0.85 // set to 0 to avoid background + }, + xaxis: { + show: null, // null = auto-detect, true = always, false = never + position: "bottom", // or "top" + mode: null, // null or "time" + color: null, // base color, labels, ticks + tickColor: null, // possibly different color of ticks, e.g. "rgba(0,0,0,0.15)" + transform: null, // null or f: number -> number to transform axis + inverseTransform: null, // if transform is set, this should be the inverse function + min: null, // min. value to show, null means set automatically + max: null, // max. value to show, null means set automatically + autoscaleMargin: null, // margin in % to add if auto-setting min/max + ticks: null, // either [1, 3] or [[1, "a"], 3] or (fn: axis info -> ticks) or app. number of ticks for auto-ticks + tickFormatter: null, // fn: number -> string + labelWidth: null, // size of tick labels in pixels + labelHeight: null, + reserveSpace: null, // whether to reserve space even if axis isn't shown + tickLength: null, // size in pixels of ticks, or "full" for whole line + alignTicksWithAxis: null, // axis number or null for no sync + + // mode specific options + tickDecimals: null, // no. of decimals, null means auto + tickSize: null, // number or [number, "unit"] + minTickSize: null, // number or [number, "unit"] + monthNames: null, // list of names of months + timeformat: null, // format string to use + twelveHourClock: false // 12 or 24 time in time mode + }, + yaxis: { + autoscaleMargin: 0.02, + position: "left" // or "right" + }, + xaxes: [], + yaxes: [], + series: { + points: { + show: false, + radius: 3, + lineWidth: 2, // in pixels + fill: true, + fillColor: "#ffffff", + symbol: "circle" // or callback + }, + lines: { + // we don't put in show: false so we can see + // whether lines were actively disabled + lineWidth: 2, // in pixels + fill: false, + fillColor: null, + steps: false + }, + bars: { + show: false, + lineWidth: 2, // in pixels + barWidth: 1, // in units of the x axis + fill: true, + fillColor: null, + align: "left", // or "center" + horizontal: false + }, + shadowSize: 3 + }, + grid: { + show: true, + aboveData: false, + color: "#545454", // primary color used for outline and labels + backgroundColor: null, // null for transparent, else color + borderColor: null, // set if different from the grid color + tickColor: null, // color for the ticks, e.g. "rgba(0,0,0,0.15)" + labelMargin: 5, // in pixels + axisMargin: 8, // in pixels + borderWidth: 2, // in pixels + minBorderMargin: null, // in pixels, null means taken from points radius + markings: null, // array of ranges or fn: axes -> array of ranges + markingsColor: "#f4f4f4", + markingsLineWidth: 2, + // interactive stuff + clickable: false, + hoverable: false, + autoHighlight: true, // highlight in case mouse is near + mouseActiveRadius: 10 // how far the mouse can be away to activate an item + }, + hooks: {} + }, + canvas = null, // the canvas for the plot itself + overlay = null, // canvas for interactive stuff on top of plot + eventHolder = null, // jQuery object that events should be bound to + ctx = null, octx = null, + xaxes = [], yaxes = [], + plotOffset = { left: 0, right: 0, top: 0, bottom: 0}, + canvasWidth = 0, canvasHeight = 0, + plotWidth = 0, plotHeight = 0, + hooks = { + processOptions: [], + processRawData: [], + processDatapoints: [], + drawSeries: [], + draw: [], + bindEvents: [], + drawOverlay: [], + shutdown: [] + }, + plot = this; + + // public functions + plot.setData = setData; + plot.setupGrid = setupGrid; + plot.draw = draw; + plot.getPlaceholder = function() { return placeholder; }; + plot.getCanvas = function() { return canvas; }; + plot.getPlotOffset = function() { return plotOffset; }; + plot.width = function () { return plotWidth; }; + plot.height = function () { return plotHeight; }; + plot.offset = function () { + var o = eventHolder.offset(); + o.left += plotOffset.left; + o.top += plotOffset.top; + return o; + }; + plot.getData = function () { return series; }; + plot.getAxes = function () { + var res = {}, i; + $.each(xaxes.concat(yaxes), function (_, axis) { + if (axis) + res[axis.direction + (axis.n != 1 ? axis.n : "") + "axis"] = axis; + }); + return res; + }; + plot.getXAxes = function () { return xaxes; }; + plot.getYAxes = function () { return yaxes; }; + plot.c2p = canvasToAxisCoords; + plot.p2c = axisToCanvasCoords; + plot.getOptions = function () { return options; }; + plot.highlight = highlight; + plot.unhighlight = unhighlight; + plot.triggerRedrawOverlay = triggerRedrawOverlay; + plot.pointOffset = function(point) { + return { + left: parseInt(xaxes[axisNumber(point, "x") - 1].p2c(+point.x) + plotOffset.left), + top: parseInt(yaxes[axisNumber(point, "y") - 1].p2c(+point.y) + plotOffset.top) + }; + }; + plot.shutdown = shutdown; + plot.resize = function () { + getCanvasDimensions(); + resizeCanvas(canvas); + resizeCanvas(overlay); + }; + + // public attributes + plot.hooks = hooks; + + // initialize + initPlugins(plot); + parseOptions(options_); + setupCanvases(); + setData(data_); + setupGrid(); + draw(); + bindEvents(); + + + function executeHooks(hook, args) { + args = [plot].concat(args); + for (var i = 0; i < hook.length; ++i) + hook[i].apply(this, args); + } + + function initPlugins() { + for (var i = 0; i < plugins.length; ++i) { + var p = plugins[i]; + p.init(plot); + if (p.options) + $.extend(true, options, p.options); + } + } + + function parseOptions(opts) { + var i; + + $.extend(true, options, opts); + + if (options.xaxis.color == null) + options.xaxis.color = options.grid.color; + if (options.yaxis.color == null) + options.yaxis.color = options.grid.color; + + if (options.xaxis.tickColor == null) // backwards-compatibility + options.xaxis.tickColor = options.grid.tickColor; + if (options.yaxis.tickColor == null) // backwards-compatibility + options.yaxis.tickColor = options.grid.tickColor; + + if (options.grid.borderColor == null) + options.grid.borderColor = options.grid.color; + if (options.grid.tickColor == null) + options.grid.tickColor = $.color.parse(options.grid.color).scale('a', 0.22).toString(); + + // fill in defaults in axes, copy at least always the + // first as the rest of the code assumes it'll be there + for (i = 0; i < Math.max(1, options.xaxes.length); ++i) + options.xaxes[i] = $.extend(true, {}, options.xaxis, options.xaxes[i]); + for (i = 0; i < Math.max(1, options.yaxes.length); ++i) + options.yaxes[i] = $.extend(true, {}, options.yaxis, options.yaxes[i]); + + // backwards compatibility, to be removed in future + if (options.xaxis.noTicks && options.xaxis.ticks == null) + options.xaxis.ticks = options.xaxis.noTicks; + if (options.yaxis.noTicks && options.yaxis.ticks == null) + options.yaxis.ticks = options.yaxis.noTicks; + if (options.x2axis) { + options.xaxes[1] = $.extend(true, {}, options.xaxis, options.x2axis); + options.xaxes[1].position = "top"; + } + if (options.y2axis) { + options.yaxes[1] = $.extend(true, {}, options.yaxis, options.y2axis); + options.yaxes[1].position = "right"; + } + if (options.grid.coloredAreas) + options.grid.markings = options.grid.coloredAreas; + if (options.grid.coloredAreasColor) + options.grid.markingsColor = options.grid.coloredAreasColor; + if (options.lines) + $.extend(true, options.series.lines, options.lines); + if (options.points) + $.extend(true, options.series.points, options.points); + if (options.bars) + $.extend(true, options.series.bars, options.bars); + if (options.shadowSize != null) + options.series.shadowSize = options.shadowSize; + + // save options on axes for future reference + for (i = 0; i < options.xaxes.length; ++i) + getOrCreateAxis(xaxes, i + 1).options = options.xaxes[i]; + for (i = 0; i < options.yaxes.length; ++i) + getOrCreateAxis(yaxes, i + 1).options = options.yaxes[i]; + + // add hooks from options + for (var n in hooks) + if (options.hooks[n] && options.hooks[n].length) + hooks[n] = hooks[n].concat(options.hooks[n]); + + executeHooks(hooks.processOptions, [options]); + } + + function setData(d) { + series = parseData(d); + fillInSeriesOptions(); + processData(); + } + + function parseData(d) { + var res = []; + for (var i = 0; i < d.length; ++i) { + var s = $.extend(true, {}, options.series); + + if (d[i].data != null) { + s.data = d[i].data; // move the data instead of deep-copy + delete d[i].data; + + $.extend(true, s, d[i]); + + d[i].data = s.data; + } + else + s.data = d[i]; + res.push(s); + } + + return res; + } + + function axisNumber(obj, coord) { + var a = obj[coord + "axis"]; + if (typeof a == "object") // if we got a real axis, extract number + a = a.n; + if (typeof a != "number") + a = 1; // default to first axis + return a; + } + + function allAxes() { + // return flat array without annoying null entries + return $.grep(xaxes.concat(yaxes), function (a) { return a; }); + } + + function canvasToAxisCoords(pos) { + // return an object with x/y corresponding to all used axes + var res = {}, i, axis; + for (i = 0; i < xaxes.length; ++i) { + axis = xaxes[i]; + if (axis && axis.used) + res["x" + axis.n] = axis.c2p(pos.left); + } + + for (i = 0; i < yaxes.length; ++i) { + axis = yaxes[i]; + if (axis && axis.used) + res["y" + axis.n] = axis.c2p(pos.top); + } + + if (res.x1 !== undefined) + res.x = res.x1; + if (res.y1 !== undefined) + res.y = res.y1; + + return res; + } + + function axisToCanvasCoords(pos) { + // get canvas coords from the first pair of x/y found in pos + var res = {}, i, axis, key; + + for (i = 0; i < xaxes.length; ++i) { + axis = xaxes[i]; + if (axis && axis.used) { + key = "x" + axis.n; + if (pos[key] == null && axis.n == 1) + key = "x"; + + if (pos[key] != null) { + res.left = axis.p2c(pos[key]); + break; + } + } + } + + for (i = 0; i < yaxes.length; ++i) { + axis = yaxes[i]; + if (axis && axis.used) { + key = "y" + axis.n; + if (pos[key] == null && axis.n == 1) + key = "y"; + + if (pos[key] != null) { + res.top = axis.p2c(pos[key]); + break; + } + } + } + + return res; + } + + function getOrCreateAxis(axes, number) { + if (!axes[number - 1]) + axes[number - 1] = { + n: number, // save the number for future reference + direction: axes == xaxes ? "x" : "y", + options: $.extend(true, {}, axes == xaxes ? options.xaxis : options.yaxis) + }; + + return axes[number - 1]; + } + + function fillInSeriesOptions() { + var i; + + // collect what we already got of colors + var neededColors = series.length, + usedColors = [], + assignedColors = []; + for (i = 0; i < series.length; ++i) { + var sc = series[i].color; + if (sc != null) { + --neededColors; + if (typeof sc == "number") + assignedColors.push(sc); + else + usedColors.push($.color.parse(series[i].color)); + } + } + + // we might need to generate more colors if higher indices + // are assigned + for (i = 0; i < assignedColors.length; ++i) { + neededColors = Math.max(neededColors, assignedColors[i] + 1); + } + + // produce colors as needed + var colors = [], variation = 0; + i = 0; + while (colors.length < neededColors) { + var c; + if (options.colors.length == i) // check degenerate case + c = $.color.make(100, 100, 100); + else + c = $.color.parse(options.colors[i]); + + // vary color if needed + var sign = variation % 2 == 1 ? -1 : 1; + c.scale('rgb', 1 + sign * Math.ceil(variation / 2) * 0.2) + + // FIXME: if we're getting to close to something else, + // we should probably skip this one + colors.push(c); + + ++i; + if (i >= options.colors.length) { + i = 0; + ++variation; + } + } + + // fill in the options + var colori = 0, s; + for (i = 0; i < series.length; ++i) { + s = series[i]; + + // assign colors + if (s.color == null) { + s.color = colors[colori].toString(); + ++colori; + } + else if (typeof s.color == "number") + s.color = colors[s.color].toString(); + + // turn on lines automatically in case nothing is set + if (s.lines.show == null) { + var v, show = true; + for (v in s) + if (s[v] && s[v].show) { + show = false; + break; + } + if (show) + s.lines.show = true; + } + + // setup axes + s.xaxis = getOrCreateAxis(xaxes, axisNumber(s, "x")); + s.yaxis = getOrCreateAxis(yaxes, axisNumber(s, "y")); + } + } + + function processData() { + var topSentry = Number.POSITIVE_INFINITY, + bottomSentry = Number.NEGATIVE_INFINITY, + fakeInfinity = Number.MAX_VALUE, + i, j, k, m, length, + s, points, ps, x, y, axis, val, f, p; + + function updateAxis(axis, min, max) { + if (min < axis.datamin && min != -fakeInfinity) + axis.datamin = min; + if (max > axis.datamax && max != fakeInfinity) + axis.datamax = max; + } + + $.each(allAxes(), function (_, axis) { + // init axis + axis.datamin = topSentry; + axis.datamax = bottomSentry; + axis.used = false; + }); + + for (i = 0; i < series.length; ++i) { + s = series[i]; + s.datapoints = { points: [] }; + + executeHooks(hooks.processRawData, [ s, s.data, s.datapoints ]); + } + + // first pass: clean and copy data + for (i = 0; i < series.length; ++i) { + s = series[i]; + + var data = s.data, format = s.datapoints.format; + + if (!format) { + format = []; + // find out how to copy + format.push({ x: true, number: true, required: true }); + format.push({ y: true, number: true, required: true }); + + if (s.bars.show || (s.lines.show && s.lines.fill)) { + format.push({ y: true, number: true, required: false, defaultValue: 0 }); + if (s.bars.horizontal) { + delete format[format.length - 1].y; + format[format.length - 1].x = true; + } + } + + s.datapoints.format = format; + } + + if (s.datapoints.pointsize != null) + continue; // already filled in + + s.datapoints.pointsize = format.length; + + ps = s.datapoints.pointsize; + points = s.datapoints.points; + + insertSteps = s.lines.show && s.lines.steps; + s.xaxis.used = s.yaxis.used = true; + + for (j = k = 0; j < data.length; ++j, k += ps) { + p = data[j]; + + var nullify = p == null; + if (!nullify) { + for (m = 0; m < ps; ++m) { + val = p[m]; + f = format[m]; + + if (f) { + if (f.number && val != null) { + val = +val; // convert to number + if (isNaN(val)) + val = null; + else if (val == Infinity) + val = fakeInfinity; + else if (val == -Infinity) + val = -fakeInfinity; + } + + if (val == null) { + if (f.required) + nullify = true; + + if (f.defaultValue != null) + val = f.defaultValue; + } + } + + points[k + m] = val; + } + } + + if (nullify) { + for (m = 0; m < ps; ++m) { + val = points[k + m]; + if (val != null) { + f = format[m]; + // extract min/max info + if (f.x) + updateAxis(s.xaxis, val, val); + if (f.y) + updateAxis(s.yaxis, val, val); + } + points[k + m] = null; + } + } + else { + // a little bit of line specific stuff that + // perhaps shouldn't be here, but lacking + // better means... + if (insertSteps && k > 0 + && points[k - ps] != null + && points[k - ps] != points[k] + && points[k - ps + 1] != points[k + 1]) { + // copy the point to make room for a middle point + for (m = 0; m < ps; ++m) + points[k + ps + m] = points[k + m]; + + // middle point has same y + points[k + 1] = points[k - ps + 1]; + + // we've added a point, better reflect that + k += ps; + } + } + } + } + + // give the hooks a chance to run + for (i = 0; i < series.length; ++i) { + s = series[i]; + + executeHooks(hooks.processDatapoints, [ s, s.datapoints]); + } + + // second pass: find datamax/datamin for auto-scaling + for (i = 0; i < series.length; ++i) { + s = series[i]; + points = s.datapoints.points, + ps = s.datapoints.pointsize; + + var xmin = topSentry, ymin = topSentry, + xmax = bottomSentry, ymax = bottomSentry; + + for (j = 0; j < points.length; j += ps) { + if (points[j] == null) + continue; + + for (m = 0; m < ps; ++m) { + val = points[j + m]; + f = format[m]; + if (!f || val == fakeInfinity || val == -fakeInfinity) + continue; + + if (f.x) { + if (val < xmin) + xmin = val; + if (val > xmax) + xmax = val; + } + if (f.y) { + if (val < ymin) + ymin = val; + if (val > ymax) + ymax = val; + } + } + } + + if (s.bars.show) { + // make sure we got room for the bar on the dancing floor + var delta = s.bars.align == "left" ? 0 : -s.bars.barWidth/2; + if (s.bars.horizontal) { + ymin += delta; + ymax += delta + s.bars.barWidth; + } + else { + xmin += delta; + xmax += delta + s.bars.barWidth; + } + } + + updateAxis(s.xaxis, xmin, xmax); + updateAxis(s.yaxis, ymin, ymax); + } + + $.each(allAxes(), function (_, axis) { + if (axis.datamin == topSentry) + axis.datamin = null; + if (axis.datamax == bottomSentry) + axis.datamax = null; + }); + } + + function makeCanvas(skipPositioning, cls) { + var c = document.createElement('canvas'); + c.className = cls; + c.width = canvasWidth; + c.height = canvasHeight; + + if (!skipPositioning) + $(c).css({ position: 'absolute', left: 0, top: 0 }); + + $(c).appendTo(placeholder); + + if (!c.getContext) // excanvas hack + c = window.G_vmlCanvasManager.initElement(c); + + // used for resetting in case we get replotted + c.getContext("2d").save(); + + return c; + } + + function getCanvasDimensions() { + canvasWidth = placeholder.width(); + canvasHeight = placeholder.height(); + + if (canvasWidth <= 0 || canvasHeight <= 0) + throw "Invalid dimensions for plot, width = " + canvasWidth + ", height = " + canvasHeight; + } + + function resizeCanvas(c) { + // resizing should reset the state (excanvas seems to be + // buggy though) + if (c.width != canvasWidth) + c.width = canvasWidth; + + if (c.height != canvasHeight) + c.height = canvasHeight; + + // so try to get back to the initial state (even if it's + // gone now, this should be safe according to the spec) + var cctx = c.getContext("2d"); + cctx.restore(); + + // and save again + cctx.save(); + } + + function setupCanvases() { + var reused, + existingCanvas = placeholder.children("canvas.base"), + existingOverlay = placeholder.children("canvas.overlay"); + + if (existingCanvas.length == 0 || existingOverlay == 0) { + // init everything + + placeholder.html(""); // make sure placeholder is clear + + placeholder.css({ padding: 0 }); // padding messes up the positioning + + if (placeholder.css("position") == 'static') + placeholder.css("position", "relative"); // for positioning labels and overlay + + getCanvasDimensions(); + + canvas = makeCanvas(true, "base"); + overlay = makeCanvas(false, "overlay"); // overlay canvas for interactive features + + reused = false; + } + else { + // reuse existing elements + + canvas = existingCanvas.get(0); + overlay = existingOverlay.get(0); + + reused = true; + } + + ctx = canvas.getContext("2d"); + octx = overlay.getContext("2d"); + + // we include the canvas in the event holder too, because IE 7 + // sometimes has trouble with the stacking order + eventHolder = $([overlay, canvas]); + + if (reused) { + // run shutdown in the old plot object + placeholder.data("plot").shutdown(); + + // reset reused canvases + plot.resize(); + + // make sure overlay pixels are cleared (canvas is cleared when we redraw) + octx.clearRect(0, 0, canvasWidth, canvasHeight); + + // then whack any remaining obvious garbage left + eventHolder.unbind(); + placeholder.children().not([canvas, overlay]).remove(); + } + + // save in case we get replotted + placeholder.data("plot", plot); + } + + function bindEvents() { + // bind events + if (options.grid.hoverable) { + eventHolder.mousemove(onMouseMove); + eventHolder.mouseleave(onMouseLeave); + } + + if (options.grid.clickable) + eventHolder.click(onClick); + + executeHooks(hooks.bindEvents, [eventHolder]); + } + + function shutdown() { + if (redrawTimeout) + clearTimeout(redrawTimeout); + + eventHolder.unbind("mousemove", onMouseMove); + eventHolder.unbind("mouseleave", onMouseLeave); + eventHolder.unbind("click", onClick); + + executeHooks(hooks.shutdown, [eventHolder]); + } + + function setTransformationHelpers(axis) { + // set helper functions on the axis, assumes plot area + // has been computed already + + function identity(x) { return x; } + + var s, m, t = axis.options.transform || identity, + it = axis.options.inverseTransform; + + // precompute how much the axis is scaling a point + // in canvas space + if (axis.direction == "x") { + s = axis.scale = plotWidth / Math.abs(t(axis.max) - t(axis.min)); + m = Math.min(t(axis.max), t(axis.min)); + } + else { + s = axis.scale = plotHeight / Math.abs(t(axis.max) - t(axis.min)); + s = -s; + m = Math.max(t(axis.max), t(axis.min)); + } + + // data point to canvas coordinate + if (t == identity) // slight optimization + axis.p2c = function (p) { return (p - m) * s; }; + else + axis.p2c = function (p) { return (t(p) - m) * s; }; + // canvas coordinate to data point + if (!it) + axis.c2p = function (c) { return m + c / s; }; + else + axis.c2p = function (c) { return it(m + c / s); }; + } + + function measureTickLabels(axis) { + var opts = axis.options, i, ticks = axis.ticks || [], labels = [], + l, w = opts.labelWidth, h = opts.labelHeight, dummyDiv; + + function makeDummyDiv(labels, width) { + return $('
    ' + + '
    ' + + labels.join("") + '
    ') + .appendTo(placeholder); + } + + if (axis.direction == "x") { + // to avoid measuring the widths of the labels (it's slow), we + // construct fixed-size boxes and put the labels inside + // them, we don't need the exact figures and the + // fixed-size box content is easy to center + if (w == null) + w = Math.floor(canvasWidth / (ticks.length > 0 ? ticks.length : 1)); + + // measure x label heights + if (h == null) { + labels = []; + for (i = 0; i < ticks.length; ++i) { + l = ticks[i].label; + if (l) + labels.push('
    ' + l + '
    '); + } + + if (labels.length > 0) { + // stick them all in the same div and measure + // collective height + labels.push('
    '); + dummyDiv = makeDummyDiv(labels, "width:10000px;"); + h = dummyDiv.height(); + dummyDiv.remove(); + } + } + } + else if (w == null || h == null) { + // calculate y label dimensions + for (i = 0; i < ticks.length; ++i) { + l = ticks[i].label; + if (l) + labels.push('
    ' + l + '
    '); + } + + if (labels.length > 0) { + dummyDiv = makeDummyDiv(labels, ""); + if (w == null) + w = dummyDiv.children().width(); + if (h == null) + h = dummyDiv.find("div.tickLabel").height(); + dummyDiv.remove(); + } + } + + if (w == null) + w = 0; + if (h == null) + h = 0; + + axis.labelWidth = w; + axis.labelHeight = h; + } + + function allocateAxisBoxFirstPhase(axis) { + // find the bounding box of the axis by looking at label + // widths/heights and ticks, make room by diminishing the + // plotOffset + + var lw = axis.labelWidth, + lh = axis.labelHeight, + pos = axis.options.position, + tickLength = axis.options.tickLength, + axismargin = options.grid.axisMargin, + padding = options.grid.labelMargin, + all = axis.direction == "x" ? xaxes : yaxes, + index; + + // determine axis margin + var samePosition = $.grep(all, function (a) { + return a && a.options.position == pos && a.reserveSpace; + }); + if ($.inArray(axis, samePosition) == samePosition.length - 1) + axismargin = 0; // outermost + + // determine tick length - if we're innermost, we can use "full" + if (tickLength == null) + tickLength = "full"; + + var sameDirection = $.grep(all, function (a) { + return a && a.reserveSpace; + }); + + var innermost = $.inArray(axis, sameDirection) == 0; + if (!innermost && tickLength == "full") + tickLength = 5; + + if (!isNaN(+tickLength)) + padding += +tickLength; + + // compute box + if (axis.direction == "x") { + lh += padding; + + if (pos == "bottom") { + plotOffset.bottom += lh + axismargin; + axis.box = { top: canvasHeight - plotOffset.bottom, height: lh }; + } + else { + axis.box = { top: plotOffset.top + axismargin, height: lh }; + plotOffset.top += lh + axismargin; + } + } + else { + lw += padding; + + if (pos == "left") { + axis.box = { left: plotOffset.left + axismargin, width: lw }; + plotOffset.left += lw + axismargin; + } + else { + plotOffset.right += lw + axismargin; + axis.box = { left: canvasWidth - plotOffset.right, width: lw }; + } + } + + // save for future reference + axis.position = pos; + axis.tickLength = tickLength; + axis.box.padding = padding; + axis.innermost = innermost; + } + + function allocateAxisBoxSecondPhase(axis) { + // set remaining bounding box coordinates + if (axis.direction == "x") { + axis.box.left = plotOffset.left; + axis.box.width = plotWidth; + } + else { + axis.box.top = plotOffset.top; + axis.box.height = plotHeight; + } + } + + function setupGrid() { + var i, axes = allAxes(); + + // first calculate the plot and axis box dimensions + + $.each(axes, function (_, axis) { + axis.show = axis.options.show; + if (axis.show == null) + axis.show = axis.used; // by default an axis is visible if it's got data + + axis.reserveSpace = axis.show || axis.options.reserveSpace; + + setRange(axis); + }); + + allocatedAxes = $.grep(axes, function (axis) { return axis.reserveSpace; }); + + plotOffset.left = plotOffset.right = plotOffset.top = plotOffset.bottom = 0; + if (options.grid.show) { + $.each(allocatedAxes, function (_, axis) { + // make the ticks + setupTickGeneration(axis); + setTicks(axis); + snapRangeToTicks(axis, axis.ticks); + + // find labelWidth/Height for axis + measureTickLabels(axis); + }); + + // with all dimensions in house, we can compute the + // axis boxes, start from the outside (reverse order) + for (i = allocatedAxes.length - 1; i >= 0; --i) + allocateAxisBoxFirstPhase(allocatedAxes[i]); + + // make sure we've got enough space for things that + // might stick out + var minMargin = options.grid.minBorderMargin; + if (minMargin == null) { + minMargin = 0; + for (i = 0; i < series.length; ++i) + minMargin = Math.max(minMargin, series[i].points.radius + series[i].points.lineWidth/2); + } + + for (var a in plotOffset) { + plotOffset[a] += options.grid.borderWidth; + plotOffset[a] = Math.max(minMargin, plotOffset[a]); + } + } + + plotWidth = canvasWidth - plotOffset.left - plotOffset.right; + plotHeight = canvasHeight - plotOffset.bottom - plotOffset.top; + + // now we got the proper plotWidth/Height, we can compute the scaling + $.each(axes, function (_, axis) { + setTransformationHelpers(axis); + }); + + if (options.grid.show) { + $.each(allocatedAxes, function (_, axis) { + allocateAxisBoxSecondPhase(axis); + }); + + insertAxisLabels(); + } + + insertLegend(); + } + + function setRange(axis) { + var opts = axis.options, + min = +(opts.min != null ? opts.min : axis.datamin), + max = +(opts.max != null ? opts.max : axis.datamax), + delta = max - min; + + if (delta == 0.0) { + // degenerate case + var widen = max == 0 ? 1 : 0.01; + + if (opts.min == null) + min -= widen; + // always widen max if we couldn't widen min to ensure we + // don't fall into min == max which doesn't work + if (opts.max == null || opts.min != null) + max += widen; + } + else { + // consider autoscaling + var margin = opts.autoscaleMargin; + if (margin != null) { + if (opts.min == null) { + min -= delta * margin; + // make sure we don't go below zero if all values + // are positive + if (min < 0 && axis.datamin != null && axis.datamin >= 0) + min = 0; + } + if (opts.max == null) { + max += delta * margin; + if (max > 0 && axis.datamax != null && axis.datamax <= 0) + max = 0; + } + } + } + axis.min = min; + axis.max = max; + } + + function setupTickGeneration(axis) { + var opts = axis.options; + + // estimate number of ticks + var noTicks; + if (typeof opts.ticks == "number" && opts.ticks > 0) + noTicks = opts.ticks; + else + // heuristic based on the model a*sqrt(x) fitted to + // some data points that seemed reasonable + noTicks = 0.3 * Math.sqrt(axis.direction == "x" ? canvasWidth : canvasHeight); + + var delta = (axis.max - axis.min) / noTicks, + size, generator, unit, formatter, i, magn, norm; + + if (opts.mode == "time") { + // pretty handling of time + + // map of app. size of time units in milliseconds + var timeUnitSize = { + "second": 1000, + "minute": 60 * 1000, + "hour": 60 * 60 * 1000, + "day": 24 * 60 * 60 * 1000, + "month": 30 * 24 * 60 * 60 * 1000, + "year": 365.2425 * 24 * 60 * 60 * 1000 + }; + + + // the allowed tick sizes, after 1 year we use + // an integer algorithm + var spec = [ + [1, "second"], [2, "second"], [5, "second"], [10, "second"], + [30, "second"], + [1, "minute"], [2, "minute"], [5, "minute"], [10, "minute"], + [30, "minute"], + [1, "hour"], [2, "hour"], [4, "hour"], + [8, "hour"], [12, "hour"], + [1, "day"], [2, "day"], [3, "day"], + [0.25, "month"], [0.5, "month"], [1, "month"], + [2, "month"], [3, "month"], [6, "month"], + [1, "year"] + ]; + + var minSize = 0; + if (opts.minTickSize != null) { + if (typeof opts.tickSize == "number") + minSize = opts.tickSize; + else + minSize = opts.minTickSize[0] * timeUnitSize[opts.minTickSize[1]]; + } + + for (var i = 0; i < spec.length - 1; ++i) + if (delta < (spec[i][0] * timeUnitSize[spec[i][1]] + + spec[i + 1][0] * timeUnitSize[spec[i + 1][1]]) / 2 + && spec[i][0] * timeUnitSize[spec[i][1]] >= minSize) + break; + size = spec[i][0]; + unit = spec[i][1]; + + // special-case the possibility of several years + if (unit == "year") { + magn = Math.pow(10, Math.floor(Math.log(delta / timeUnitSize.year) / Math.LN10)); + norm = (delta / timeUnitSize.year) / magn; + if (norm < 1.5) + size = 1; + else if (norm < 3) + size = 2; + else if (norm < 7.5) + size = 5; + else + size = 10; + + size *= magn; + } + + axis.tickSize = opts.tickSize || [size, unit]; + + generator = function(axis) { + var ticks = [], + tickSize = axis.tickSize[0], unit = axis.tickSize[1], + d = new Date(axis.min); + + var step = tickSize * timeUnitSize[unit]; + + if (unit == "second") + d.setUTCSeconds(floorInBase(d.getUTCSeconds(), tickSize)); + if (unit == "minute") + d.setUTCMinutes(floorInBase(d.getUTCMinutes(), tickSize)); + if (unit == "hour") + d.setUTCHours(floorInBase(d.getUTCHours(), tickSize)); + if (unit == "month") + d.setUTCMonth(floorInBase(d.getUTCMonth(), tickSize)); + if (unit == "year") + d.setUTCFullYear(floorInBase(d.getUTCFullYear(), tickSize)); + + // reset smaller components + d.setUTCMilliseconds(0); + if (step >= timeUnitSize.minute) + d.setUTCSeconds(0); + if (step >= timeUnitSize.hour) + d.setUTCMinutes(0); + if (step >= timeUnitSize.day) + d.setUTCHours(0); + if (step >= timeUnitSize.day * 4) + d.setUTCDate(1); + if (step >= timeUnitSize.year) + d.setUTCMonth(0); + + + var carry = 0, v = Number.NaN, prev; + do { + prev = v; + v = d.getTime(); + ticks.push(v); + if (unit == "month") { + if (tickSize < 1) { + // a bit complicated - we'll divide the month + // up but we need to take care of fractions + // so we don't end up in the middle of a day + d.setUTCDate(1); + var start = d.getTime(); + d.setUTCMonth(d.getUTCMonth() + 1); + var end = d.getTime(); + d.setTime(v + carry * timeUnitSize.hour + (end - start) * tickSize); + carry = d.getUTCHours(); + d.setUTCHours(0); + } + else + d.setUTCMonth(d.getUTCMonth() + tickSize); + } + else if (unit == "year") { + d.setUTCFullYear(d.getUTCFullYear() + tickSize); + } + else + d.setTime(v + step); + } while (v < axis.max && v != prev); + + return ticks; + }; + + formatter = function (v, axis) { + var d = new Date(v); + + // first check global format + if (opts.timeformat != null) + return $.plot.formatDate(d, opts.timeformat, opts.monthNames); + + var t = axis.tickSize[0] * timeUnitSize[axis.tickSize[1]]; + var span = axis.max - axis.min; + var suffix = (opts.twelveHourClock) ? " %p" : ""; + + if (t < timeUnitSize.minute) + fmt = "%h:%M:%S" + suffix; + else if (t < timeUnitSize.day) { + if (span < 2 * timeUnitSize.day) + fmt = "%h:%M" + suffix; + else + fmt = "%b %d %h:%M" + suffix; + } + else if (t < timeUnitSize.month) + fmt = "%b %d"; + else if (t < timeUnitSize.year) { + if (span < timeUnitSize.year) + fmt = "%b"; + else + fmt = "%b %y"; + } + else + fmt = "%y"; + + return $.plot.formatDate(d, fmt, opts.monthNames); + }; + } + else { + // pretty rounding of base-10 numbers + var maxDec = opts.tickDecimals; + var dec = -Math.floor(Math.log(delta) / Math.LN10); + if (maxDec != null && dec > maxDec) + dec = maxDec; + + magn = Math.pow(10, -dec); + norm = delta / magn; // norm is between 1.0 and 10.0 + + if (norm < 1.5) + size = 1; + else if (norm < 3) { + size = 2; + // special case for 2.5, requires an extra decimal + if (norm > 2.25 && (maxDec == null || dec + 1 <= maxDec)) { + size = 2.5; + ++dec; + } + } + else if (norm < 7.5) + size = 5; + else + size = 10; + + size *= magn; + + if (opts.minTickSize != null && size < opts.minTickSize) + size = opts.minTickSize; + + axis.tickDecimals = Math.max(0, maxDec != null ? maxDec : dec); + axis.tickSize = opts.tickSize || size; + + generator = function (axis) { + var ticks = []; + + // spew out all possible ticks + var start = floorInBase(axis.min, axis.tickSize), + i = 0, v = Number.NaN, prev; + do { + prev = v; + v = start + i * axis.tickSize; + ticks.push(v); + ++i; + } while (v < axis.max && v != prev); + return ticks; + }; + + formatter = function (v, axis) { + return v.toFixed(axis.tickDecimals); + }; + } + + if (opts.alignTicksWithAxis != null) { + var otherAxis = (axis.direction == "x" ? xaxes : yaxes)[opts.alignTicksWithAxis - 1]; + if (otherAxis && otherAxis.used && otherAxis != axis) { + // consider snapping min/max to outermost nice ticks + var niceTicks = generator(axis); + if (niceTicks.length > 0) { + if (opts.min == null) + axis.min = Math.min(axis.min, niceTicks[0]); + if (opts.max == null && niceTicks.length > 1) + axis.max = Math.max(axis.max, niceTicks[niceTicks.length - 1]); + } + + generator = function (axis) { + // copy ticks, scaled to this axis + var ticks = [], v, i; + for (i = 0; i < otherAxis.ticks.length; ++i) { + v = (otherAxis.ticks[i].v - otherAxis.min) / (otherAxis.max - otherAxis.min); + v = axis.min + v * (axis.max - axis.min); + ticks.push(v); + } + return ticks; + }; + + // we might need an extra decimal since forced + // ticks don't necessarily fit naturally + if (axis.mode != "time" && opts.tickDecimals == null) { + var extraDec = Math.max(0, -Math.floor(Math.log(delta) / Math.LN10) + 1), + ts = generator(axis); + + // only proceed if the tick interval rounded + // with an extra decimal doesn't give us a + // zero at end + if (!(ts.length > 1 && /\..*0$/.test((ts[1] - ts[0]).toFixed(extraDec)))) + axis.tickDecimals = extraDec; + } + } + } + + axis.tickGenerator = generator; + if ($.isFunction(opts.tickFormatter)) + axis.tickFormatter = function (v, axis) { return "" + opts.tickFormatter(v, axis); }; + else + axis.tickFormatter = formatter; + } + + function setTicks(axis) { + var oticks = axis.options.ticks, ticks = []; + if (oticks == null || (typeof oticks == "number" && oticks > 0)) + ticks = axis.tickGenerator(axis); + else if (oticks) { + if ($.isFunction(oticks)) + // generate the ticks + ticks = oticks({ min: axis.min, max: axis.max }); + else + ticks = oticks; + } + + // clean up/labelify the supplied ticks, copy them over + var i, v; + axis.ticks = []; + for (i = 0; i < ticks.length; ++i) { + var label = null; + var t = ticks[i]; + if (typeof t == "object") { + v = +t[0]; + if (t.length > 1) + label = t[1]; + } + else + v = +t; + if (label == null) + label = axis.tickFormatter(v, axis); + if (!isNaN(v)) + axis.ticks.push({ v: v, label: label }); + } + } + + function snapRangeToTicks(axis, ticks) { + if (axis.options.autoscaleMargin && ticks.length > 0) { + // snap to ticks + if (axis.options.min == null) + axis.min = Math.min(axis.min, ticks[0].v); + if (axis.options.max == null && ticks.length > 1) + axis.max = Math.max(axis.max, ticks[ticks.length - 1].v); + } + } + + function draw() { + ctx.clearRect(0, 0, canvasWidth, canvasHeight); + + var grid = options.grid; + + // draw background, if any + if (grid.show && grid.backgroundColor) + drawBackground(); + + if (grid.show && !grid.aboveData) + drawGrid(); + + for (var i = 0; i < series.length; ++i) { + executeHooks(hooks.drawSeries, [ctx, series[i]]); + drawSeries(series[i]); + } + + executeHooks(hooks.draw, [ctx]); + + if (grid.show && grid.aboveData) + drawGrid(); + } + + function extractRange(ranges, coord) { + var axis, from, to, key, axes = allAxes(); + + for (i = 0; i < axes.length; ++i) { + axis = axes[i]; + if (axis.direction == coord) { + key = coord + axis.n + "axis"; + if (!ranges[key] && axis.n == 1) + key = coord + "axis"; // support x1axis as xaxis + if (ranges[key]) { + from = ranges[key].from; + to = ranges[key].to; + break; + } + } + } + + // backwards-compat stuff - to be removed in future + if (!ranges[key]) { + axis = coord == "x" ? xaxes[0] : yaxes[0]; + from = ranges[coord + "1"]; + to = ranges[coord + "2"]; + } + + // auto-reverse as an added bonus + if (from != null && to != null && from > to) { + var tmp = from; + from = to; + to = tmp; + } + + return { from: from, to: to, axis: axis }; + } + + function drawBackground() { + ctx.save(); + ctx.translate(plotOffset.left, plotOffset.top); + + ctx.fillStyle = getColorOrGradient(options.grid.backgroundColor, plotHeight, 0, "rgba(255, 255, 255, 0)"); + ctx.fillRect(0, 0, plotWidth, plotHeight); + ctx.restore(); + } + + function drawGrid() { + var i; + + ctx.save(); + ctx.translate(plotOffset.left, plotOffset.top); + + // draw markings + var markings = options.grid.markings; + if (markings) { + if ($.isFunction(markings)) { + var axes = plot.getAxes(); + // xmin etc. is backwards compatibility, to be + // removed in the future + axes.xmin = axes.xaxis.min; + axes.xmax = axes.xaxis.max; + axes.ymin = axes.yaxis.min; + axes.ymax = axes.yaxis.max; + + markings = markings(axes); + } + + for (i = 0; i < markings.length; ++i) { + var m = markings[i], + xrange = extractRange(m, "x"), + yrange = extractRange(m, "y"); + + // fill in missing + if (xrange.from == null) + xrange.from = xrange.axis.min; + if (xrange.to == null) + xrange.to = xrange.axis.max; + if (yrange.from == null) + yrange.from = yrange.axis.min; + if (yrange.to == null) + yrange.to = yrange.axis.max; + + // clip + if (xrange.to < xrange.axis.min || xrange.from > xrange.axis.max || + yrange.to < yrange.axis.min || yrange.from > yrange.axis.max) + continue; + + xrange.from = Math.max(xrange.from, xrange.axis.min); + xrange.to = Math.min(xrange.to, xrange.axis.max); + yrange.from = Math.max(yrange.from, yrange.axis.min); + yrange.to = Math.min(yrange.to, yrange.axis.max); + + if (xrange.from == xrange.to && yrange.from == yrange.to) + continue; + + // then draw + xrange.from = xrange.axis.p2c(xrange.from); + xrange.to = xrange.axis.p2c(xrange.to); + yrange.from = yrange.axis.p2c(yrange.from); + yrange.to = yrange.axis.p2c(yrange.to); + + if (xrange.from == xrange.to || yrange.from == yrange.to) { + // draw line + ctx.beginPath(); + ctx.strokeStyle = m.color || options.grid.markingsColor; + ctx.lineWidth = m.lineWidth || options.grid.markingsLineWidth; + ctx.moveTo(xrange.from, yrange.from); + ctx.lineTo(xrange.to, yrange.to); + ctx.stroke(); + } + else { + // fill area + ctx.fillStyle = m.color || options.grid.markingsColor; + ctx.fillRect(xrange.from, yrange.to, + xrange.to - xrange.from, + yrange.from - yrange.to); + } + } + } + + // draw the ticks + var axes = allAxes(), bw = options.grid.borderWidth; + + for (var j = 0; j < axes.length; ++j) { + var axis = axes[j], box = axis.box, + t = axis.tickLength, x, y, xoff, yoff; + if (!axis.show || axis.ticks.length == 0) + continue + + ctx.strokeStyle = axis.options.tickColor || $.color.parse(axis.options.color).scale('a', 0.22).toString(); + ctx.lineWidth = 1; + + // find the edges + if (axis.direction == "x") { + x = 0; + if (t == "full") + y = (axis.position == "top" ? 0 : plotHeight); + else + y = box.top - plotOffset.top + (axis.position == "top" ? box.height : 0); + } + else { + y = 0; + if (t == "full") + x = (axis.position == "left" ? 0 : plotWidth); + else + x = box.left - plotOffset.left + (axis.position == "left" ? box.width : 0); + } + + // draw tick bar + if (!axis.innermost) { + ctx.beginPath(); + xoff = yoff = 0; + if (axis.direction == "x") + xoff = plotWidth; + else + yoff = plotHeight; + + if (ctx.lineWidth == 1) { + x = Math.floor(x) + 0.5; + y = Math.floor(y) + 0.5; + } + + ctx.moveTo(x, y); + ctx.lineTo(x + xoff, y + yoff); + ctx.stroke(); + } + + // draw ticks + ctx.beginPath(); + for (i = 0; i < axis.ticks.length; ++i) { + var v = axis.ticks[i].v; + + xoff = yoff = 0; + + if (v < axis.min || v > axis.max + // skip those lying on the axes if we got a border + || (t == "full" && bw > 0 + && (v == axis.min || v == axis.max))) + continue; + + if (axis.direction == "x") { + x = axis.p2c(v); + yoff = t == "full" ? -plotHeight : t; + + if (axis.position == "top") + yoff = -yoff; + } + else { + y = axis.p2c(v); + xoff = t == "full" ? -plotWidth : t; + + if (axis.position == "left") + xoff = -xoff; + } + + if (ctx.lineWidth == 1) { + if (axis.direction == "x") + x = Math.floor(x) + 0.5; + else + y = Math.floor(y) + 0.5; + } + + ctx.moveTo(x, y); + ctx.lineTo(x + xoff, y + yoff); + } + + ctx.stroke(); + } + + + // draw border + if (bw) { + ctx.lineWidth = bw; + ctx.strokeStyle = options.grid.borderColor; + ctx.strokeRect(-bw/2, -bw/2, plotWidth + bw, plotHeight + bw); + } + + ctx.restore(); + } + + function insertAxisLabels() { + placeholder.find(".tickLabels").remove(); + + var html = ['
    ']; + + var axes = allAxes(); + for (var j = 0; j < axes.length; ++j) { + var axis = axes[j], box = axis.box; + if (!axis.show) + continue; + //debug: html.push('
    ') + html.push('
    '); + for (var i = 0; i < axis.ticks.length; ++i) { + var tick = axis.ticks[i]; + if (!tick.label || tick.v < axis.min || tick.v > axis.max) + continue; + + var pos = {}, align; + + if (axis.direction == "x") { + align = "center"; + pos.left = Math.round(plotOffset.left + axis.p2c(tick.v) - axis.labelWidth/2); + if (axis.position == "bottom") + pos.top = box.top + box.padding; + else + pos.bottom = canvasHeight - (box.top + box.height - box.padding); + } + else { + pos.top = Math.round(plotOffset.top + axis.p2c(tick.v) - axis.labelHeight/2); + if (axis.position == "left") { + pos.right = canvasWidth - (box.left + box.width - box.padding) + align = "right"; + } + else { + pos.left = box.left + box.padding; + align = "left"; + } + } + + pos.width = axis.labelWidth; + + var style = ["position:absolute", "text-align:" + align ]; + for (var a in pos) + style.push(a + ":" + pos[a] + "px") + + html.push('
    ' + tick.label + '
    '); + } + html.push('
    '); + } + + html.push('
    '); + + placeholder.append(html.join("")); + } + + function drawSeries(series) { + if (series.lines.show) + drawSeriesLines(series); + if (series.bars.show) + drawSeriesBars(series); + if (series.points.show) + drawSeriesPoints(series); + } + + function drawSeriesLines(series) { + function plotLine(datapoints, xoffset, yoffset, axisx, axisy) { + var points = datapoints.points, + ps = datapoints.pointsize, + prevx = null, prevy = null; + + ctx.beginPath(); + for (var i = ps; i < points.length; i += ps) { + var x1 = points[i - ps], y1 = points[i - ps + 1], + x2 = points[i], y2 = points[i + 1]; + + if (x1 == null || x2 == null) + continue; + + // clip with ymin + if (y1 <= y2 && y1 < axisy.min) { + if (y2 < axisy.min) + continue; // line segment is outside + // compute new intersection point + x1 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1; + y1 = axisy.min; + } + else if (y2 <= y1 && y2 < axisy.min) { + if (y1 < axisy.min) + continue; + x2 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1; + y2 = axisy.min; + } + + // clip with ymax + if (y1 >= y2 && y1 > axisy.max) { + if (y2 > axisy.max) + continue; + x1 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1; + y1 = axisy.max; + } + else if (y2 >= y1 && y2 > axisy.max) { + if (y1 > axisy.max) + continue; + x2 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1; + y2 = axisy.max; + } + + // clip with xmin + if (x1 <= x2 && x1 < axisx.min) { + if (x2 < axisx.min) + continue; + y1 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1; + x1 = axisx.min; + } + else if (x2 <= x1 && x2 < axisx.min) { + if (x1 < axisx.min) + continue; + y2 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1; + x2 = axisx.min; + } + + // clip with xmax + if (x1 >= x2 && x1 > axisx.max) { + if (x2 > axisx.max) + continue; + y1 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1; + x1 = axisx.max; + } + else if (x2 >= x1 && x2 > axisx.max) { + if (x1 > axisx.max) + continue; + y2 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1; + x2 = axisx.max; + } + + if (x1 != prevx || y1 != prevy) + ctx.moveTo(axisx.p2c(x1) + xoffset, axisy.p2c(y1) + yoffset); + + prevx = x2; + prevy = y2; + ctx.lineTo(axisx.p2c(x2) + xoffset, axisy.p2c(y2) + yoffset); + } + ctx.stroke(); + } + + function plotLineArea(datapoints, axisx, axisy) { + var points = datapoints.points, + ps = datapoints.pointsize, + bottom = Math.min(Math.max(0, axisy.min), axisy.max), + i = 0, top, areaOpen = false, + ypos = 1, segmentStart = 0, segmentEnd = 0; + + // we process each segment in two turns, first forward + // direction to sketch out top, then once we hit the + // end we go backwards to sketch the bottom + while (true) { + if (ps > 0 && i > points.length + ps) + break; + + i += ps; // ps is negative if going backwards + + var x1 = points[i - ps], + y1 = points[i - ps + ypos], + x2 = points[i], y2 = points[i + ypos]; + + if (areaOpen) { + if (ps > 0 && x1 != null && x2 == null) { + // at turning point + segmentEnd = i; + ps = -ps; + ypos = 2; + continue; + } + + if (ps < 0 && i == segmentStart + ps) { + // done with the reverse sweep + ctx.fill(); + areaOpen = false; + ps = -ps; + ypos = 1; + i = segmentStart = segmentEnd + ps; + continue; + } + } + + if (x1 == null || x2 == null) + continue; + + // clip x values + + // clip with xmin + if (x1 <= x2 && x1 < axisx.min) { + if (x2 < axisx.min) + continue; + y1 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1; + x1 = axisx.min; + } + else if (x2 <= x1 && x2 < axisx.min) { + if (x1 < axisx.min) + continue; + y2 = (axisx.min - x1) / (x2 - x1) * (y2 - y1) + y1; + x2 = axisx.min; + } + + // clip with xmax + if (x1 >= x2 && x1 > axisx.max) { + if (x2 > axisx.max) + continue; + y1 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1; + x1 = axisx.max; + } + else if (x2 >= x1 && x2 > axisx.max) { + if (x1 > axisx.max) + continue; + y2 = (axisx.max - x1) / (x2 - x1) * (y2 - y1) + y1; + x2 = axisx.max; + } + + if (!areaOpen) { + // open area + ctx.beginPath(); + ctx.moveTo(axisx.p2c(x1), axisy.p2c(bottom)); + areaOpen = true; + } + + // now first check the case where both is outside + if (y1 >= axisy.max && y2 >= axisy.max) { + ctx.lineTo(axisx.p2c(x1), axisy.p2c(axisy.max)); + ctx.lineTo(axisx.p2c(x2), axisy.p2c(axisy.max)); + continue; + } + else if (y1 <= axisy.min && y2 <= axisy.min) { + ctx.lineTo(axisx.p2c(x1), axisy.p2c(axisy.min)); + ctx.lineTo(axisx.p2c(x2), axisy.p2c(axisy.min)); + continue; + } + + // else it's a bit more complicated, there might + // be a flat maxed out rectangle first, then a + // triangular cutout or reverse; to find these + // keep track of the current x values + var x1old = x1, x2old = x2; + + // clip the y values, without shortcutting, we + // go through all cases in turn + + // clip with ymin + if (y1 <= y2 && y1 < axisy.min && y2 >= axisy.min) { + x1 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1; + y1 = axisy.min; + } + else if (y2 <= y1 && y2 < axisy.min && y1 >= axisy.min) { + x2 = (axisy.min - y1) / (y2 - y1) * (x2 - x1) + x1; + y2 = axisy.min; + } + + // clip with ymax + if (y1 >= y2 && y1 > axisy.max && y2 <= axisy.max) { + x1 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1; + y1 = axisy.max; + } + else if (y2 >= y1 && y2 > axisy.max && y1 <= axisy.max) { + x2 = (axisy.max - y1) / (y2 - y1) * (x2 - x1) + x1; + y2 = axisy.max; + } + + // if the x value was changed we got a rectangle + // to fill + if (x1 != x1old) { + ctx.lineTo(axisx.p2c(x1old), axisy.p2c(y1)); + // it goes to (x1, y1), but we fill that below + } + + // fill triangular section, this sometimes result + // in redundant points if (x1, y1) hasn't changed + // from previous line to, but we just ignore that + ctx.lineTo(axisx.p2c(x1), axisy.p2c(y1)); + ctx.lineTo(axisx.p2c(x2), axisy.p2c(y2)); + + // fill the other rectangle if it's there + if (x2 != x2old) { + ctx.lineTo(axisx.p2c(x2), axisy.p2c(y2)); + ctx.lineTo(axisx.p2c(x2old), axisy.p2c(y2)); + } + } + } + + ctx.save(); + ctx.translate(plotOffset.left, plotOffset.top); + ctx.lineJoin = "round"; + + var lw = series.lines.lineWidth, + sw = series.shadowSize; + // FIXME: consider another form of shadow when filling is turned on + if (lw > 0 && sw > 0) { + // draw shadow as a thick and thin line with transparency + ctx.lineWidth = sw; + ctx.strokeStyle = "rgba(0,0,0,0.1)"; + // position shadow at angle from the mid of line + var angle = Math.PI/18; + plotLine(series.datapoints, Math.sin(angle) * (lw/2 + sw/2), Math.cos(angle) * (lw/2 + sw/2), series.xaxis, series.yaxis); + ctx.lineWidth = sw/2; + plotLine(series.datapoints, Math.sin(angle) * (lw/2 + sw/4), Math.cos(angle) * (lw/2 + sw/4), series.xaxis, series.yaxis); + } + + ctx.lineWidth = lw; + ctx.strokeStyle = series.color; + var fillStyle = getFillStyle(series.lines, series.color, 0, plotHeight); + if (fillStyle) { + ctx.fillStyle = fillStyle; + plotLineArea(series.datapoints, series.xaxis, series.yaxis); + } + + if (lw > 0) + plotLine(series.datapoints, 0, 0, series.xaxis, series.yaxis); + ctx.restore(); + } + + function drawSeriesPoints(series) { + function plotPoints(datapoints, radius, fillStyle, offset, shadow, axisx, axisy, symbol) { + var points = datapoints.points, ps = datapoints.pointsize; + + for (var i = 0; i < points.length; i += ps) { + var x = points[i], y = points[i + 1]; + if (x == null || x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max) + continue; + + ctx.beginPath(); + x = axisx.p2c(x); + y = axisy.p2c(y) + offset; + if (symbol == "circle") + ctx.arc(x, y, radius, 0, shadow ? Math.PI : Math.PI * 2, false); + else + symbol(ctx, x, y, radius, shadow); + ctx.closePath(); + + if (fillStyle) { + ctx.fillStyle = fillStyle; + ctx.fill(); + } + ctx.stroke(); + } + } + + ctx.save(); + ctx.translate(plotOffset.left, plotOffset.top); + + var lw = series.points.lineWidth, + sw = series.shadowSize, + radius = series.points.radius, + symbol = series.points.symbol; + if (lw > 0 && sw > 0) { + // draw shadow in two steps + var w = sw / 2; + ctx.lineWidth = w; + ctx.strokeStyle = "rgba(0,0,0,0.1)"; + plotPoints(series.datapoints, radius, null, w + w/2, true, + series.xaxis, series.yaxis, symbol); + + ctx.strokeStyle = "rgba(0,0,0,0.2)"; + plotPoints(series.datapoints, radius, null, w/2, true, + series.xaxis, series.yaxis, symbol); + } + + ctx.lineWidth = lw; + ctx.strokeStyle = series.color; + plotPoints(series.datapoints, radius, + getFillStyle(series.points, series.color), 0, false, + series.xaxis, series.yaxis, symbol); + ctx.restore(); + } + + function drawBar(x, y, b, barLeft, barRight, offset, fillStyleCallback, axisx, axisy, c, horizontal, lineWidth) { + var left, right, bottom, top, + drawLeft, drawRight, drawTop, drawBottom, + tmp; + + // in horizontal mode, we start the bar from the left + // instead of from the bottom so it appears to be + // horizontal rather than vertical + if (horizontal) { + drawBottom = drawRight = drawTop = true; + drawLeft = false; + left = b; + right = x; + top = y + barLeft; + bottom = y + barRight; + + // account for negative bars + if (right < left) { + tmp = right; + right = left; + left = tmp; + drawLeft = true; + drawRight = false; + } + } + else { + drawLeft = drawRight = drawTop = true; + drawBottom = false; + left = x + barLeft; + right = x + barRight; + bottom = b; + top = y; + + // account for negative bars + if (top < bottom) { + tmp = top; + top = bottom; + bottom = tmp; + drawBottom = true; + drawTop = false; + } + } + + // clip + if (right < axisx.min || left > axisx.max || + top < axisy.min || bottom > axisy.max) + return; + + if (left < axisx.min) { + left = axisx.min; + drawLeft = false; + } + + if (right > axisx.max) { + right = axisx.max; + drawRight = false; + } + + if (bottom < axisy.min) { + bottom = axisy.min; + drawBottom = false; + } + + if (top > axisy.max) { + top = axisy.max; + drawTop = false; + } + + left = axisx.p2c(left); + bottom = axisy.p2c(bottom); + right = axisx.p2c(right); + top = axisy.p2c(top); + + // fill the bar + if (fillStyleCallback) { + c.beginPath(); + c.moveTo(left, bottom); + c.lineTo(left, top); + c.lineTo(right, top); + c.lineTo(right, bottom); + c.fillStyle = fillStyleCallback(bottom, top); + c.fill(); + } + + // draw outline + if (lineWidth > 0 && (drawLeft || drawRight || drawTop || drawBottom)) { + c.beginPath(); + + // FIXME: inline moveTo is buggy with excanvas + c.moveTo(left, bottom + offset); + if (drawLeft) + c.lineTo(left, top + offset); + else + c.moveTo(left, top + offset); + if (drawTop) + c.lineTo(right, top + offset); + else + c.moveTo(right, top + offset); + if (drawRight) + c.lineTo(right, bottom + offset); + else + c.moveTo(right, bottom + offset); + if (drawBottom) + c.lineTo(left, bottom + offset); + else + c.moveTo(left, bottom + offset); + c.stroke(); + } + } + + function drawSeriesBars(series) { + function plotBars(datapoints, barLeft, barRight, offset, fillStyleCallback, axisx, axisy) { + var points = datapoints.points, ps = datapoints.pointsize; + + for (var i = 0; i < points.length; i += ps) { + if (points[i] == null) + continue; + drawBar(points[i], points[i + 1], points[i + 2], barLeft, barRight, offset, fillStyleCallback, axisx, axisy, ctx, series.bars.horizontal, series.bars.lineWidth); + } + } + + ctx.save(); + ctx.translate(plotOffset.left, plotOffset.top); + + // FIXME: figure out a way to add shadows (for instance along the right edge) + ctx.lineWidth = series.bars.lineWidth; + ctx.strokeStyle = series.color; + var barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2; + var fillStyleCallback = series.bars.fill ? function (bottom, top) { return getFillStyle(series.bars, series.color, bottom, top); } : null; + plotBars(series.datapoints, barLeft, barLeft + series.bars.barWidth, 0, fillStyleCallback, series.xaxis, series.yaxis); + ctx.restore(); + } + + function getFillStyle(filloptions, seriesColor, bottom, top) { + var fill = filloptions.fill; + if (!fill) + return null; + + if (filloptions.fillColor) + return getColorOrGradient(filloptions.fillColor, bottom, top, seriesColor); + + var c = $.color.parse(seriesColor); + c.a = typeof fill == "number" ? fill : 0.4; + c.normalize(); + return c.toString(); + } + + function insertLegend() { + placeholder.find(".legend").remove(); + + if (!options.legend.show) + return; + + var fragments = [], rowStarted = false, + lf = options.legend.labelFormatter, s, label; + for (var i = 0; i < series.length; ++i) { + s = series[i]; + label = s.label; + if (!label) + continue; + + if (i % options.legend.noColumns == 0) { + if (rowStarted) + fragments.push(''); + fragments.push(''); + rowStarted = true; + } + + if (lf) + label = lf(label, s); + + fragments.push( + '
    ' + + '' + label + ''); + } + if (rowStarted) + fragments.push(''); + + if (fragments.length == 0) + return; + + var table = '' + fragments.join("") + '
    '; + if (options.legend.container != null) + $(options.legend.container).html(table); + else { + var pos = "", + p = options.legend.position, + m = options.legend.margin; + if (m[0] == null) + m = [m, m]; + if (p.charAt(0) == "n") + pos += 'top:' + (m[1] + plotOffset.top) + 'px;'; + else if (p.charAt(0) == "s") + pos += 'bottom:' + (m[1] + plotOffset.bottom) + 'px;'; + if (p.charAt(1) == "e") + pos += 'right:' + (m[0] + plotOffset.right) + 'px;'; + else if (p.charAt(1) == "w") + pos += 'left:' + (m[0] + plotOffset.left) + 'px;'; + var legend = $('
    ' + table.replace('style="', 'style="position:absolute;' + pos +';') + '
    ').appendTo(placeholder); + if (options.legend.backgroundOpacity != 0.0) { + // put in the transparent background + // separately to avoid blended labels and + // label boxes + var c = options.legend.backgroundColor; + if (c == null) { + c = options.grid.backgroundColor; + if (c && typeof c == "string") + c = $.color.parse(c); + else + c = $.color.extract(legend, 'background-color'); + c.a = 1; + c = c.toString(); + } + var div = legend.children(); + $('
    ').prependTo(legend).css('opacity', options.legend.backgroundOpacity); + } + } + } + + + // interactive features + + var highlights = [], + redrawTimeout = null; + + // returns the data item the mouse is over, or null if none is found + function findNearbyItem(mouseX, mouseY, seriesFilter) { + var maxDistance = options.grid.mouseActiveRadius, + smallestDistance = maxDistance * maxDistance + 1, + item = null, foundPoint = false, i, j; + + for (i = series.length - 1; i >= 0; --i) { + if (!seriesFilter(series[i])) + continue; + + var s = series[i], + axisx = s.xaxis, + axisy = s.yaxis, + points = s.datapoints.points, + ps = s.datapoints.pointsize, + mx = axisx.c2p(mouseX), // precompute some stuff to make the loop faster + my = axisy.c2p(mouseY), + maxx = maxDistance / axisx.scale, + maxy = maxDistance / axisy.scale; + + // with inverse transforms, we can't use the maxx/maxy + // optimization, sadly + if (axisx.options.inverseTransform) + maxx = Number.MAX_VALUE; + if (axisy.options.inverseTransform) + maxy = Number.MAX_VALUE; + + if (s.lines.show || s.points.show) { + for (j = 0; j < points.length; j += ps) { + var x = points[j], y = points[j + 1]; + if (x == null) + continue; + + // For points and lines, the cursor must be within a + // certain distance to the data point + if (x - mx > maxx || x - mx < -maxx || + y - my > maxy || y - my < -maxy) + continue; + + // We have to calculate distances in pixels, not in + // data units, because the scales of the axes may be different + var dx = Math.abs(axisx.p2c(x) - mouseX), + dy = Math.abs(axisy.p2c(y) - mouseY), + dist = dx * dx + dy * dy; // we save the sqrt + + // use <= to ensure last point takes precedence + // (last generally means on top of) + if (dist < smallestDistance) { + smallestDistance = dist; + item = [i, j / ps]; + } + } + } + + if (s.bars.show && !item) { // no other point can be nearby + var barLeft = s.bars.align == "left" ? 0 : -s.bars.barWidth/2, + barRight = barLeft + s.bars.barWidth; + + for (j = 0; j < points.length; j += ps) { + var x = points[j], y = points[j + 1], b = points[j + 2]; + if (x == null) + continue; + + // for a bar graph, the cursor must be inside the bar + if (series[i].bars.horizontal ? + (mx <= Math.max(b, x) && mx >= Math.min(b, x) && + my >= y + barLeft && my <= y + barRight) : + (mx >= x + barLeft && mx <= x + barRight && + my >= Math.min(b, y) && my <= Math.max(b, y))) + item = [i, j / ps]; + } + } + } + + if (item) { + i = item[0]; + j = item[1]; + ps = series[i].datapoints.pointsize; + + return { datapoint: series[i].datapoints.points.slice(j * ps, (j + 1) * ps), + dataIndex: j, + series: series[i], + seriesIndex: i }; + } + + return null; + } + + function onMouseMove(e) { + if (options.grid.hoverable) + triggerClickHoverEvent("plothover", e, + function (s) { return s["hoverable"] != false; }); + } + + function onMouseLeave(e) { + if (options.grid.hoverable) + triggerClickHoverEvent("plothover", e, + function (s) { return false; }); + } + + function onClick(e) { + triggerClickHoverEvent("plotclick", e, + function (s) { return s["clickable"] != false; }); + } + + // trigger click or hover event (they send the same parameters + // so we share their code) + function triggerClickHoverEvent(eventname, event, seriesFilter) { + var offset = eventHolder.offset(), + canvasX = event.pageX - offset.left - plotOffset.left, + canvasY = event.pageY - offset.top - plotOffset.top, + pos = canvasToAxisCoords({ left: canvasX, top: canvasY }); + + pos.pageX = event.pageX; + pos.pageY = event.pageY; + + var item = findNearbyItem(canvasX, canvasY, seriesFilter); + + if (item) { + // fill in mouse pos for any listeners out there + item.pageX = parseInt(item.series.xaxis.p2c(item.datapoint[0]) + offset.left + plotOffset.left); + item.pageY = parseInt(item.series.yaxis.p2c(item.datapoint[1]) + offset.top + plotOffset.top); + } + + if (options.grid.autoHighlight) { + // clear auto-highlights + for (var i = 0; i < highlights.length; ++i) { + var h = highlights[i]; + if (h.auto == eventname && + !(item && h.series == item.series && + h.point[0] == item.datapoint[0] && + h.point[1] == item.datapoint[1])) + unhighlight(h.series, h.point); + } + + if (item) + highlight(item.series, item.datapoint, eventname); + } + + placeholder.trigger(eventname, [ pos, item ]); + } + + function triggerRedrawOverlay() { + if (!redrawTimeout) + redrawTimeout = setTimeout(drawOverlay, 30); + } + + function drawOverlay() { + redrawTimeout = null; + + // draw highlights + octx.save(); + octx.clearRect(0, 0, canvasWidth, canvasHeight); + octx.translate(plotOffset.left, plotOffset.top); + + var i, hi; + for (i = 0; i < highlights.length; ++i) { + hi = highlights[i]; + + if (hi.series.bars.show) + drawBarHighlight(hi.series, hi.point); + else + drawPointHighlight(hi.series, hi.point); + } + octx.restore(); + + executeHooks(hooks.drawOverlay, [octx]); + } + + function highlight(s, point, auto) { + if (typeof s == "number") + s = series[s]; + + if (typeof point == "number") { + var ps = s.datapoints.pointsize; + point = s.datapoints.points.slice(ps * point, ps * (point + 1)); + } + + var i = indexOfHighlight(s, point); + if (i == -1) { + highlights.push({ series: s, point: point, auto: auto }); + + triggerRedrawOverlay(); + } + else if (!auto) + highlights[i].auto = false; + } + + function unhighlight(s, point) { + if (s == null && point == null) { + highlights = []; + triggerRedrawOverlay(); + } + + if (typeof s == "number") + s = series[s]; + + if (typeof point == "number") + point = s.data[point]; + + var i = indexOfHighlight(s, point); + if (i != -1) { + highlights.splice(i, 1); + + triggerRedrawOverlay(); + } + } + + function indexOfHighlight(s, p) { + for (var i = 0; i < highlights.length; ++i) { + var h = highlights[i]; + if (h.series == s && h.point[0] == p[0] + && h.point[1] == p[1]) + return i; + } + return -1; + } + + function drawPointHighlight(series, point) { + var x = point[0], y = point[1], + axisx = series.xaxis, axisy = series.yaxis; + + if (x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max) + return; + + var pointRadius = series.points.radius + series.points.lineWidth / 2; + octx.lineWidth = pointRadius; + octx.strokeStyle = $.color.parse(series.color).scale('a', 0.5).toString(); + var radius = 1.5 * pointRadius, + x = axisx.p2c(x), + y = axisy.p2c(y); + + octx.beginPath(); + if (series.points.symbol == "circle") + octx.arc(x, y, radius, 0, 2 * Math.PI, false); + else + series.points.symbol(octx, x, y, radius, false); + octx.closePath(); + octx.stroke(); + } + + function drawBarHighlight(series, point) { + octx.lineWidth = series.bars.lineWidth; + octx.strokeStyle = $.color.parse(series.color).scale('a', 0.5).toString(); + var fillStyle = $.color.parse(series.color).scale('a', 0.5).toString(); + var barLeft = series.bars.align == "left" ? 0 : -series.bars.barWidth/2; + drawBar(point[0], point[1], point[2] || 0, barLeft, barLeft + series.bars.barWidth, + 0, function () { return fillStyle; }, series.xaxis, series.yaxis, octx, series.bars.horizontal, series.bars.lineWidth); + } + + function getColorOrGradient(spec, bottom, top, defaultColor) { + if (typeof spec == "string") + return spec; + else { + // assume this is a gradient spec; IE currently only + // supports a simple vertical gradient properly, so that's + // what we support too + var gradient = ctx.createLinearGradient(0, top, 0, bottom); + + for (var i = 0, l = spec.colors.length; i < l; ++i) { + var c = spec.colors[i]; + if (typeof c != "string") { + var co = $.color.parse(defaultColor); + if (c.brightness != null) + co = co.scale('rgb', c.brightness) + if (c.opacity != null) + co.a *= c.opacity; + c = co.toString(); + } + gradient.addColorStop(i / (l - 1), c); + } + + return gradient; + } + } + } + + $.plot = function(placeholder, data, options) { + //var t0 = new Date(); + var plot = new Plot($(placeholder), data, options, $.plot.plugins); + //(window.console ? console.log : alert)("time used (msecs): " + ((new Date()).getTime() - t0.getTime())); + return plot; + }; + + $.plot.version = "0.7"; + + $.plot.plugins = []; + + // returns a string with the date d formatted according to fmt + $.plot.formatDate = function(d, fmt, monthNames) { + var leftPad = function(n) { + n = "" + n; + return n.length == 1 ? "0" + n : n; + }; + + var r = []; + var escape = false, padNext = false; + var hours = d.getUTCHours(); + var isAM = hours < 12; + if (monthNames == null) + monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + + if (fmt.search(/%p|%P/) != -1) { + if (hours > 12) { + hours = hours - 12; + } else if (hours == 0) { + hours = 12; + } + } + for (var i = 0; i < fmt.length; ++i) { + var c = fmt.charAt(i); + + if (escape) { + switch (c) { + case 'h': c = "" + hours; break; + case 'H': c = leftPad(hours); break; + case 'M': c = leftPad(d.getUTCMinutes()); break; + case 'S': c = leftPad(d.getUTCSeconds()); break; + case 'd': c = "" + d.getUTCDate(); break; + case 'm': c = "" + (d.getUTCMonth() + 1); break; + case 'y': c = "" + d.getUTCFullYear(); break; + case 'b': c = "" + monthNames[d.getUTCMonth()]; break; + case 'p': c = (isAM) ? ("" + "am") : ("" + "pm"); break; + case 'P': c = (isAM) ? ("" + "AM") : ("" + "PM"); break; + case '0': c = ""; padNext = true; break; + } + if (c && padNext) { + c = leftPad(c); + padNext = false; + } + r.push(c); + if (!padNext) + escape = false; + } + else { + if (c == "%") + escape = true; + else + r.push(c); + } + } + return r.join(""); + }; + + // round to nearby lower multiple of base + function floorInBase(n, base) { + return base * Math.floor(n / base); + } + +})(jQuery); diff --git a/includes/jquery/flot/jquery.min.js b/includes/jquery/flot/jquery.min.js new file mode 100644 index 0000000000..6422523161 --- /dev/null +++ b/includes/jquery/flot/jquery.min.js @@ -0,0 +1,23 @@ +/* + * jQuery JavaScript Library v1.5.1 + * http://jquery.com/ + * + * Copyright 2011, John Resig + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * Includes Sizzle.js + * http://sizzlejs.com/ + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * + * Date: Wed Feb 23 13:55:29 2011 -0500 + */ +(function(aY,H){var al=aY.document;var a=(function(){var bn=function(bI,bJ){return new bn.fn.init(bI,bJ,bl)},bD=aY.jQuery,bp=aY.$,bl,bH=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,bv=/\S/,br=/^\s+/,bm=/\s+$/,bq=/\d/,bj=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,bw=/^[\],:{}\s]*$/,bF=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,by=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,bs=/(?:^|:|,)(?:\s*\[)+/g,bh=/(webkit)[ \/]([\w.]+)/,bA=/(opera)(?:.*version)?[ \/]([\w.]+)/,bz=/(msie) ([\w.]+)/,bB=/(mozilla)(?:.*? rv:([\w.]+))?/,bG=navigator.userAgent,bE,bC=false,bk,e="then done fail isResolved isRejected promise".split(" "),bd,bu=Object.prototype.toString,bo=Object.prototype.hasOwnProperty,bi=Array.prototype.push,bt=Array.prototype.slice,bx=String.prototype.trim,be=Array.prototype.indexOf,bg={};bn.fn=bn.prototype={constructor:bn,init:function(bI,bM,bL){var bK,bN,bJ,bO;if(!bI){return this}if(bI.nodeType){this.context=this[0]=bI;this.length=1;return this}if(bI==="body"&&!bM&&al.body){this.context=al;this[0]=al.body;this.selector="body";this.length=1;return this}if(typeof bI==="string"){bK=bH.exec(bI);if(bK&&(bK[1]||!bM)){if(bK[1]){bM=bM instanceof bn?bM[0]:bM;bO=(bM?bM.ownerDocument||bM:al);bJ=bj.exec(bI);if(bJ){if(bn.isPlainObject(bM)){bI=[al.createElement(bJ[1])];bn.fn.attr.call(bI,bM,true)}else{bI=[bO.createElement(bJ[1])]}}else{bJ=bn.buildFragment([bK[1]],[bO]);bI=(bJ.cacheable?bn.clone(bJ.fragment):bJ.fragment).childNodes}return bn.merge(this,bI)}else{bN=al.getElementById(bK[2]);if(bN&&bN.parentNode){if(bN.id!==bK[2]){return bL.find(bI)}this.length=1;this[0]=bN}this.context=al;this.selector=bI;return this}}else{if(!bM||bM.jquery){return(bM||bL).find(bI)}else{return this.constructor(bM).find(bI)}}}else{if(bn.isFunction(bI)){return bL.ready(bI)}}if(bI.selector!==H){this.selector=bI.selector;this.context=bI.context}return bn.makeArray(bI,this)},selector:"",jquery:"1.5.1",length:0,size:function(){return this.length},toArray:function(){return bt.call(this,0)},get:function(bI){return bI==null?this.toArray():(bI<0?this[this.length+bI]:this[bI])},pushStack:function(bJ,bL,bI){var bK=this.constructor();if(bn.isArray(bJ)){bi.apply(bK,bJ)}else{bn.merge(bK,bJ)}bK.prevObject=this;bK.context=this.context;if(bL==="find"){bK.selector=this.selector+(this.selector?" ":"")+bI}else{if(bL){bK.selector=this.selector+"."+bL+"("+bI+")"}}return bK},each:function(bJ,bI){return bn.each(this,bJ,bI)},ready:function(bI){bn.bindReady();bk.done(bI);return this},eq:function(bI){return bI===-1?this.slice(bI):this.slice(bI,+bI+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(bt.apply(this,arguments),"slice",bt.call(arguments).join(","))},map:function(bI){return this.pushStack(bn.map(this,function(bK,bJ){return bI.call(bK,bJ,bK)}))},end:function(){return this.prevObject||this.constructor(null)},push:bi,sort:[].sort,splice:[].splice};bn.fn.init.prototype=bn.fn;bn.extend=bn.fn.extend=function(){var bR,bK,bI,bJ,bO,bP,bN=arguments[0]||{},bM=1,bL=arguments.length,bQ=false;if(typeof bN==="boolean"){bQ=bN;bN=arguments[1]||{};bM=2}if(typeof bN!=="object"&&!bn.isFunction(bN)){bN={}}if(bL===bM){bN=this;--bM}for(;bM0){return}bk.resolveWith(al,[bn]);if(bn.fn.trigger){bn(al).trigger("ready").unbind("ready")}}},bindReady:function(){if(bC){return}bC=true;if(al.readyState==="complete"){return setTimeout(bn.ready,1)}if(al.addEventListener){al.addEventListener("DOMContentLoaded",bd,false);aY.addEventListener("load",bn.ready,false)}else{if(al.attachEvent){al.attachEvent("onreadystatechange",bd);aY.attachEvent("onload",bn.ready);var bI=false;try{bI=aY.frameElement==null}catch(bJ){}if(al.documentElement.doScroll&&bI){bf()}}}},isFunction:function(bI){return bn.type(bI)==="function"},isArray:Array.isArray||function(bI){return bn.type(bI)==="array"},isWindow:function(bI){return bI&&typeof bI==="object"&&"setInterval" in bI},isNaN:function(bI){return bI==null||!bq.test(bI)||isNaN(bI)},type:function(bI){return bI==null?String(bI):bg[bu.call(bI)]||"object"},isPlainObject:function(bJ){if(!bJ||bn.type(bJ)!=="object"||bJ.nodeType||bn.isWindow(bJ)){return false}if(bJ.constructor&&!bo.call(bJ,"constructor")&&!bo.call(bJ.constructor.prototype,"isPrototypeOf")){return false}var bI;for(bI in bJ){}return bI===H||bo.call(bJ,bI)},isEmptyObject:function(bJ){for(var bI in bJ){return false}return true},error:function(bI){throw bI},parseJSON:function(bI){if(typeof bI!=="string"||!bI){return null}bI=bn.trim(bI);if(bw.test(bI.replace(bF,"@").replace(by,"]").replace(bs,""))){return aY.JSON&&aY.JSON.parse?aY.JSON.parse(bI):(new Function("return "+bI))()}else{bn.error("Invalid JSON: "+bI)}},parseXML:function(bK,bI,bJ){if(aY.DOMParser){bJ=new DOMParser();bI=bJ.parseFromString(bK,"text/xml")}else{bI=new ActiveXObject("Microsoft.XMLDOM");bI.async="false";bI.loadXML(bK)}bJ=bI.documentElement;if(!bJ||!bJ.nodeName||bJ.nodeName==="parsererror"){bn.error("Invalid XML: "+bK)}return bI},noop:function(){},globalEval:function(bK){if(bK&&bv.test(bK)){var bJ=al.head||al.getElementsByTagName("head")[0]||al.documentElement,bI=al.createElement("script");if(bn.support.scriptEval()){bI.appendChild(al.createTextNode(bK))}else{bI.text=bK}bJ.insertBefore(bI,bJ.firstChild);bJ.removeChild(bI)}},nodeName:function(bJ,bI){return bJ.nodeName&&bJ.nodeName.toUpperCase()===bI.toUpperCase()},each:function(bL,bP,bK){var bJ,bM=0,bN=bL.length,bI=bN===H||bn.isFunction(bL);if(bK){if(bI){for(bJ in bL){if(bP.apply(bL[bJ],bK)===false){break}}}else{for(;bM1){var bN=bt.call(arguments,0),bL=bO,bK=function(bP){return function(bQ){bN[bP]=arguments.length>1?bt.call(arguments,0):bQ;if(!(--bL)){bI.resolveWith(bM,bN)}}};while((bO--)){bJ=bN[bO];if(bJ&&bn.isFunction(bJ.promise)){bJ.promise().then(bK(bO),bI.reject)}else{--bL}}if(!bL){bI.resolveWith(bM,bN)}}else{if(bI!==bJ){bI.resolve(bJ)}}return bM},uaMatch:function(bJ){bJ=bJ.toLowerCase();var bI=bh.exec(bJ)||bA.exec(bJ)||bz.exec(bJ)||bJ.indexOf("compatible")<0&&bB.exec(bJ)||[];return{browser:bI[1]||"",version:bI[2]||"0"}},sub:function(){function bJ(bL,bM){return new bJ.fn.init(bL,bM)}bn.extend(true,bJ,this);bJ.superclass=this;bJ.fn=bJ.prototype=this();bJ.fn.constructor=bJ;bJ.subclass=this.subclass;bJ.fn.init=function bK(bL,bM){if(bM&&bM instanceof bn&&!(bM instanceof bJ)){bM=bJ(bM)}return bn.fn.init.call(this,bL,bM,bI)};bJ.fn.init.prototype=bJ.fn;var bI=bJ(al);return bJ},browser:{}});bk=bn._Deferred();bn.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(bJ,bI){bg["[object "+bI+"]"]=bI.toLowerCase()});bE=bn.uaMatch(bG);if(bE.browser){bn.browser[bE.browser]=true;bn.browser.version=bE.version}if(bn.browser.webkit){bn.browser.safari=true}if(be){bn.inArray=function(bI,bJ){return be.call(bJ,bI)}}if(bv.test("\xA0")){br=/^[\s\xA0]+/;bm=/[\s\xA0]+$/}bl=bn(al);if(al.addEventListener){bd=function(){al.removeEventListener("DOMContentLoaded",bd,false);bn.ready()}}else{if(al.attachEvent){bd=function(){if(al.readyState==="complete"){al.detachEvent("onreadystatechange",bd);bn.ready()}}}}function bf(){if(bn.isReady){return}try{al.documentElement.doScroll("left")}catch(bI){setTimeout(bf,1);return}bn.ready()}return bn})();(function(){a.support={};var bd=al.createElement("div");bd.style.display="none";bd.innerHTML="
    a";var bm=bd.getElementsByTagName("*"),bk=bd.getElementsByTagName("a")[0],bl=al.createElement("select"),be=bl.appendChild(al.createElement("option")),bj=bd.getElementsByTagName("input")[0];if(!bm||!bm.length||!bk){return}a.support={leadingWhitespace:bd.firstChild.nodeType===3,tbody:!bd.getElementsByTagName("tbody").length,htmlSerialize:!!bd.getElementsByTagName("link").length,style:/red/.test(bk.getAttribute("style")),hrefNormalized:bk.getAttribute("href")==="/a",opacity:/^0.55$/.test(bk.style.opacity),cssFloat:!!bk.style.cssFloat,checkOn:bj.value==="on",optSelected:be.selected,deleteExpando:true,optDisabled:false,checkClone:false,noCloneEvent:true,noCloneChecked:true,boxModel:null,inlineBlockNeedsLayout:false,shrinkWrapBlocks:false,reliableHiddenOffsets:true};bj.checked=true;a.support.noCloneChecked=bj.cloneNode(true).checked;bl.disabled=true;a.support.optDisabled=!be.disabled;var bf=null;a.support.scriptEval=function(){if(bf===null){var bo=al.documentElement,bp=al.createElement("script"),br="script"+a.now();try{bp.appendChild(al.createTextNode("window."+br+"=1;"))}catch(bq){}bo.insertBefore(bp,bo.firstChild);if(aY[br]){bf=true;delete aY[br]}else{bf=false}bo.removeChild(bp);bo=bp=br=null}return bf};try{delete bd.test}catch(bh){a.support.deleteExpando=false}if(!bd.addEventListener&&bd.attachEvent&&bd.fireEvent){bd.attachEvent("onclick",function bn(){a.support.noCloneEvent=false;bd.detachEvent("onclick",bn)});bd.cloneNode(true).fireEvent("onclick")}bd=al.createElement("div");bd.innerHTML="";var bg=al.createDocumentFragment();bg.appendChild(bd.firstChild);a.support.checkClone=bg.cloneNode(true).cloneNode(true).lastChild.checked;a(function(){var bp=al.createElement("div"),e=al.getElementsByTagName("body")[0];if(!e){return}bp.style.width=bp.style.paddingLeft="1px";e.appendChild(bp);a.boxModel=a.support.boxModel=bp.offsetWidth===2;if("zoom" in bp.style){bp.style.display="inline";bp.style.zoom=1;a.support.inlineBlockNeedsLayout=bp.offsetWidth===2;bp.style.display="";bp.innerHTML="
    ";a.support.shrinkWrapBlocks=bp.offsetWidth!==2}bp.innerHTML="
    t
    ";var bo=bp.getElementsByTagName("td");a.support.reliableHiddenOffsets=bo[0].offsetHeight===0;bo[0].style.display="";bo[1].style.display="none";a.support.reliableHiddenOffsets=a.support.reliableHiddenOffsets&&bo[0].offsetHeight===0;bp.innerHTML="";e.removeChild(bp).style.display="none";bp=bo=null});var bi=function(e){var bp=al.createElement("div");e="on"+e;if(!bp.attachEvent){return true}var bo=(e in bp);if(!bo){bp.setAttribute(e,"return;");bo=typeof bp[e]==="function"}bp=null;return bo};a.support.submitBubbles=bi("submit");a.support.changeBubbles=bi("change");bd=bm=bk=null})();var aE=/^(?:\{.*\}|\[.*\])$/;a.extend({cache:{},uuid:0,expando:"jQuery"+(a.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:true,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:true},hasData:function(e){e=e.nodeType?a.cache[e[a.expando]]:e[a.expando];return !!e&&!P(e)},data:function(bf,bd,bh,bg){if(!a.acceptData(bf)){return}var bk=a.expando,bj=typeof bd==="string",bi,bl=bf.nodeType,e=bl?a.cache:bf,be=bl?bf[a.expando]:bf[a.expando]&&a.expando;if((!be||(bg&&be&&!e[be][bk]))&&bj&&bh===H){return}if(!be){if(bl){bf[a.expando]=be=++a.uuid}else{be=a.expando}}if(!e[be]){e[be]={};if(!bl){e[be].toJSON=a.noop}}if(typeof bd==="object"||typeof bd==="function"){if(bg){e[be][bk]=a.extend(e[be][bk],bd)}else{e[be]=a.extend(e[be],bd)}}bi=e[be];if(bg){if(!bi[bk]){bi[bk]={}}bi=bi[bk]}if(bh!==H){bi[bd]=bh}if(bd==="events"&&!bi[bd]){return bi[bk]&&bi[bk].events}return bj?bi[bd]:bi},removeData:function(bg,be,bh){if(!a.acceptData(bg)){return}var bj=a.expando,bk=bg.nodeType,bd=bk?a.cache:bg,bf=bk?bg[a.expando]:a.expando;if(!bd[bf]){return}if(be){var bi=bh?bd[bf][bj]:bd[bf];if(bi){delete bi[be];if(!P(bi)){return}}}if(bh){delete bd[bf][bj];if(!P(bd[bf])){return}}var e=bd[bf][bj];if(a.support.deleteExpando||bd!=aY){delete bd[bf]}else{bd[bf]=null}if(e){bd[bf]={};if(!bk){bd[bf].toJSON=a.noop}bd[bf][bj]=e}else{if(bk){if(a.support.deleteExpando){delete bg[a.expando]}else{if(bg.removeAttribute){bg.removeAttribute(a.expando)}else{bg[a.expando]=null}}}}},_data:function(bd,e,be){return a.data(bd,e,be,true)},acceptData:function(bd){if(bd.nodeName){var e=a.noData[bd.nodeName.toLowerCase()];if(e){return !(e===true||bd.getAttribute("classid")!==e)}}return true}});a.fn.extend({data:function(bg,bi){var bh=null;if(typeof bg==="undefined"){if(this.length){bh=a.data(this[0]);if(this[0].nodeType===1){var e=this[0].attributes,be;for(var bf=0,bd=e.length;bf-1){return true}}return false},val:function(bk){if(!arguments.length){var be=this[0];if(be){if(a.nodeName(be,"option")){var bd=be.attributes.value;return !bd||bd.specified?be.value:be.text}if(a.nodeName(be,"select")){var bi=be.selectedIndex,bl=[],bm=be.options,bh=be.type==="select-one";if(bi<0){return null}for(var bf=bh?bi:0,bj=bh?bi+1:bm.length;bf=0}else{if(a.nodeName(this,"select")){var bn=a.makeArray(bq);a("option",this).each(function(){this.selected=a.inArray(a(this).val(),bn)>=0});if(!bn.length){this.selectedIndex=-1}}else{this.value=bq}}})}});a.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(bd,e,bi,bl){if(!bd||bd.nodeType===3||bd.nodeType===8||bd.nodeType===2){return H}if(bl&&e in a.attrFn){return a(bd)[e](bi)}var be=bd.nodeType!==1||!a.isXMLDoc(bd),bh=bi!==H;e=be&&a.props[e]||e;if(bd.nodeType===1){var bg=a2.test(e);if(e==="selected"&&!a.support.optSelected){var bj=bd.parentNode;if(bj){bj.selectedIndex;if(bj.parentNode){bj.parentNode.selectedIndex}}}if((e in bd||bd[e]!==H)&&be&&!bg){if(bh){if(e==="type"&&f.test(bd.nodeName)&&bd.parentNode){a.error("type property can't be changed")}if(bi===null){if(bd.nodeType===1){bd.removeAttribute(e)}}else{bd[e]=bi}}if(a.nodeName(bd,"form")&&bd.getAttributeNode(e)){return bd.getAttributeNode(e).nodeValue}if(e==="tabIndex"){var bk=bd.getAttributeNode("tabIndex");return bk&&bk.specified?bk.value:C.test(bd.nodeName)||k.test(bd.nodeName)&&bd.href?0:H}return bd[e]}if(!a.support.style&&be&&e==="style"){if(bh){bd.style.cssText=""+bi}return bd.style.cssText}if(bh){bd.setAttribute(e,""+bi)}if(!bd.attributes[e]&&(bd.hasAttribute&&!bd.hasAttribute(e))){return H}var bf=!a.support.hrefNormalized&&be&&bg?bd.getAttribute(e,2):bd.getAttribute(e);return bf===null?H:bf}if(bh){bd[e]=bi}return bd[e]}});var aP=/\.(.*)$/,a0=/^(?:textarea|input|select)$/i,K=/\./g,aa=/ /g,aw=/[^\w\s.|`]/g,E=function(e){return e.replace(aw,"\\$&")};a.event={add:function(bg,bk,br,bi){if(bg.nodeType===3||bg.nodeType===8){return}try{if(a.isWindow(bg)&&(bg!==aY&&!bg.frameElement)){bg=aY}}catch(bl){}if(br===false){br=a5}else{if(!br){return}}var be,bp;if(br.handler){be=br;br=be.handler}if(!br.guid){br.guid=a.guid++}var bm=a._data(bg);if(!bm){return}var bq=bm.events,bj=bm.handle;if(!bq){bm.events=bq={}}if(!bj){bm.handle=bj=function(){return typeof a!=="undefined"&&!a.event.triggered?a.event.handle.apply(bj.elem,arguments):H}}bj.elem=bg;bk=bk.split(" ");var bo,bh=0,bd;while((bo=bk[bh++])){bp=be?a.extend({},be):{handler:br,data:bi};if(bo.indexOf(".")>-1){bd=bo.split(".");bo=bd.shift();bp.namespace=bd.slice(0).sort().join(".")}else{bd=[];bp.namespace=""}bp.type=bo;if(!bp.guid){bp.guid=br.guid}var bf=bq[bo],bn=a.event.special[bo]||{};if(!bf){bf=bq[bo]=[];if(!bn.setup||bn.setup.call(bg,bi,bd,bj)===false){if(bg.addEventListener){bg.addEventListener(bo,bj,false)}else{if(bg.attachEvent){bg.attachEvent("on"+bo,bj)}}}}if(bn.add){bn.add.call(bg,bp);if(!bp.handler.guid){bp.handler.guid=br.guid}}bf.push(bp);a.event.global[bo]=true}bg=null},global:{},remove:function(br,bm,be,bi){if(br.nodeType===3||br.nodeType===8){return}if(be===false){be=a5}var bu,bh,bj,bo,bp=0,bf,bk,bn,bg,bl,e,bt,bq=a.hasData(br)&&a._data(br),bd=bq&&bq.events;if(!bq||!bd){return}if(bm&&bm.type){be=bm.handler;bm=bm.type}if(!bm||typeof bm==="string"&&bm.charAt(0)==="."){bm=bm||"";for(bh in bd){a.event.remove(br,bh+bm)}return}bm=bm.split(" ");while((bh=bm[bp++])){bt=bh;e=null;bf=bh.indexOf(".")<0;bk=[];if(!bf){bk=bh.split(".");bh=bk.shift();bn=new RegExp("(^|\\.)"+a.map(bk.slice(0).sort(),E).join("\\.(?:.*\\.)?")+"(\\.|$)")}bl=bd[bh];if(!bl){continue}if(!be){for(bo=0;bo=0){bd.type=bm=bm.slice(0,-1);bd.exclusive=true}if(!bf){bd.stopPropagation();if(a.event.global[bm]){a.each(a.cache,function(){var br=a.expando,bq=this[br];if(bq&&bq.events&&bq.events[bm]){a.event.trigger(bd,bi,bq.handle.elem)}})}}if(!bf||bf.nodeType===3||bf.nodeType===8){return H}bd.result=H;bd.target=bf;bi=a.makeArray(bi);bi.unshift(bd)}bd.currentTarget=bf;var bj=a._data(bf,"handle");if(bj){bj.apply(bf,bi)}var bo=bf.parentNode||bf.ownerDocument;try{if(!(bf&&bf.nodeName&&a.noData[bf.nodeName.toLowerCase()])){if(bf["on"+bm]&&bf["on"+bm].apply(bf,bi)===false){bd.result=false;bd.preventDefault()}}}catch(bn){}if(!bd.isPropagationStopped()&&bo){a.event.trigger(bd,bi,bo,true)}else{if(!bd.isDefaultPrevented()){var be,bk=bd.target,e=bm.replace(aP,""),bp=a.nodeName(bk,"a")&&e==="click",bl=a.event.special[e]||{};if((!bl._default||bl._default.call(bf,bd)===false)&&!bp&&!(bk&&bk.nodeName&&a.noData[bk.nodeName.toLowerCase()])){try{if(bk[e]){be=bk["on"+e];if(be){bk["on"+e]=null}a.event.triggered=true;bk[e]()}}catch(bg){}if(be){bk["on"+e]=be}a.event.triggered=false}}}},handle:function(e){var bl,be,bd,bn,bm,bh=[],bj=a.makeArray(arguments);e=bj[0]=a.event.fix(e||aY.event);e.currentTarget=this;bl=e.type.indexOf(".")<0&&!e.exclusive;if(!bl){bd=e.type.split(".");e.type=bd.shift();bh=bd.slice(0).sort();bn=new RegExp("(^|\\.)"+bh.join("\\.(?:.*\\.)?")+"(\\.|$)")}e.namespace=e.namespace||bh.join(".");bm=a._data(this,"events");be=(bm||{})[e.type];if(bm&&be){be=be.slice(0);for(var bg=0,bf=be.length;bg-1?a.map(bd.options,function(bf){return bf.selected}).join("-"):""}else{if(bd.nodeName.toLowerCase()==="select"){be=bd.selectedIndex}}}return be},X=function X(bf){var bd=bf.target,be,bg;if(!a0.test(bd.nodeName)||bd.readOnly){return}be=a._data(bd,"_change_data");bg=j(bd);if(bf.type!=="focusout"||bd.type!=="radio"){a._data(bd,"_change_data",bg)}if(be===H||bg===be){return}if(be!=null||bg){bf.type="change";bf.liveFired=H;a.event.trigger(bf,arguments[1],bd)}};a.event.special.change={filters:{focusout:X,beforedeactivate:X,click:function(bf){var be=bf.target,bd=be.type;if(bd==="radio"||bd==="checkbox"||be.nodeName.toLowerCase()==="select"){X.call(this,bf)}},keydown:function(bf){var be=bf.target,bd=be.type;if((bf.keyCode===13&&be.nodeName.toLowerCase()!=="textarea")||(bf.keyCode===32&&(bd==="checkbox"||bd==="radio"))||bd==="select-multiple"){X.call(this,bf)}},beforeactivate:function(be){var bd=be.target;a._data(bd,"_change_data",j(bd))}},setup:function(be,bd){if(this.type==="file"){return false}for(var e in a6){a.event.add(this,e+".specialChange",a6[e])}return a0.test(this.nodeName)},teardown:function(e){a.event.remove(this,".specialChange");return a0.test(this.nodeName)}};a6=a.event.special.change.filters;a6.focus=a6.beforeactivate}function aN(bd,bf,e){var be=a.extend({},e[0]);be.type=bd;be.originalEvent={};be.liveFired=H;a.event.handle.call(bf,be);if(be.isDefaultPrevented()){e[0].preventDefault()}}if(al.addEventListener){a.each({focus:"focusin",blur:"focusout"},function(be,e){a.event.special[e]={setup:function(){this.addEventListener(be,bd,true)},teardown:function(){this.removeEventListener(be,bd,true)}};function bd(bf){bf=a.event.fix(bf);bf.type=e;return a.event.handle.call(this,bf)}})}a.each(["bind","one"],function(bd,e){a.fn[e]=function(bj,bk,bi){if(typeof bj==="object"){for(var bg in bj){this[e](bg,bk,bj[bg],bi)}return this}if(a.isFunction(bk)||bk===false){bi=bk;bk=H}var bh=e==="one"?a.proxy(bi,function(bl){a(this).unbind(bl,bh);return bi.apply(this,arguments)}):bi;if(bj==="unload"&&e!=="one"){this.one(bj,bk,bi)}else{for(var bf=0,be=this.length;bfbf){break}bn.currentTarget=bh.elem;bn.data=bh.handleObj.data;bn.handleObj=bh.handleObj;br=bh.handleObj.origHandler.apply(bh.elem,arguments);if(br===false||bn.isPropagationStopped()){bf=bh.level;if(br===false){bk=false}if(bn.isImmediatePropagationStopped()){break}}}return bk}function n(bd,e){return(bd&&bd!=="*"?bd+".":"")+e.replace(K,"`").replace(aa,"&")}a.each(("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error").split(" "),function(bd,e){a.fn[e]=function(bf,be){if(be==null){be=bf;bf=null}return arguments.length>0?this.bind(e,bf,be):this.trigger(e)};if(a.attrFn){a.attrFn[e]=true}}); +/* + * Sizzle CSS Selector Engine + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * More information: http://sizzlejs.com/ + */ +(function(){var bn=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,bo=0,br=Object.prototype.toString,bi=false,bh=true,bp=/\\/g,bv=/\W/;[0,0].sort(function(){bh=false;return 0});var bf=function(bA,e,bD,bE){bD=bD||[];e=e||al;var bG=e;if(e.nodeType!==1&&e.nodeType!==9){return[]}if(!bA||typeof bA!=="string"){return bD}var bx,bI,bL,bw,bH,bK,bJ,bC,bz=true,by=bf.isXML(e),bB=[],bF=bA;do{bn.exec("");bx=bn.exec(bF);if(bx){bF=bx[3];bB.push(bx[1]);if(bx[2]){bw=bx[3];break}}}while(bx);if(bB.length>1&&bj.exec(bA)){if(bB.length===2&&bk.relative[bB[0]]){bI=bs(bB[0]+bB[1],e)}else{bI=bk.relative[bB[0]]?[e]:bf(bB.shift(),e);while(bB.length){bA=bB.shift();if(bk.relative[bA]){bA+=bB.shift()}bI=bs(bA,bI)}}}else{if(!bE&&bB.length>1&&e.nodeType===9&&!by&&bk.match.ID.test(bB[0])&&!bk.match.ID.test(bB[bB.length-1])){bH=bf.find(bB.shift(),e,by);e=bH.expr?bf.filter(bH.expr,bH.set)[0]:bH.set[0]}if(e){bH=bE?{expr:bB.pop(),set:bl(bE)}:bf.find(bB.pop(),bB.length===1&&(bB[0]==="~"||bB[0]==="+")&&e.parentNode?e.parentNode:e,by);bI=bH.expr?bf.filter(bH.expr,bH.set):bH.set;if(bB.length>0){bL=bl(bI)}else{bz=false}while(bB.length){bK=bB.pop();bJ=bK;if(!bk.relative[bK]){bK=""}else{bJ=bB.pop()}if(bJ==null){bJ=e}bk.relative[bK](bL,bJ,by)}}else{bL=bB=[]}}if(!bL){bL=bI}if(!bL){bf.error(bK||bA)}if(br.call(bL)==="[object Array]"){if(!bz){bD.push.apply(bD,bL)}else{if(e&&e.nodeType===1){for(bC=0;bL[bC]!=null;bC++){if(bL[bC]&&(bL[bC]===true||bL[bC].nodeType===1&&bf.contains(e,bL[bC]))){bD.push(bI[bC])}}}else{for(bC=0;bL[bC]!=null;bC++){if(bL[bC]&&bL[bC].nodeType===1){bD.push(bI[bC])}}}}}else{bl(bL,bD)}if(bw){bf(bw,bG,bD,bE);bf.uniqueSort(bD)}return bD};bf.uniqueSort=function(bw){if(bq){bi=bh;bw.sort(bq);if(bi){for(var e=1;e0};bf.find=function(bC,e,bD){var bB;if(!bC){return[]}for(var by=0,bx=bk.order.length;by":function(bB,bw){var bA,bz=typeof bw==="string",bx=0,e=bB.length;if(bz&&!bv.test(bw)){bw=bw.toLowerCase();for(;bx=0)){if(!bx){e.push(bA)}}else{if(bx){bw[bz]=false}}}}return false},ID:function(e){return e[1].replace(bp,"")},TAG:function(bw,e){return bw[1].replace(bp,"").toLowerCase()},CHILD:function(e){if(e[1]==="nth"){if(!e[2]){bf.error(e[0])}e[2]=e[2].replace(/^\+|\s*/g,"");var bw=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(e[2]==="even"&&"2n"||e[2]==="odd"&&"2n+1"||!/\D/.test(e[2])&&"0n+"+e[2]||e[2]);e[2]=(bw[1]+(bw[2]||1))-0;e[3]=bw[3]-0}else{if(e[2]){bf.error(e[0])}}e[0]=bo++;return e},ATTR:function(bz,bw,bx,e,bA,bB){var by=bz[1]=bz[1].replace(bp,"");if(!bB&&bk.attrMap[by]){bz[1]=bk.attrMap[by]}bz[4]=(bz[4]||bz[5]||"").replace(bp,"");if(bz[2]==="~="){bz[4]=" "+bz[4]+" "}return bz},PSEUDO:function(bz,bw,bx,e,bA){if(bz[1]==="not"){if((bn.exec(bz[3])||"").length>1||/^\w/.test(bz[3])){bz[3]=bf(bz[3],null,null,bw)}else{var by=bf.filter(bz[3],bw,bx,true^bA);if(!bx){e.push.apply(e,by)}return false}}else{if(bk.match.POS.test(bz[0])||bk.match.CHILD.test(bz[0])){return true}}return bz},POS:function(e){e.unshift(true);return e}},filters:{enabled:function(e){return e.disabled===false&&e.type!=="hidden"},disabled:function(e){return e.disabled===true},checked:function(e){return e.checked===true},selected:function(e){if(e.parentNode){e.parentNode.selectedIndex}return e.selected===true},parent:function(e){return !!e.firstChild},empty:function(e){return !e.firstChild},has:function(bx,bw,e){return !!bf(e[3],bx).length},header:function(e){return(/h\d/i).test(e.nodeName)},text:function(e){return"text"===e.getAttribute("type")},radio:function(e){return"radio"===e.type},checkbox:function(e){return"checkbox"===e.type},file:function(e){return"file"===e.type},password:function(e){return"password"===e.type},submit:function(e){return"submit"===e.type},image:function(e){return"image"===e.type},reset:function(e){return"reset"===e.type},button:function(e){return"button"===e.type||e.nodeName.toLowerCase()==="button"},input:function(e){return(/input|select|textarea|button/i).test(e.nodeName)}},setFilters:{first:function(bw,e){return e===0},last:function(bx,bw,e,by){return bw===by.length-1},even:function(bw,e){return e%2===0},odd:function(bw,e){return e%2===1},lt:function(bx,bw,e){return bwe[3]-0},nth:function(bx,bw,e){return e[3]-0===bw},eq:function(bx,bw,e){return e[3]-0===bw}},filter:{PSEUDO:function(bx,bC,bB,bD){var e=bC[1],bw=bk.filters[e];if(bw){return bw(bx,bB,bC,bD)}else{if(e==="contains"){return(bx.textContent||bx.innerText||bf.getText([bx])||"").indexOf(bC[3])>=0}else{if(e==="not"){var by=bC[3];for(var bA=0,bz=by.length;bA=0)}}},ID:function(bw,e){return bw.nodeType===1&&bw.getAttribute("id")===e},TAG:function(bw,e){return(e==="*"&&bw.nodeType===1)||bw.nodeName.toLowerCase()===e},CLASS:function(bw,e){return(" "+(bw.className||bw.getAttribute("class"))+" ").indexOf(e)>-1},ATTR:function(bA,by){var bx=by[1],e=bk.attrHandle[bx]?bk.attrHandle[bx](bA):bA[bx]!=null?bA[bx]:bA.getAttribute(bx),bB=e+"",bz=by[2],bw=by[4];return e==null?bz==="!=":bz==="="?bB===bw:bz==="*="?bB.indexOf(bw)>=0:bz==="~="?(" "+bB+" ").indexOf(bw)>=0:!bw?bB&&e!==false:bz==="!="?bB!==bw:bz==="^="?bB.indexOf(bw)===0:bz==="$="?bB.substr(bB.length-bw.length)===bw:bz==="|="?bB===bw||bB.substr(0,bw.length+1)===bw+"-":false},POS:function(bz,bw,bx,bA){var e=bw[2],by=bk.setFilters[e];if(by){return by(bz,bx,bw,bA)}}}};var bj=bk.match.POS,be=function(bw,e){return"\\"+(e-0+1)};for(var bg in bk.match){bk.match[bg]=new RegExp(bk.match[bg].source+(/(?![^\[]*\])(?![^\(]*\))/.source));bk.leftMatch[bg]=new RegExp(/(^(?:.|\r|\n)*?)/.source+bk.match[bg].source.replace(/\\(\d+)/g,be))}var bl=function(bw,e){bw=Array.prototype.slice.call(bw,0);if(e){e.push.apply(e,bw);return e}return bw};try{Array.prototype.slice.call(al.documentElement.childNodes,0)[0].nodeType}catch(bu){bl=function(bz,by){var bx=0,bw=by||[];if(br.call(bz)==="[object Array]"){Array.prototype.push.apply(bw,bz)}else{if(typeof bz.length==="number"){for(var e=bz.length;bx";e.insertBefore(bw,e.firstChild);if(al.getElementById(bx)){bk.find.ID=function(bz,bA,bB){if(typeof bA.getElementById!=="undefined"&&!bB){var by=bA.getElementById(bz[1]);return by?by.id===bz[1]||typeof by.getAttributeNode!=="undefined"&&by.getAttributeNode("id").nodeValue===bz[1]?[by]:H:[]}};bk.filter.ID=function(bA,by){var bz=typeof bA.getAttributeNode!=="undefined"&&bA.getAttributeNode("id");return bA.nodeType===1&&bz&&bz.nodeValue===by}}e.removeChild(bw);e=bw=null})();(function(){var e=al.createElement("div");e.appendChild(al.createComment(""));if(e.getElementsByTagName("*").length>0){bk.find.TAG=function(bw,bA){var bz=bA.getElementsByTagName(bw[1]);if(bw[1]==="*"){var by=[];for(var bx=0;bz[bx];bx++){if(bz[bx].nodeType===1){by.push(bz[bx])}}bz=by}return bz}}e.innerHTML="";if(e.firstChild&&typeof e.firstChild.getAttribute!=="undefined"&&e.firstChild.getAttribute("href")!=="#"){bk.attrHandle.href=function(bw){return bw.getAttribute("href",2)}}e=null})();if(al.querySelectorAll){(function(){var e=bf,by=al.createElement("div"),bx="__sizzle__";by.innerHTML="

    ";if(by.querySelectorAll&&by.querySelectorAll(".TEST").length===0){return}bf=function(bJ,bA,bE,bI){bA=bA||al;if(!bI&&!bf.isXML(bA)){var bH=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(bJ);if(bH&&(bA.nodeType===1||bA.nodeType===9)){if(bH[1]){return bl(bA.getElementsByTagName(bJ),bE)}else{if(bH[2]&&bk.find.CLASS&&bA.getElementsByClassName){return bl(bA.getElementsByClassName(bH[2]),bE)}}}if(bA.nodeType===9){if(bJ==="body"&&bA.body){return bl([bA.body],bE)}else{if(bH&&bH[3]){var bD=bA.getElementById(bH[3]);if(bD&&bD.parentNode){if(bD.id===bH[3]){return bl([bD],bE)}}else{return bl([],bE)}}}try{return bl(bA.querySelectorAll(bJ),bE)}catch(bF){}}else{if(bA.nodeType===1&&bA.nodeName.toLowerCase()!=="object"){var bB=bA,bC=bA.getAttribute("id"),bz=bC||bx,bL=bA.parentNode,bK=/^\s*[+~]/.test(bJ);if(!bC){bA.setAttribute("id",bz)}else{bz=bz.replace(/'/g,"\\$&")}if(bK&&bL){bA=bA.parentNode}try{if(!bK||bL){return bl(bA.querySelectorAll("[id='"+bz+"'] "+bJ),bE)}}catch(bG){}finally{if(!bC){bB.removeAttribute("id")}}}}}return e(bJ,bA,bE,bI)};for(var bw in e){bf[bw]=e[bw]}by=null})()}(function(){var e=al.documentElement,bx=e.matchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.msMatchesSelector,bw=false;try{bx.call(al.documentElement,"[test!='']:sizzle")}catch(by){bw=true}if(bx){bf.matchesSelector=function(bz,bB){bB=bB.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!bf.isXML(bz)){try{if(bw||!bk.match.PSEUDO.test(bB)&&!/!=/.test(bB)){return bx.call(bz,bB)}}catch(bA){}}return bf(bB,null,null,[bz]).length>0}}})();(function(){var e=al.createElement("div");e.innerHTML="
    ";if(!e.getElementsByClassName||e.getElementsByClassName("e").length===0){return}e.lastChild.className="e";if(e.getElementsByClassName("e").length===1){return}bk.order.splice(1,0,"CLASS");bk.find.CLASS=function(bw,bx,by){if(typeof bx.getElementsByClassName!=="undefined"&&!by){return bx.getElementsByClassName(bw[1])}};e=null})();function bd(bw,bB,bA,bE,bC,bD){for(var by=0,bx=bE.length;by0){bz=e;break}}}e=e[bw]}bE[by]=bz}}}if(al.documentElement.contains){bf.contains=function(bw,e){return bw!==e&&(bw.contains?bw.contains(e):true)}}else{if(al.documentElement.compareDocumentPosition){bf.contains=function(bw,e){return !!(bw.compareDocumentPosition(e)&16)}}else{bf.contains=function(){return false}}}bf.isXML=function(e){var bw=(e?e.ownerDocument||e:0).documentElement;return bw?bw.nodeName!=="HTML":false};var bs=function(e,bC){var bA,by=[],bz="",bx=bC.nodeType?[bC]:bC;while((bA=bk.match.PSEUDO.exec(e))){bz+=bA[0];e=e.replace(bk.match.PSEUDO,"")}e=bk.relative[e]?e+"*":e;for(var bB=0,bw=bx.length;bB0){for(var bi=bh;bi0},closest:function(bm,bd){var bj=[],bg,be,bl=this[0];if(a.isArray(bm)){var bi,bf,bh={},e=1;if(bl&&bm.length){for(bg=0,be=bm.length;bg-1:a(bl).is(bi)){bj.push({selector:bf,elem:bl,level:e})}}bl=bl.parentNode;e++}}return bj}var bk=F.test(bm)?a(bm,bd||this.context):null;for(bg=0,be=this.length;bg-1:a.find.matchesSelector(bl,bm)){bj.push(bl);break}else{bl=bl.parentNode;if(!bl||!bl.ownerDocument||bl===bd){break}}}}bj=bj.length>1?a.unique(bj):bj;return this.pushStack(bj,"closest",bm)},index:function(e){if(!e||typeof e==="string"){return a.inArray(this[0],e?a(e):this.parent().children())}return a.inArray(e.jquery?e[0]:e,this)},add:function(e,bd){var bf=typeof e==="string"?a(e,bd):a.makeArray(e),be=a.merge(this.get(),bf);return this.pushStack(B(bf[0])||B(be[0])?be:a.unique(be))},andSelf:function(){return this.add(this.prevObject)}});function B(e){return !e||!e.parentNode||e.parentNode.nodeType===11}a.each({parent:function(bd){var e=bd.parentNode;return e&&e.nodeType!==11?e:null},parents:function(e){return a.dir(e,"parentNode")},parentsUntil:function(bd,e,be){return a.dir(bd,"parentNode",be)},next:function(e){return a.nth(e,2,"nextSibling")},prev:function(e){return a.nth(e,2,"previousSibling")},nextAll:function(e){return a.dir(e,"nextSibling")},prevAll:function(e){return a.dir(e,"previousSibling")},nextUntil:function(bd,e,be){return a.dir(bd,"nextSibling",be)},prevUntil:function(bd,e,be){return a.dir(bd,"previousSibling",be)},siblings:function(e){return a.sibling(e.parentNode.firstChild,e)},children:function(e){return a.sibling(e.firstChild)},contents:function(e){return a.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:a.makeArray(e.childNodes)}},function(e,bd){a.fn[e]=function(bh,be){var bg=a.map(this,bd,bh),bf=M.call(arguments);if(!W.test(e)){be=bh}if(be&&typeof be==="string"){bg=a.filter(be,bg)}bg=this.length>1&&!ao[e]?a.unique(bg):bg;if((this.length>1||aW.test(be))&&ai.test(e)){bg=bg.reverse()}return this.pushStack(bg,e,bf.join(","))}});a.extend({filter:function(be,e,bd){if(bd){be=":not("+be+")"}return e.length===1?a.find.matchesSelector(e[0],be)?[e[0]]:[]:a.find.matches(be,e)},dir:function(be,bd,bg){var e=[],bf=be[bd];while(bf&&bf.nodeType!==9&&(bg===H||bf.nodeType!==1||!a(bf).is(bg))){if(bf.nodeType===1){e.push(bf)}bf=bf[bd]}return e},nth:function(bg,e,be,bf){e=e||1;var bd=0;for(;bg;bg=bg[be]){if(bg.nodeType===1&&++bd===e){break}}return bg},sibling:function(be,bd){var e=[];for(;be;be=be.nextSibling){if(be.nodeType===1&&be!==bd){e.push(be)}}return e}});function av(bf,be,e){if(a.isFunction(be)){return a.grep(bf,function(bh,bg){var bi=!!be.call(bh,bg,bh);return bi===e})}else{if(be.nodeType){return a.grep(bf,function(bh,bg){return(bh===be)===e})}else{if(typeof be==="string"){var bd=a.grep(bf,function(bg){return bg.nodeType===1});if(a9.test(be)){return a.filter(be,bd,!e)}else{be=a.filter(be,bd)}}}}return a.grep(bf,function(bh,bg){return(a.inArray(bh,be)>=0)===e})}var ab=/ jQuery\d+="(?:\d+|null)"/g,aj=/^\s+/,O=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,c=/<([\w:]+)/,v=/",""],legend:[1,"
    ","
    "],thead:[1,"","
    "],tr:[2,"","
    "],td:[3,"","
    "],col:[2,"","
    "],area:[1,"",""],_default:[0,"",""]};an.optgroup=an.option;an.tbody=an.tfoot=an.colgroup=an.caption=an.thead;an.th=an.td;if(!a.support.htmlSerialize){an._default=[1,"div
    ","
    "]}a.fn.extend({text:function(e){if(a.isFunction(e)){return this.each(function(be){var bd=a(this);bd.text(e.call(this,be,bd.text()))})}if(typeof e!=="object"&&e!==H){return this.empty().append((this[0]&&this[0].ownerDocument||al).createTextNode(e))}return a.text(this)},wrapAll:function(e){if(a.isFunction(e)){return this.each(function(be){a(this).wrapAll(e.call(this,be))})}if(this[0]){var bd=a(e,this[0].ownerDocument).eq(0).clone(true);if(this[0].parentNode){bd.insertBefore(this[0])}bd.map(function(){var be=this;while(be.firstChild&&be.firstChild.nodeType===1){be=be.firstChild}return be}).append(this)}return this},wrapInner:function(e){if(a.isFunction(e)){return this.each(function(bd){a(this).wrapInner(e.call(this,bd))})}return this.each(function(){var bd=a(this),be=bd.contents();if(be.length){be.wrapAll(e)}else{bd.append(e)}})},wrap:function(e){return this.each(function(){a(this).wrapAll(e)})},unwrap:function(){return this.parent().each(function(){if(!a.nodeName(this,"body")){a(this).replaceWith(this.childNodes)}}).end()},append:function(){return this.domManip(arguments,true,function(e){if(this.nodeType===1){this.appendChild(e)}})},prepend:function(){return this.domManip(arguments,true,function(e){if(this.nodeType===1){this.insertBefore(e,this.firstChild)}})},before:function(){if(this[0]&&this[0].parentNode){return this.domManip(arguments,false,function(bd){this.parentNode.insertBefore(bd,this)})}else{if(arguments.length){var e=a(arguments[0]);e.push.apply(e,this.toArray());return this.pushStack(e,"before",arguments)}}},after:function(){if(this[0]&&this[0].parentNode){return this.domManip(arguments,false,function(bd){this.parentNode.insertBefore(bd,this.nextSibling)})}else{if(arguments.length){var e=this.pushStack(this,"after",arguments);e.push.apply(e,a(arguments[0]).toArray());return e}}},remove:function(e,bf){for(var bd=0,be;(be=this[bd])!=null;bd++){if(!e||a.filter(e,[be]).length){if(!bf&&be.nodeType===1){a.cleanData(be.getElementsByTagName("*"));a.cleanData([be])}if(be.parentNode){be.parentNode.removeChild(be)}}}return this},empty:function(){for(var e=0,bd;(bd=this[e])!=null;e++){if(bd.nodeType===1){a.cleanData(bd.getElementsByTagName("*"))}while(bd.firstChild){bd.removeChild(bd.firstChild)}}return this},clone:function(bd,e){bd=bd==null?false:bd;e=e==null?bd:e;return this.map(function(){return a.clone(this,bd,e)})},html:function(bf){if(bf===H){return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(ab,""):null}else{if(typeof bf==="string"&&!L.test(bf)&&(a.support.leadingWhitespace||!aj.test(bf))&&!an[(c.exec(bf)||["",""])[1].toLowerCase()]){bf=bf.replace(O,"<$1>");try{for(var be=0,bd=this.length;be1&&be0?this.clone(true):this).get();a(bk[bi])[bd](bg);bh=bh.concat(bg)}return this.pushStack(bh,e,bk.selector)}}});function a1(e){if("getElementsByTagName" in e){return e.getElementsByTagName("*")}else{if("querySelectorAll" in e){return e.querySelectorAll("*")}else{return[]}}}a.extend({clone:function(bg,bi,be){var bh=bg.cloneNode(true),e,bd,bf;if((!a.support.noCloneEvent||!a.support.noCloneChecked)&&(bg.nodeType===1||bg.nodeType===11)&&!a.isXMLDoc(bg)){ac(bg,bh);e=a1(bg);bd=a1(bh);for(bf=0;e[bf];++bf){ac(e[bf],bd[bf])}}if(bi){s(bg,bh);if(be){e=a1(bg);bd=a1(bh);for(bf=0;e[bf];++bf){s(e[bf],bd[bf])}}}return bh},clean:function(be,bg,bn,bi){bg=bg||al;if(typeof bg.createElement==="undefined"){bg=bg.ownerDocument||bg[0]&&bg[0].ownerDocument||al}var bo=[];for(var bm=0,bh;(bh=be[bm])!=null;bm++){if(typeof bh==="number"){bh+=""}if(!bh){continue}if(typeof bh==="string"&&!T.test(bh)){bh=bg.createTextNode(bh)}else{if(typeof bh==="string"){bh=bh.replace(O,"<$1>");var bp=(c.exec(bh)||["",""])[1].toLowerCase(),bf=an[bp]||an._default,bl=bf[0],bd=bg.createElement("div");bd.innerHTML=bf[1]+bh+bf[2];while(bl--){bd=bd.lastChild}if(!a.support.tbody){var e=v.test(bh),bk=bp==="table"&&!e?bd.firstChild&&bd.firstChild.childNodes:bf[1]===""&&!e?bd.childNodes:[];for(var bj=bk.length-1;bj>=0;--bj){if(a.nodeName(bk[bj],"tbody")&&!bk[bj].childNodes.length){bk[bj].parentNode.removeChild(bk[bj])}}}if(!a.support.leadingWhitespace&&aj.test(bh)){bd.insertBefore(bg.createTextNode(aj.exec(bh)[0]),bd.firstChild)}bh=bd.childNodes}}if(bh.nodeType){bo.push(bh)}else{bo=a.merge(bo,bh)}}if(bn){for(bm=0;bo[bm];bm++){if(bi&&a.nodeName(bo[bm],"script")&&(!bo[bm].type||bo[bm].type.toLowerCase()==="text/javascript")){bi.push(bo[bm].parentNode?bo[bm].parentNode.removeChild(bo[bm]):bo[bm])}else{if(bo[bm].nodeType===1){bo.splice.apply(bo,[bm+1,0].concat(a.makeArray(bo[bm].getElementsByTagName("script"))))}bn.appendChild(bo[bm])}}}return bo},cleanData:function(bd){var bg,be,e=a.cache,bl=a.expando,bj=a.event.special,bi=a.support.deleteExpando;for(var bh=0,bf;(bf=bd[bh])!=null;bh++){if(bf.nodeName&&a.noData[bf.nodeName.toLowerCase()]){continue}be=bf[a.expando];if(be){bg=e[be]&&e[be][bl];if(bg&&bg.events){for(var bk in bg.events){if(bj[bk]){a.event.remove(bf,bk)}else{a.removeEvent(bf,bk,bg.handle)}}if(bg.handle){bg.handle.elem=null}}if(bi){delete bf[a.expando]}else{if(bf.removeAttribute){bf.removeAttribute(a.expando)}}delete e[be]}}}});function a8(e,bd){if(bd.src){a.ajax({url:bd.src,async:false,dataType:"script"})}else{a.globalEval(bd.text||bd.textContent||bd.innerHTML||"")}if(bd.parentNode){bd.parentNode.removeChild(bd)}}var ae=/alpha\([^)]*\)/i,ak=/opacity=([^)]*)/,aM=/-([a-z])/ig,y=/([A-Z])/g,aZ=/^-?\d+(?:px)?$/i,a7=/^-?\d/,aV={position:"absolute",visibility:"hidden",display:"block"},ag=["Left","Right"],aR=["Top","Bottom"],U,ay,aL,l=function(e,bd){return bd.toUpperCase()};a.fn.css=function(e,bd){if(arguments.length===2&&bd===H){return this}return a.access(this,e,bd,true,function(bf,be,bg){return bg!==H?a.style(bf,be,bg):a.css(bf,be)})};a.extend({cssHooks:{opacity:{get:function(be,bd){if(bd){var e=U(be,"opacity","opacity");return e===""?"1":e}else{return be.style.opacity}}}},cssNumber:{zIndex:true,fontWeight:true,opacity:true,zoom:true,lineHeight:true},cssProps:{"float":a.support.cssFloat?"cssFloat":"styleFloat"},style:function(bf,be,bk,bg){if(!bf||bf.nodeType===3||bf.nodeType===8||!bf.style){return}var bj,bh=a.camelCase(be),bd=bf.style,bl=a.cssHooks[bh];be=a.cssProps[bh]||bh;if(bk!==H){if(typeof bk==="number"&&isNaN(bk)||bk==null){return}if(typeof bk==="number"&&!a.cssNumber[bh]){bk+="px"}if(!bl||!("set" in bl)||(bk=bl.set(bf,bk))!==H){try{bd[be]=bk}catch(bi){}}}else{if(bl&&"get" in bl&&(bj=bl.get(bf,false,bg))!==H){return bj}return bd[be]}},css:function(bh,bg,bd){var bf,be=a.camelCase(bg),e=a.cssHooks[be];bg=a.cssProps[be]||be;if(e&&"get" in e&&(bf=e.get(bh,true,bd))!==H){return bf}else{if(U){return U(bh,bg,be)}}},swap:function(bf,be,bg){var e={};for(var bd in be){e[bd]=bf.style[bd];bf.style[bd]=be[bd]}bg.call(bf);for(bd in be){bf.style[bd]=e[bd]}},camelCase:function(e){return e.replace(aM,l)}});a.curCSS=a.css;a.each(["height","width"],function(bd,e){a.cssHooks[e]={get:function(bg,bf,be){var bh;if(bf){if(bg.offsetWidth!==0){bh=o(bg,e,be)}else{a.swap(bg,aV,function(){bh=o(bg,e,be)})}if(bh<=0){bh=U(bg,e,e);if(bh==="0px"&&aL){bh=aL(bg,e,e)}if(bh!=null){return bh===""||bh==="auto"?"0px":bh}}if(bh<0||bh==null){bh=bg.style[e];return bh===""||bh==="auto"?"0px":bh}return typeof bh==="string"?bh:bh+"px"}},set:function(be,bf){if(aZ.test(bf)){bf=parseFloat(bf);if(bf>=0){return bf+"px"}}else{return bf}}}});if(!a.support.opacity){a.cssHooks.opacity={get:function(bd,e){return ak.test((e&&bd.currentStyle?bd.currentStyle.filter:bd.style.filter)||"")?(parseFloat(RegExp.$1)/100)+"":e?"1":""},set:function(bf,bg){var be=bf.style;be.zoom=1;var e=a.isNaN(bg)?"":"alpha(opacity="+bg*100+")",bd=be.filter||"";be.filter=ae.test(bd)?bd.replace(ae,e):be.filter+" "+e}}}if(al.defaultView&&al.defaultView.getComputedStyle){ay=function(bh,e,bf){var be,bg,bd;bf=bf.replace(y,"-$1").toLowerCase();if(!(bg=bh.ownerDocument.defaultView)){return H}if((bd=bg.getComputedStyle(bh,null))){be=bd.getPropertyValue(bf);if(be===""&&!a.contains(bh.ownerDocument.documentElement,bh)){be=a.style(bh,bf)}}return be}}if(al.documentElement.currentStyle){aL=function(bg,be){var bh,bd=bg.currentStyle&&bg.currentStyle[be],e=bg.runtimeStyle&&bg.runtimeStyle[be],bf=bg.style;if(!aZ.test(bd)&&a7.test(bd)){bh=bf.left;if(e){bg.runtimeStyle.left=bg.currentStyle.left}bf.left=be==="fontSize"?"1em":(bd||0);bd=bf.pixelLeft+"px";bf.left=bh;if(e){bg.runtimeStyle.left=e}}return bd===""?"auto":bd}}U=ay||aL;function o(be,bd,e){var bg=bd==="width"?ag:aR,bf=bd==="width"?be.offsetWidth:be.offsetHeight;if(e==="border"){return bf}a.each(bg,function(){if(!e){bf-=parseFloat(a.css(be,"padding"+this))||0}if(e==="margin"){bf+=parseFloat(a.css(be,"margin"+this))||0}else{bf-=parseFloat(a.css(be,"border"+this+"Width"))||0}});return bf}if(a.expr&&a.expr.filters){a.expr.filters.hidden=function(be){var bd=be.offsetWidth,e=be.offsetHeight;return(bd===0&&e===0)||(!a.support.reliableHiddenOffsets&&(be.style.display||a.css(be,"display"))==="none")};a.expr.filters.visible=function(e){return !a.expr.filters.hidden(e)}}var i=/%20/g,ah=/\[\]$/,bc=/\r?\n/g,ba=/#.*$/,ar=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,aO=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,aB=/(?:^file|^widget|\-extension):$/,aD=/^(?:GET|HEAD)$/,b=/^\/\//,I=/\?/,aU=/)<[^<]*)*<\/script>/gi,p=/^(?:select|textarea)/i,g=/\s+/,bb=/([?&])_=[^&]*/,R=/(^|\-)([a-z])/g,aJ=function(bd,e,be){return e+be.toUpperCase()},G=/^([\w\+\.\-]+:)\/\/([^\/?#:]*)(?::(\d+))?/,z=a.fn.load,V={},q={},au,r;try{au=al.location.href}catch(am){au=al.createElement("a");au.href="";au=au.href}r=G.exec(au.toLowerCase());function d(e){return function(bg,bi){if(typeof bg!=="string"){bi=bg;bg="*"}if(a.isFunction(bi)){var bf=bg.toLowerCase().split(g),be=0,bh=bf.length,bd,bj,bk;for(;be=0){var e=be.slice(bg,be.length);be=be.slice(0,bg)}var bf="GET";if(bh){if(a.isFunction(bh)){bi=bh;bh=H}else{if(typeof bh==="object"){bh=a.param(bh,a.ajaxSettings.traditional);bf="POST"}}}var bd=this;a.ajax({url:be,type:bf,dataType:"html",data:bh,complete:function(bk,bj,bl){bl=bk.responseText;if(bk.isResolved()){bk.done(function(bm){bl=bm});bd.html(e?a("
    ").append(bl.replace(aU,"")).find(e):bl)}if(bi){bd.each(bi,[bl,bj,bk])}}});return this},serialize:function(){return a.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?a.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||p.test(this.nodeName)||aO.test(this.type))}).map(function(e,bd){var be=a(this).val();return be==null?null:a.isArray(be)?a.map(be,function(bg,bf){return{name:bd.name,value:bg.replace(bc,"\r\n")}}):{name:bd.name,value:be.replace(bc,"\r\n")}}).get()}});a.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(e,bd){a.fn[bd]=function(be){return this.bind(bd,be)}});a.each(["get","post"],function(e,bd){a[bd]=function(be,bg,bh,bf){if(a.isFunction(bg)){bf=bf||bh;bh=bg;bg=H}return a.ajax({type:bd,url:be,data:bg,success:bh,dataType:bf})}});a.extend({getScript:function(e,bd){return a.get(e,H,bd,"script")},getJSON:function(e,bd,be){return a.get(e,bd,be,"json")},ajaxSetup:function(be,e){if(!e){e=be;be=a.extend(true,a.ajaxSettings,e)}else{a.extend(true,be,a.ajaxSettings,e)}for(var bd in {context:1,url:1}){if(bd in e){be[bd]=e[bd]}else{if(bd in a.ajaxSettings){be[bd]=a.ajaxSettings[bd]}}}return be},ajaxSettings:{url:au,isLocal:aB.test(r[1]),global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":"*/*"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":aY.String,"text html":true,"text json":a.parseJSON,"text xml":a.parseXML}},ajaxPrefilter:d(V),ajaxTransport:d(q),ajax:function(bh,bf){if(typeof bh==="object"){bf=bh;bh=H}bf=bf||{};var bl=a.ajaxSetup({},bf),bz=bl.context||bl,bo=bz!==bl&&(bz.nodeType||bz instanceof a)?a(bz):a.event,by=a.Deferred(),bv=a._Deferred(),bj=bl.statusCode||{},bk,bp={},bx,bg,bt,bm,bq,bi=0,be,bs,br={readyState:0,setRequestHeader:function(e,bA){if(!bi){bp[e.toLowerCase().replace(R,aJ)]=bA}return this},getAllResponseHeaders:function(){return bi===2?bx:null},getResponseHeader:function(bA){var e;if(bi===2){if(!bg){bg={};while((e=ar.exec(bx))){bg[e[1].toLowerCase()]=e[2]}}e=bg[bA.toLowerCase()]}return e===H?null:e},overrideMimeType:function(e){if(!bi){bl.mimeType=e}return this},abort:function(e){e=e||"abort";if(bt){bt.abort(e)}bn(0,e);return this}};function bn(bF,bD,bG,bC){if(bi===2){return}bi=2;if(bm){clearTimeout(bm)}bt=H;bx=bC||"";br.readyState=bF?4:0;var bA,bK,bJ,bE=bG?a4(bl,br,bG):H,bB,bI;if(bF>=200&&bF<300||bF===304){if(bl.ifModified){if((bB=br.getResponseHeader("Last-Modified"))){a.lastModified[bk]=bB}if((bI=br.getResponseHeader("Etag"))){a.etag[bk]=bI}}if(bF===304){bD="notmodified";bA=true}else{try{bK=D(bl,bE);bD="success";bA=true}catch(bH){bD="parsererror";bJ=bH}}}else{bJ=bD;if(!bD||bF){bD="error";if(bF<0){bF=0}}}br.status=bF;br.statusText=bD;if(bA){by.resolveWith(bz,[bK,bD,br])}else{by.rejectWith(bz,[br,bD,bJ])}br.statusCode(bj);bj=H;if(be){bo.trigger("ajax"+(bA?"Success":"Error"),[br,bl,bA?bK:bJ])}bv.resolveWith(bz,[br,bD]);if(be){bo.trigger("ajaxComplete",[br,bl]);if(!(--a.active)){a.event.trigger("ajaxStop")}}}by.promise(br);br.success=br.done;br.error=br.fail;br.complete=bv.done;br.statusCode=function(bA){if(bA){var e;if(bi<2){for(e in bA){bj[e]=[bj[e],bA[e]]}}else{e=bA[br.status];br.then(e,e)}}return this};bl.url=((bh||bl.url)+"").replace(ba,"").replace(b,r[1]+"//");bl.dataTypes=a.trim(bl.dataType||"*").toLowerCase().split(g);if(!bl.crossDomain){bq=G.exec(bl.url.toLowerCase());bl.crossDomain=!!(bq&&(bq[1]!=r[1]||bq[2]!=r[2]||(bq[3]||(bq[1]==="http:"?80:443))!=(r[3]||(r[1]==="http:"?80:443))))}if(bl.data&&bl.processData&&typeof bl.data!=="string"){bl.data=a.param(bl.data,bl.traditional)}aI(V,bl,bf,br);if(bi===2){return false}be=bl.global;bl.type=bl.type.toUpperCase();bl.hasContent=!aD.test(bl.type);if(be&&a.active++===0){a.event.trigger("ajaxStart")}if(!bl.hasContent){if(bl.data){bl.url+=(I.test(bl.url)?"&":"?")+bl.data}bk=bl.url;if(bl.cache===false){var bd=a.now(),bw=bl.url.replace(bb,"$1_="+bd);bl.url=bw+((bw===bl.url)?(I.test(bl.url)?"&":"?")+"_="+bd:"")}}if(bl.data&&bl.hasContent&&bl.contentType!==false||bf.contentType){bp["Content-Type"]=bl.contentType}if(bl.ifModified){bk=bk||bl.url;if(a.lastModified[bk]){bp["If-Modified-Since"]=a.lastModified[bk]}if(a.etag[bk]){bp["If-None-Match"]=a.etag[bk]}}bp.Accept=bl.dataTypes[0]&&bl.accepts[bl.dataTypes[0]]?bl.accepts[bl.dataTypes[0]]+(bl.dataTypes[0]!=="*"?", */*; q=0.01":""):bl.accepts["*"];for(bs in bl.headers){br.setRequestHeader(bs,bl.headers[bs])}if(bl.beforeSend&&(bl.beforeSend.call(bz,br,bl)===false||bi===2)){br.abort();return false}for(bs in {success:1,error:1,complete:1}){br[bs](bl[bs])}bt=aI(q,bl,bf,br);if(!bt){bn(-1,"No Transport")}else{br.readyState=1;if(be){bo.trigger("ajaxSend",[br,bl])}if(bl.async&&bl.timeout>0){bm=setTimeout(function(){br.abort("timeout")},bl.timeout)}try{bi=1;bt.send(bp,bn)}catch(bu){if(status<2){bn(-1,bu)}else{a.error(bu)}}}return br},param:function(e,be){var bd=[],bg=function(bh,bi){bi=a.isFunction(bi)?bi():bi;bd[bd.length]=encodeURIComponent(bh)+"="+encodeURIComponent(bi)};if(be===H){be=a.ajaxSettings.traditional}if(a.isArray(e)||(e.jquery&&!a.isPlainObject(e))){a.each(e,function(){bg(this.name,this.value)})}else{for(var bf in e){u(bf,e[bf],be,bg)}}return bd.join("&").replace(i,"+")}});function u(be,bg,bd,bf){if(a.isArray(bg)&&bg.length){a.each(bg,function(bi,bh){if(bd||ah.test(be)){bf(be,bh)}else{u(be+"["+(typeof bh==="object"||a.isArray(bh)?bi:"")+"]",bh,bd,bf)}})}else{if(!bd&&bg!=null&&typeof bg==="object"){if(a.isArray(bg)||a.isEmptyObject(bg)){bf(be,"")}else{for(var e in bg){u(be+"["+e+"]",bg[e],bd,bf)}}}else{bf(be,bg)}}}a.extend({active:0,lastModified:{},etag:{}});function a4(bl,bk,bh){var bd=bl.contents,bj=bl.dataTypes,be=bl.responseFields,bg,bi,bf,e;for(bi in be){if(bi in bh){bk[be[bi]]=bh[bi]}}while(bj[0]==="*"){bj.shift();if(bg===H){bg=bl.mimeType||bk.getResponseHeader("content-type")}}if(bg){for(bi in bd){if(bd[bi]&&bd[bi].test(bg)){bj.unshift(bi);break}}}if(bj[0] in bh){bf=bj[0]}else{for(bi in bh){if(!bj[0]||bl.converters[bi+" "+bj[0]]){bf=bi;break}if(!e){e=bi}}bf=bf||e}if(bf){if(bf!==bj[0]){bj.unshift(bf)}return bh[bf]}}function D(bp,bh){if(bp.dataFilter){bh=bp.dataFilter(bh,bp.dataType)}var bl=bp.dataTypes,bo={},bi,bm,be=bl.length,bj,bk=bl[0],bf,bg,bn,bd,e;for(bi=1;bi=0;bf--){if(be[bf].elem===this){if(e){be[bf](true)}be.splice(bf,1)}}});if(!e){this.dequeue()}return this}});function aQ(bd,e){var be={};a.each(ax.concat.apply([],ax.slice(0,e)),function(){be[this]=bd});return be}a.each({slideDown:aQ("show",1),slideUp:aQ("hide",1),slideToggle:aQ("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,bd){a.fn[e]=function(be,bg,bf){return this.animate(bd,be,bg,bf)}});a.extend({speed:function(be,bf,bd){var e=be&&typeof be==="object"?a.extend({},be):{complete:bd||!bd&&bf||a.isFunction(be)&&be,duration:be,easing:bd&&bf||bf&&!a.isFunction(bf)&&bf};e.duration=a.fx.off?0:typeof e.duration==="number"?e.duration:e.duration in a.fx.speeds?a.fx.speeds[e.duration]:a.fx.speeds._default;e.old=e.complete;e.complete=function(){if(e.queue!==false){a(this).dequeue()}if(a.isFunction(e.old)){e.old.call(this)}};return e},easing:{linear:function(be,bf,e,bd){return e+bd*be},swing:function(be,bf,e,bd){return((-Math.cos(be*Math.PI)/2)+0.5)*bd+e}},timers:[],fx:function(bd,e,be){this.options=e;this.elem=bd;this.prop=be;if(!e.orig){e.orig={}}}});a.fx.prototype={update:function(){if(this.options.step){this.options.step.call(this.elem,this.now,this)}(a.fx.step[this.prop]||a.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null)){return this.elem[this.prop]}var e,bd=a.css(this.elem,this.prop);return isNaN(e=parseFloat(bd))?!bd||bd==="auto"?0:bd:e},custom:function(bh,bg,bf){var e=this,be=a.fx;this.startTime=a.now();this.start=bh;this.end=bg;this.unit=bf||this.unit||(a.cssNumber[this.prop]?"":"px");this.now=this.start;this.pos=this.state=0;function bd(bi){return e.step(bi)}bd.elem=this.elem;if(bd()&&a.timers.push(bd)&&!aS){aS=setInterval(be.tick,be.interval)}},show:function(){this.options.orig[this.prop]=a.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur());a(this.elem).show()},hide:function(){this.options.orig[this.prop]=a.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(bf){var bk=a.now(),bg=true;if(bf||bk>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var bh in this.options.curAnim){if(this.options.curAnim[bh]!==true){bg=false}}if(bg){if(this.options.overflow!=null&&!a.support.shrinkWrapBlocks){var be=this.elem,bl=this.options;a.each(["","X","Y"],function(bm,bn){be.style["overflow"+bn]=bl.overflow[bm]})}if(this.options.hide){a(this.elem).hide()}if(this.options.hide||this.options.show){for(var e in this.options.curAnim){a.style(this.elem,e,this.options.orig[e])}}this.options.complete.call(this.elem)}return false}else{var bd=bk-this.startTime;this.state=bd/this.options.duration;var bi=this.options.specialEasing&&this.options.specialEasing[this.prop];var bj=this.options.easing||(a.easing.swing?"swing":"linear");this.pos=a.easing[bi||bj](this.state,bd,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update()}return true}};a.extend(a.fx,{tick:function(){var bd=a.timers;for(var e=0;e").appendTo("body"),bd=e.css("display");e.remove();if(bd==="none"||bd===""){bd="block"}N[be]=bd}return N[be]}var S=/^t(?:able|d|h)$/i,Y=/^(?:body|html)$/i;if("getBoundingClientRect" in al.documentElement){a.fn.offset=function(bq){var bg=this[0],bj;if(bq){return this.each(function(e){a.offset.setOffset(this,bq,e)})}if(!bg||!bg.ownerDocument){return null}if(bg===bg.ownerDocument.body){return a.offset.bodyOffset(bg)}try{bj=bg.getBoundingClientRect()}catch(bn){}var bp=bg.ownerDocument,be=bp.documentElement;if(!bj||!a.contains(be,bg)){return bj?{top:bj.top,left:bj.left}:{top:0,left:0}}var bk=bp.body,bl=az(bp),bi=be.clientTop||bk.clientTop||0,bm=be.clientLeft||bk.clientLeft||0,bd=(bl.pageYOffset||a.support.boxModel&&be.scrollTop||bk.scrollTop),bh=(bl.pageXOffset||a.support.boxModel&&be.scrollLeft||bk.scrollLeft),bo=bj.top+bd-bi,bf=bj.left+bh-bm;return{top:bo,left:bf}}}else{a.fn.offset=function(bn){var bh=this[0];if(bn){return this.each(function(bo){a.offset.setOffset(this,bn,bo)})}if(!bh||!bh.ownerDocument){return null}if(bh===bh.ownerDocument.body){return a.offset.bodyOffset(bh)}a.offset.initialize();var bk,be=bh.offsetParent,bd=bh,bm=bh.ownerDocument,bf=bm.documentElement,bi=bm.body,bj=bm.defaultView,e=bj?bj.getComputedStyle(bh,null):bh.currentStyle,bl=bh.offsetTop,bg=bh.offsetLeft;while((bh=bh.parentNode)&&bh!==bi&&bh!==bf){if(a.offset.supportsFixedPosition&&e.position==="fixed"){break}bk=bj?bj.getComputedStyle(bh,null):bh.currentStyle;bl-=bh.scrollTop;bg-=bh.scrollLeft;if(bh===be){bl+=bh.offsetTop;bg+=bh.offsetLeft;if(a.offset.doesNotAddBorder&&!(a.offset.doesAddBorderForTableAndCells&&S.test(bh.nodeName))){bl+=parseFloat(bk.borderTopWidth)||0;bg+=parseFloat(bk.borderLeftWidth)||0}bd=be;be=bh.offsetParent}if(a.offset.subtractsBorderForOverflowNotVisible&&bk.overflow!=="visible"){bl+=parseFloat(bk.borderTopWidth)||0;bg+=parseFloat(bk.borderLeftWidth)||0}e=bk}if(e.position==="relative"||e.position==="static"){bl+=bi.offsetTop;bg+=bi.offsetLeft}if(a.offset.supportsFixedPosition&&e.position==="fixed"){bl+=Math.max(bf.scrollTop,bi.scrollTop);bg+=Math.max(bf.scrollLeft,bi.scrollLeft)}return{top:bl,left:bg}}}a.offset={initialize:function(){var e=al.body,bd=al.createElement("div"),bg,bi,bh,bj,be=parseFloat(a.css(e,"marginTop"))||0,bf="
    ";a.extend(bd.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"});bd.innerHTML=bf;e.insertBefore(bd,e.firstChild);bg=bd.firstChild;bi=bg.firstChild;bj=bg.nextSibling.firstChild.firstChild;this.doesNotAddBorder=(bi.offsetTop!==5);this.doesAddBorderForTableAndCells=(bj.offsetTop===5);bi.style.position="fixed";bi.style.top="20px";this.supportsFixedPosition=(bi.offsetTop===20||bi.offsetTop===15);bi.style.position=bi.style.top="";bg.style.overflow="hidden";bg.style.position="relative";this.subtractsBorderForOverflowNotVisible=(bi.offsetTop===-5);this.doesNotIncludeMarginInBodyOffset=(e.offsetTop!==be);e.removeChild(bd);e=bd=bg=bi=bh=bj=null;a.offset.initialize=a.noop},bodyOffset:function(e){var be=e.offsetTop,bd=e.offsetLeft;a.offset.initialize();if(a.offset.doesNotIncludeMarginInBodyOffset){be+=parseFloat(a.css(e,"marginTop"))||0;bd+=parseFloat(a.css(e,"marginLeft"))||0}return{top:be,left:bd}},setOffset:function(bf,bo,bi){var bj=a.css(bf,"position");if(bj==="static"){bf.style.position="relative"}var bh=a(bf),bd=bh.offset(),e=a.css(bf,"top"),bm=a.css(bf,"left"),bn=(bj==="absolute"&&a.inArray("auto",[e,bm])>-1),bl={},bk={},be,bg;if(bn){bk=bh.position()}be=bn?bk.top:parseInt(e,10)||0;bg=bn?bk.left:parseInt(bm,10)||0;if(a.isFunction(bo)){bo=bo.call(bf,bi,bd)}if(bo.top!=null){bl.top=(bo.top-bd.top)+be}if(bo.left!=null){bl.left=(bo.left-bd.left)+bg}if("using" in bo){bo.using.call(bf,bl)}else{bh.css(bl)}}};a.fn.extend({position:function(){if(!this[0]){return null}var be=this[0],bd=this.offsetParent(),bf=this.offset(),e=Y.test(bd[0].nodeName)?{top:0,left:0}:bd.offset();bf.top-=parseFloat(a.css(be,"marginTop"))||0;bf.left-=parseFloat(a.css(be,"marginLeft"))||0;e.top+=parseFloat(a.css(bd[0],"borderTopWidth"))||0;e.left+=parseFloat(a.css(bd[0],"borderLeftWidth"))||0;return{top:bf.top-e.top,left:bf.left-e.left}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||al.body;while(e&&(!Y.test(e.nodeName)&&a.css(e,"position")==="static")){e=e.offsetParent}return e})}});a.each(["Left","Top"],function(bd,e){var be="scroll"+e;a.fn[be]=function(bh){var bf=this[0],bg;if(!bf){return null}if(bh!==H){return this.each(function(){bg=az(this);if(bg){bg.scrollTo(!bd?bh:a(bg).scrollLeft(),bd?bh:a(bg).scrollTop())}else{this[be]=bh}})}else{bg=az(bf);return bg?("pageXOffset" in bg)?bg[bd?"pageYOffset":"pageXOffset"]:a.support.boxModel&&bg.document.documentElement[be]||bg.document.body[be]:bf[be]}}});function az(e){return a.isWindow(e)?e:e.nodeType===9?e.defaultView||e.parentWindow:false}a.each(["Height","Width"],function(bd,e){var be=e.toLowerCase();a.fn["inner"+e]=function(){return this[0]?parseFloat(a.css(this[0],be,"padding")):null};a.fn["outer"+e]=function(bf){return this[0]?parseFloat(a.css(this[0],be,bf?"margin":"border")):null};a.fn[be]=function(bg){var bh=this[0];if(!bh){return bg==null?null:this}if(a.isFunction(bg)){return this.each(function(bl){var bk=a(this);bk[be](bg.call(this,bl,bk[be]()))})}if(a.isWindow(bh)){var bi=bh.document.documentElement["client"+e];return bh.document.compatMode==="CSS1Compat"&&bi||bh.document.body["client"+e]||bi}else{if(bh.nodeType===9){return Math.max(bh.documentElement["client"+e],bh.body["scroll"+e],bh.documentElement["scroll"+e],bh.body["offset"+e],bh.documentElement["offset"+e])}else{if(bg===H){var bj=a.css(bh,be),bf=parseFloat(bj);return a.isNaN(bf)?bj:bf}else{return this.css(be,typeof bg==="string"?bg:bg+"px")}}}}});aY.jQuery=aY.$=a})(window); \ No newline at end of file diff --git a/includes/jquery/jquery-1.7.2.min.js b/includes/jquery/jquery-1.7.2.min.js new file mode 100644 index 0000000000..16ad06c5ac --- /dev/null +++ b/includes/jquery/jquery-1.7.2.min.js @@ -0,0 +1,4 @@ +/*! jQuery v1.7.2 jquery.com | jquery.org/license */ +(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cu(a){if(!cj[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ck||(ck=c.createElement("iframe"),ck.frameBorder=ck.width=ck.height=0),b.appendChild(ck);if(!cl||!ck.createElement)cl=(ck.contentWindow||ck.contentDocument).document,cl.write((f.support.boxModel?"":"")+""),cl.close();d=cl.createElement(a),cl.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ck)}cj[a]=e}return cj[a]}function ct(a,b){var c={};f.each(cp.concat.apply([],cp.slice(0,b)),function(){c[this]=a});return c}function cs(){cq=b}function cr(){setTimeout(cs,0);return cq=f.now()}function ci(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ch(){try{return new a.XMLHttpRequest}catch(b){}}function cb(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){if(c!=="border")for(;e=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?+d:j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.2",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a!=null&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){if(typeof c!="string"||!c)return null;var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c
    a",d=p.getElementsByTagName("*"),e=p.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=p.getElementsByTagName("input")[0],b={leadingWhitespace:p.firstChild.nodeType===3,tbody:!p.getElementsByTagName("tbody").length,htmlSerialize:!!p.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:p.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,pixelMargin:!0},f.boxModel=b.boxModel=c.compatMode==="CSS1Compat",i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete p.test}catch(r){b.deleteExpando=!1}!p.addEventListener&&p.attachEvent&&p.fireEvent&&(p.attachEvent("onclick",function(){b.noCloneEvent=!1}),p.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),i.setAttribute("name","t"),p.appendChild(i),j=c.createDocumentFragment(),j.appendChild(p.lastChild),b.checkClone=j.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,j.removeChild(i),j.appendChild(p);if(p.attachEvent)for(n in{submit:1,change:1,focusin:1})m="on"+n,o=m in p,o||(p.setAttribute(m,"return;"),o=typeof p[m]=="function"),b[n+"Bubbles"]=o;j.removeChild(p),j=g=h=p=i=null,f(function(){var d,e,g,h,i,j,l,m,n,q,r,s,t,u=c.getElementsByTagName("body")[0];!u||(m=1,t="padding:0;margin:0;border:",r="position:absolute;top:0;left:0;width:1px;height:1px;",s=t+"0;visibility:hidden;",n="style='"+r+t+"5px solid #000;",q="
    "+""+"
    ",d=c.createElement("div"),d.style.cssText=s+"width:0;height:0;position:static;top:0;margin-top:"+m+"px",u.insertBefore(d,u.firstChild),p=c.createElement("div"),d.appendChild(p),p.innerHTML="
    t
    ",k=p.getElementsByTagName("td"),o=k[0].offsetHeight===0,k[0].style.display="",k[1].style.display="none",b.reliableHiddenOffsets=o&&k[0].offsetHeight===0,a.getComputedStyle&&(p.innerHTML="",l=c.createElement("div"),l.style.width="0",l.style.marginRight="0",p.style.width="2px",p.appendChild(l),b.reliableMarginRight=(parseInt((a.getComputedStyle(l,null)||{marginRight:0}).marginRight,10)||0)===0),typeof p.style.zoom!="undefined"&&(p.innerHTML="",p.style.width=p.style.padding="1px",p.style.border=0,p.style.overflow="hidden",p.style.display="inline",p.style.zoom=1,b.inlineBlockNeedsLayout=p.offsetWidth===3,p.style.display="block",p.style.overflow="visible",p.innerHTML="
    ",b.shrinkWrapBlocks=p.offsetWidth!==3),p.style.cssText=r+s,p.innerHTML=q,e=p.firstChild,g=e.firstChild,i=e.nextSibling.firstChild.firstChild,j={doesNotAddBorder:g.offsetTop!==5,doesAddBorderForTableAndCells:i.offsetTop===5},g.style.position="fixed",g.style.top="20px",j.fixedPosition=g.offsetTop===20||g.offsetTop===15,g.style.position=g.style.top="",e.style.overflow="hidden",e.style.position="relative",j.subtractsBorderForOverflowNotVisible=g.offsetTop===-5,j.doesNotIncludeMarginInBodyOffset=u.offsetTop!==m,a.getComputedStyle&&(p.style.marginTop="1%",b.pixelMargin=(a.getComputedStyle(p,null)||{marginTop:0}).marginTop!=="1%"),typeof d.style.zoom!="undefined"&&(d.style.zoom=1),u.removeChild(d),l=p=d=null,f.extend(b,j))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e1,null,!1)},removeData:function(a){return this.each(function(){f.removeData(this,a)})}}),f.extend({_mark:function(a,b){a&&(b=(b||"fx")+"mark",f._data(a,b,(f._data(a,b)||0)+1))},_unmark:function(a,b,c){a!==!0&&(c=b,b=a,a=!1);if(b){c=c||"fx";var d=c+"mark",e=a?0:(f._data(b,d)||1)-1;e?f._data(b,d,e):(f.removeData(b,d,!0),n(b,c,"mark"))}},queue:function(a,b,c){var d;if(a){b=(b||"fx")+"queue",d=f._data(a,b),c&&(!d||f.isArray(c)?d=f._data(a,b,f.makeArray(c)):d.push(c));return d||[]}},dequeue:function(a,b){b=b||"fx";var c=f.queue(a,b),d=c.shift(),e={};d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),f._data(a,b+".run",e),d.call(a,function(){f.dequeue(a,b)},e)),c.length||(f.removeData(a,b+"queue "+b+".run",!0),n(a,b,"queue"))}}),f.fn.extend({queue:function(a,c){var d=2;typeof a!="string"&&(c=a,a="fx",d--);if(arguments.length1)},removeAttr:function(a){return this.each(function(){f.removeAttr(this,a)})},prop:function(a,b){return f.access(this,f.prop,a,b,arguments.length>1)},removeProp:function(a){a=f.propFix[a]||a;return this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,g,h,i;if(f.isFunction(a))return this.each(function(b){f(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(p);for(c=0,d=this.length;c-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.type]||f.valHooks[this.nodeName.toLowerCase()];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.type]||f.valHooks[g.nodeName.toLowerCase()];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h,i=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;i=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/(?:^|\s)hover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function( +a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")};f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler,g=p.selector),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;le&&j.push({elem:this,matches:d.slice(e)});for(k=0;k0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));o.match.globalPOS=p;var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

    ";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
    ";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/]","i"),bd=/checked\s*(?:[^=]|=\s*.checked.)/i,be=/\/(java|ecma)script/i,bf=/^\s*",""],legend:[1,"
    ","
    "],thead:[1,"","
    "],tr:[2,"","
    "],td:[3,"","
    "],col:[2,"","
    "],area:[1,"",""],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div
    ","
    "]),f.fn.extend({text:function(a){return f.access(this,function(a){return a===b?f.text(this):this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f +.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){return f.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return c.nodeType===1?c.innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(;d1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||f.isXMLDoc(a)||!bc.test("<"+a.nodeName+">")?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g,h,i,j=[];b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);for(var k=0,l;(l=a[k])!=null;k++){typeof l=="number"&&(l+="");if(!l)continue;if(typeof l=="string")if(!_.test(l))l=b.createTextNode(l);else{l=l.replace(Y,"<$1>");var m=(Z.exec(l)||["",""])[1].toLowerCase(),n=bg[m]||bg._default,o=n[0],p=b.createElement("div"),q=bh.childNodes,r;b===c?bh.appendChild(p):U(b).appendChild(p),p.innerHTML=n[1]+l+n[2];while(o--)p=p.lastChild;if(!f.support.tbody){var s=$.test(l),t=m==="table"&&!s?p.firstChild&&p.firstChild.childNodes:n[1]===""&&!s?p.childNodes:[];for(i=t.length-1;i>=0;--i)f.nodeName(t[i],"tbody")&&!t[i].childNodes.length&&t[i].parentNode.removeChild(t[i])}!f.support.leadingWhitespace&&X.test(l)&&p.insertBefore(b.createTextNode(X.exec(l)[0]),p.firstChild),l=p.childNodes,p&&(p.parentNode.removeChild(p),q.length>0&&(r=q[q.length-1],r&&r.parentNode&&r.parentNode.removeChild(r)))}var u;if(!f.support.appendChecked)if(l[0]&&typeof (u=l.length)=="number")for(i=0;i1)},f.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=by(a,"opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":f.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var g,h,i=f.camelCase(c),j=a.style,k=f.cssHooks[i];c=f.cssProps[i]||i;if(d===b){if(k&&"get"in k&&(g=k.get(a,!1,e))!==b)return g;return j[c]}h=typeof d,h==="string"&&(g=bu.exec(d))&&(d=+(g[1]+1)*+g[2]+parseFloat(f.css(a,c)),h="number");if(d==null||h==="number"&&isNaN(d))return;h==="number"&&!f.cssNumber[i]&&(d+="px");if(!k||!("set"in k)||(d=k.set(a,d))!==b)try{j[c]=d}catch(l){}}},css:function(a,c,d){var e,g;c=f.camelCase(c),g=f.cssHooks[c],c=f.cssProps[c]||c,c==="cssFloat"&&(c="float");if(g&&"get"in g&&(e=g.get(a,!0,d))!==b)return e;if(by)return by(a,c)},swap:function(a,b,c){var d={},e,f;for(f in b)d[f]=a.style[f],a.style[f]=b[f];e=c.call(a);for(f in b)a.style[f]=d[f];return e}}),f.curCSS=f.css,c.defaultView&&c.defaultView.getComputedStyle&&(bz=function(a,b){var c,d,e,g,h=a.style;b=b.replace(br,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b))),!f.support.pixelMargin&&e&&bv.test(b)&&bt.test(c)&&(g=h.width,h.width=c,c=e.width,h.width=g);return c}),c.documentElement.currentStyle&&(bA=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f==null&&g&&(e=g[b])&&(f=e),bt.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),by=bz||bA,f.each(["height","width"],function(a,b){f.cssHooks[b]={get:function(a,c,d){if(c)return a.offsetWidth!==0?bB(a,b,d):f.swap(a,bw,function(){return bB(a,b,d)})},set:function(a,b){return bs.test(b)?b+"px":b}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bq.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bp,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bp.test(g)?g.replace(bp,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){return f.swap(a,{display:"inline-block"},function(){return b?by(a,"margin-right"):a.style.marginRight})}})}),f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)}),f.each({margin:"",padding:"",border:"Width"},function(a,b){f.cssHooks[a+b]={expand:function(c){var d,e=typeof c=="string"?c.split(" "):[c],f={};for(d=0;d<4;d++)f[a+bx[d]+b]=e[d]||e[d-2]||e[0];return f}}});var bC=/%20/g,bD=/\[\]$/,bE=/\r?\n/g,bF=/#.*$/,bG=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bH=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bI=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bJ=/^(?:GET|HEAD)$/,bK=/^\/\//,bL=/\?/,bM=/)<[^<]*)*<\/script>/gi,bN=/^(?:select|textarea)/i,bO=/\s+/,bP=/([?&])_=[^&]*/,bQ=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bR=f.fn.load,bS={},bT={},bU,bV,bW=["*/"]+["*"];try{bU=e.href}catch(bX){bU=c.createElement("a"),bU.href="",bU=bU.href}bV=bQ.exec(bU.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bR)return bR.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
    ").append(c.replace(bM,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bN.test(this.nodeName)||bH.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bE,"\r\n")}}):{name:b.name,value:c.replace(bE,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b$(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b$(a,b);return a},ajaxSettings:{url:bU,isLocal:bI.test(bV[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bW},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bY(bS),ajaxTransport:bY(bT),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?ca(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cb(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bG.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bF,"").replace(bK,bV[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bO),d.crossDomain==null&&(r=bQ.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bV[1]&&r[2]==bV[2]&&(r[3]||(r[1]==="http:"?80:443))==(bV[3]||(bV[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bZ(bS,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bJ.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bL.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bP,"$1_="+x);d.url=y+(y===d.url?(bL.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bW+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bZ(bT,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)b_(g,a[g],c,e);return d.join("&").replace(bC,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cc=f.now(),cd=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cc++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=typeof b.data=="string"&&/^application\/x\-www\-form\-urlencoded/.test(b.contentType);if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(cd.test(b.url)||e&&cd.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(cd,l),b.url===j&&(e&&(k=k.replace(cd,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var ce=a.ActiveXObject?function(){for(var a in cg)cg[a](0,1)}:!1,cf=0,cg;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ch()||ci()}:ch,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,ce&&delete cg[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n);try{m.text=h.responseText}catch(a){}try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cf,ce&&(cg||(cg={},f(a).unload(ce)),cg[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cj={},ck,cl,cm=/^(?:toggle|show|hide)$/,cn=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,co,cp=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cq;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(ct("show",3),a,b,c);for(var g=0,h=this.length;g=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,c){var d=/Y/.test(c);f.fn[a]=function(e){return f.access(this,function(a,e,g){var h=cy(a);if(g===b)return h?c in h?h[c]:f.support.boxModel&&h.document.documentElement[e]||h.document.body[e]:a[e];h?h.scrollTo(d?f(h).scrollLeft():g,d?g:f(h).scrollTop()):a[e]=g},a,e,arguments.length,null)}}),f.each({Height:"height",Width:"width"},function(a,c){var d="client"+a,e="scroll"+a,g="offset"+a;f.fn["inner"+a]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,c,"padding")):this[c]():null},f.fn["outer"+a]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,c,a?"margin":"border")):this[c]():null},f.fn[c]=function(a){return f.access(this,function(a,c,h){var i,j,k,l;if(f.isWindow(a)){i=a.document,j=i.documentElement[d];return f.support.boxModel&&j||i.body&&i.body[d]||j}if(a.nodeType===9){i=a.documentElement;if(i[d]>=i[e])return i[d];return Math.max(a.body[e],i[e],a.body[g],i[g])}if(h===b){k=f.css(a,c),l=parseFloat(k);return f.isNumeric(l)?l:k}f(a).css(c,h)},c,a,arguments.length,null)}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window); \ No newline at end of file diff --git a/includes/lib_cdr.php b/includes/lib_cdr.php new file mode 100644 index 0000000000..911bf39c89 --- /dev/null +++ b/includes/lib_cdr.php @@ -0,0 +1,100 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +/* +if ($db_type == "sqlite") { + try { + if (strlen($dbfilename) == 0) { + //if (strlen($_SERVER["SERVER_NAME"]) == 0) { $_SERVER["SERVER_NAME"] = "http://localhost"; } + $server_name = $_SERVER["SERVER_NAME"]; + $server_name = str_replace ("www.", "", $server_name); + $server_name = str_replace ("example.net", "example.com", $server_name); + //$server_name = str_replace (".", "_", $server_name); + $dbfilenameshort = $server_name; + $dbfilename = $server_name.'.db'; + } + else { + $dbfilenameshort = $dbfilename; + } + $db_file_path = str_replace("\\", "/", $db_file_path); + + + if (file_exists($db_file_path.'/'.$dbfilename)) { + //echo "main file exists
    "; + } + else { //file doese not exist + + //--- begin: create the sqlite db file ----------------------------------------- + $filename = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/includes/install/sql/sqlite.sql'; + $file_contents = file_get_contents($filename); + //echo "
    \n";
    +				//echo $file_contents;
    +				//echo "
    \n"; + //exit; + + //replace \r\n with \n then explode on \n + $file_contents = str_replace("\r\n", "\n", $file_contents); + + //loop line by line through all the lines of sql code + $stringarray = explode("\n", $file_contents); + $x = 0; + foreach($stringarray as $sql) { + //create the call detail records database + if (strtolower(substr($sql, 0, 18)) == "create table v_cdr") { + try { + $dbcdr = new PDO('sqlite:'.$db_file_path.'/'.$dbfilenameshort.'.cdr.db'); //sqlite 3 + $dbcdr->query($sql); + unset($dbcdr); + } + catch (PDOException $error) { + print "error: " . $error->getMessage() . "
    "; + die(); + } + } + $x++; + } + unset ($file_contents, $sql); + //--- end: create the sqlite db ----------------------------------------- + + if (is_writable($db_file_path.'/'.$dbfilename)) { //is writable + //use database in current location + } + else { //not writable + echo "The database ".$db_file_path."/".$dbfilename." is not writeable2."; + exit; + } + } + + unset($db); + //$db = new PDO('sqlite::memory:'); //sqlite 3 + $db = new PDO('sqlite:'.$db_file_path.'/'.$dbfilenameshort.'.cdr.db'); //sqlite 3 + } + catch (PDOException $error) { + print "error: " . $error->getMessage() . "
    "; + die(); + } +} +*/ +?> \ No newline at end of file diff --git a/includes/lib_functions.php b/includes/lib_functions.php new file mode 100644 index 0000000000..6b2f514232 --- /dev/null +++ b/includes/lib_functions.php @@ -0,0 +1,948 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + + if (!function_exists('software_version')) { + function software_version() { + return '3.0.4'; + } + } + + if (!function_exists('check_str')) { + function check_str($string) { + global $db_type; + //when code in db is urlencoded the ' does not need to be modified + if ($db_type == "sqlite") { + if (function_exists('sqlite_escape_string')) { + $string = sqlite_escape_string($string); + } + else { + $string = str_replace("''","'",$string); + } + } + if ($db_type == "pgsql") { + $string = pg_escape_string($string); + } + if ($db_type == "mysql") { + $tmp_str = mysql_real_escape_string($string); + if (strlen($tmp_str)) { + $string = $tmp_str; + } + else { + $search = array("\x00", "\n", "\r", "\\", "'", "\"", "\x1a"); + $replace = array("\\x00", "\\n", "\\r", "\\\\" ,"\'", "\\\"", "\\\x1a"); + $string = str_replace($search, $replace, $string); + } + } + return trim($string); //remove white space + } + } + + if (!function_exists('check_sql')) { + function check_sql($string) { + return trim($string); //remove white space + } + } + + if (!function_exists('uuid')) { + function uuid() { + //uuid version 4 + return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', + // 32 bits for "time_low" + mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), + + // 16 bits for "time_mid" + mt_rand( 0, 0xffff ), + + // 16 bits for "time_hi_and_version", + // four most significant bits holds version number 4 + mt_rand( 0, 0x0fff ) | 0x4000, + + // 16 bits, 8 bits for "clk_seq_hi_res", + // 8 bits for "clk_seq_low", + // two most significant bits holds zero and one for variant DCE1.1 + mt_rand( 0, 0x3fff ) | 0x8000, + + // 48 bits for "node" + mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) + ); + } + //echo uuid(); + } + + if (!function_exists('recursive_copy')) { + function recursive_copy($src,$dst) { + $dir = opendir($src); + if (!$dir) { + throw new Exception("recursive_copy() source directory '".$src."' does not exist."); + } + if (!is_dir($dst)) { + if (!mkdir($dst)) { + throw new Exception("recursive_copy() failed to create destination directory '".$dst."'"); + } + } + while(false !== ( $file = readdir($dir)) ) { + if (( $file != '.' ) && ( $file != '..' )) { + if ( is_dir($src . '/' . $file) ) { + recursive_copy($src . '/' . $file,$dst . '/' . $file); + } + else { + copy($src . '/' . $file,$dst . '/' . $file); + } + } + } + closedir($dir); + } + } + + if (!function_exists('if_group')) { + function if_group($group) { + //set default false + $result = false; + //search for the permission + if (count($_SESSION["groups"]) > 0) { + foreach($_SESSION["groups"] as $row) { + if ($row['group_name'] == $group) { + $result = true; + break; + } + } + } + //return the result + return $result; + } + } + + if (!function_exists('permission_exists')) { + function permission_exists($permission) { + //set default false + $result = false; + //search for the permission + if (count($_SESSION["permissions"]) > 0) { + foreach($_SESSION["permissions"] as $row) { + if ($row['permission_name'] == $permission) { + $result = true; + break; + } + } + } + //return the result + return $result; + } + } + + if (!function_exists('group_members')) { + function group_members($db, $user_uuid) { + global $domain_uuid; + $sql = "select * from v_group_users "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and user_uuid = '".$user_uuid."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + $group_members = "||"; + foreach($result as $field) { + //get the list of groups + $group_members .= $field['group_name']."||"; + } + unset($sql, $result, $row_count); + return $group_members; + } + } + + if (!function_exists('if_group_member')) { + function if_group_member($group_members, $group) { + if (stripos($group_members, "||".$group."||") === false) { + return false; //group does not exist + } + else { + return true; //group exists + } + } + } + + if (!function_exists('superadmin_list')) { + function superadmin_list($db) { + global $domain_uuid; + $sql = "select * from v_group_users "; + $sql .= "where group_name = 'superadmin' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + $superadmin_list = "||"; + foreach($result as $field) { + //get the list of superadmins + $superadmin_list .= $field['user_uuid']."||"; + } + unset($sql, $result, $row_count); + return $superadmin_list; + } + } + //superadmin_list($db); + + if (!function_exists('if_superadmin')) { + function if_superadmin($superadmin_list, $user_uuid) { + if (stripos($superadmin_list, "||".$user_uuid."||") === false) { + return false; //user_uuid does not exist + } + else { + return true; //user_uuid exists + } + } + } + + if (!function_exists('html_select_other')) { + function html_select_other($db, $table_name, $field_name, $sql_where_optional, $field_current_value) { + //html select other : build a select box from distinct items in db with option for other + global $domain_uuid; + + $html = "
    \n"; + $html .= "\n"; + $html .= "\n"; + $html .= "\n"; + $html .= "\n"; + $html .= "
    \n"; + $html .= "\n"; + $html .= "\n"; + $html .= "\n"; + $html .= "\n"; + $html .= "
    "; + + return $html; + } + } + + if (!function_exists('html_select')) { + function html_select($db, $table_name, $field_name, $sql_where_optional, $field_current_value, $field_value = '', $style = '') { + //html select other : build a select box from distinct items in db with option for other + global $domain_uuid; + + if (strlen($field_value) > 0) { + $html .= "\n"; + $html .= "\n"; + $sql = "SELECT distinct($field_name) as $field_name FROM $table_name $sql_where_optional "; + } + + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + if ($result_count > 0) { //if user account exists then show login + foreach($result as $field) { + if (strlen($field[$field_name]) > 0) { + if ($field_current_value == $field[$field_name]) { + if (strlen($field_value) > 0) { + $html .= "\n"; + } + else { + $html .= "\n"; + } + } + else { + if (strlen($field_value) > 0) { + $html .= "\n"; + } + else { + $html .= "\n"; + } + } + } + } + } + unset($sql, $result, $result_count); + $html .= "\n"; + + return $html; + } + } + //$table_name = 'v_templates'; $field_name = 'templatename'; $sql_where_optional = "where domain_uuid = '$domain_uuid' "; $field_current_value = ''; + //echo html_select($db, $table_name, $field_name, $sql_where_optional, $field_current_value); + + if (!function_exists('html_select_on_change')) { + function html_select_on_change($db, $table_name, $field_name, $sql_where_optional, $field_current_value, $onchange, $field_value = '') { + //html select other : build a select box from distinct items in db with option for other + global $domain_uuid; + + $html .= "\n"; + + return $html; + } + } + + if (!function_exists('th_order_by')) { + //html table header order by + function th_order_by($field_name, $columntitle, $order_by, $order) { + + $html = "    "; + if (strlen($order_by)==0) { + $html .= "$columntitle"; + } + else { + if ($order=="asc") { + $html .= "$columntitle"; + } + else { + $html .= "$columntitle"; + } + } + $html .= "    "; + return $html; + } + } + ////example usage + //$table_name = 'tblcontacts'; $field_name = 'contactcategory'; $sql_where_optional = "", $field_current_value =''; + //echo html_select_other($db, $table_name, $field_name, $sql_where_optional, $field_current_value); + //// On the page that recieves the POST + //if (check_str($_POST["contactcategory"]) == "Other") { //echo "found: ".$contactcategory; + // $contactcategory = check_str($_POST["contactcategoryother"]); + //} + + if (!function_exists('log_add')) { + function log_add($db, $log_type, $log_status, $log_desc, $log_add_user, $log_add_user_ip) { + return; //this disables the function + global $domain_uuid; + + $sql = "insert into logs "; + $sql .= "("; + $sql .= "log_type, "; + $sql .= "log_status, "; + $sql .= "log_desc, "; + $sql .= "log_add_user, "; + $sql .= "log_add_user_ip, "; + $sql .= "log_add_date "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$log_type', "; + $sql .= "'$log_status', "; + $sql .= "'$log_desc', "; + $sql .= "'$log_add_user', "; + $sql .= "'$log_add_user_ip', "; + $sql .= "now() "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + } + //$log_type = ''; $log_status=''; $log_add_user=''; $log_desc=''; + //log_add($db, $log_type, $log_status, $log_desc, $log_add_user, $_SERVER["REMOTE_ADDR"]); + + if (!function_exists('get_ext')) { + function get_ext($filename) { + preg_match('/[^?]*/', $filename, $matches); + $string = $matches[0]; + + $pattern = preg_split('/\./', $string, -1, PREG_SPLIT_OFFSET_CAPTURE); + + // check if there is any extension + if(count($pattern) == 1){ + //echo 'No File Extension Present'; + return ''; + } + + if(count($pattern) > 1) { + $filenamepart = $pattern[count($pattern)-1][0]; + preg_match('/[^?]*/', $filenamepart, $matches); + return $matches[0]; + } + } + //echo "ext: ".get_ext('test.txt'); + } + + if (!function_exists('file_upload')) { + function file_upload($field = '', $file_type = '', $dest_dir = '') { + + $uploadtempdir = $_ENV["TEMP"]."\\"; + ini_set('upload_tmp_dir', $uploadtempdir); + + $tmp_name = $_FILES[$field]["tmp_name"]; + $file_name = $_FILES[$field]["name"]; + $file_type = $_FILES[$field]["type"]; + $file_size = $_FILES[$field]["size"]; + $file_ext = get_ext($file_name); + $file_name_orig = $file_name; + $file_name_base = substr($file_name, 0, (strlen($file_name) - (strlen($file_ext)+1))); + //$dest_dir = '/tmp'; + + if ($file_size == 0){ + return; + } + + if (!is_dir($dest_dir)) { + echo "dest_dir not found
    \n"; + return; + } + + //check if allowed file type + if ($file_type == "img") { + switch (strtolower($file_ext)) { + case "jpg": + break; + case "png": + break; + case "gif": + break; + case "bmp": + break; + case "psd": + break; + case "tif": + break; + default: + return false; + } + } + if ($file_type == "file") { + switch (strtolower($file_ext)) { + case "doc": + break; + case "pdf": + break; + case "ppt": + break; + case "xls": + break; + case "zip": + break; + case "exe": + break; + default: + return false; + } + } + + //find unique filename: check if file exists if it does then increment the filename + $i = 1; + while( file_exists($dest_dir.'/'.$file_name)) { + if (strlen($file_ext)> 0) { + $file_name = $file_name_base . $i .'.'. $file_ext; + } + else { + $file_name = $file_name_orig . $i; + } + $i++; + } + + //echo "file_type: ".$file_type."
    \n"; + //echo "tmp_name: ".$tmp_name."
    \n"; + //echo "file_name: ".$file_name."
    \n"; + //echo "file_ext: ".$file_ext."
    \n"; + //echo "file_name_orig: ".$file_name_orig."
    \n"; + //echo "file_name_base: ".$file_name_base."
    \n"; + //echo "dest_dir: ".$dest_dir."
    \n"; + + //move the file to upload directory + //bool move_uploaded_file ( string $filename, string $destination ) + + if (move_uploaded_file($tmp_name, $dest_dir.'/'.$file_name)){ + return $file_name; + } + else { + echo "File upload failed! Here's some debugging info:\n"; + return false; + } + exit; + + } //end function + } + + if ( !function_exists('sys_get_temp_dir')) { + function sys_get_temp_dir() { + if( $temp=getenv('TMP') ) return $temp; + if( $temp=getenv('TEMP') ) return $temp; + if( $temp=getenv('TMPDIR') ) return $temp; + $temp=tempnam(__FILE__,''); + if (file_exists($temp)) { + unlink($temp); + return dirname($temp); + } + return null; + } + } + //echo realpath(sys_get_temp_dir()); + + if (!function_exists('username_exists')) { + function username_exists($username) { + global $db, $domain_uuid; + $sql = "select * from v_users "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and username = '".$username."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + if ($result_count > 0) { + return true; + } + else { + return false; + } + } + } + + if (!function_exists('add_extension_user')) { + function add_extension_user($extension_uuid, $username) { + global $db, $domain_uuid; + //get the user_uuid by using the username + $sql = "select * from v_users "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and username = '$username' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset($prep_statement); + foreach ($result as &$row) { + //check if the user_uuid exists in v_extension_users + $sql = "select * from v_extension_users "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and user_uuid = '".$row["user_uuid"]."' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $extension_users_result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset($prep_statement); + //assign the extension to the user + if (count($extension_users_result) == 0) { + $sql = "insert into v_extension_users "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "extension_uuid, "; + $sql .= "user_uuid "; + $sql .= ") "; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$extension_uuid', "; + $sql .= "'".$row["user_uuid"]."' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } + } + unset ($result); + } + } + + if (!function_exists('user_add')) { + function user_add($username, $password, $user_email='') { + global $db, $domain_uuid, $v_salt; + $user_uuid = uuid(); + if (strlen($username) == 0) { return false; } + if (strlen($password) == 0) { return false; } + if (!username_exists($username)) { + //salt used with the password to create a one way hash + $salt = generate_password('20', '4'); + //add the user account + $user_type = 'Individual'; + $user_category = 'user'; + $sql = "insert into v_users "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "user_uuid, "; + $sql .= "username, "; + $sql .= "password, "; + $sql .= "salt, "; + if (strlen($user_email) > 0) { $sql .= "user_email, "; } + $sql .= "user_add_date, "; + $sql .= "user_add_user "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$user_uuid', "; + $sql .= "'$username', "; + $sql .= "'".md5($salt.$password)."', "; + $sql .= "'$salt', "; + if (strlen($user_email) > 0) { $sql .= "'$user_email', "; } + $sql .= "now(), "; + $sql .= "'".$_SESSION["username"]."' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + //add the user to the member group + $group_name = 'user'; + $sql = "insert into v_group_users "; + $sql .= "("; + $sql .= "group_user_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "group_name, "; + $sql .= "user_uuid "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$domain_uuid', "; + $sql .= "'$group_name', "; + $sql .= "'$user_uuid' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } //end if !username_exists + } //end function definition + } //end function_exists + +function switch_module_is_running($fp, $mod) { + if (!$fp) { + //if the handle does not exist create it + $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); + //if the handle still does not exist show an error message + if (!$fp) { + $msg = "
    Connection to Event Socket failed.
    "; + } + } + if ($fp) { + //send the api command to check if the module exists + $switchcmd = "module_exists $mod"; + $switch_result = event_socket_request($fp, 'api '.$switchcmd); + unset($switchcmd); + if (trim($switch_result) == "true") { + return true; + } + else { + return false; + } + } + else { + return false; + } +} +//switch_module_is_running('mod_spidermonkey'); + +//format a number (n) replace with a number (r) remove the number +function format_string ($format, $data) { + $x=0; + $tmp = ''; + for ($i = 0; $i <= strlen($format); $i++) { + $tmp_format = strtolower(substr($format, $i, 1)); + if ($tmp_format == 'x') { + $tmp .= substr($data, $x, 1); + $x++; + } + elseif ($tmp_format == 'r') { + $x++; + } + else { + $tmp .= $tmp_format; + } + } + return $tmp; +} + +//get the format and use it to format the phone number + function format_phone($phone_number) { + if (strlen($_SESSION["format_phone_array"]) == 0) { + $_SESSION["format_phone_array"] = ""; //clear the menu + global $domain_uuid, $db; + $sql = "select * from v_vars "; + $sql .= "where var_name = 'format_phone' "; + $sql .= "and var_enabled = 'true' "; + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $_SESSION["format_phone_array"][] = $row["var_value"]; + } + unset ($prep_statement); + } + } + foreach ($_SESSION["format_phone_array"] as &$format) { + $format_count = substr_count($format, 'x'); + $format_count = $format_count + substr_count($format, 'R'); + if ($format_count == strlen($phone_number)) { + //format the number + $phone_number = format_string($format, $phone_number); + } + } + return $phone_number; + } + +//browser detection without browscap.ini dependency + function http_user_agent() { + $u_agent = $_SERVER['HTTP_USER_AGENT']; + $bname = 'Unknown'; + $platform = 'Unknown'; + $version= ""; + + //get the platform? + if (preg_match('/linux/i', $u_agent)) { + $platform = 'linux'; + } + elseif (preg_match('/macintosh|mac os x/i', $u_agent)) { + $platform = 'mac'; + } + elseif (preg_match('/windows|win32/i', $u_agent)) { + $platform = 'windows'; + } + + //get the name of the useragent yes seperately and for good reason + if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent)) + { + $bname = 'Internet Explorer'; + $ub = "MSIE"; + } + elseif(preg_match('/Firefox/i',$u_agent)) + { + $bname = 'Mozilla Firefox'; + $ub = "Firefox"; + } + elseif(preg_match('/Chrome/i',$u_agent)) + { + $bname = 'Google Chrome'; + $ub = "Chrome"; + } + elseif(preg_match('/Safari/i',$u_agent)) + { + $bname = 'Apple Safari'; + $ub = "Safari"; + } + elseif(preg_match('/Opera/i',$u_agent)) + { + $bname = 'Opera'; + $ub = "Opera"; + } + elseif(preg_match('/Netscape/i',$u_agent)) + { + $bname = 'Netscape'; + $ub = "Netscape"; + } + + //finally get the correct version number + $known = array('Version', $ub, 'other'); + $pattern = '#(?' . join('|', $known) . + ')[/ ]+(?[0-9.|a-zA-Z.]*)#'; + if (!preg_match_all($pattern, $u_agent, $matches)) { + // we have no matching number just continue + } + + // see how many we have + $i = count($matches['browser']); + if ($i != 1) { + //we will have two since we are not using 'other' argument yet + //see if version is before or after the name + if (strripos($u_agent,"Version") < strripos($u_agent,$ub)){ + $version= $matches['version'][0]; + } + else { + $version= $matches['version'][1]; + } + } + else { + $version= $matches['version'][0]; + } + + // check if we have a number + if ($version==null || $version=="") {$version="?";} + + return array( + 'userAgent' => $u_agent, + 'name' => $bname, + 'version' => $version, + 'platform' => $platform, + 'pattern' => $pattern + ); + } + +//tail php function for non posix systems + function tail($file, $num_to_get=10) { + $fp = fopen($file, 'r'); + $position = filesize($file); + $chunklen = 4096; + if($position-$chunklen<=0) { + fseek($fp,0); + } + else { + fseek($fp, $position-$chunklen); + } + $data="";$ret="";$lc=0; + while($chunklen > 0) + { + $data = fread($fp, $chunklen); + $dl=strlen($data); + for($i=$dl-1;$i>=0;$i--){ + if($data[$i]=="\n"){ + if($lc==0 && $ret!="")$lc++; + $lc++; + if($lc>$num_to_get)return $ret; + } + $ret=$data[$i].$ret; + } + if($position-$chunklen<=0){ + fseek($fp,0); + $chunklen=$chunklen-abs($position-$chunklen); + }else fseek($fp, $position-$chunklen); + $position = $position - $chunklen; + } + fclose($fp); + return $ret; + } + +//generate a random password with upper, lowercase and symbols + function generate_password($length = 10, $strength = 4) { + $password = ''; + $charset = ''; + if ($strength >= 1) { $charset .= "0123456789"; } + if ($strength >= 2) { $charset .= "abcdefghijkmnopqrstuvwxyz"; } + if ($strength >= 3) { $charset .= "ABCDEFGHIJKLMNPQRSTUVWXYZ"; } + if ($strength >= 4) { $charset .= "!!!!!^$%*?....."; } + srand((double)microtime() * rand(1000000, 9999999)); + while ($length > 0) { + $password.= $charset[rand(0, strlen($charset)-1)]; + $length--; + } + return $password; + } + //echo generate_password(4, 4); + +//based on Wez Furlong do_post_request + if (!function_exists('send_http_request')) { + function send_http_request($url, $data, $method = "POST", $optional_headers = null) { + $params = array('http' => array( + 'method' => $method, + 'content' => $data + )); + if ($optional_headers !== null) { + $params['http']['header'] = $optional_headers; + } + $ctx = stream_context_create($params); + $fp = @fopen($url, 'rb', false, $ctx); + if (!$fp) { + throw new Exception("Problem with $url, $php_errormsg"); + } + $response = @stream_get_contents($fp); + if ($response === false) { + throw new Exception("Problem reading data from $url, $php_errormsg"); + } + return $response; + } + } + +//convert the string to a named array + if(!function_exists('csv_to_named_array')) { + function csv_to_named_array($tmp_str, $tmp_delimiter) { + $tmp_array = explode ("\n", $tmp_str); + $result = ''; + if (trim(strtoupper($tmp_array[0])) != "+OK") { + $tmp_field_name_array = explode ($tmp_delimiter, $tmp_array[0]); + $x = 0; + foreach ($tmp_array as $row) { + if ($x > 0) { + $tmp_field_value_array = explode ($tmp_delimiter, $tmp_array[$x]); + $y = 0; + foreach ($tmp_field_value_array as $tmp_value) { + $tmp_name = $tmp_field_name_array[$y]; + if (trim(strtoupper($tmp_value)) != "+OK") { + $result[$x][$tmp_name] = $tmp_value; + } + $y++; + } + } + $x++; + } + unset($row); + } + return $result; + } + } + +function get_time_zone_offset($remote_tz, $origin_tz = 'UTC') { + $origin_dtz = new DateTimeZone($origin_tz); + $remote_dtz = new DateTimeZone($remote_tz); + $origin_dt = new DateTime("now", $origin_dtz); + $remote_dt = new DateTime("now", $remote_dtz); + $offset = $remote_dtz->getOffset($remote_dt) - $origin_dtz->getOffset($origin_dt); + return $offset; +} + +function number_pad($number,$n) { + return str_pad((int) $number,$n,"0",STR_PAD_LEFT); +} + +?> \ No newline at end of file diff --git a/includes/lib_pdo.php b/includes/lib_pdo.php new file mode 100644 index 0000000000..2cecab0678 --- /dev/null +++ b/includes/lib_pdo.php @@ -0,0 +1,374 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane + Raymond Chandler + */ +include "root.php"; +require_once "includes/lib_functions.php"; + +//set defaults + if (isset($dbtype) > 0) { + $db_type = $dbtype; + } + if (isset($dbhost) > 0) { + $db_host = $dbhost; + } + if (isset($dbport) > 0) { + $db_port = $dbport; + } + if (isset($dbname) > 0) { + $db_name = $dbname; + } + if (isset($dbusername) > 0) { + $db_username = $dbusername; + } + if (isset($dbpassword) > 0) { + $db_password = $dbpassword; + } + if (isset($db_file_path) > 0) { + $db_path = $db_file_path; + } + if (isset($dbfilename) > 0) { + $db_name = $dbfilename; + } + +if (!function_exists('get_db_field_names')) { + function get_db_field_names($db, $table, $db_name='fusionpbx') { + $query = sprintf('SELECT * FROM %s LIMIT 1', $table); + foreach ($db->query($query, PDO::FETCH_ASSOC) as $row) { + return array_keys($row); + } + + // if we're still here, we need to try something else + $fields = array(); + $driver = $db->getAttribute(PDO::ATTR_DRIVER_NAME); + if ($driver == 'sqlite') { + $query = sprintf("Pragma table_info(%s);", $table); + $stmt = $db->prepare($query); + $result = $stmt->execute(); + $rows = $stmt->fetchAll(PDO::FETCH_NAMED); + //printf('
    %s
    ', print_r($rows, true)); + $row_count = count($rows); + //printf('
    %s
    ', print_r($rows, true)); + for ($i = 0; $i < $row_count; $i++) { + array_push($fields, $rows[$i]['name']); + } + return $fields; + } else { + $query = sprintf("SELECT * FROM information_schema.columns + WHERE table_schema='%s' AND table_name='%s';" + , $db_name, $table + ); + $stmt = $db->prepare($query); + $result = $stmt->execute(); + $rows = $stmt->fetchAll(PDO::FETCH_NAMED); + $row_count = count($rows); + //printf('
    %s
    ', print_r($rows, true)); + for ($i = 0; $i < $row_count; $i++) { + array_push($fields, $rows[$i]['COLUMN_NAME']); + } + return $fields; + } + } +} + +if ($db_type == "sqlite") { + //prepare the database connection + if (strlen($db_name) == 0) { + //if (strlen($_SERVER["SERVER_NAME"]) == 0) { $_SERVER["SERVER_NAME"] = "http://localhost"; } + $server_name = $_SERVER["SERVER_NAME"]; + $server_name = str_replace ("www.", "", $server_name); + //$server_name = str_replace (".", "_", $server_name); + $db_name_short = $server_name; + $db_name = $server_name.'.db'; + } + else { + $db_name_short = $db_name; + } + + $filepath = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure'; + $db_path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/secure'; + $db_path = realpath($db_path); + if (file_exists($db_path.'/'.$db_name)) { + //echo "database file exists
    "; + } + else { + if (is_writable($db_path.'/'.$db_name)) { + //use database in current location + } + else { //not writable + echo "The database ".$db_path."/".$db_name." does not exist or is not writable."; + exit; + } + } + + if (!function_exists('php_md5')) { + function php_md5($string) { + return md5($string); + } + } + if (!function_exists('php_unix_timestamp')) { + function php_unix_timestamp($string) { + return strtotime($string); + } + } + if (!function_exists('php_now')) { + function php_now() { + return date("Y-m-d H:i:s"); + } + } + if (!function_exists('php_left')) { + function php_left($string, $num) { + return substr($string, 0, $num); + } + } + if (!function_exists('php_right')) { + function php_right($string, $num) { + return substr($string, (strlen($string)-$num), strlen($string)); + } + } + + //database connection + try { + //create the database connection object + //$db = new PDO('sqlite2:example.db'); //sqlite 2 + //$db = new PDO('sqlite::memory:'); //sqlite 3 + $db = new PDO('sqlite:'.$db_path.'/'.$db_name); //sqlite 3 + //enable foreign key constraints + $db->query('PRAGMA foreign_keys = ON;'); + //add additional functions to SQLite so that they are accessible inside SQL + //bool PDO::sqliteCreateFunction ( string function_name, callback callback [, int num_args] ) + $db->sqliteCreateFunction('md5', 'php_md5', 1); + $db->sqliteCreateFunction('unix_timestamp', 'php_unix_timestamp', 1); + $db->sqliteCreateFunction('now', 'php_now', 0); + $db->sqliteCreateFunction('sqlitedatatype', 'phpsqlitedatatype', 2); + $db->sqliteCreateFunction('strleft', 'php_left', 2); + $db->sqliteCreateFunction('strright', 'php_right', 2); + } + catch (PDOException $error) { + print "error: " . $error->getMessage() . "
    "; + die(); + } +} //end if db_type sqlite + + +if ($db_type == "mysql") { + //database connection + try { + //required for mysql_real_escape_string + if (function_exists(mysql_connect)) { + $mysql_connection = mysql_connect($db_host, $db_username, $db_password); + } + //mysql pdo connection + if (strlen($db_host) == 0 && strlen($db_port) == 0) { + //if both host and port are empty use the unix socket + $db = new PDO("mysql:host=$db_host;unix_socket=/var/run/mysqld/mysqld.sock;dbname=$db_name", $db_username, $db_password); + } + else { + if (strlen($db_port) == 0) { + //leave out port if it is empty + $db = new PDO("mysql:host=$db_host;dbname=$db_name;", $db_username, $db_password, array( + PDO::ATTR_ERRMODE, + PDO::ERRMODE_EXCEPTION + )); + } + else { + $db = new PDO("mysql:host=$db_host;port=$db_port;dbname=$db_name;", $db_username, $db_password, array( + PDO::ATTR_ERRMODE, + PDO::ERRMODE_EXCEPTION + )); + } + } + } + catch (PDOException $error) { + print "error: " . $error->getMessage() . "
    "; + die(); + } +} //end if db_type mysql + + +if ($db_type == "pgsql") { + //database connection + try { + if (strlen($db_host) > 0) { + if (strlen($db_port) == 0) { $db_port = "5432"; } + $db = new PDO("pgsql:host=$db_host port=$db_port dbname=$db_name user=$db_username password=$db_password"); + } + else { + $db = new PDO("pgsql:dbname=$db_name user=$db_username password=$db_password"); + } + } + catch (PDOException $error) { + print "error: " . $error->getMessage() . "
    "; + die(); + } +} //end if db_type pgsql + +//domain list + if (strlen($_SESSION["domain_uuid"]) == 0) { + //get the domain + $domain_array = explode(":", $_SERVER["HTTP_HOST"]); + //get the domain_uuid + $sql = "select * from v_domains "; + $sql .= "order by domain_name asc "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach($result as $row) { + if (count($result) == 1) { + $_SESSION["domain_uuid"] = $row["domain_uuid"]; + $_SESSION["domain_name"] = $row['domain_name']; + } + else { + if ($row['domain_name'] == $domain_array[0] || $row['domain_name'] == 'www.'.$domain_array[0]) { + $_SESSION["domain_uuid"] = $row["domain_uuid"]; + $_SESSION["domain_name"] = $row["domain_name"]; + } + } + $_SESSION['domains'][$row['domain_uuid']]['domain_uuid'] = $row['domain_uuid']; + $_SESSION['domains'][$row['domain_uuid']]['domain_name'] = $row['domain_name']; + } + unset($result, $prep_statement); + } + +//get the session settings + if (!isset($_SESSION['domain']['menu'])) { + //get the default settings + $sql = "select * from v_default_settings "; + $sql .= "where default_setting_enabled = 'true' "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach($result as $row) { + $name = $row['default_setting_name']; + $category = $row['default_setting_category']; + $subcategory = $row['default_setting_subcategory']; + if (strlen($subcategory) == 0) { + $_SESSION[$category][$name] = $row['default_setting_value']; + } + else { + $_SESSION[$category][$subcategory][$name] = $row['default_setting_value']; + } + } + + //get the domains settings + $sql = "select * from v_domain_settings "; + $sql .= "where domain_uuid = '".$_SESSION["domain_uuid"]."' "; + $sql .= "and domain_setting_enabled = 'true' "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach($result as $row) { + $name = $row['domain_setting_name']; + $category = $row['domain_setting_category']; + $subcategory = $row['domain_setting_subcategory']; + if (strlen($subcategory) == 0) { + //$$category[$name] = $row['domain_setting_value']; + $_SESSION[$category][$name] = $row['domain_setting_value']; + } + else { + //$$category[$subcategory][$name] = $row['domain_setting_value']; + $_SESSION[$category][$subcategory][$name] = $row['domain_setting_value']; + } + } + + //get the user settings + $sql = "select * from v_user_settings "; + $sql .= "where domain_uuid = '".$_SESSION["domain_uuid"]."' "; + $sql .= "and user_uuid = '".$_SESSION["user_uuid"]."' "; + $sql .= "and user_setting_enabled = 'true' "; + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach($result as $row) { + $name = $row['user_setting_name']; + $category = $row['user_setting_category']; + $subcategory = $row['user_setting_subcategory']; + if (strlen($subcategory) == 0) { + //$$category[$name] = $row['domain_setting_value']; + $_SESSION[$category][$name] = $row['user_setting_value']; + } + else { + //$$category[$subcategory][$name] = $row['domain_setting_value']; + $_SESSION[$category][$subcategory][$name] = $row['user_setting_value']; + } + } + } + + //set the values from the session variables + if (strlen($_SESSION['domain']['time_zone']['name']) > 0) { + //server time zone + $_SESSION['time_zone']['system'] = date_default_timezone_get(); + //domain time zone set in system settings + $_SESSION['time_zone']['domain'] = $_SESSION['domain']['time_zone']['name']; + //set the domain time zone as the default time zone + date_default_timezone_set($_SESSION['domain']['time_zone']['name']); + } + + //set the context + if (strlen($_SESSION["context"]) == 0) { + if (count($_SESSION["domains"]) > 1) { + $_SESSION["context"] = $_SESSION["domain_name"]; + } + else { + $_SESSION["context"] = 'default'; + } + } + } + +//recordings add the domain to the path if there is more than one domains + if (count($_SESSION["domains"]) > 1) { + if (strlen($_SESSION['switch']['recordings']['dir']) > 0) { + if (substr($_SESSION['switch']['recordings']['dir'], -strlen($_SESSION["domain_name"])) != $_SESSION["domain_name"]) { + //get the default recordings directory + $sql = "select * from v_default_settings "; + $sql .= "where default_setting_enabled = 'true' "; + $sql .= "and default_setting_category = 'switch' "; + $sql .= "and default_setting_subcategory = 'recordings' "; + $sql .= "and default_setting_name = 'dir' "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + $result_default_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach($result_default_settings as $row) { + $name = $row['default_setting_name']; + $category = $row['default_setting_category']; + $subcategory = $row['default_setting_subcategory']; + $switch_recordings_dir = $row['default_setting_value']; + } + //add the domain + $_SESSION['switch']['recordings']['dir'] = $switch_recordings_dir.'/'.$_SESSION["domain_name"]; + } + } + } + +//set the domain_uuid variable from the session + if (strlen($_SESSION["domain_uuid"]) > 0) { + $domain_uuid = $_SESSION["domain_uuid"]; + } + else { + $domain_uuid = uuid(); + } + +?> \ No newline at end of file diff --git a/includes/lib_pdo_vm.php b/includes/lib_pdo_vm.php new file mode 100644 index 0000000000..e5b75d4120 --- /dev/null +++ b/includes/lib_pdo_vm.php @@ -0,0 +1,69 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require "includes/require.php"; + +//get the contents of xml_cdr.conf.xml + $conf_xml_string = file_get_contents($_SESSION['switch']['conf']['dir'].'/autoload_configs/voicemail.conf.xml'); + +//parse the xml to get the call detail record info + try { + $conf_xml = simplexml_load_string($conf_xml_string); + } + catch(Exception $e) { + echo $e->getMessage(); + } + +//define variables + $odbc_dsn = ''; + $odbc_db_user = ''; + $odbc_db_pass = ''; + +//find the odbc info + foreach ($conf_xml->profiles->profile->param as $row) { + if ($row->attributes()->name == "odbc-dsn") { + $odbc_array = explode(":", $row->attributes()->value); + $odbc_dsn = $odbc_array[0]; + $odbc_db_user = $odbc_array[1]; + $odbc_db_pass = $odbc_array[2]; + } + } + +//database connection + try { + unset($db); + if (strlen($odbc_dsn) == 0) { + $db = new PDO('sqlite:'.$_SESSION['switch']['db']['dir'].'/voicemail_default.db'); //sqlite 3 + } + else { + $db = new PDO("odbc:$odbc_dsn", "$odbc_db_user", "$odbc_db_pass"); + } + } + catch (PDOException $e) { + echo 'Connection failed: ' . $e->getMessage(); + } + + ?> \ No newline at end of file diff --git a/includes/lib_php.php b/includes/lib_php.php new file mode 100644 index 0000000000..e6b2366ba6 --- /dev/null +++ b/includes/lib_php.php @@ -0,0 +1,67 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + //error_reporting(E_ALL ^ E_NOTICE); //hide notices + error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ); //hide notices and warnings + //error_reporting(E_ALL); + + //session handling + //start the session + session_start(); + //set the last activity time stamp + $_SESSION['session']['last_activity'] = time(); + //check whether to timout the session + //if (isset($_SESSION['session']['last_activity']) && (time() - $_SESSION['session']['last_activity'] > 14400)) { + // session_destroy(); // destroy session data in storage + // session_unset(); // unset $_SESSION variable for the runtime + //} + //regenerate sessions to avoid session id attacks such as session fixation + if (!isset($_SESSION['session']['created'])) { + $_SESSION['session']['created'] = time(); + } else if (time() - $_SESSION['session']['created'] > 1800) { + // session started more than 30 minutes ago + session_regenerate_id(true); // rotate the session id + $_SESSION['session']['created'] = time(); // update creation time + } + + //get the document_root parent directory + $document_root_parent = join(array_slice(explode("\\",realpath($_SERVER["DOCUMENT_ROOT"])),0,-1), '/'); + + //if magic quotes is enabled remove the slashes + if (get_magic_quotes_gpc()) { + $in = array(&$_GET, &$_POST, &$_REQUEST, &$_COOKIE); + while (list($k,$v) = each($in)) { + foreach ($v as $key => $val) { + if (!is_array($val)) { + $in[$k][$key] = stripslashes($val); + continue; + } + $in[] =& $in[$k][$key]; + } + } + unset($in); + } + +?> diff --git a/includes/lib_schema.php b/includes/lib_schema.php new file mode 100644 index 0000000000..cb0025a564 --- /dev/null +++ b/includes/lib_schema.php @@ -0,0 +1,584 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +//require_once "includes/require.php"; +//require_once "includes/classes/database.php"; +//$db = new database; +//$db->db = $db; +//$db->db_type = $db_type; +//$db->add(); + +function db_table_exists_alternate ($db, $db_type, $table_name) { + $sql = "select count(*) from $table_name "; + $result = $db->query($sql); + if ($result > 0) { + return true; //table exists + } + else { + return false; //table doesn't exist + } +} + +function db_table_exists ($db, $db_type, $db_name, $table_name) { + $sql = ""; + if ($db_type == "sqlite") { + $sql .= "SELECT * FROM sqlite_master WHERE type='table' and name='$table_name' "; + } + if ($db_type == "pgsql") { + $sql .= "select * from pg_tables where schemaname='public' and tablename = '$table_name' "; + } + if ($db_type == "mysql") { + $sql .= "SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = '$db_name' and TABLE_NAME = '$table_name' "; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + if (count($result) > 0) { + return true; //table exists + } + else { + return false; //table doesn't exist + } +} + +function db_table_info($db, $db_name, $db_type, $table_name) { + if (strlen($table_name) == 0) { return false; } + if ($db_type == "sqlite") { + $sql = "PRAGMA table_info(".$table_name.");"; + } + if ($db_type == "pgsql") { + $sql = "SELECT ordinal_position, "; + $sql .= "column_name, "; + $sql .= "data_type, "; + $sql .= "column_default, "; + $sql .= "is_nullable, "; + $sql .= "character_maximum_length, "; + $sql .= "numeric_precision "; + $sql .= "FROM information_schema.columns "; + $sql .= "WHERE table_name = '".$table_name."' "; + $sql .= "and table_catalog = '".$db_name."' "; + $sql .= "ORDER BY ordinal_position; "; + } + if ($db_type == "mysql") { + $sql = "describe ".$table_name.";"; + } + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + return $prep_statement->fetchAll(PDO::FETCH_ASSOC); +} + +function db_data_type($db_type, $table_info, $column_name) { + if ($db_type == "sqlite") { + foreach ($table_info as $key => &$row) { + if ($row['name'] == $column_name) { + return $row['type']; + } + } + } + if ($db_type == "pgsql") { + foreach ($table_info as $key => &$row) { + if ($row['column_name'] == $column_name) { + return $row['data_type']; + } + } + } + if ($db_type == "mysql") { + foreach ($table_info as $key => &$row) { + if ($row['Field'] == $column_name) { + return $row['Type']; + } + } + } +} + +function db_sqlite_column_exists($table_info, $column_name) { + foreach ($table_info as $key => &$row) { + if ($row['name'] == $column_name) { + return true; + } + } + return $false; +} + +function db_column_exists ($db, $db_type, $db_name, $table_name, $column_name) { + global $display_type; + + if ($db_type == "sqlite") { + $table_info = db_table_info($db, $db_name, $db_type, $table_name); + if (db_sqlite_column_exists($table_info, $column_name)) { + return true; + } + else { + return false; + } + } + if ($db_type == "pgsql") { + $sql = "SELECT attname FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = '$table_name') AND attname = '$column_name'; "; + } + if ($db_type == "mysql") { + //$sql .= "SELECT * FROM information_schema.COLUMNS where TABLE_SCHEMA = '$db_name' and TABLE_NAME = '$table_name' and COLUMN_NAME = '$column_name' "; + $sql = "show columns from $table_name where field = '$column_name' "; + } + if ($sql) { + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + if (!$result) { + return false; + } + if (count($result) > 0) { + return true; + } + else { + return false; + } + unset ($prep_statement); + } +} + +function db_column_data_type ($db, $db_type, $db_name, $table_name, $column_name) { + $table_info = db_table_info($db, $db_name, $db_type, $table_name); + return db_data_type($db_type, $table_info, $column_name); +} + +function db_create_table ($apps, $db_type, $table) { + foreach ($apps as $x => &$app) { + foreach ($app['db'] as $y => $row) { + if ($row['table'] == $table) { + $sql = "CREATE TABLE " . $row['table'] . " (\n"; + $field_count = 0; + foreach ($row['fields'] as $field) { + if ($field['deprecated'] == "true") { + //skip this row + } + else { + if ($field_count > 0 ) { $sql .= ",\n"; } + if (is_array($field['name'])) { + $sql .= $field['name']['text'] . " "; + } + else { + $sql .= $field['name'] . " "; + } + if (is_array($field['type'])) { + $sql .= $field['type'][$db_type]; + } + else { + $sql .= $field['type']; + } + $field_count++; + } + } + $sql .= ");\n\n"; + return $sql; + } + } + } +} + +function db_insert_into ($apps, $db_type, $table) { + foreach ($apps as $x => &$app) { + foreach ($app['db'] as $y => $row) { + if ($row['table'] == $table) { + $sql = "INSERT INTO " . $row['table'] . " ("; + $field_count = 0; + foreach ($row['fields'] as $field) { + if ($field['deprecated'] == "true") { + //skip this field + } + else { + if ($field_count > 0 ) { $sql .= ","; } + if (is_array($field['name'])) { + $sql .= $field['name']['text']; + } + else { + $sql .= $field['name']; + } + $field_count++; + } + } + $sql .= ")\n"; + $sql .= "SELECT "; + $field_count = 0; + foreach ($row['fields'] as $field) { + if ($field['deprecated'] == "true") { + //skip this field + } + else { + if ($field_count > 0 ) { $sql .= ","; } + if (is_array($field['name'])) { + if ($field['exists'] == "false") { + $sql .= $field['name']['deprecated']; + } + else { + $sql .= $field['name']['text']; + } + } + else { + $sql .= $field['name']; + } + $field_count++; + } + } + $sql .= " FROM tmp_".$row['table'].";\n\n"; + return $sql; + } + } + } +} + +function db_upgrade_schema ($db, $db_type, $db_name, $display_results) { + global $display_type; + + //PHP PDO check if table or column exists + //check if table exists + // SELECT * FROM sqlite_master WHERE type='table' AND name='v_cdr' + //check if column exists + // SELECT * FROM sqlite_master WHERE type='table' AND name='v_cdr' AND sql LIKE '%caller_id_name TEXT,%' + //aditional information + // http://www.sqlite.org/faq.html#q9 + + //postgresql + //list all tables in the database + // SELECT table_name FROM pg_tables WHERE schemaname='public'; + //check if table exists + // SELECT * FROM pg_tables WHERE schemaname='public' AND table_name = 'v_groups' + //check if column exists + // SELECT attname FROM pg_attribute WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'v_cdr') AND attname = 'caller_id_name'; + //mysql + //list all tables in the database + // SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = 'fusionpbx' + //check if table exists + // SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = 'fusionpbx' AND TABLE_NAME = 'v_groups' + //check if column exists + // SELECT * FROM information_schema.COLUMNS where TABLE_SCHEMA = 'fusionpbx' AND TABLE_NAME = 'v_cdr' AND COLUMN_NAME = 'context' + //oracle + //check if table exists + // SELECT TABLE_NAME FROM ALL_TABLES + + //get the $apps array from the installed apps from the core and mod directories + $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php"); + $x=0; + foreach ($config_list as &$config_path) { + include($config_path); + $x++; + } + + //update the app db array add exists true or false + $sql = ''; + foreach ($apps as $x => &$app) { + foreach ($app['db'] as $y => &$row) { + $table_name = $row['table']; + if (strlen($table_name) > 0) { + //check if the table exists + if (db_table_exists($db, $db_type, $db_name, $table_name)) { + $apps[$x]['db'][$y]['exists'] = 'true'; + } + else { + $apps[$x]['db'][$y]['exists'] = 'false'; + } + //check if the column exists + foreach ($row['fields'] as $z => $field) { + if ($field['deprecated'] == "true") { + //skip this field + } + else { + if (is_array($field['name'])) { + $field_name = $field['name']['text']; + } + else { + $field_name = $field['name']; + } + if (strlen(field_name) > 0) { + if (db_column_exists ($db, $db_type, $db_name, $table_name, $field_name)) { + //found + $apps[$x]['db'][$y]['fields'][$z]['exists'] = 'true'; + } + else { + //not found + $apps[$x]['db'][$y]['fields'][$z]['exists'] = 'false'; + } + } + unset($field_name); + } + } + unset($table_name); + } + } + } + + //prepare the variables + $sql_update = ''; + $var_uuid = $_GET["id"]; + + //add missing tables and fields + foreach ($apps as $x => &$app) { + foreach ($app['db'] as $y => &$row) { + $table_name = $row['table']; + //check if the table exists + if ($row['exists'] == "true") { + if (count($row['fields']) > 0) { + foreach ($row['fields'] as $z => $field) { + if ($field['deprecated'] == "true") { + //skip this field + } + else { + //get the data type + if (is_array($field['type'])) { + $field_type = $field['type'][$db_type]; + } + else { + $field_type = $field['type']; + } + //get the field name + if (is_array($field['name'])) { + $field_name = $field['name']['text']; + } + else { + $field_name = $field['name']; + } + //find missing fields and add them + if ($field['deprecated'] == "true") { + //skip this row + } + else { + if (is_array($field['name'])) { + if ($field['exists'] == "false" && !db_column_exists ($db, $db_type, $db_name, $table_name, $field['name']['deprecated'])) { + $sql_update .= "ALTER TABLE ".$table_name." ADD ".$field['name']['text']." ".$field_type.";\n"; + } + } + else { + if ($field['exists'] == "false") { + $sql_update .= "ALTER TABLE ".$table_name." ADD ".$field['name']." ".$field_type.";\n"; + } + } + } + //rename fields where the name has changed + if (is_array($field['name'])) { + if (db_column_exists ($db, $db_type, $db_name, $table_name, $field['name']['deprecated'])) { + if ($db_type == "pgsql") { + $sql_update .= "ALTER TABLE ".$table_name." RENAME COLUMN ".$field['name']['deprecated']." to ".$field['name']['text'].";\n"; + } + if ($db_type == "mysql") { + $field_type = str_replace("AUTO_INCREMENT PRIMARY KEY", "", $field_type); + $sql_update .= "ALTER TABLE ".$table_name." CHANGE ".$field['name']['deprecated']." ".$field['name']['text']." ".$field_type.";\n"; + } + if ($db_type == "sqlite") { + //a change has been made to the field name + $apps[$x]['db'][$y]['rebuild'] = 'true'; + } + } + } + //change the data type if it has been changed + //if the data type in the app db array is different than the type in the database then change the data type + $db_field_type = db_column_data_type ($db, $db_type, $db_name, $table_name, $field_name); + if ($db_field_type != $field_type) { + if ($db_type == "pgsql") { + if (strtolower($field_type) == "uuid") { + $sql_update .= "ALTER TABLE ".$table_name." ALTER COLUMN ".$field_name." TYPE uuid USING\n"; + $sql_update .= "CAST(regexp_replace(".$field_name.", '([A-Z0-9]{4})([A-Z0-9]{12})', E'\\1-\\2')\n"; + $sql_update .= "AS uuid);\n"; + } + else { + if ($db_field_type = "integer" && strtolower($field_type) == "serial") { + //field type has not changed + } elseif ($db_field_type = "timestamp without time zone" && strtolower($field_type) == "timestamp") { + //field type has not changed + } elseif ($db_field_type = "character" && strtolower($field_type) == "char(1)") { + //field type has not changed + } + else { + $sql_update .= "-- $db_type, $db_name, $table_name, $field_name ".db_column_data_type ($db, $db_type, $db_name, $table_name, $field_name)."
    "; + $sql_update .= "ALTER TABLE ".$table_name." ALTER COLUMN ".$field_name." TYPE ".$field_type.";\n"; + } + } + } + if ($db_type == "mysql") { + $sql_update .= "ALTER TABLE ".$table_name." modify ".$field_name." ".$field_type.";\n"; + } + if ($db_type == "sqlite") { + //a change has been made to the field type + $apps[$x]['db'][$y]['rebuild'] = 'true'; + } + } + } + } + unset($column_array); + } + } + else { + //create table + $sql_update .= db_create_table($apps, $db_type, $row['table']); + } + } + } + //rebuild and populate the table + foreach ($apps as $x => &$app) { + foreach ($app['db'] as $y => &$row) { + $table_name = $row['table']; + if ($row['rebuild'] == "true") { + if ($db_type == "sqlite") { + //rename the table + $sql_update .= "ALTER TABLE ".$table_name." RENAME TO tmp_".$table_name.";\n"; + //create the table + $sql_update .= db_create_table($apps, $db_type, $table_name); + //insert the data into the new table + $sql_update .= db_insert_into($apps, $db_type, $table_name); + //drop the old table + $sql_update .= "DROP TABLE tmp_".$table_name.";\n"; + } + } + } + } + //display results as html + if ($display_results && $display_type == "html") { + //show the database type + echo "Database Type: ".$db_type. "

    "; + //start the table + echo "\n"; + //show the changes + if (strlen($sql_update) > 0) { + echo "\n"; + echo "\n"; + echo "\n"; + } + //list all tables + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + //build the html while looping through the app db array + $sql = ''; + foreach ($apps as &$app) { + foreach ($app['db'] as $row) { + $table_name = $row['table']; + echo "\n"; + + //check if the table exists + if ($row['exists'] == "true") { + echo "\n"; + echo "\n"; + + if (count($row['fields']) > 0) { + echo "\n"; + } + } + else { + echo "\n"; + echo "\n"; + echo "\n"; + } + echo "\n"; + } + } + unset ($prep_statement); + //end the list of tables + echo "
    \n"; + echo "
    \n"; + echo "SQL Changes:
    \n"; + echo "
    \n";
    +					echo $sql_update;
    +					echo "
    \n"; + echo "
    \n"; + echo "
    TableExistsDetails
    table
    $table_name
    true\n"; + //show the list of columns + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + foreach ($row['fields'] as $field) { + if ($field['deprecated'] == "true") { + //skip this field + } + else { + if (is_array($field['name'])) { + $field_name = $field['name']['text']; + } + else { + $field_name = $field['name']; + } + if (is_array($field['type'])) { + $field_type = $field['type'][$db_type]; + } + else { + $field_type = $field['type']; + } + echo "\n"; + echo "\n"; + echo "\n"; + if ($field['exists'] == "true") { + echo "\n"; + echo "\n"; + } + else { + echo "\n"; + echo "\n"; + } + echo "\n"; + } + } + unset($column_array); + echo "
    nametypeexists
    ".$field_name."".$field_type."true false 
    \n"; + echo "
    table
    $table_name
    exists
    false
     
    \n"; + echo "
    \n"; + } + + //loop line by line through all the lines of sql code + $x = 0; + if (strlen($sql_update) == 0 && $display_type == "text") { + echo " Schema: no change\n"; + } + else { + if ($display_type == "text") { + echo " Schema:\n"; + } + //$db->beginTransaction(); + $update_array = explode(";", $sql_update); + foreach($update_array as $sql) { + if (strlen(trim($sql))) { + try { + $db->query(trim($sql)); + if ($display_type == "text") { + echo " $sql\n"; + } + } + catch (PDOException $error) { + if ($display_results) { + echo " error: " . $error->getMessage() . " sql: $sql
    "; + } + } + } + } + //$db->commit(); + echo "\n"; + unset ($file_contents, $sql_update, $sql); + } + +} //end function + +?> \ No newline at end of file diff --git a/includes/lib_switch.php b/includes/lib_switch.php new file mode 100644 index 0000000000..b94c9ec54e --- /dev/null +++ b/includes/lib_switch.php @@ -0,0 +1,4335 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; + +//preferences + $v_label_show = false; + $v_menu_tab_show = false; + $v_fax_show = true; + $v_path_show = true; + +//get user defined variables + if (strlen($_SESSION['user_defined_variables']) == 0) { + $sql = "select * from v_vars "; + $sql .= "where var_cat = 'Defaults' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + foreach ($result as &$row) { + switch ($row["var_name"]) { + case "username": + //not allowed to override this value + break; + case "groups": + //not allowed to override this value + break; + case "menu": + //not allowed to override this value + break; + case "template_name": + //not allowed to override this value + break; + case "template_content": + //not allowed to override this value + break; + case "extension_array": + //not allowed to override this value + break; + case "user_extension_array": + //not allowed to override this value + break; + case "user_array": + //not allowed to override this value + break; + default: + $_SESSION[$row["var_name"]] = $row["var_value"]; + } + } + //when this value is cleared it will re-read the user defined variables + $_SESSION["user_defined_variables"] = "set"; + } + +/* +function v_settings() { + global $db, $domain_uuid; + + //get the program directory + $program_dir = ''; + $doc_root = $_SERVER["DOCUMENT_ROOT"]; + $doc_root = str_replace ("\\", "/", $doc_root); + $doc_root_array = explode("/", $doc_root); + $doc_root_array_count = count($doc_root_array); + $x = 0; + foreach ($doc_root_array as $value) { + $program_dir = $program_dir.$value."/"; + if (($doc_root_array_count-3) == $x) { + break; + } + $x++; + } + $program_dir = rtrim($program_dir, "/"); + + //get the domains variables + $sql = "select * from v_domain_settings "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and domain_setting_enabled = 'true' "; + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach($result as $row) { + $name = $row['domain_setting_name']; + $settings_array[$name] = $row['domain_setting_value']; + } + } + + //get the server variables + $sql = "select * from v_server_settings "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and domain_setting_enabled = 'true' "; + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach($result as $row) { + $name = $row['server_setting_name']; + $settings_array[$name] = $row['server_setting_value']; + } + } + + //return the results + return $settings_array; +} +//update the settings +//$settings_array = v_settings(); +foreach($settings_array as $name => $value) { + $$name = $value; +} +*/ + +//create the recordings/archive/year/month/day directory structure + $v_recording_archive_dir = $_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M")."/".date("d"); + if(!is_dir($v_recording_archive_dir)) { + mkdir($v_recording_archive_dir, 0764, true); + chmod($_SESSION['switch']['recordings']['dir']."/archive/".date("Y"), 0764); + chmod($_SESSION['switch']['recordings']['dir']."/archive/".date("Y")."/".date("M"), 0764); + chmod($v_recording_archive_dir, 0764); + } + +//get the event socket information + if (strlen($_SESSION['event_socket_ip_address']) == 0) { + $sql = "select * from v_settings "; + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + foreach ($result as &$row) { + $_SESSION['event_socket_ip_address'] = $row["event_socket_ip_address"]; + $_SESSION['event_socket_port'] = $row["event_socket_port"]; + $_SESSION['event_socket_password'] = $row["event_socket_password"]; + break; //limit to 1 row + } + } + } + +//get the extensions that are assigned to this user + if (strlen($_SESSION["user_uuid"]) > 0 && count($_SESSION['user']['extension']) == 0) { + //get the user extension list + unset($_SESSION['user']['extension']); + $sql = "select e.extension, e.user_context, e.extension_uuid from v_extensions as e, v_extension_users as u "; + $sql .= "where e.domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and e.extension_uuid = u.extension_uuid "; + $sql .= "and u.user_uuid = '".$_SESSION['user_uuid']."' "; + $sql .= "and e.enabled = 'true' "; + $sql .= "order by e.extension asc "; + $result = $db->query($sql)->fetchAll(PDO::FETCH_ASSOC); + if (count($result) > 0) { + $x = 0; + foreach($result as $row) { + $_SESSION['user']['extension'][$x]['user'] = $row['extension']; + $_SESSION['user']['extension'][$x]['extension_uuid'] = $row['extension_uuid']; + $_SESSION['user_context'] = $row["user_context"]; + $x++; + } + } + //if no extension has been assigned then setting user_context will still need to be set + if (strlen($_SESSION['user_context']) == 0) { + if (count($_SESSION['domains']) == 1) { + $_SESSION['user_context'] = "default"; + } + else { + $_SESSION['user_context'] = $_SESSION['domain_name']; + } + } + } + +if ($db_type == "sqlite") { + //sqlite: check if call detail record (CDR) db file exists if not create it + if (!file_exists($db_file_path.'/'.$server_name.'.cdr.db')) { + //echo "file does not exist: ".$_SESSION['switch']['db']['dir'].'/cdr.db'; + if (copy($db_file_path.'/cdr.clean.db', $db_file_path.'/'.$server_name.'.cdr.db')) { + //echo "copy succeeded.\n"; + } + } +} + +function build_menu() { + global $v_menu_tab_show; + + if ($v_menu_tab_show) { + global $config; + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ $relative_url = $_SERVER["DOCUMENT_ROOT"].'/fusionpbx'; } else { $relative_url = '/'; } + + $tab_array = array(); + $menu_selected = false; + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_settings.php") { $menu_selected = true; } + $tab_array[] = array(gettext("Settings"), $menu_selected, $relative_url."/v_settings.php"); + unset($menu_selected); + + $menu_selected = false; + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/dialplans.php") { $menu_selected = true; } + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/dialplans.php") { $menu_selected = true; } + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/dialplan_edit.php") { $menu_selected = true; } + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/dialplan_details_edit.php") { $menu_selected = true; } + $tab_array[] = array(gettext("Dialplan"), $menu_selected, $relative_url."/dialplans.php"); + unset($menu_selected); + + $menu_selected = false; + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_extensions.php") { $menu_selected = true; } + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_extensions_edit.php") { $menu_selected = true; } + $tab_array[] = array(gettext("Extensions"), $menu_selected, $relative_url."/v_extensions.php"); + unset($menu_selected); + + $menu_selected = false; + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_features.php") { $menu_selected = true; } + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_fax.php") { $menu_selected = true; } + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_fax_edit.php") { $menu_selected = true; } + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_hunt_group.php") { $menu_selected = true; } + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_hunt_group_edit.php") { $menu_selected = true; } + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_hunt_group_destinations.php") { $menu_selected = true; } + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_hunt_group_destinations_edit.php") { $menu_selected = true; } + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_auto_attendant.php") { $menu_selected = true; } + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_auto_attendant_edit.php") { $menu_selected = true; } + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_auto_attendant_options_edit.php") { $menu_selected = true; } + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_modules.php") { $menu_selected = true; } + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_recordings.php") { $menu_selected = true; } + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_recordings_edit.php") { $menu_selected = true; } + $tab_array[] = array(gettext("Features"), $menu_selected, $relative_url."/v_features.php"); + unset($menu_selected); + + $menu_selected = false; + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_gateways.php") { $menu_selected = true; } + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_gateways_edit.php") { $menu_selected = true; } + $tab_array[] = array(gettext("Gateways"), $menu_selected, $relative_url."/v_gateways.php"); + unset($menu_selected); + + $menu_selected = false; + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_profiles.php") { $menu_selected = true; } + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_profile_edit.php") { $menu_selected = true; } + $tab_array[] = array(gettext("Profiles"), $menu_selected, $relative_url."/v_profiles.php"); + unset($menu_selected); + + $menu_selected = false; + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_status.php") { $menu_selected = true; } + $tab_array[] = array(gettext("Status"), $menu_selected, $relative_url."/v_status.php"); + unset($menu_selected); + + $menu_selected = false; + if ($_SERVER["SCRIPT_NAME"] == $relative_url."/v_vars.php") { $menu_selected = true; } + $tab_array[] = array(gettext("Vars"), $menu_selected, $relative_url."/v_vars.php"); + unset($menu_selected); + } +} + + +function event_socket_create($host, $port, $password){ + $fp = fsockopen($host, $port, $errno, $errdesc, 3); + socket_set_blocking($fp,false); + + if (!$fp) { + //error "invalid handle
    \n"; + //echo "error number: ".$errno."
    \n"; + //echo "error description: ".$errdesc."
    \n"; + } + else { + //connected to the socket return the handle + while (!feof($fp)) { + $buffer = fgets($fp, 1024); + usleep(100); //allow time for reponse + if (trim($buffer) == "Content-Type: auth/request") { + fputs($fp, "auth $password\n\n"); + break; + } + } + return $fp; + } +} //end function + + +function event_socket_request($fp, $cmd) { + if ($fp) { + fputs($fp, $cmd."\n\n"); + usleep(100); //allow time for reponse + + $response = ""; + $i = 0; + $contentlength = 0; + while (!feof($fp)) { + $buffer = fgets($fp, 4096); + if ($contentlength > 0) { + $response .= $buffer; + } + + if ($contentlength == 0) { //if content length is already don't process again + if (strlen(trim($buffer)) > 0) { //run only if buffer has content + $temparray = explode(":", trim($buffer)); + if ($temparray[0] == "Content-Length") { + $contentlength = trim($temparray[1]); + } + } + } + + usleep(20); //allow time for reponse + + //optional because of script timeout //don't let while loop become endless + if ($i > 1000000) { break; } + + if ($contentlength > 0) { //is contentlength set + //stop reading if all content has been read. + if (strlen($response) >= $contentlength) { + break; + } + } + $i++; + } + + return $response; + } + else { + echo "no handle"; + } +} + + +function event_socket_request_cmd($cmd) { + global $db, $domain_uuid, $host; + + $sql = "select * from v_settings "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + foreach ($result as &$row) { + $event_socket_ip_address = $row["event_socket_ip_address"]; + $event_socket_port = $row["event_socket_port"]; + $event_socket_password = $row["event_socket_password"]; + break; //limit to 1 row + } + unset ($prep_statement); + + $fp = event_socket_create($event_socket_ip_address, $event_socket_port, $event_socket_password); + $response = event_socket_request($fp, $cmd); + fclose($fp); +} + +function byte_convert( $bytes ) { + if ($bytes<=0) { + return '0 Byte'; + } + + $convention=1000; //[1000->10^x|1024->2^x] + $s=array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'); + $e=floor(log($bytes,$convention)); + $e=floor(log($bytes,$convention)); + return round($bytes/pow($convention,$e),2).' '.$s[$e]; +} + +function lan_sip_profile() { + global $config; + clearstatcache(); + + //if the lan directory does not exist then create it + if (!is_readable($_SESSION['switch']['conf']['dir'].'/sip_profiles/lan/')) { + exec("mkdir ".$_SESSION['switch']['conf']['dir']."/sip_profiles/lan/"); + } + + //create the LAN profile if it doesn't exist + if (!file_exists($_SESSION['switch']['conf']['dir'].'/sip_profiles/lan.xml')) { + $lan_ip = $config['interfaces']['lan']['ipaddr']; + if (strlen($lan_ip) > 0) { + exec("cp ".$_SESSION['switch']['conf']['dir']."/sip_profiles/internal.xml ".$_SESSION['switch']['conf']['dir']."/sip_profiles/lan.xml"); + + $filename = $_SESSION['switch']['conf']['dir']."/sip_profiles/lan.xml"; + $handle = fopen($filename,"rb"); + $contents = fread($handle, filesize($filename)); + fclose($handle); + + $handle = fopen($filename,"w"); + $contents = str_replace("", "", $contents); + $contents = str_replace("", "", $contents); + $contents = str_replace("", "", $contents); + $contents = str_replace("", "", $contents); + $contents = str_replace("", "", $contents); + fwrite($handle, $contents); + unset($contents); + fclose($handle); + unset($filename); + } + } +} + +function ListFiles($dir) { + if($dh = opendir($dir)) { + $files = Array(); + $inner_files = Array(); + + while($file = readdir($dh)) { + if($file != "." && $file != ".." && $file[0] != '.') { + if(is_dir($dir . "/" . $file)) { + //$inner_files = ListFiles($dir . "/" . $file); //recursive + if(is_array($inner_files)) $files = array_merge($files, $inner_files); + } else { + array_push($files, $file); + //array_push($files, $dir . "/" . $file); + } + } + } + closedir($dh); + return $files; + } +} + +function switch_select_destination($select_type, $select_label, $select_name, $select_value, $select_style, $action='') { + //select_type can be ivr, dialplan, or call_center_contact + global $config, $db, $domain_uuid; + + if (if_group("superadmin")) { + echo "\n"; + echo "\n"; + } + + //default selection found to false + $selection_found = false; + + if (if_group("superadmin")) { + echo " \n"; + } + + echo " \n"; + + //list call center queues + $sql = "select * from v_call_center_queues "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "order by queue_name asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + $previous_call_center_name = ""; + foreach ($result as &$row) { + $queue_name = $row["queue_name"]; + $queue_name = str_replace('_${domain_name}@default', '', $queue_name); + $queue_extension = $row["queue_extension"]; + if ($previous_call_center_name != $queue_name) { + if ("menu-exec-app:transfer ".$queue_extension." XML ".$_SESSION["context"] == $select_value || "transfer:".$queue_extension." XML ".$_SESSION["context"] == $select_value) { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + $selection_found = true; + } + else { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + $previous_call_center_name = $queue_name; + } + } + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + unset ($prep_statement); + + //list call groups + $sql = "select distinct(call_group) from v_extensions "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "order by call_group asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $x = 0; + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + $previous_call_group_name = ""; + foreach ($result as &$row) { + $call_groups = $row["call_group"]; + $call_group_array = explode(",", $call_groups); + foreach ($call_group_array as $call_group) { + $call_group = trim($call_group); + if ($previous_call_group_name != $call_group) { + if ("menu-exec-app:bridge group/".$call_group."@".$_SESSION['domain_name'] == $select_value || "bridge:group/".$call_group."@".$_SESSION['domain_name'] == $select_value) { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + $selection_found = true; + } + else { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + $previous_call_group_name = $call_group; + } + } + $x++; + } + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + unset ($prep_statement); + + //list conferences + $sql = "select * from v_conferences "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "order by conference_name asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $x = 0; + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + foreach ($result as &$row) { + $name = $row["conference_name"]; + $extension = $row["conference_extension"]; + $description = $row["conference_description"]; + if ("execute_extension ".$extension." XML ".$_SESSION['context'] == $select_value || "execute_extension:".$extension." XML ".$_SESSION['context'] == $select_value) { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + $selection_found = true; + } + else { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + $x++; + } + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + unset ($prep_statement); + + //list destinations + $sql = "select * from v_destinations "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and destination_enabled = 'true' "; + $sql .= "order by destination_name asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $x = 0; + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + foreach ($result as &$row) { + $name = $row["destination_name"]; + $context = $row["destination_context"]; + $extension = $row["destination_extension"]; + $description = $row["destination_description"]; + if ("execute_extension ".$extension." XML ".$context == $select_value || "execute_extension:".$extension." XML ".$context == $select_value) { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + $selection_found = true; + } + else { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + $x++; + } + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + unset ($prep_statement); + + //list extensions + $sql = "select * from v_extensions "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and enabled = 'true' "; + $sql .= "order by extension asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + if ($select_type == "dialplan" || $select_type == "ivr" || $select_type == "call_center_contact") { + echo "\n"; + } + foreach ($result as &$row) { + $extension = $row["extension"]; + $context = $row["user_context"]; + $description = $row["description"]; + if ("transfer ".$extension." XML ".$context == $select_value || "transfer:".$extension." XML ".$context == $select_value || "user/$extension@".$_SESSION['domains'][$domain_uuid]['domain_name'] == $select_value) { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + if ($select_type == "call_center_contact") { + echo " \n"; + } + $selection_found = true; + } + else { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + if ($select_type == "call_center_contact") { + echo " \n"; + } + } + } + if ($select_type == "dialplan" || $select_type == "ivr" || $select_type == "call_center_contact") { + echo "\n"; + } + unset ($prep_statement, $extension); + + //list fax extensions + if ($select_type == "dialplan" || $select_type == "ivr") { + $sql = "select * from v_fax "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "order by fax_extension asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + echo "\n"; + foreach ($result as &$row) { + $fax_name = $row["fax_name"]; + $extension = $row["fax_extension"]; + if ("transfer $extension XML ".$_SESSION["context"] == $select_value || "transfer:".$extension." XML ".$_SESSION["context"] == $select_value) { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + $selection_found = true; + } + else { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + } + echo "\n"; + unset ($prep_statement, $extension); + } + + //list fifo queues + $sql = "select * from v_dialplan_details "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "order by dialplan_detail_data asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $x = 0; + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + foreach ($result as &$row) { + //$dialplan_detail_tag = $row["dialplan_detail_tag"]; + if ($row["dialplan_detail_type"] == "fifo") { + if (strpos($row["dialplan_detail_data"], '@${domain_name} in') !== false) { + $dialplan_uuid = $row["dialplan_uuid"]; + //get the extension number using the dialplan_uuid + $sql = "select dialplan_detail_data as extension_number "; + $sql .= "from v_dialplan_details "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $sql .= "and dialplan_detail_type = 'destination_number' "; + $tmp = $db->query($sql)->fetch(PDO::FETCH_ASSOC); + $extension_number = $tmp['extension_number']; + $extension_number = ltrim($extension_number, "^"); + $extension_number = ltrim($extension_number, "\\"); + $extension_number = rtrim($extension_number, "$"); + unset($tmp); + + //get the extension number using the dialplan_uuid + $sql = "select * "; + $sql .= "from v_dialplans "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $tmp = $db->query($sql)->fetch(PDO::FETCH_ASSOC); + $dialplan_name = $tmp['dialplan_name']; + $dialplan_name = str_replace("_", " ", $dialplan_name); + unset($tmp); + + $fifo_name = $row["dialplan_detail_data"]; + $fifo_name = str_replace('@${domain_name} in', '', $fifo_name); + $option_label = $extension_number.' '.$dialplan_name; + if ($select_type == "ivr") { + if ("menu-exec-app:transfer ".$row["dialplan_detail_data"] == $select_value) { + echo " \n"; + $selection_found = true; + } + else { + echo " \n"; + } + } + if ($select_type == "dialplan") { + if ("transfer:".$row["dialplan_detail_data"] == $select_value) { + echo " \n"; + $selection_found = true; + } + else { + echo " \n"; + } + } + } + } + } + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + unset ($prep_statement); + + //gateways + if (if_group("superadmin")) { + if ($select_type == "dialplan" || $select_type == "ivr" || $select_type == "call_center_contact") { + echo "\n"; + } + $sql = "select * from v_gateways "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and enabled = 'true' "; + $sql .= "order by gateway asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + $result_count = count($result); + unset ($prep_statement, $sql); + $tmp_selected = ''; + foreach($result as $row) { + if ($row['gateway'] == $select_value) { + $tmp_selected = "selected='selected'"; + } + if ($select_type == "dialplan") { + if (count($_SESSION['domains']) == 1) { + echo " \n"; + } + else { + echo " \n"; + } + } + if ($select_type == "ivr") { + if (count($_SESSION['domains']) == 1) { + echo " \n"; + } + else { + echo " \n"; + } + } + if ($select_type == "call_center_contact") { + if (count($_SESSION['domains']) == 1) { + echo " \n"; + } + else { + echo " \n"; + } + } + $tmp_selected = ''; + } + unset($sql, $result); + if ($select_type == "dialplan" || $select_type == "ivr" || $select_type == "call_center_contact") { + echo "\n"; + } + } + + //list hunt groups + $sql = "select * from v_hunt_groups "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and ( "; + $sql .= "hunt_group_type = 'simultaneous' "; + $sql .= "or hunt_group_type = 'sequence' "; + $sql .= "or hunt_group_type = 'sequentially' "; + $sql .= ") "; + $sql .= "order by hunt_group_extension asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + foreach ($result as &$row) { + $extension = $row["hunt_group_extension"]; + $hunt_group_name = $row["hunt_group_name"]; + if ("transfer $extension XML ".$_SESSION["context"] == $select_value || "transfer:".$extension." XML ".$_SESSION["context"] == $select_value) { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + $selection_found = true; + } + else { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + } + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + unset ($prep_statement, $extension); + + //list ivr menus + $sql = "select * from v_ivr_menus "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and ivr_menu_enabled = 'true' "; + $sql .= "order by ivr_menu_extension asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + foreach ($result as &$row) { + $extension = $row["ivr_menu_extension"]; + $extension_name = $row["ivr_menu_name"]; + $extension_label = $row["ivr_menu_name"]; + $extension_name = str_replace(" ", "_", $extension_name); + if (count($_SESSION["domains"]) > 1) { + $extension_name = $_SESSION['domains'][$row['domain_uuid']]['domain_name'].'-'.$extension_name; + } + if ("ivr:".$extension_name."" == $select_value || "ivr ".$extension_name == $select_value || "transfer:".$extension." XML ".$_SESSION["context"] == $select_value) { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + $selection_found = true; + } + else { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + } + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + unset ($prep_statement, $extension); + + //list ivr menus + if ($select_type == "ivr") { + //list sub ivr menu + $sql = "select * from v_ivr_menus "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and ivr_menu_enabled = 'true' "; + $sql .= "order by ivr_menu_name asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + foreach ($result as &$row) { + $extension_name = $row["ivr_menu_name"]; + $extension_label = $row["ivr_menu_name"]; + $extension_name = str_replace(" ", "_", $extension_name); + if (count($_SESSION["domains"]) > 1) { + $extension_name = $_SESSION['domains'][$row['domain_uuid']]['domain_name'].'-'.$extension_name; + } + if ($extension_name == $select_value) { + echo " \n"; + $selection_found = true; + } + else { + echo " \n"; + } + } + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + unset ($prep_statement, $extension_name); + + //list ivr misc + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + if ($ivr_menu_option_action == "menu-top") { + echo " \n"; + $selection_found = true; + } + else { + echo " \n"; + } + if ($ivr_menu_option_action == "menu-exit") { + echo " \n"; + $selection_found = true; + } + else { + echo " \n"; + } + if (strlen($select_value) > 0) { + if (!$selection_found) { + echo " \n"; + } + } + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + } + + //list the languages + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + //dutch + if ("menu-exec-app:set default_language=nl" == $select_value || "set:default_language=nl" == $select_value) { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + else { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + //english + if ("menu-exec-app:set default_language=en" == $select_value || "set:default_language=en" == $select_value) { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + else { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + //french + if ("menu-exec-app:set default_language=fr" == $select_value || "set:default_language=fr" == $select_value) { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + else { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + //italian + if ("menu-exec-app:set default_language=it" == $select_value || "set:default_language=it" == $select_value) { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + else { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + //german + if ("menu-exec-app:set default_language=de" == $select_value || "set:default_language=de" == $select_value) { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + else { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + //portuguese - portugal + if ("menu-exec-app:set default_language=de" == $select_value || "set:default_language=de" == $select_value) { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + else { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + //portuguese - brazil + if ("menu-exec-app:set default_language=pt-br" == $select_value || "set:default_language=de" == $select_value) { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + else { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + //spanish + if ("menu-exec-app:set default_language=es" == $select_value || "set:default_language=es" == $select_value) { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + else { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + + //recordings + if ($select_type == "dialplan" || $select_type == "ivr") { + if($dh = opendir($_SESSION['switch']['recordings']['dir']."/")) { + $tmp_selected = false; + $files = Array(); + echo "\n"; + while($file = readdir($dh)) { + if($file != "." && $file != ".." && $file[0] != '.') { + if(is_readable($_SESSION['switch']['recordings']['dir'] . "/" . $file)) { + //this is a directory + } + else { + if ($ivr_menu_greet_long == $_SESSION['switch']['recordings']['dir']."/".$file) { + $tmp_selected = true; + if ($select_type == "dialplan") { + echo " \n"; + } + if ($select_type == "ivr") { + echo " \n"; + } + } + else { + if ($select_type == "dialplan") { + echo " \n"; + } + if ($select_type == "ivr") { + echo " \n"; + } + } + } + } + } + closedir($dh); + echo "\n"; + } + } + + //ring groups + $sql = "select * from v_ring_groups "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and ring_group_enabled = 'true' "; + $sql .= "order by ring_group_extension asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + foreach ($result as &$row) { + $extension = $row["ring_group_extension"]; + $context = $row["ring_group_context"]; + $description = $row["ring_group_description"]; + if ("transfer ".$extension." XML ".$context == $select_value || "transfer:".$extension." XML ".$context == $select_value) { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + $selection_found = true; + } + else { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + } + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + + //list time conditions + $sql = "select * from v_dialplan_details "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $x = 0; + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + foreach ($result as &$row) { + //$dialplan_detail_tag = $row["dialplan_detail_tag"]; + switch ($row['dialplan_detail_type']) { + case "hour": + $time_array[$row['dialplan_uuid']] = $row['dialplan_detail_type']; + break; + case "minute": + $time_array[$row['dialplan_uuid']] = $row['dialplan_detail_type']; + break; + case "minute-of-day": + $time_array[$row['dialplan_uuid']] = $row['dialplan_detail_type']; + break; + case "mday": + $time_array[$row['dialplan_uuid']] = $row['dialplan_detail_type']; + break; + case "mweek": + $time_array[$row['dialplan_uuid']] = $row['dialplan_detail_type']; + break; + case "mon": + $time_array[$row['dialplan_uuid']] = $row['dialplan_detail_type']; + break; + case "yday": + $time_array[$row['dialplan_uuid']] = $row['dialplan_detail_type']; + break; + case "year": + $time_array[$row['dialplan_uuid']] = $row['dialplan_detail_type']; + break; + case "wday": + $time_array[$row['dialplan_uuid']] = $row['dialplan_detail_type']; + break; + case "week": + $time_array[$row['dialplan_uuid']] = $row['dialplan_detail_type']; + break; + default: + //$time_array[$row['dialplan_uuid']] = $row['dialplan_detail_type']; + break; + } + } + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + foreach($time_array as $key=>$val) { + $dialplan_uuid = $key; + //get the extension number using the dialplan_uuid + $sql = "select dialplan_detail_data as extension_number "; + $sql .= "from v_dialplan_details "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $sql .= "and dialplan_detail_type = 'destination_number' "; + $sql .= "order by extension_number asc "; + $tmp = $db->query($sql)->fetch(PDO::FETCH_ASSOC); + $extension_number = $tmp['extension_number']; + $extension_number = ltrim($extension_number, "^"); + $extension_number = ltrim($extension_number, "\\"); + $extension_number = rtrim($extension_number, "$"); + unset($tmp); + + //get the extension number using the dialplan_uuid + $sql = "select * "; + $sql .= "from v_dialplans "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $tmp = $db->query($sql)->fetch(PDO::FETCH_ASSOC); + $dialplan_name = $tmp['dialplan_name']; + $dialplan_name = str_replace("_", " ", $dialplan_name); + unset($tmp); + + $option_label = $extension_number.' '.$dialplan_name; + if ($select_type == "ivr") { + if ("menu-exec-app:transfer ".$extension_number." XML ".$_SESSION["context"] == $select_value) { + echo " \n"; + $selection_found = true; + } + else { + echo " \n"; + } + } + if ($select_type == "dialplan") { + if ("transfer:".$extension_number == $select_value) { + echo " \n"; + $selection_found = true; + } + else { + echo " \n"; + } + } + } + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + unset ($prep_statement); + + //list voicemail + $sql = "select * from v_extensions "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and enabled = 'true' "; + $sql .= "order by extension asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + foreach ($result as &$row) { + $extension = $row["extension"]; + $context = $row["user_context"]; + $description = $row["description"]; + if ("voicemail default \${domain_name} ".$extension == $select_value || "voicemail:default \${domain_name} ".$extension == $select_value) { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + $selection_found = true; + } + else { + if ($select_type == "ivr") { + echo " \n"; + } + if ($select_type == "dialplan") { + echo " \n"; + } + } + } + if ($select_type == "dialplan" || $select_type == "ivr") { + echo "\n"; + } + + //other + if (if_group("superadmin")) { + if ($select_type == "dialplan" || $select_type == "ivr" || $select_type == "call_center_contact") { + echo "\n"; + } + if ($select_type == "dialplan" || $select_type == "ivr") { + //set the default value + $selected = ''; + //answer + if ($select_value == "answer") { $selected = "selected='selected'"; } + if ($select_type == "dialplan") { + echo " \n"; + } + if ($select_type == "ivr") { + echo " \n"; + } + //bridge + if ($select_value == "bridge") { $selected = "selected='selected'"; } + if ($select_type == "dialplan") { + echo " \n"; + } + if ($select_type == "ivr") { + echo " \n"; + } + //db + if ($select_value == "db") { $selected = "selected='selected'"; } + if ($select_type == "dialplan") { + echo " \n"; + } + if ($select_type == "ivr") { + echo " \n"; + } + //export + if ($select_value == "export") { $selected = "selected='selected'"; } + if ($select_type == "dialplan") { + echo " \n"; + } + if ($select_type == "ivr") { + echo " \n"; + } + //global_set + if ($select_value == "global_set") { $selected = "selected='selected'"; } + if ($select_type == "dialplan") { + echo " \n"; + } + if ($select_type == "ivr") { + echo " \n"; + } + //group + if ($select_value == "group") { $selected = "selected='selected'"; } + if ($select_type == "dialplan") { + echo " \n"; + } + if ($select_type == "ivr") { + echo " \n"; + } + //hangup + if ($select_value == "hangup") { $selected = "selected='selected'"; } + if ($select_type == "dialplan") { + echo " \n"; + } + if ($select_type == "ivr") { + echo " \n"; + } + //info + if ($select_value == "info") { $selected = "selected='selected'"; } + if ($select_type == "dialplan") { + echo " \n"; + } + if ($select_type == "ivr") { + echo " \n"; + } + //javascript + if ($select_value == "javascript") { $selected = "selected='selected'"; } + if ($select_type == "dialplan") { + echo " \n"; + } + if ($select_type == "ivr") { + echo " \n"; + } + //lua + if ($select_value == "lua") { $selected = "selected='selected'"; } + if ($select_type == "dialplan") { + echo " \n"; + } + if ($select_type == "ivr") { + echo " \n"; + } + //perl + if ($select_value == "perl") { $selected = "selected='selected'"; } + if ($select_type == "dialplan") { + echo " \n"; + } + if ($select_type == "ivr") { + echo " \n"; + } + //reject + if ($select_value == "reject") { $selected = "selected='selected'"; } + if ($select_type == "dialplan") { + echo " \n"; + } + if ($select_type == "ivr") { + echo " \n"; + } + //set + if ($select_value == "set") { $selected = "selected='selected'"; } + if ($select_type == "dialplan") { + echo " \n"; + } + if ($select_type == "ivr") { + echo " \n"; + } + //sleep + if ($select_value == "sleep") { $selected = "selected='selected'"; } + if ($select_type == "dialplan") { + echo " \n"; + } + if ($select_type == "ivr") { + echo " \n"; + } + //transfer + if ($select_value == "transfer") { $selected = "selected='selected'"; } + if ($select_type == "dialplan") { + echo " \n"; + } + if ($select_type == "ivr") { + echo " \n"; + } + //other + if ($select_value == "other") { + echo " \n"; + } else { + echo " \n"; + } + } + if (!$selection_found) { + if (strlen($select_label) > 0) { + echo " \n"; + } + else { + echo " \n"; + } + } + if ($select_type == "dialplan" || $select_type == "ivr" || $select_type == "call_center_contact") { + echo "\n"; + } + } + + /* + //echo " \n"; + //echo " \n"; + echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + */ + unset ($prep_statement, $extension); + + echo " \n"; + if (if_group("superadmin")) { + echo ""; + } +} + +function save_setting_xml() { + global $db, $domain_uuid, $host, $config; + + $sql = "select * from v_settings "; + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + foreach ($result as &$row) { + $fout = fopen($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/v_config_cli.php","w"); + $tmp_xml = ""; + fwrite($fout, $tmp_xml); + unset($tmp_xml); + fclose($fout); + + $fout = fopen($_SESSION['switch']['conf']['dir']."/directory/default/default.xml","w"); + $tmp_xml = "\n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= "\n"; + fwrite($fout, $tmp_xml); + unset($tmp_xml); + fclose($fout); + + $event_socket_ip_address = $row['event_socket_ip_address']; + if (strlen($event_socket_ip_address) == 0) { $event_socket_ip_address = '127.0.0.1'; } + + $fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/event_socket.conf.xml","w"); + $tmp_xml = "\n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= ""; + fwrite($fout, $tmp_xml); + unset($tmp_xml, $event_socket_password); + fclose($fout); + + $fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/xml_rpc.conf.xml","w"); + $tmp_xml = "\n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= "\n"; + fwrite($fout, $tmp_xml); + unset($tmp_xml); + fclose($fout); + + //shout.conf.xml + $fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/shout.conf.xml","w"); + $tmp_xml = "\n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= ""; + fwrite($fout, $tmp_xml); + unset($tmp_xml); + fclose($fout); + + break; //limit to 1 row + } + unset ($prep_statement); + } + + //apply settings reminder + $_SESSION["reload_xml"] = true; + + //$cmd = "api reloadxml"; + //event_socket_request_cmd($cmd); + //unset($cmd); +} + +function save_extension_xml() { + //declare global variables + global $config, $db, $domain_uuid; + + //get the context based from the domain_uuid + if (count($_SESSION['domains']) == 1) { + $user_context = "default"; + } + else { + $user_context = $_SESSION['domains'][$domain_uuid]['domain_name']; + } + + //delete all old extensions to prepare for new ones + $dialplan_list = glob($_SESSION['switch']['extensions']['dir']."/".$user_context."/v_*.xml"); + foreach($dialplan_list as $name => $value) { + unlink($value); + } + + //write the xml files + $sql = "select * from v_extensions "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "order by call_group asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $i = 0; + $extension_xml_condensed = false; + + while($row = $prep_statement->fetch(PDO::FETCH_ASSOC)) { + $call_group = $row['call_group']; + $call_group = str_replace(";", ",", $call_group); + $tmp_array = explode(",", $call_group); + foreach ($tmp_array as &$tmp_call_group) { + $tmp_call_group = trim($tmp_call_group); + if (strlen($tmp_call_group) > 0) { + if (strlen($call_group_array[$tmp_call_group]) == 0) { + $call_group_array[$tmp_call_group] = $row['extension']; + } + else { + $call_group_array[$tmp_call_group] = $call_group_array[$tmp_call_group].','.$row['extension']; + } + } + $i++; + } + $user_context = $row['user_context']; + $vm_password = $row['vm_password']; + $vm_password = str_replace("#", "", $vm_password); //preserves leading zeros + + //echo "enabled: ".$row['enabled']; + if ($row['enabled'] != "false") { + //remove invalid characters from the file names + $extension = $row['extension']; + $extension = str_replace(" ", "_", $extension); + $extension = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $extension); + + $tmp_xml .= "\n"; + $cidr = ''; + if (strlen($row['cidr']) > 0) { + $cidr = " cidr=\"" . $row['cidr'] . "\""; + } + $number_alias = ''; + if (strlen($row['number_alias']) > 0) { + $number_alias = " number-alias=\"".$row['number_alias']."\""; + } + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + switch ($row['vm_enabled']) { + case "true": + $tmp_xml .= " \n"; + break; + case "false": + $tmp_xml .= " \n"; + break; + default: + $tmp_xml .= " \n"; + } + if (strlen($row['vm_mailto']) > 0) { + $tmp_xml .= " \n"; + + switch ($row['vm_attach_file']) { + case "true": + $tmp_xml .= " \n"; + break; + case "false": + $tmp_xml .= " \n"; + break; + default: + $tmp_xml .= " \n"; + } + switch ($row['vm_keep_local_after_email']) { + case "true": + $tmp_xml .= " \n"; + break; + case "false": + $tmp_xml .= " \n"; + break; + default: + $tmp_xml .= " \n"; + } + $tmp_xml .= " \n"; + } + if (strlen($row['mwi_account']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['auth_acl']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['directory_exten_visible']) > 0) { + $tmp_xml .= " \n"; + } + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + if (strlen($row['call_group']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['hold_music']) > 0) { + $tmp_xml .= " \n"; + } + $tmp_xml .= " \n"; + if (strlen($switch_account_code) > 0) { + $tmp_xml .= " \n"; + } + else { + $tmp_xml .= " \n"; + } + $tmp_xml .= " \n"; + if (strlen($row['effective_caller_id_name']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['effective_caller_id_number']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['outbound_caller_id_name']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['outbound_caller_id_number']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['emergency_caller_id_number']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['directory_full_name']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['directory_visible']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['limit_max']) > 0) { + $tmp_xml .= " \n"; + } + else { + $tmp_xml .= " \n"; + } + if (strlen($row['limit_destination']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['sip_force_contact']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['sip_force_expires']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['nibble_account']) > 0) { + $tmp_xml .= " \n"; + } + switch ($row['sip_bypass_media']) { + case "bypass-media": + $tmp_xml .= " \n"; + break; + case "bypass-media-after-bridge": + $tmp_xml .= " \n"; + break; + case "proxy-media": + $tmp_xml .= " \n"; + break; + } + + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + + if (!is_readable($_SESSION['switch']['extensions']['dir']."/".$row['user_context'])) { + mkdir($_SESSION['switch']['extensions']['dir']."/".$row['user_context'],0755,true); + } + if (strlen($extension) > 0) { + $fout = fopen($_SESSION['switch']['extensions']['dir']."/".$row['user_context']."/v_".$extension.".xml","w"); + } + $tmp_xml .= "\n"; + fwrite($fout, $tmp_xml); + unset($tmp_xml); + fclose($fout); + } + } + unset ($prep_statement); + + //prepare extension + $extension_dir_path = realpath($_SESSION['switch']['extensions']['dir']); + $user_context = str_replace(" ", "_", $user_context); + $user_context = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $user_context); + + //define the group members + $tmp_xml = "\n"; + $tmp_xml .= "\n"; + $tmp_xml .= "\n"; + $tmp_xml .= " \n"; + if ($user_context == "default") { + $tmp_xml .= " \n"; + } + else { + $tmp_xml .= " \n"; + } + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= "\n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= "\n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= "\n"; + $previous_call_group = ""; + foreach ($call_group_array as $key => $value) { + $call_group = trim($key); + $extension_list = trim($value); + if (strlen($call_group) > 0) { + if ($previous_call_group != $call_group) { + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $extension_array = explode(",", $extension_list); + foreach ($extension_array as &$tmp_extension) { + $tmp_xml .= " \n"; + } + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + $tmp_xml .= "\n"; + } + $previous_call_group = $call_group; + } + unset($call_group); + } + $tmp_xml .= " \n"; + $tmp_xml .= "\n"; + $tmp_xml .= " \n"; + $tmp_xml .= ""; + + //write the xml file + if (is_readable($extension_dir_path) && strlen($extension_dir_path) > 0) { + $fout = fopen($extension_dir_path."/".$user_context.".xml","w"); + fwrite($fout, $tmp_xml); + unset($tmp_xml); + fclose($fout); + } + + //syncrhonize the phone directory + sync_directory(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + + //$cmd = "api reloadxml"; + //event_socket_request_cmd($cmd); + //unset($cmd); +} + +function filename_safe($filename) { + // lower case + $filename = strtolower($filename); + + // replace spaces with a '_' + $filename = str_replace(" ", "_", $filename); + + // loop through string + $result = ''; + for ($i=0; $i 1) { + $v_needle = 'v_'.$_SESSION['domain_name'].'-'; + } + else { + $v_needle = 'v_'; + } + $gateway_list = glob($_SESSION['switch']['gateways']['dir'] . "/*/".$v_needle."*.xml"); + foreach ($gateway_list as $gateway_file) { + unlink($gateway_file); + } + + //get the list of gateways and write the xml + $sql = "select * from v_gateways "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + foreach ($result as &$row) { + if ($row['enabled'] != "false") { + //remove invalid characters from the file names + $gateway = $row['gateway']; + $gateway = str_replace(" ", "_", $gateway); + $gateway = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $gateway); + //set the default profile as external + $profile = $row['profile']; + if (strlen($profile) == 0) { + $profile = "external"; + } + if (count($_SESSION["domains"]) > 1) { + $fout = fopen($_SESSION['switch']['gateways']['dir']."/".$profile."/v_".$_SESSION['domain_name'].'-'.$gateway.".xml","w"); + $tmp_xml .= "\n"; + $tmp_xml .= " \n"; + } + else { + $fout = fopen($_SESSION['switch']['gateways']['dir']."/".$profile."/v_".$gateway.".xml","w"); + $tmp_xml .= "\n"; + $tmp_xml .= " \n"; + } + if (strlen($row['username']) > 0) { + $tmp_xml .= " \n"; + } + else { + $tmp_xml .= " \n"; + } + if (strlen($row['distinct_to']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['auth_username']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['password']) > 0) { + $tmp_xml .= " \n"; + } + else { + $tmp_xml .= " \n"; + } + if (strlen($row['realm']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['from_user']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['from_domain']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['proxy']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['register_proxy']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['outbound_proxy']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['expire_seconds']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['register']) > 0) { + $tmp_xml .= " \n"; + } + + if (strlen($row['register_transport']) > 0) { + switch ($row['register_transport']) { + case "udp": + $tmp_xml .= " \n"; + break; + case "tcp": + $tmp_xml .= " \n"; + break; + case "tls": + $tmp_xml .= " \n"; + $tmp_xml .= " \n"; + break; + default: + $tmp_xml .= " \n"; + } + } + + if (strlen($row['retry_seconds']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['extension']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['ping']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['context']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['caller_id_in_from']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['supress_cng']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['sip_cid_type']) > 0) { + $tmp_xml .= " \n"; + } + if (strlen($row['extension_in_contact']) > 0) { + $tmp_xml .= " \n"; + } + + $tmp_xml .= " \n"; + $tmp_xml .= ""; + + fwrite($fout, $tmp_xml); + unset($tmp_xml); + fclose($fout); + } + + } //end foreach + unset($prep_statement); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + +} + + +function save_module_xml() { + global $config, $db, $domain_uuid; + + $xml = ""; + $xml .= "\n"; + $xml .= " \n"; + + $sql = "select * from v_modules "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $prev_module_cat = ''; + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + foreach ($result as $row) { + if ($prev_module_cat != $row['module_cat']) { + $xml .= "\n \n"; + } + if ($row['module_enabled'] == "true"){ + $xml .= " \n"; + } + $prev_module_cat = $row['module_cat']; + } + $xml .= "\n"; + $xml .= " \n"; + $xml .= ""; + + $fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/modules.conf.xml","w"); + fwrite($fout, $xml); + unset($xml); + fclose($fout); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + + //$cmd = "api reloadxml"; + //event_socket_request_cmd($cmd); + //unset($cmd); +} + +function save_var_xml() { + global $config, $db, $domain_uuid; + + $fout = fopen($_SESSION['switch']['conf']['dir']."/vars.xml","w"); + $xml = ''; + + $sql = "select * from v_vars "; + $sql .= "where var_enabled = 'true' "; + $sql .= "order by var_cat, var_order asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $prev_var_cat = ''; + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + foreach ($result as &$row) { + if ($row['var_cat'] != 'Provision') { + if ($prev_var_cat != $row['var_cat']) { + $xml .= "\n\n"; + if (strlen($row["var_description"]) > 0) { + $xml .= "\n"; + } + } + $xml .= "\n"; + } + $prev_var_cat = $row['var_cat']; + } + $xml .= "\n"; + fwrite($fout, $xml); + unset($xml); + fclose($fout); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + + //$cmd = "api reloadxml"; + //event_socket_request_cmd($cmd); + //unset($cmd); +} + +function outbound_route_to_bridge ($destination_number) { + global $domain_uuid, $db; + + $destination_number = trim($destination_number); + if (is_numeric($destination_number)) { + //not found, continue to process the function + } + else { + //not a number, brige_array and exit the function + $bridge_array[0] = $destination_number; + return $bridge_array; + } + + $sql = "select * from v_dialplans "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and app_uuid = '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' "; + $sql .= "order by dialplan_order asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + $x = 0; + foreach ($result as &$row) { + //set as variables + $dialplan_uuid = $row['dialplan_uuid']; + $dialplan_detail_tag = $row["dialplan_detail_tag"]; + $dialplan_detail_type = $row['dialplan_detail_type']; + $dialplan_continue = $row['dialplan_continue']; + + //get the extension number using the dialplan_uuid + $sql = "select * "; + $sql .= "from v_dialplan_details "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $sql .= "order by dialplan_detail_order asc "; + $sub_result = $db->query($sql)->fetchAll(PDO::FETCH_ASSOC); + $regex_match = false; + foreach ($sub_result as &$sub_row) { + if ($sub_row['dialplan_detail_tag'] == "condition") { + if ($sub_row['dialplan_detail_type'] == "destination_number") { + $dialplan_detail_data = $sub_row['dialplan_detail_data']; + $pattern = '/'.$dialplan_detail_data.'/'; + preg_match($pattern, $destination_number, $matches, PREG_OFFSET_CAPTURE); + if (count($matches) == 0) { + $regex_match = false; + } + else { + $regex_match = true; + $regex_match_1 = $matches[1][0]; + $regex_match_2 = $matches[2][0]; + $regex_match_3 = $matches[3][0]; + $regex_match_4 = $matches[4][0]; + $regex_match_5 = $matches[5][0]; + } + } + } + } + if ($regex_match) { + foreach ($sub_result as &$sub_row) { + $dialplan_detail_data = $sub_row['dialplan_detail_data']; + if ($sub_row['dialplan_detail_tag'] == "action" && $sub_row['dialplan_detail_type'] == "bridge" && $dialplan_detail_data != "\${enum_auto_route}") { + $dialplan_detail_data = str_replace("\$1", $regex_match_1, $dialplan_detail_data); + $dialplan_detail_data = str_replace("\$2", $regex_match_2, $dialplan_detail_data); + $dialplan_detail_data = str_replace("\$3", $regex_match_3, $dialplan_detail_data); + $dialplan_detail_data = str_replace("\$4", $regex_match_4, $dialplan_detail_data); + $dialplan_detail_data = str_replace("\$5", $regex_match_5, $dialplan_detail_data); + //echo "dialplan_detail_data: $dialplan_detail_data"; + $bridge_array[$x] = $dialplan_detail_data; + $x++; + if ($dialplan_continue == "false") { + break 2; + } + } + } + } + } + return $bridge_array; + unset ($prep_statement); +} +//$destination_number = '1231234'; +//$bridge_array = outbound_route_to_bridge ($destination_number); +//foreach ($bridge_array as &$bridge) { +// echo "bridge: ".$bridge."
    "; +//} + +function extension_exists($extension) { + global $db, $domain_uuid; + $sql = "select * from v_extensions "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and extension = '$extension' "; + $sql .= "and enabled = 'true' "; + $result = $db->query($sql)->fetchAll(PDO::FETCH_ASSOC); + if (count($result) > 0) { + return true; + } + else { + return false; + } +} + +function save_hunt_group_xml() { + + //Hunt Group Lua Notes: + //get the domain + //loop through all Hunt Groups + //get the Hunt Group information such as the name and description + //add each Hunt Group to the dialplan + //get the list of destinations then build the Hunt Group lua + + //get the domain + global $db, $domain_uuid, $host, $config; + + $tmp = ""; + $tmp .= "\n"; + $tmp .= " domain_name = \"".$domain."\"; //by default this is the ipv4 address of FreeSWITCH used for transfer to voicemail\n"; + $tmp .= "\n"; + $tmp .= "\n"; + + //prepare for hunt group .lua files to be written. delete all hunt groups that are prefixed with huntgroup_ and have a file extension of .lua + $v_prefix = 'v_huntgroup_'; + if($dh = opendir($_SESSION['switch']['scripts']['dir'])) { + $files = Array(); + while($file = readdir($dh)) { + if($file != "." && $file != ".." && $file[0] != '.') { + if(is_dir($dir . "/" . $file)) { + //this is a directory + } else { + if (substr($file,0, strlen($v_prefix)) == $v_prefix && substr($file,-4) == '.lua') { + if ($file != "huntgroup_originate.lua") { + unlink($_SESSION['switch']['scripts']['dir'].'/'.$file); + } + } + } + } + } + closedir($dh); + } + + //loop through all Hunt Groups + $x = 0; + + $sql = "select * from v_hunt_groups "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + foreach ($result as &$row) { + //get the Hunt Group information such as the name and description + //$row['hunt_group_uuid'] + //$row['hunt_group_extension'] + //$row['hunt_group_name'] + //$row['hunt_group_type'] + //$row['hunt_group_timeout'] + //$row['hunt_group_context'] + //$row['hunt_group_ringback'] + //$row['hunt_group_cid_name_prefix'] + //$row['hunt_group_pin'] + //$row['hunt_group_caller_announce'] + //$row['hunt_group_enabled'] + //$row['hunt_group_description'] + $domain_uuid = $row['domain_uuid']; + $dialplan_uuid = $row['dialplan_uuid']; + + //add each hunt group to the dialplan + if (strlen($row['hunt_group_uuid']) > 0) { + //set default action to add + $action = 'add'; + //check whether the dialplan entry exists in the database + $action = 'add'; //set default action to add + $i = 0; + $sql = "select count(*) as num_rows from v_dialplans "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and dialplan_uuid = '".$dialplan_uuid."' "; + $prep_statement_2 = $db->prepare(check_sql($sql)); + if ($prep_statement_2) { + $prep_statement_2->execute(); + $row2 = $prep_statement_2->fetch(PDO::FETCH_ASSOC); + if ($row2['num_rows'] > 0) { + //$num_rows = $row2['num_rows']; + $action = 'update'; + } + } + unset($prep_statement, $result); + + if ($action == 'add') { + //create dialplan entry for each huntgroup + $app_uuid = '0610f841-2e27-4c5f-7926-08ab3aad02e0'; + if ($row['hunt_group_enabled'] == "false") { + $dialplan_enabled = 'false'; + } + else { + $dialplan_enabled = 'true'; + } + if (strlen($dialplan_uuid) == 0) { + //create a dialplan uuid + $dialplan_uuid = uuid(); + //update the hunt groups table with the database + $sql = "update v_hunt_groups "; + $sql .= "set dialplan_uuid = '".$dialplan_uuid."' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and hunt_group_uuid = '".$row['hunt_group_uuid']."' "; + $db->query($sql); + unset($sql); + } + + require_once "includes/classes/dialplan.php"; + $dialplan = new dialplan; + $dialplan->domain_uuid = $_SESSION['domain_uuid']; + $dialplan->app_uuid = $app_uuid; + $dialplan->dialplan_uuid = $dialplan_uuid; + $dialplan->dialplan_name = $row['hunt_group_name']; + //$dialplan->dialplan_continue = $dialplan_continue; + $dialplan->dialplan_order = '330'; + $dialplan->dialplan_context = $_SESSION['context']; + $dialplan->dialplan_enabled = $dialplan_enabled; + $dialplan->dialplan_description = $row['hunt_group_description']; + $dialplan->dialplan_add(); + unset($dialplan); + } + + if ($action == 'update') { + //update the huntgroup fifo + $dialplan_name = $row['hunt_group_name'].'.park'; + $dialplan_order = '330'; + $context = $row['hunt_group_context']; + if ($row['hunt_group_enabled'] == "false") { + $enabled = 'false'; + } + else { + $enabled = 'true'; + } + $description = $row['hunt_group_description']; + $hunt_group_uuid = $row['hunt_group_uuid']; + + $sql = "update v_dialplans set "; + $sql .= "dialplan_name = '$dialplan_name', "; + $sql .= "dialplan_order = '$dialplan_order', "; + $sql .= "dialplan_context = '$context', "; + $sql .= "dialplan_enabled = '$enabled', "; + $sql .= "dialplan_description = '$description' "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and dialplan_uuid = '".$dialplan_uuid."' "; + $db->query($sql); + unset($sql); + + $sql = "delete from v_dialplan_details "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $db->query($sql); + unset($sql); + } + + //if action is add or update + if ($action == 'add' || $action == 'update') { + require_once "includes/classes/dialplan.php"; + $dialplan = new dialplan; + $dialplan->domain_uuid = $_SESSION['domain_uuid']; + $dialplan->dialplan_uuid = $dialplan_uuid; + $dialplan->dialplan_detail_tag = 'condition'; //condition, action, antiaction + $dialplan->dialplan_detail_type = 'destination_number'; + $dialplan->dialplan_detail_data = '^'.$row['hunt_group_extension'].'$'; + //$dialplan->dialplan_detail_break = ''; + //$dialplan->dialplan_detail_inline = ''; + $dialplan->dialplan_detail_group = '1'; + $dialplan->dialplan_detail_order = '010'; + $dialplan->dialplan_detail_add(); + unset($dialplan); + + $dialplan = new dialplan; + $dialplan->domain_uuid = $_SESSION['domain_uuid']; + $dialplan->dialplan_uuid = $dialplan_uuid; + $dialplan->dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan->dialplan_detail_type = 'lua'; + $dialplan->dialplan_detail_data = 'v_huntgroup_'.$_SESSION['domain_name'].'_'.$row['hunt_group_extension'].'.lua'; + //$dialplan->dialplan_detail_break = ''; + //$dialplan->dialplan_detail_inline = ''; + $dialplan->dialplan_detail_group = '1'; + $dialplan->dialplan_detail_order = '020'; + $dialplan->dialplan_detail_add(); + unset($dialplan); + + $dialplan = new dialplan; + $dialplan->domain_uuid = $_SESSION['domain_uuid']; + $dialplan->dialplan_uuid = $dialplan_uuid; + $dialplan->dialplan_detail_tag = 'condition'; //condition, action, antiaction + $dialplan->dialplan_detail_type = 'destination_number'; + $dialplan->dialplan_detail_data = '^\*'.$row['hunt_group_extension'].'$'; + $dialplan->dialplan_detail_break = 'on-true'; + //$dialplan->dialplan_detail_inline = ''; + $dialplan->dialplan_detail_group = '2'; + $dialplan->dialplan_detail_order = '020'; + $dialplan->dialplan_detail_add(); + unset($dialplan); + + $dialplan = new dialplan; + $dialplan->domain_uuid = $_SESSION['domain_uuid']; + $dialplan->dialplan_uuid = $dialplan_uuid; + $dialplan->dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan->dialplan_detail_type = 'set'; + $dialplan->dialplan_detail_data = 'fifo_music=$${hold_music}'; + //$dialplan->dialplan_detail_break = ''; + //$dialplan->dialplan_detail_inline = ''; + $dialplan->dialplan_detail_group = '2'; + $dialplan->dialplan_detail_order = '020'; + $dialplan->dialplan_detail_add(); + unset($dialplan); + + $hunt_group_timeout_type = $row['hunt_group_timeout_type']; + $hunt_group_timeout_destination = $row['hunt_group_timeout_destination']; + if ($hunt_group_timeout_type == "voicemail") { $hunt_group_timeout_destination = '*99'.$hunt_group_timeout_destination; } + $dialplan = new dialplan; + $dialplan->domain_uuid = $_SESSION['domain_uuid']; + $dialplan->dialplan_uuid = $dialplan_uuid; + $dialplan->dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan->dialplan_detail_type = 'set'; + $dialplan->dialplan_detail_data = 'fifo_orbit_exten='.$hunt_group_timeout_destination.':'.$row['hunt_group_timeout']; + //$dialplan->dialplan_detail_break = ''; + //$dialplan->dialplan_detail_inline = ''; + $dialplan->dialplan_detail_group = '2'; + $dialplan->dialplan_detail_order = '030'; + $dialplan->dialplan_detail_add(); + unset($dialplan); + + $dialplan = new dialplan; + $dialplan->domain_uuid = $_SESSION['domain_uuid']; + $dialplan->dialplan_uuid = $dialplan_uuid; + $dialplan->dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan->dialplan_detail_type = 'fifo'; + $dialplan->dialplan_detail_data = $row['hunt_group_extension'].'@${domain_name} in'; + //$dialplan->dialplan_detail_break = ''; + //$dialplan->dialplan_detail_inline = ''; + $dialplan->dialplan_detail_group = '2'; + $dialplan->dialplan_detail_order = '040'; + $dialplan->dialplan_detail_add(); + unset($dialplan); + } + + //save the dialplan xml files + save_dialplan_xml(); + } //end if strlen hunt_group_uuid; add the Hunt Group to the dialplan + + //get the list of destinations then build the Hunt Group Lua + $tmp = "\n"; + $tmp .= "session:preAnswer();\n"; + $tmp .= "extension = '".$row['hunt_group_extension']."';\n"; + $tmp .= "result = '';\n"; + $tmp .= "timeoutpin = 7500;\n"; + $tmp .= "sip_profile = 'internal';\n"; + $tmp .= "\n"; + + $tmp .= "function extension_registered(domain_name, sip_profile, extension)\n"; + $tmp .= " api = freeswitch.API();\n"; + $tmp .= " result = api:execute(\"sofia_contact\", sip_profile..\"/\"..extension..\"@\"..domain_name);\n"; + $tmp .= " if (result == \"error/user_not_registered\") then\n"; + $tmp .= " return false;\n"; + $tmp .= " else\n"; + $tmp .= " return true;\n"; + $tmp .= " end\n"; + $tmp .= "end\n"; + $tmp .= "\n"; + + $tmp .= "\n"; + $tmp .= "sounds_dir = session:getVariable(\"sounds_dir\");\n"; + $tmp .= "uuid = session:getVariable(\"uuid\");\n"; + $tmp .= "dialed_extension = session:getVariable(\"dialed_extension\");\n"; + $tmp .= "domain_name = session:getVariable(\"domain_name\");\n"; + $tmp .= "caller_id_name = session:getVariable(\"caller_id_name\");\n"; + $tmp .= "caller_id_number = session:getVariable(\"caller_id_number\");\n"; + $tmp .= "effective_caller_id_name = session:getVariable(\"effective_caller_id_name\");\n"; + $tmp .= "effective_caller_id_number = session:getVariable(\"effective_caller_id_number\");\n"; + $tmp .= "outbound_caller_id_name = session:getVariable(\"outbound_caller_id_name\");\n"; + $tmp .= "outbound_caller_id_number = session:getVariable(\"outbound_caller_id_number\");\n"; + $tmp .= "\n"; + + $tmp .= "--set the sounds path for the language, dialect and voice\n"; + $tmp .= " default_language = session:getVariable(\"default_language\");\n"; + $tmp .= " default_dialect = session:getVariable(\"default_dialect\");\n"; + $tmp .= " default_voice = session:getVariable(\"default_voice\");\n"; + $tmp .= " if (not default_language) then default_language = 'en'; end\n"; + $tmp .= " if (not default_dialect) then default_dialect = 'us'; end\n"; + $tmp .= " if (not default_voice) then default_voice = 'callie'; end\n"; + $tmp .= "\n"; + + //pin number requested from caller if provided + if (strlen($row['hunt_group_pin']) > 0) { + $tmp .= "pin = '".$row['hunt_group_pin']."';\n"; + $tmp .= "digits = session:playAndGetDigits(".strlen($row['hunt_group_pin']).", ".strlen($row['hunt_group_pin']).", 3, 3000, \"#\", sounds_dir..\"/\"..default_language..\"/\"..default_dialect..\"/\"..default_voice..\"/custom/please_enter_the_pin_number.wav\", \"\", \"\\\\d+\");\n"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= "if (digits == pin) then\n"; + $tmp .= " --continue\n"; + $tmp .= "\n"; + } + + //caller announce requested from caller if provided + if ($row['hunt_group_caller_announce'] == "true" || $row['hunt_group_call_prompt'] == "true") { + if ($row['hunt_group_caller_announce'] == "true") { + $tmp .= "function originate(domain_name, session, sipuri, extension, caller_id_name, caller_id_number, caller_announce) \n"; + } + else { + $tmp .= "function originate(domain_name, session, sipuri, extension, caller_id_name, caller_id_number) \n"; + } + $tmp .= " --caller_id_name = caller_id_name.replace(\" \", \"..\");\n"; + $tmp .= " caller_id_name = string.gsub(caller_id_name, \" \", \"..\");\n"; + //$tmp .= " --session:execute(\"luarun\", \"huntgroup_originate.lua \"..domain_name..\" \"..uuid..\" \"..sipuri..\" \"..extension..\" \"..caller_id_name..\" \"..caller_id_number..\" \"..caller_announce);\n"; + $tmp .= " api = freeswitch.API();\n"; + if ($row['hunt_group_caller_announce'] == "true") { + $tmp .= " result = api:execute(\"luarun\", \"huntgroup_originate.lua \"..domain_name..\" \"..uuid..\" \"..sipuri..\" \"..extension..\" \"..caller_id_name..\" \"..caller_id_number..\" \"..caller_announce);\n"; + } + else { + $tmp .= " result = api:execute(\"luarun\", \"huntgroup_originate.lua \"..domain_name..\" \"..uuid..\" \"..sipuri..\" \"..extension..\" \"..caller_id_name..\" \"..caller_id_number..\"\");\n"; + } + $tmp .= "end"; + $tmp .= "\n"; + + if ($row['hunt_group_caller_announce'] == "true") { + $tmp .= "caller_announce = \"".$tmp_dir."/\"..extension..\"_\"..uuid..\".wav\";\n"; + $tmp .= "session:streamFile(sounds_dir..\"/\"..default_language..\"/\"..default_dialect..\"/\"..default_voice..\"/custom/please_say_your_name_and_reason_for_calling.wav\");\n"; + $tmp .= "session:execute(\"gentones\", \"%(1000, 0, 640)\");\n"; + $tmp .= "session:execute(\"set\", \"playback_terminators=#\");\n"; + $tmp .= "session:execute(\"record\", caller_announce..\" 180 200\");\n"; + } + $tmp .= "\n"; + $tmp .= "session:setAutoHangup(false);\n"; + $tmp .= "session:execute(\"transfer\", \"*\"..extension..\" XML ".$_SESSION["context"]."\");\n"; + $tmp .= "\n"; + } + + //set caller id prefix + if (strlen($row['hunt_group_cid_name_prefix'])> 0) { + $tmp .= "if caller_id_name then\n"; + $tmp .= " session:setVariable(\"caller_id_name\", \"".$row['hunt_group_cid_name_prefix']."\"..caller_id_name);\n"; + $tmp .= "end\n"; + $tmp .= "if effective_caller_id_name then\n"; + $tmp .= " session:setVariable(\"effective_caller_id_name\", \"".$row['hunt_group_cid_name_prefix']."\"..effective_caller_id_name);\n"; + $tmp .= "elseif caller_id_name then\n"; + $tmp .= " --effective_caller_id_name missing, set to caller_id_name\n"; + $tmp .= " session:setVariable(\"effective_caller_id_name\", \"".$row['hunt_group_cid_name_prefix']."\"..caller_id_name);\n"; + $tmp .= "end\n"; + $tmp .= "if outbound_caller_id_name then\n"; + $tmp .= " session:setVariable(\"outbound_caller_id_name\", \"".$row['hunt_group_cid_name_prefix']."\"..outbound_caller_id_name);\n"; + $tmp .= "end\n"; + } + + //set ring back + if (isset($row['hunt_group_ringback'])){ + if ($row['hunt_group_ringback'] == "music"){ + $tmp .= "session:execute(\"set\", \"ringback=\${hold_music}\"); --set to music\n"; + $tmp .= "session:execute(\"set\", \"transfer_ringback=\${hold_music}\"); --set to music\n"; + } + else { + $tmp .= "session:execute(\"set\", \"ringback=\$\${".$row['hunt_group_ringback']."}\"); --set to ringtone\n"; + $tmp .= "session:execute(\"set\", \"transfer_ringback=\$\${".$row['hunt_group_ringback']."}\"); --set to ringtone\n"; + } + if ($row['hunt_group_ringback'] == "ring"){ + $tmp .= "session:execute(\"set\", \"ringback=\$\${us-ring}\"); --set to ringtone\n"; + $tmp .= "session:execute(\"set\", \"transfer_ringback=\$\${us-ring}\"); --set to ringtone\n"; + } + } + else { + $tmp .= "session:execute(\"set\", \"ringback=\${hold_music}\"); --set to ringtone\n"; + $tmp .= "session:execute(\"set\", \"transfer_ringback=\${hold_music}\"); --set to ringtone\n"; + } + + if ($row['hunt_group_timeout'] > 0) { + //$tmp .= "session:setVariable(\"call_timeout\", \"".$row['hunt_group_timeout']."\");\n"; + $tmp .= "session:setVariable(\"continue_on_fail\", \"true\");\n"; + $tmp .= "session:setVariable(\"ignore_early_media\", \"true\");\n"; + } + $tmp .= "session:setVariable(\"hangup_after_bridge\", \"true\");\n"; + $tmp .= "\n"; + $tmp .= "--freeswitch.consoleLog( \"info\", \"dialed extension:\"..dialed_extension..\"\\n\" );\n"; + $tmp .= "--freeswitch.consoleLog( \"info\", \"domain: \"..domain..\"\\n\" );\n"; + $tmp .= "--freeswitch.consoleLog( \"info\", \"us_ring: \"..us_ring..\"\\n\" );\n"; + $tmp .= "--freeswitch.consoleLog( \"info\", \"domain_name: \"..domain_name..\"\\n\" );\n"; + $tmp .= "\n"; + + $tmp .= "--freeswitch.consoleLog( \"info\", \"action call now don't wait for dtmf\\n\" );\n"; + if ($row['hunt_group_caller_announce'] == "true" || $row['hunt_group_call_prompt'] == "true") { + //do nothing + } + else { + $tmp .= "if session:ready() then\n"; + //$tmp .= " session.answer();\n"; + } + $tmp .= "\n"; + + $i = 0; + $sql = "select * from v_hunt_group_destinations "; + $sql .= "where hunt_group_uuid = '".$row['hunt_group_uuid']."' "; + $sql .= "and domain_uuid = '$domain_uuid' "; + //$sql .= "and destination_enabled = 'true' "; + $sql .= "order by destination_order asc "; + $prep_statement_2 = $db->prepare($sql); + $prep_statement_2->execute(); + while($ent = $prep_statement_2->fetch(PDO::FETCH_ASSOC)) { + //$ent['hunt_group_uuid'] + //$ent['destination_data'] + //$ent['destination_type'] + //$ent['destination_profile'] + //$ent['destination_order'] + //$ent['destination_enabled'] + //$ent['destination_description'] + + $destination_timeout = $ent['destination_timeout']; + if (strlen($destination_timeout) == 0) { + if (strlen($row['hunt_group_timeout']) == 0) { + $destination_timeout = '30'; + } + else { + $destination_timeout = $row['hunt_group_timeout']; + } + } + + //set the default profile + if (strlen($ent['destination_data']) == 0) { $ent['destination_data'] = "internal"; } + + if ($ent['destination_type'] == "extension") { + //$tmp .= " sofia_contact_".$ent['destination_data']." = \"\${sofia_contact(".$ent['destination_profile']."/".$ent['destination_data']."@\"..domain_name..\")}\";\n"; + $tmp_sub_array["application"] = "bridge"; + $tmp_sub_array["type"] = "extension"; + $tmp_sub_array["extension"] = $ent['destination_data']; + //$tmp_sub_array["data"] = "\"[leg_timeout=$destination_timeout]\"..sofia_contact_".$ent['destination_data']; + $tmp_sub_array["data"] = "\"[leg_timeout=$destination_timeout]user/".$ent['destination_data']."@\"..domain_name"; + $tmp_array[$i] = $tmp_sub_array; + unset($tmp_sub_array); + } + if ($ent['destination_type'] == "voicemail") { + $tmp_sub_array["application"] = "voicemail"; + $tmp_sub_array["type"] = "voicemail"; + $tmp .= " session:execute(\"voicemail\", \"default \${domain_name} ".$ent['destination_data']."\");\n"; + //$tmp_sub_array["application"] = "voicemail"; + //$tmp_sub_array["data"] = "default \${domain_name} ".$ent['destination_data']; + //$tmp_array[$i] = $tmp_sub_array; + unset($tmp_sub_array); + } + if ($ent['destination_type'] == "sip uri") { + $tmp_sub_array["application"] = "bridge"; + $tmp_sub_array["type"] = "sip uri"; + //$destination_data = "{user=foo}loopback/".$ent['destination_data']."/default/XML"; + $bridge_array = outbound_route_to_bridge ($ent['destination_data']); + $destination_data = $bridge_array[0]; + $tmp_sub_array["application"] = "bridge"; + $tmp_sub_array["data"] = "\"[leg_timeout=$destination_timeout,origination_caller_id_name=\"..outbound_caller_id_name..\",origination_caller_id_number=\"..outbound_caller_id_number..\"]".$destination_data."\""; + $tmp_array[$i] = $tmp_sub_array; + unset($tmp_sub_array); + unset($destination_data); + } + $i++; + } //end while + unset ($sql, $prep_statement_2); + unset($i, $ent); + + $i = 0; + if(count($tmp_array) > 0) { + foreach ($tmp_array as $ent) { + $tmpdata = $ent["data"]; + if ($ent["application"] == "voicemail") { $tmpdata = "*99".$tmpdata; } + if ($i < 1) { + $tmp_buffer = $tmpdata; + } + else { + $tmp_buffer .= "..\",\"..".$tmpdata; + } + $i++; + } + } + unset($i); + $tmp_application = $tmp_array[0]["application"]; + + if ($row['hunt_group_type'] == "simultaneous" || $row['hunt_group_type'] == "follow_me_simultaneous" || $row['hunt_group_type'] == "call_forward") { + $tmp_switch = "simultaneous"; + } + if ($row['hunt_group_type'] == "sequence" || $row['hunt_group_type'] == "follow_me_sequence" || $row['hunt_group_type'] == "sequentially") { + $tmp_switch = "sequence"; + } + switch ($tmp_switch) { + case "simultaneous": + if ($row['hunt_group_caller_announce'] == "true" || $row['hunt_group_call_prompt'] == "true") { + $i = 0; + if (count($tmp_array) > 0) { + foreach ($tmp_array as $tmp_row) { + $tmpdata = $tmp_row["data"]; + if ($tmp_row["application"] == "voicemail") { + $tmpdata = "*99".$tmpdata; + } + else { + if ($tmp_row["type"] == "extension") { + $tmp .= "if (extension_registered(domain_name, sip_profile, '".$tmp_row["extension"]."')) then\n"; + $tmp .= " "; + } + if ($row['hunt_group_caller_announce'] == "true") { + $tmp .= "result = originate (domain_name, session, ".$tmpdata.", extension, caller_id_name, caller_id_number, caller_announce);\n"; + } + else { + $tmp .= "result = originate (domain_name, session, ".$tmpdata.", extension, caller_id_name, caller_id_number);\n"; + } + if ($tmp_row["type"] == "extension") { + $tmp .= "end\n"; + } + } + } + } + } + else { + $tmp .= "\n"; + if (strlen($tmp_buffer) > 0) { + $tmp .= " session:execute(\"".$tmp_application."\", $tmp_buffer);\n"; + } + } + break; + case "sequence": + $tmp .= "\n"; + $i = 0; + if (count($tmp_array) > 0) { + if ($row['hunt_group_caller_announce'] == "true" || $row['hunt_group_call_prompt'] == "true") { + $i = 0; + if (count($tmp_array) > 0) { + foreach ($tmp_array as $tmp_row) { + $tmpdata = $tmp_row["data"]; + if ($tmp_row["application"] == "voicemail") { + $tmpdata = "*99".$tmpdata; + } + else { + if ($tmp_row["type"] == "extension") { + $tmp .= "if (extension_registered(domain_name, sip_profile, '".$tmp_row["extension"]."')) then\n"; + $tmp .= " "; + } + if ($row['hunt_group_caller_announce'] == "true") { + $tmp .= "result = originate (domain_name, session, ".$tmpdata.", extension, caller_id_name, caller_id_number, caller_announce);\n"; + } + else { + $tmp .= "result = originate (domain_name, session, ".$tmpdata.", extension, caller_id_name, caller_id_number);\n"; + } + if ($tmp_row["type"] == "extension") { + $tmp .= "end\n"; + } + } + } + } + } + else { + foreach ($tmp_array as $tmp_row) { + if (strlen($tmp_row["data"]) > 0) { + $tmp .= " session:execute(\"".$tmp_application."\", ".$tmp_row["data"].");\n"; + } + } + } + unset($tmp_row); + } + break; + } + unset($tmp_switch, $tmp_buffer, $tmp_array); + + //set the timeout destination + $hunt_group_timeout_destination = $row['hunt_group_timeout_destination']; + if ($row['hunt_group_timeout_type'] == "extension") { $hunt_group_timeout_type = "transfer"; } + if ($row['hunt_group_timeout_type'] == "voicemail") { $hunt_group_timeout_type = "voicemail"; $hunt_group_timeout_destination = "default \${domain_name} ".$hunt_group_timeout_destination; } + if ($row['hunt_group_timeout_type'] == "sip uri") { $hunt_group_timeout_type = "bridge"; } + $tmp .= "\n"; + if ($row['hunt_group_caller_announce'] == "true" || $row['hunt_group_call_prompt'] == "true") { + //do nothing + } + else { + $tmp .= " --timeout\n"; + if ($row['hunt_group_type'] != 'dnd') { + $tmp .= " originate_disposition = session:getVariable(\"originate_disposition\");\n"; + $tmp .= " if originate_disposition ~= \"SUCCESS\" then\n"; + } + $tmp .= " session:execute(\"".$hunt_group_timeout_type."\", \"".$hunt_group_timeout_destination."\");\n"; + if ($row['hunt_group_type'] != 'dnd') { + $tmp .= " end\n"; + } + } + + if ($row['hunt_group_caller_announce'] == "true" || $row['hunt_group_call_prompt'] == "true") { + //do nothing + } + else { + $tmp .= "end --end if session:ready\n"; + } + $tmp .= "\n"; + //pin number requested from caller if provided + if (strlen($row['hunt_group_pin']) > 0) { + $tmp .= "else \n"; + $tmp .= " session:streamFile(sounds_dir..\"/\"..default_language..\"/\"..default_dialect..\"/\"..default_voice..\"/custom/your_pin_number_is_incorect_goodbye.wav\");\n"; + $tmp .= " session:hangup();\n"; + $tmp .= "end\n"; + $tmp .= "\n"; + } + + //unset variables + $tmp .= "\n"; + $tmp .= "--clear variables\n"; + $tmp .= "dialed_extension = \"\";\n"; + $tmp .= "new_extension = \"\";\n"; + $tmp .= "domain_name = \"\";\n"; + $tmp .= "\n"; + + //remove invalid characters from the file names + $huntgroup_extension = $row['hunt_group_extension']; + $huntgroup_extension = str_replace(" ", "_", $huntgroup_extension); + $huntgroup_extension = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $huntgroup_extension); + + //write the hungroup lua script + if (strlen($row['hunt_group_extension']) > 0) { + if ($row['hunt_group_enabled'] != "false") { + $hunt_group_filename = "v_huntgroup_".$_SESSION['domains'][$domain_uuid]['domain_name']."_".$huntgroup_extension.".lua"; + //echo "location".$_SESSION['switch']['scripts']['dir']."/".$hunt_group_filename; + $fout = fopen($_SESSION['switch']['scripts']['dir']."/".$hunt_group_filename,"w"); + fwrite($fout, $tmp); + unset($hunt_group_filename); + fclose($fout); + } + } + } //end while + + //apply settings reminder + $_SESSION["reload_xml"] = true; +} //end huntgroup function lua + + +function get_recording_filename($id) { + global $domain_uuid, $db; + $sql = "select * from v_recordings "; + $sql .= "where recording_uuid = '$id' "; + $sql .= "and domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + foreach ($result as &$row) { + //$filename = $row["filename"]; + //$recording_name = $row["recording_name"]; + //$recording_uuid = $row["recording_uuid"]; + return $row["filename"]; + break; //limit to 1 row + } + unset ($prep_statement); +} + +function dialplan_add($domain_uuid, $dialplan_uuid, $dialplan_name, $dialplan_order, $dialplan_context, $dialplan_enabled, $dialplan_description, $app_uuid) { + global $db, $db_type; + $sql = "insert into v_dialplans "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + if (strlen($app_uuid) > 0) { + $sql .= "app_uuid, "; + } + $sql .= "dialplan_name, "; + $sql .= "dialplan_order, "; + $sql .= "dialplan_context, "; + $sql .= "dialplan_enabled, "; + $sql .= "dialplan_description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'$dialplan_uuid', "; + if (strlen($app_uuid) > 0) { + $sql .= "'$app_uuid', "; + } + $sql .= "'$dialplan_name', "; + $sql .= "'$dialplan_order', "; + $sql .= "'$dialplan_context', "; + $sql .= "'$dialplan_enabled', "; + $sql .= "'$dialplan_description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); +} + +function dialplan_detail_add($domain_uuid, $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data) { + global $db; + $dialplan_detail_uuid = uuid(); + $sql = "insert into v_dialplan_details "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "dialplan_uuid, "; + $sql .= "dialplan_detail_uuid, "; + $sql .= "dialplan_detail_tag, "; + $sql .= "dialplan_detail_group, "; + $sql .= "dialplan_detail_order, "; + $sql .= "dialplan_detail_type, "; + $sql .= "dialplan_detail_data "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'".check_str($dialplan_uuid)."', "; + $sql .= "'".check_str($dialplan_detail_uuid)."', "; + $sql .= "'".check_str($dialplan_detail_tag)."', "; + if (strlen($dialplan_detail_group) == 0) { + $sql .= "null, "; + } + else { + $sql .= "'".check_str($dialplan_detail_group)."', "; + } + $sql .= "'".check_str($dialplan_detail_order)."', "; + $sql .= "'".check_str($dialplan_detail_type)."', "; + $sql .= "'".check_str($dialplan_detail_data)."' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); +} + +function save_dialplan_xml() { + global $db, $domain_uuid; + + //get the context based from the domain_uuid + if (count($_SESSION['domains']) == 1) { + $user_context = "default"; + } + else { + $user_context = $_SESSION['domains'][$domain_uuid]['domain_name']; + } + + //prepare for dialplan .xml files to be written. delete all dialplan files that are prefixed with dialplan_ and have a file extension of .xml + $dialplan_list = glob($_SESSION['switch']['dialplan']['dir'] . "/*/*v_dialplan*.xml"); + foreach($dialplan_list as $name => $value) { + unlink($value); + } + $dialplan_list = glob($_SESSION['switch']['dialplan']['dir'] . "/*/*_v_*.xml"); + foreach($dialplan_list as $name => $value) { + unlink($value); + } + $dialplan_list = glob($_SESSION['switch']['dialplan']['dir'] . "/*/*/*_v_*.xml"); + foreach($dialplan_list as $name => $value) { + unlink($value); + } + + $sql = "select * from v_dialplans "; + $sql .= "where dialplan_enabled = 'true' "; + $prep_statement = $db->prepare(check_sql($sql)); + if ($prep_statement) { + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + foreach ($result as &$row) { + $tmp = ""; + $tmp .= "\n"; + + $dialplan_continue = ''; + if ($row['dialplan_continue'] == "true") { + $dialplan_continue = "continue=\"true\""; + } + + $tmp = "\n"; + + $sql = " select * from v_dialplan_details "; + $sql .= " where dialplan_uuid = '".$row['dialplan_uuid']."' "; + $sql .= " and domain_uuid = '".$row['domain_uuid']."' "; + $sql .= " order by dialplan_detail_group asc, dialplan_detail_order asc "; + $prep_statement_2 = $db->prepare($sql); + if ($prep_statement_2) { + $prep_statement_2->execute(); + $result2 = $prep_statement_2->fetchAll(PDO::FETCH_NAMED); + $result_count2 = count($result2); + unset ($prep_statement_2, $sql); + + //create a new array that is sorted into groups and put the tags in order conditions, actions, anti-actions + $details = ''; + $previous_tag = ''; + $details[$group]['condition_count'] = ''; + //conditions + $x = 0; + $y = 0; + foreach($result2 as $row2) { + if ($row2['dialplan_detail_tag'] == "condition") { + //get the group + $group = $row2['dialplan_detail_group']; + //get the generic type + switch ($row2['dialplan_detail_type']) { + case "hour": + $type = 'time'; + break; + case "minute": + $type = 'time'; + break; + case "minute-of-day": + $type = 'time'; + break; + case "mday": + $type = 'time'; + break; + case "mweek": + $type = 'time'; + break; + case "mon": + $type = 'time'; + break; + case "yday": + $type = 'time'; + break; + case "year": + $type = 'time'; + break; + case "wday": + $type = 'time'; + break; + case "week": + $type = 'time'; + break; + default: + $type = 'default'; + } + + //add the conditions to the details array + $details[$group]['condition-'.$x]['dialplan_detail_tag'] = $row2['dialplan_detail_tag']; + $details[$group]['condition-'.$x]['dialplan_detail_type'] = $row2['dialplan_detail_type']; + $details[$group]['condition-'.$x]['dialplan_uuid'] = $row2['dialplan_uuid']; + $details[$group]['condition-'.$x]['dialplan_detail_order'] = $row2['dialplan_detail_order']; + $details[$group]['condition-'.$x]['field'][$y]['type'] = $row2['dialplan_detail_type']; + $details[$group]['condition-'.$x]['field'][$y]['data'] = $row2['dialplan_detail_data']; + $details[$group]['condition-'.$x]['dialplan_detail_break'] = $row2['dialplan_detail_break']; + $details[$group]['condition-'.$x]['dialplan_detail_group'] = $row2['dialplan_detail_group']; + $details[$group]['condition-'.$x]['dialplan_detail_inline'] = $row2['dialplan_detail_inline']; + if ($type == "time") { + $y++; + } + } + if ($type == "default") { + $x++; + $y = 0; + } + } + + //actions + $x = 0; + foreach($result2 as $row2) { + if ($row2['dialplan_detail_tag'] == "action") { + $group = $row2['dialplan_detail_group']; + foreach ($row2 as $key => $val) { + $details[$group]['action-'.$x][$key] = $val; + } + } + $x++; + } + //anti-actions + $x = 0; + foreach($result2 as $row2) { + if ($row2['dialplan_detail_tag'] == "anti-action") { + $group = $row2['dialplan_detail_group']; + foreach ($row2 as $key => $val) { + $details[$group]['anti-action-'.$x][$key] = $val; + } + } + $x++; + } + unset($result2); + } + + $i=1; + if ($result_count2 > 0) { + foreach($details as $group) { + $current_count = 0; + $x = 0; + foreach($group as $ent) { + $close_condition_tag = true; + if (empty($ent)) { + $close_condition_tag = false; + } + $current_tag = $ent['dialplan_detail_tag']; + $c = 0; + if ($ent['dialplan_detail_tag'] == "condition") { + //get the generic type + switch ($ent['dialplan_detail_type']) { + case "hour": + $type = 'time'; + break; + case "minute": + $type = 'time'; + break; + case "minute-of-day": + $type = 'time'; + break; + case "mday": + $type = 'time'; + break; + case "mweek": + $type = 'time'; + break; + case "mon": + $type = 'time'; + break; + case "yday": + $type = 'time'; + break; + case "year": + $type = 'time'; + break; + case "wday": + $type = 'time'; + break; + case "week": + $type = 'time'; + break; + default: + $type = 'default'; + } + + //set the attribute and expression + $condition_attribute = ''; + foreach($ent['field'] as $field) { + if ($type == "time") { + if (strlen($field['type']) > 0) { + $condition_attribute .= $field['type'].'="'.$field['data'].'" '; + } + $condition_expression = ''; + } + if ($type == "default") { + $condition_attribute = ''; + if (strlen($field['type']) > 0) { + $condition_attribute = 'field="'.$field['type'].'" '; + } + $condition_expression = ''; + if (strlen($field['data']) > 0) { + $condition_expression = 'expression="'.$field['data'].'" '; + } + } + } + + //get the condition break attribute + $condition_break = ''; + if (strlen($ent['dialplan_detail_break']) > 0) { + $condition_break = "break=\"".$ent['dialplan_detail_break']."\" "; + } + + //get the count + $count = 0; + foreach($details as $group2) { + foreach($group2 as $ent2) { + if ($ent2['dialplan_detail_group'] == $ent['dialplan_detail_group'] && $ent2['dialplan_detail_tag'] == "condition") { + $count++; + } + } + } + + //use the correct type of dialplan_detail_tag open or self closed + if ($count == 1) { //single condition + //start dialplan_detail_tag + $tmp .= " \n"; + } + else { //more than one condition + $current_count++; + if ($current_count < $count) { + //all tags should be self-closing except the last one + $tmp .= " \n"; + } + else { + //for the last dialplan_detail_tag use the start dialplan_detail_tag + $tmp .= " \n"; + } + } + } + //actions + if ($ent['dialplan_detail_tag'] == "action") { + //get the action inline attribute + $action_inline = ''; + if (strlen($ent['dialplan_detail_inline']) > 0) { + $action_inline = "inline=\"".$ent['dialplan_detail_inline']."\""; + } + if (strlen($ent['dialplan_detail_data']) > 0) { + $tmp .= " \n"; + } + else { + $tmp .= " \n"; + } + } + //anti-actions + if ($ent['dialplan_detail_tag'] == "anti-action") { + if (strlen($ent['dialplan_detail_data']) > 0) { + $tmp .= " \n"; + } + else { + $tmp .= " \n"; + } + } + //set the previous dialplan_detail_tag + $previous_tag = $ent['dialplan_detail_tag']; + $i++; + } //end foreach + if ($close_condition_tag == true) { + $tmp .= " \n"; + } + $x++; + } + if ($condition_count > 0) { + $condition_count = $result_count2; + } + unset($sql, $result_count2, $result2, $row_count2); + } //end if results + $tmp .= "\n"; + + $dialplan_order = $row['dialplan_order']; + if (strlen($dialplan_order) == 0) { $dialplan_order = "000".$dialplan_order; } + if (strlen($dialplan_order) == 1) { $dialplan_order = "00".$dialplan_order; } + if (strlen($dialplan_order) == 2) { $dialplan_order = "0".$dialplan_order; } + if (strlen($dialplan_order) == 4) { $dialplan_order = "999"; } + if (strlen($dialplan_order) == 5) { $dialplan_order = "999"; } + + //remove invalid characters from the file names + $dialplan_name = $row['dialplan_name']; + $dialplan_name = str_replace(" ", "_", $dialplan_name); + $dialplan_name = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $dialplan_name); + + $dialplan_filename = $dialplan_order."_v_".$dialplan_name.".xml"; + if (strlen($row['dialplan_context']) > 0) { + if (!is_dir($_SESSION['switch']['dialplan']['dir']."/".$row['dialplan_context'])) { + mkdir($_SESSION['switch']['dialplan']['dir']."/".$row['dialplan_context'],0755,true); + } + if ($row['dialplan_context'] == "public") { + if (count($_SESSION['domains']) > 1) { + if (!is_dir($_SESSION['switch']['dialplan']['dir']."/public/".$_SESSION['domains'][$row['domain_uuid']]['domain_name'])) { + mkdir($_SESSION['switch']['dialplan']['dir']."/public/".$_SESSION['domains'][$row['domain_uuid']]['domain_name'],0755,true); + } + file_put_contents($_SESSION['switch']['dialplan']['dir']."/public/".$_SESSION['domains'][$row['domain_uuid']]['domain_name']."/".$dialplan_filename, $tmp); + } + else { + file_put_contents($_SESSION['switch']['dialplan']['dir']."/public/".$dialplan_filename, $tmp); + } + } + else { + if (!is_dir($_SESSION['switch']['dialplan']['dir']."/".$row['dialplan_context'])) { + mkdir($_SESSION['switch']['dialplan']['dir']."/".$row['dialplan_context'],0755,true); + } + file_put_contents($_SESSION['switch']['dialplan']['dir']."/".$row['dialplan_context']."/".$dialplan_filename, $tmp); + } + } + + unset($dialplan_filename); + unset($tmp); + } //end while + } + + //apply settings reminder + $_SESSION["reload_xml"] = true; +} + + +if (!function_exists('phone_letter_to_number')) { + function phone_letter_to_number($tmp) { + $tmp = strtolower($tmp); + if ($tmp == "a" | $tmp == "b" | $tmp == "c") { return 2; } + if ($tmp == "d" | $tmp == "e" | $tmp == "f") { return 3; } + if ($tmp == "g" | $tmp == "h" | $tmp == "i") { return 4; } + if ($tmp == "j" | $tmp == "k" | $tmp == "l") { return 5; } + if ($tmp == "m" | $tmp == "n" | $tmp == "o") { return 6; } + if ($tmp == "p" | $tmp == "q" | $tmp == "r" | $tmp == "s") { return 7; } + if ($tmp == "t" | $tmp == "u" | $tmp == "v") { return 8; } + if ($tmp == "w" | $tmp == "x" | $tmp == "y" | $tmp == "z") { return 9; } + } +} + + +if (!function_exists('sync_directory')) { + function sync_directory() { + + global $domain_uuid, $db; + + $tmp = "include(\"config.js\");\n"; + $tmp .= "//var sounds_dir\n"; + $tmp .= "var admin_pin = \"\";\n"; + $tmp .= "var search_type = \"\";\n"; + $tmp .= "//var tmp_dir\n"; + $tmp .= "var digitmaxlength = 0;\n"; + $tmp .= "var timeoutpin = 5000;\n"; + $tmp .= "var timeouttransfer = 5000;\n"; + $tmp .= "\n"; + $tmp .= "var dtmf = new Object( );\n"; + $tmp .= "dtmf.digits = \"\";\n"; + $tmp .= "\n"; + $tmp .= "function mycb( session, type, obj, arg ) {\n"; + $tmp .= " try {\n"; + $tmp .= " if ( type == \"dtmf\" ) {\n"; + $tmp .= " console_log( \"info\", \"digit: \"+obj.digit+\"\\n\" );\n"; + $tmp .= " if ( obj.digit == \"#\" ) {\n"; + $tmp .= " //console_log( \"info\", \"detected pound sign.\\n\" );\n"; + $tmp .= " exit = true;\n"; + $tmp .= " return( false );\n"; + $tmp .= " }\n"; + $tmp .= " if ( obj.digit == \"*\" ) {\n"; + $tmp .= " //console_log( \"info\", \"detected pound sign.\\n\" );\n"; + $tmp .= " exit = true;\n"; + $tmp .= " return( false );\n"; + $tmp .= " }\n"; + $tmp .= " dtmf.digits += obj.digit;\n"; + $tmp .= " if ( dtmf.digits.length >= digitmaxlength ) {\n"; + $tmp .= " exit = true;\n"; + $tmp .= " return( false );\n"; + $tmp .= " }\n"; + $tmp .= " }\n"; + $tmp .= " } catch (e) {\n"; + $tmp .= " console_log( \"err\", e+\"\\n\" );\n"; + $tmp .= " }\n"; + $tmp .= " return( true );\n"; + $tmp .= "} //end function mycb\n"; + $tmp .= "\n"; + $tmp .= "function directory_search(search_type) {\n"; + $tmp .= "\n"; + $tmp .= " digitmaxlength = 3;\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-enter_person.wav\");\n"; + $tmp .= " if (search_type == \"last_name\") {\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-last_name.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-to_search_by.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-first_name.wav\", mycb, \"dtmf\");\n"; + $tmp .= " }\n"; + $tmp .= " if (search_type == \"first_name\") {\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-first_name.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-to_search_by.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-last_name.wav\", mycb, \"dtmf\");\n"; + $tmp .= " }\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-press.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.execute(\"say\", \"en name_spelled iterated 1\");\n"; + $tmp .= " session.collectInput( mycb, dtmf, timeoutpin );\n"; + $tmp .= " var dtmf_search = dtmf.digits;\n"; + $tmp .= " //console_log( \"info\", \"--\" + dtmf.digits + \"--\\n\" );\n"; + $tmp .= " if (dtmf_search == \"1\") {\n"; + $tmp .= " //console_log( \"info\", \"press 1 detected: \" + dtmf.digits + \"\\n\" );\n"; + $tmp .= " //console_log( \"info\", \"press 1 detected: \" + search_type + \"\\n\" );\n"; + $tmp .= " if (search_type == \"last_name\") {\n"; + $tmp .= " //console_log( \"info\", \"press 1 detected last_name: \" + search_type + \"\\n\" );\n"; + $tmp .= " search_type = \"first_name\";\n"; + $tmp .= " }\n"; + $tmp .= " else {\n"; + $tmp .= " //console_log( \"info\", \"press 1 detected first_name: \" + search_type + \"\\n\" );\n"; + $tmp .= " search_type = \"last_name\";\n"; + $tmp .= " }\n"; + $tmp .= " dtmf_search = \"\";\n"; + $tmp .= " dtmf.digits = \"\";\n"; + $tmp .= " directory_search(search_type);\n"; + $tmp .= " return;\n"; + $tmp .= " }\n"; + $tmp .= " console_log( \"info\", \"first 3 letters of first or last name: \" + dtmf.digits + \"\\n\" );\n"; + $tmp .= "\n"; + $tmp .= " //session.execute(\"say\", \"en name_spelled pronounced mark\");\n"; + $tmp .= " //\n"; + $tmp .= " //session.execute(\"say\", \"en number iterated 12345\");\n"; + $tmp .= " //session.execute(\"say\", \"en number pronounced 1001\");\n"; + $tmp .= " //session.execute(\"say\", \"en short_date_time pronounced [timestamp]\");\n"; + $tmp .= " //session.execute(\"say\", \"en CURRENT_TIME pronounced CURRENT_TIME\");\n"; + $tmp .= " //session.execute(\"say\", \"en CURRENT_DATE pronounced CURRENT_DATE\");\n"; + $tmp .= " //session.execute(\"say\", \"en CURRENT_DATE_TIME pronounced CURRENT_DATE_TIME\");\n"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= " //take each name and convert it to the equivalent number in php when this file is generated\n"; + $tmp .= " //then test each number see if it matches the user dtmf search keys\n"; + $tmp .= "\n"; + $tmp .= " var result_array = new Array();\n"; + $tmp .= " var x = 0;\n"; + + //get a list of extensions and the users assigned to them + $sql = "select * from v_extensions "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $x = 0; + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + foreach ($result as &$row) { + $extension = $row["extension"]; + $effective_caller_id_name = $row["effective_caller_id_name"]; + //$user_list = $row["user_list"]; + //$user_list = trim($user_list, "|"); + //$username_array = explode ("|", $user_list); + foreach ($username_array as &$username) { + if (strlen($username) > 0) { + $sql = "select * from v_users "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and username = '$username' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $tmp_result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + foreach ($tmp_result as &$row_tmp) { + $user_first_name = $row_tmp["user_first_name"]; + $user_last_name = $row_tmp["user_last_name"]; + if ($user_first_name == "na") { $user_first_name = ""; } + if ($user_last_name == "na") { $user_last_name = ""; } + if ($user_first_name == "admin") { $user_first_name = ""; } + if ($user_last_name == "admin") { $user_last_name = ""; } + if ($user_first_name == "superadmin") { $user_first_name = ""; } + if ($user_last_name == "superadmin") { $user_last_name = ""; } + if (strlen($user_first_name.$user_last_name) == 0) { + $name_array = explode (" ", $effective_caller_id_name); + $user_first_name = $name_array[0]; + if (count($name_array) > 1) { + $user_last_name = $name_array[1]; + } + } + + break; //limit to 1 row + } + $f1 = phone_letter_to_number(substr($user_first_name, 0,1)); + $f2 = phone_letter_to_number(substr($user_first_name, 1,1)); + $f3 = phone_letter_to_number(substr($user_first_name, 2,1)); + + $l1 = phone_letter_to_number(substr($user_last_name, 0,1)); + $l2 = phone_letter_to_number(substr($user_last_name, 1,1)); + $l3 = phone_letter_to_number(substr($user_last_name, 2,1)); + + //echo $sql." extension: $extension first_name $user_first_name last_name $user_last_name $tmp
    "; + + $tmp .= " if (search_type == \"first_name\" && dtmf_search == \"".$f1.$f2.$f3."\" || search_type == \"last_name\" && dtmf_search == \"".$l1.$l2.$l3."\") {\n"; + $tmp .= " result_array[x]=new Array()\n"; + $tmp .= " result_array[x]['first_name'] =\"".$user_first_name."\";\n"; + $tmp .= " result_array[x]['last_name'] =\"".$user_last_name."\";\n"; + $tmp .= " result_array[x]['extension'] = \"".$extension."\";\n"; + $tmp .= " //console_log( \"info\", \"found: ".$user_first_name." ".$user_last_name."\\n\" );\n"; + $tmp .= " x++;\n"; + $tmp .= " }\n"; + } + } + } + unset ($prep_statement); + + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= " //say the number of results that matched\n"; + $tmp .= " \$result_count = result_array.length;\n"; + $tmp .= " session.execute(\"say\", \"en number iterated \"+\$result_count);\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-result_match.wav\", mycb, \"dtmf\");\n"; + $tmp .= "\n"; + $tmp .= " //clear values\n"; + $tmp .= " dtmf_search = 0;\n"; + $tmp .= " dtmf.digits = '';\n"; + $tmp .= "\n"; + $tmp .= " if (\$result_count == 0) {\n"; + $tmp .= " //session.execute(\"transfer\", \"*347 XML ".$_SESSION["context"]."\");\n"; + $tmp .= " directory_search(search_type);\n"; + $tmp .= " return;\n"; + $tmp .= " }\n"; + $tmp .= "\n"; + $tmp .= " session.execute(\"set\", \"tts_engine=flite\");\n"; + $tmp .= " session.execute(\"set\", \"tts_voice=rms\"); //rms //kal //awb //slt\n"; + $tmp .= " session.execute(\"set\", \"playback_terminators=#\");\n"; + $tmp .= " //session.speak(\"flite\",\"kal\",\"Thanks for.. calling\");\n"; + $tmp .= "\n"; + $tmp .= " i=1;\n"; + $tmp .= " for ( i in result_array ) {\n"; + $tmp .= "\n"; + $tmp .= " //say first name and last name is at extension 1001\n"; + $tmp .= " //session.execute(\"speak\", result_array[i]['first_name']);\n"; + $tmp .= " //session.execute(\"speak\", result_array[i]['last_name']);\n"; + $tmp .= " session.execute(\"say\", \"en name_spelled pronounced \"+result_array[i]['first_name']);\n"; + $tmp .= " session.execute(\"sleep\", \"500\");\n"; + $tmp .= " session.execute(\"say\", \"en name_spelled pronounced \"+result_array[i]['last_name']);\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-at_extension.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.execute(\"say\", \"en number pronounced \"+result_array[i]['extension']);\n"; + $tmp .= "\n"; + $tmp .= " //to select this entry press 1\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-to_select_entry.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.streamFile( sounds_dir+\"/en/us/callie/directory/48000/dir-press.wav\", mycb, \"dtmf\");\n"; + $tmp .= " session.execute(\"say\", \"en number iterated 1\");\n"; + $tmp .= "\n"; + $tmp .= " //console_log( \"info\", \"first name: \" + result_array[i]['first_name'] + \"\\n\" );\n"; + $tmp .= " //console_log( \"info\", \"last name: \" + result_array[i]['last_name'] + \"\\n\" );\n"; + $tmp .= " //console_log( \"info\", \"extension: \" + result_array[i]['extension'] + \"\\n\" );\n"; + $tmp .= "\n"; + $tmp .= " //if 1 is pressed then transfer the call\n"; + $tmp .= " dtmf.digits = session.getDigits(1, \"#\", 3000);\n"; + $tmp .= " if (dtmf.digits == \"1\") {\n"; + $tmp .= " console_log( \"info\", \"directory: call transfered to: \" + result_array[i]['extension'] + \"\\n\" );\n"; + $tmp .= " session.execute(\"transfer\", result_array[i]['extension']+\" XML ".$_SESSION["context"]."\");\n"; + $tmp .= " }\n"; + $tmp .= "\n"; + $tmp .= " }\n"; + $tmp .= "}\n"; + $tmp .= "\n"; + $tmp .= "\n"; + $tmp .= "if ( session.ready() ) {\n"; + $tmp .= " session.answer();\n"; + $tmp .= " search_type = \"last_name\";\n"; + $tmp .= " directory_search(search_type);\n"; + $tmp .= " session.hangup(\"NORMAL_CLEARING\");\n"; + $tmp .= "}\n"; + $tmp .= ""; + + //write the file + $fout = fopen($switch_scripts_dir."/directory.js","w"); + fwrite($fout, $tmp); + fclose($fout); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + } //end sync_directory +} //end if function exists + +if (!function_exists('save_ivr_menu_xml')) { + function save_ivr_menu_xml() { + global $db, $domain_uuid; + + //prepare for dialplan .xml files to be written. delete all dialplan files that are prefixed with dialplan_ and have a file extension of .xml + if (count($_SESSION["domains"]) > 1) { + $v_needle = 'v_'.$_SESSION['domain_name'].'_'; + } + else { + $v_needle = 'v_'; + } + if($dh = opendir($_SESSION['switch']['conf']['dir']."/ivr_menus/")) { + $files = Array(); + while($file = readdir($dh)) { + if($file != "." && $file != ".." && $file[0] != '.') { + if(is_dir($dir . "/" . $file)) { + //this is a directory + } else { + if (strpos($file, $v_needle) !== false && substr($file,-4) == '.xml') { + //echo "file: $file
    \n"; + unlink($_SESSION['switch']['conf']['dir']."/ivr_menus/".$file); + } + } + } + } + closedir($dh); + } + + $sql = "select * from v_ivr_menus "; + $sql .= " where domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + $result_count = count($result); + unset ($prep_statement, $sql); + if ($result_count > 0) { + foreach($result as $row) { + $dialplan_uuid = $row["dialplan_uuid"]; + $ivr_menu_uuid = $row["ivr_menu_uuid"]; + $ivr_menu_name = check_str($row["ivr_menu_name"]); + $ivr_menu_extension = $row["ivr_menu_extension"]; + $ivr_menu_greet_long = $row["ivr_menu_greet_long"]; + $ivr_menu_greet_short = $row["ivr_menu_greet_short"]; + $ivr_menu_invalid_sound = $row["ivr_menu_invalid_sound"]; + $ivr_menu_exit_sound = $row["ivr_menu_exit_sound"]; + $ivr_menu_confirm_macro = $row["ivr_menu_confirm_macro"]; + $ivr_menu_confirm_key = $row["ivr_menu_confirm_key"]; + $ivr_menu_tts_engine = $row["ivr_menu_tts_engine"]; + $ivr_menu_tts_voice = $row["ivr_menu_tts_voice"]; + $ivr_menu_confirm_attempts = $row["ivr_menu_confirm_attempts"]; + $ivr_menu_timeout = $row["ivr_menu_timeout"]; + $ivr_menu_exit_app = $row["ivr_menu_exit_app"]; + $ivr_menu_exit_data = $row["ivr_menu_exit_data"]; + $ivr_menu_inter_digit_timeout = $row["ivr_menu_inter_digit_timeout"]; + $ivr_menu_max_failures = $row["ivr_menu_max_failures"]; + $ivr_menu_max_timeouts = $row["ivr_menu_max_timeouts"]; + $ivr_menu_digit_len = $row["ivr_menu_digit_len"]; + $ivr_menu_direct_dial = $row["ivr_menu_direct_dial"]; + $ivr_menu_enabled = $row["ivr_menu_enabled"]; + $ivr_menu_description = check_str($row["ivr_menu_description"]); + + //replace space with an underscore + $ivr_menu_name = str_replace(" ", "_", $ivr_menu_name); + + //add each IVR menu to the XML config + $tmp = "\n"; + if (strlen($ivr_menu_description) > 0) { + $tmp .= " \n"; + } + if (count($_SESSION["domains"]) > 1) { + $tmp .= " 0) { + $tmp .= " greet-short=\"".$ivr_menu_greet_short."\"\n"; + } + } + else { + //not found + if (strlen($ivr_menu_greet_short) > 0) { + $tmp .= " greet-short=\"".$ivr_menu_greet_short."\"\n"; + } + } + $tmp .= " invalid-sound=\"$ivr_menu_invalid_sound\"\n"; + $tmp .= " exit-sound=\"$ivr_menu_exit_sound\"\n"; + $tmp .= " confirm-macro=\"$ivr_menu_confirm_macro\"\n"; + $tmp .= " confirm-key=\"$ivr_menu_confirm_key\"\n"; + $tmp .= " tts-engine=\"$ivr_menu_tts_engine\"\n"; + $tmp .= " tts-voice=\"$ivr_menu_tts_voice\"\n"; + $tmp .= " confirm-attempts=\"$ivr_menu_confirm_attempts\"\n"; + $tmp .= " timeout=\"$ivr_menu_timeout\"\n"; + $tmp .= " inter-digit-timeout=\"$ivr_menu_inter_digit_timeout\"\n"; + $tmp .= " max-failures=\"$ivr_menu_max_failures\"\n"; + $tmp .= " max-timeouts=\"$ivr_menu_max_timeouts\"\n"; + $tmp .= " digit-len=\"$ivr_menu_digit_len\">\n"; + + $sub_sql = ""; + $sub_sql .= "select * from v_ivr_menu_options "; + $sub_sql .= "where ivr_menu_uuid = '$ivr_menu_uuid' "; + $sub_sql .= "and domain_uuid = '$domain_uuid' "; + $sub_sql .= "order by ivr_menu_option_order asc "; + $sub_prep_statement = $db->prepare(check_sql($sub_sql)); + $sub_prep_statement->execute(); + $sub_result = $sub_prep_statement->fetchAll(PDO::FETCH_ASSOC); + foreach ($sub_result as &$sub_row) { + //$ivr_menu_uuid = $sub_row["ivr_menu_uuid"]; + $ivr_menu_option_digits = $sub_row["ivr_menu_option_digits"]; + $ivr_menu_option_action = $sub_row["ivr_menu_option_action"]; + $ivr_menu_option_param = $sub_row["ivr_menu_option_param"]; + $ivr_menu_option_description = $sub_row["ivr_menu_option_description"]; + + $tmp .= " "; + if (strlen($ivr_menu_option_description) == 0) { + $tmp .= "\n"; + } + else { + $tmp .= " \n"; + } + } + unset ($sub_prep_statement, $sub_row); + + if ($ivr_menu_direct_dial == "true") { + $tmp .= " \n"; + } + $tmp .= " \n"; + $tmp .= "\n"; + + //remove invalid characters from the file names + $ivr_menu_name = str_replace(" ", "_", $ivr_menu_name); + $ivr_menu_name = preg_replace("/[\*\:\\/\<\>\|\'\"\?]/", "", $ivr_menu_name); + + //write the file + if (count($_SESSION["domains"]) > 1) { + $fout = fopen($_SESSION['switch']['conf']['dir']."/ivr_menus/v_".$_SESSION['domains'][$row['domain_uuid']]['domain_name']."_".$ivr_menu_name.".xml","w"); + } + else { + $fout = fopen($_SESSION['switch']['conf']['dir']."/ivr_menus/v_".$ivr_menu_name.".xml","w"); + } + fwrite($fout, $tmp); + fclose($fout); + } + } + save_dialplan_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + } +} + +if (!function_exists('save_call_center_xml')) { + function save_call_center_xml() { + global $db, $domain_uuid; + + //include the classes + include "includes/classes/dialplan.php"; + + $sql = "select * from v_call_center_queues "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + $result_count = count($result); + unset ($prep_statement, $sql); + if ($result_count > 0) { //found results + foreach($result as $row) { + $call_center_queue_uuid = $row["call_center_queue_uuid"]; + $domain_uuid = $row["domain_uuid"]; + $dialplan_uuid = $row["dialplan_uuid"]; + $queue_name = check_str($row["queue_name"]); + $queue_extension = $row["queue_extension"]; + $queue_strategy = $row["queue_strategy"]; + $queue_moh_sound = $row["queue_moh_sound"]; + $queue_record_template = $row["queue_record_template"]; + $queue_time_base_score = $row["queue_time_base_score"]; + $queue_max_wait_time = $row["queue_max_wait_time"]; + $queue_max_wait_time_with_no_agent = $row["queue_max_wait_time_with_no_agent"]; + $queue_tier_rules_apply = $row["queue_tier_rules_apply"]; + $queue_tier_rule_wait_second = $row["queue_tier_rule_wait_second"]; + $queue_tier_rule_wait_multiply_level = $row["queue_tier_rule_wait_multiply_level"]; + $queue_tier_rule_no_agent_no_wait = $row["queue_tier_rule_no_agent_no_wait"]; + $queue_timeout_action = $row["queue_timeout_action"]; + $queue_discard_abandoned_after = $row["queue_discard_abandoned_after"]; + $queue_abandoned_resume_allowed = $row["queue_abandoned_resume_allowed"]; + $queue_cid_prefix = $row["queue_cid_prefix"]; + $queue_description = check_str($row["queue_description"]); + + //replace space with an underscore + $queue_name = str_replace(" ", "_", $queue_name); + + //add each Queue to the dialplan + if (strlen($row['call_center_queue_uuid']) > 0) { + $action = 'add'; //set default action to add + $i = 0; + + //determine the action add or update + if (strlen($dialplan_uuid) > 0) { + $sql = "select * from v_dialplans "; + $sql .= "where dialplan_uuid = '".$dialplan_uuid."' "; + $prep_statement_2 = $db->prepare($sql); + $prep_statement_2->execute(); + while($row2 = $prep_statement_2->fetch(PDO::FETCH_ASSOC)) { + $action = 'update'; + break; //limit to 1 row + } + unset ($sql, $prep_statement_2); + } + + if ($action == 'add') { + //create queue entry in the dialplan + $dialplan_name = $queue_name; + $dialplan_order ='210'; + $dialplan_context = $_SESSION['context']; + $dialplan_enabled = 'true'; + $dialplan_description = $queue_description; + $app_uuid = '95788e50-9500-079e-2807-fd530b0ea370'; + $dialplan_uuid = uuid(); + dialplan_add($domain_uuid, $dialplan_uuid, $dialplan_name, $dialplan_order, $dialplan_context, $dialplan_enabled, $dialplan_description, $app_uuid); + + //add the dialplan_uuid to the call center table + $sql = "update v_call_center_queues set "; + $sql .= "dialplan_uuid = '$dialplan_uuid' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and call_center_queue_uuid = '".$row['call_center_queue_uuid']."' "; + $db->exec(check_sql($sql)); + unset($sql); + + //group 1 + $dialplan = new dialplan; + $dialplan->domain_uuid = $domain_uuid; + $dialplan->dialplan_uuid = $dialplan_uuid; + $dialplan->dialplan_detail_tag = 'condition'; //condition, action, antiaction + $dialplan->dialplan_detail_type = '${caller_id_name}'; + $dialplan->dialplan_detail_data = '^([^#]+#)(.*)$'; + $dialplan->dialplan_detail_break = 'never'; + $dialplan->dialplan_detail_inline = ''; + $dialplan->dialplan_detail_group = '1'; + $dialplan->dialplan_detail_order = '000'; + $dialplan->dialplan_detail_add(); + unset($dialplan); + + $dialplan = new dialplan; + $dialplan->domain_uuid = $domain_uuid; + $dialplan->dialplan_uuid = $dialplan_uuid; + $dialplan->dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan->dialplan_detail_type = 'set'; + $dialplan->dialplan_detail_data = 'caller_id_name=$2'; + $dialplan->dialplan_detail_break = ''; + $dialplan->dialplan_detail_inline = ''; + $dialplan->dialplan_detail_group = '1'; + $dialplan->dialplan_detail_order = '001'; + $dialplan->dialplan_detail_add(); + unset($dialplan); + + //group 2 + $dialplan = new dialplan; + $dialplan->domain_uuid = $domain_uuid; + $dialplan->dialplan_uuid = $dialplan_uuid; + $dialplan->dialplan_detail_tag = 'condition'; //condition, action, antiaction + $dialplan->dialplan_detail_type = 'destination_number'; + $dialplan->dialplan_detail_data = '^'.$row['queue_extension'].'$'; + $dialplan->dialplan_detail_break = ''; + $dialplan->dialplan_detail_inline = ''; + $dialplan->dialplan_detail_group = '2'; + $dialplan->dialplan_detail_order = '000'; + $dialplan->dialplan_detail_add(); + unset($dialplan); + + $dialplan = new dialplan; + $dialplan->domain_uuid = $domain_uuid; + $dialplan->dialplan_uuid = $dialplan_uuid; + $dialplan->dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan->dialplan_detail_type = 'answer'; + $dialplan->dialplan_detail_data = ''; + $dialplan->dialplan_detail_break = ''; + $dialplan->dialplan_detail_inline = ''; + $dialplan->dialplan_detail_group = '2'; + $dialplan->dialplan_detail_order = '001'; + $dialplan->dialplan_detail_add(); + unset($dialplan); + + $dialplan = new dialplan; + $dialplan->domain_uuid = $domain_uuid; + $dialplan->dialplan_uuid = $dialplan_uuid; + $dialplan->dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan->dialplan_detail_type = 'set'; + $dialplan->dialplan_detail_data = 'hangup_after_bridge=true'; + $dialplan->dialplan_detail_break = ''; + $dialplan->dialplan_detail_inline = ''; + $dialplan->dialplan_detail_group = '2'; + $dialplan->dialplan_detail_order = '002'; + $dialplan->dialplan_detail_add(); + unset($dialplan); + + $dialplan = new dialplan; + $dialplan->domain_uuid = $domain_uuid; + $dialplan->dialplan_uuid = $dialplan_uuid; + $dialplan->dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan->dialplan_detail_type = 'set'; + $dialplan->dialplan_detail_data = "caller_id_name=".$queue_cid_prefix."#\${caller_id_name}"; + $dialplan->dialplan_detail_break = ''; + $dialplan->dialplan_detail_inline = ''; + $dialplan->dialplan_detail_group = '2'; + $dialplan->dialplan_detail_order = '003'; + $dialplan->dialplan_detail_add(); + unset($dialplan); + + $dialplan = new dialplan; + $dialplan->domain_uuid = $domain_uuid; + $dialplan->dialplan_uuid = $dialplan_uuid; + $dialplan->dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan->dialplan_detail_type = 'system'; + $dialplan->dialplan_detail_data = 'mkdir -p $${base_dir}/recordings/archive/${strftime(%Y)}/${strftime(%b)}/${strftime(%d)}/'; + $dialplan->dialplan_detail_break = ''; + $dialplan->dialplan_detail_inline = ''; + $dialplan->dialplan_detail_group = '2'; + $dialplan->dialplan_detail_order = '004'; + $dialplan->dialplan_detail_add(); + unset($dialplan); + + $dialplan = new dialplan; + $dialplan->domain_uuid = $domain_uuid; + $dialplan->dialplan_uuid = $dialplan_uuid; + $dialplan->dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan->dialplan_detail_type = 'callcenter'; + $dialplan->dialplan_detail_data = $queue_name."@".$_SESSION['domains'][$domain_uuid]['domain_name']; + $dialplan->dialplan_detail_break = ''; + $dialplan->dialplan_detail_inline = ''; + $dialplan->dialplan_detail_group = '2'; + $dialplan->dialplan_detail_order = '005'; + $dialplan->dialplan_detail_add(); + unset($dialplan); + + if (strlen($queue_timeout_action) > 0) { + $action_array = explode(":",$queue_timeout_action); + $dialplan = new dialplan; + $dialplan->domain_uuid = $domain_uuid; + $dialplan->dialplan_uuid = $dialplan_uuid; + $dialplan->dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan->dialplan_detail_type = $action_array[0]; + $dialplan->dialplan_detail_data = substr($queue_timeout_action, strlen($action_array[0])+1, strlen($queue_timeout_action)); + $dialplan->dialplan_detail_break = ''; + $dialplan->dialplan_detail_inline = ''; + $dialplan->dialplan_detail_group = '2'; + $dialplan->dialplan_detail_order = '006'; + $dialplan->dialplan_detail_add(); + unset($dialplan); + } + + $dialplan = new dialplan; + $dialplan->domain_uuid = $domain_uuid; + $dialplan->dialplan_uuid = $dialplan_uuid; + $dialplan->dialplan_detail_tag = 'action'; //condition, action, antiaction + $dialplan->dialplan_detail_type = 'hangup'; + $dialplan->dialplan_detail_data = ''; + $dialplan->dialplan_detail_break = ''; + $dialplan->dialplan_detail_inline = ''; + $dialplan->dialplan_detail_group = '2'; + $dialplan->dialplan_detail_order = '007'; + $dialplan->dialplan_detail_add(); + unset($dialplan); + } + if ($action == 'update') { + //update the queue entry in the dialplan + + $dialplan_name = $queue_name; + $dialplan_order = '9'; + //$context = $row['queue_context']; + $context = 'default'; + $enabled = 'true'; + $descr = $queue_description; + $call_center_queue_uuid = $row['call_center_queue_uuid']; + + $sql = "update v_dialplans set "; + $sql .= "dialplan_name = '$dialplan_name', "; + $sql .= "dialplan_order = '$dialplan_order', "; + $sql .= "context = '$context', "; + $sql .= "enabled = '$enabled', "; + $sql .= "descr = '$descr' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_uuid = 'dialplan_uuid' "; + //echo "sql: ".$sql."
    "; + $db->query($sql); + unset($sql); + + //update the condition + $sql = "update v_dialplan_details set "; + $sql .= "dialplan_detail_data = '^".$row['queue_extension']."$' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_detail_tag = 'condition' "; + $sql .= "and dialplan_detail_type = 'destination_number' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + //echo $sql."
    "; + $db->query($sql); + unset($sql); + + //update the action + $sql = "update v_dialplan_details set "; + $sql .= "dialplan_detail_data = 'caller_id_name=".$queue_cid_prefix."\${caller_id_name}' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_detail_tag = 'action' "; + $sql .= "and dialplan_detail_type = 'set' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $sql .= "and dialplan_detail_data like '%{caller_id_name}%' "; + //echo $sql."
    "; + $db->query($sql); + + //update the action + $sql = "update v_dialplan_details set "; + $sql .= "dialplan_detail_data = '".$queue_name."@".$_SESSION['domains'][$domain_uuid]['domain_name']."' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_detail_tag = 'action' "; + $sql .= "and dialplan_detail_type = 'callcenter' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + //echo $sql."
    "; + $db->query($sql); + + unset($dialplan_name); + unset($order); + unset($context); + unset($enabled); + unset($descr); + unset($dialplan_uuid); + } + unset($action); + unset($dialplanincludeid); + } //end if strlen call_center_queue_uuid; add the call center queue to the dialplan + } + + //prepare Queue XML string + $v_queues = ''; + $sql = "select * from v_call_center_queues "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + $x=0; + foreach ($result as &$row) { + $queue_name = $row["queue_name"]; + $queue_extension = $row["queue_extension"]; + $queue_strategy = $row["queue_strategy"]; + $queue_moh_sound = $row["queue_moh_sound"]; + $queue_record_template = $row["queue_record_template"]; + $queue_time_base_score = $row["queue_time_base_score"]; + $queue_max_wait_time = $row["queue_max_wait_time"]; + $queue_max_wait_time_with_no_agent = $row["queue_max_wait_time_with_no_agent"]; + $queue_tier_rules_apply = $row["queue_tier_rules_apply"]; + $queue_tier_rule_wait_second = $row["queue_tier_rule_wait_second"]; + $queue_tier_rule_wait_multiply_level = $row["queue_tier_rule_wait_multiply_level"]; + $queue_tier_rule_no_agent_no_wait = $row["queue_tier_rule_no_agent_no_wait"]; + $queue_discard_abandoned_after = $row["queue_discard_abandoned_after"]; + $queue_abandoned_resume_allowed = $row["queue_abandoned_resume_allowed"]; + $queue_description = $row["queue_description"]; + if ($x > 0) { + $v_queues .= "\n"; + $v_queues .= " "; + } + $v_queues .= "\n"; + $v_queues .= " \n"; + $v_queues .= " \n"; + if (strlen($queue_record_template) > 0) { + $v_queues .= " \n"; + } + $v_queues .= " \n"; + $v_queues .= " \n"; + $v_queues .= " \n"; + $v_queues .= " \n"; + $v_queues .= " \n"; + $v_queues .= " \n"; + $v_queues .= " \n"; + $v_queues .= " \n"; + $v_queues .= " \n"; + $v_queues .= " "; + $x++; + } + unset ($prep_statement); + + //prepare Agent XML string + $v_agents = ''; + $sql = "select * from v_call_center_agents "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + $x=0; + foreach ($result as &$row) { + //get the values from the db and set as php variables + $agent_name = $row["agent_name"]; + $agent_type = $row["agent_type"]; + $agent_call_timeout = $row["agent_call_timeout"]; + $agent_contact = $row["agent_contact"]; + $agent_status = $row["agent_status"]; + $agent_no_answer_delay_time = $row["agent_no_answer_delay_time"]; + $agent_max_no_answer = $row["agent_max_no_answer"]; + $agent_wrap_up_time = $row["agent_wrap_up_time"]; + $agent_reject_delay_time = $row["agent_reject_delay_time"]; + $agent_busy_delay_time = $row["agent_busy_delay_time"]; + if ($x > 0) { + $v_agents .= "\n"; + $v_agents .= " "; + + } + + //get and then set the complete agent_contact with the call_timeout and when necessary confirm + $tmp_confirm = "group_confirm_file=custom/press_1_to_accept_this_call.wav,group_confirm_key=1"; + if(strstr($agent_contact, '}') === FALSE) { + //not found + if(stristr($agent_contact, 'sofia/gateway') === FALSE) { + //add the call_timeout + $tmp_agent_contact = "{call_timeout=".$agent_call_timeout."}".$agent_contact; + } + else { + //add the call_timeout and confirm + $tmp_agent_contact = $tmp_first.',call_timeout='.$agent_call_timeout.$tmp_last; + $tmp_agent_contact = "{".$tmp_confirm.",call_timeout=".$agent_call_timeout."}".$agent_contact; + } + } + else { + //found + if(stristr($agent_contact, 'sofia/gateway') === FALSE) { + //not found + if(stristr($agent_contact, 'call_timeout') === FALSE) { + //add the call_timeout + $tmp_pos = strrpos($agent_contact, "}"); + $tmp_first = substr($agent_contact, 0, $tmp_pos); + $tmp_last = substr($agent_contact, $tmp_pos); + $tmp_agent_contact = $tmp_first.',call_timeout='.$agent_call_timeout.$tmp_last; + } + else { + //the string has the call timeout + $tmp_agent_contact = $agent_contact; + } + } + else { + //found + $tmp_pos = strrpos($agent_contact, "}"); + $tmp_first = substr($agent_contact, 0, $tmp_pos); + $tmp_last = substr($agent_contact, $tmp_pos); + if(stristr($agent_contact, 'call_timeout') === FALSE) { + //add the call_timeout and confirm + $tmp_agent_contact = $tmp_first.','.$tmp_confirm.',call_timeout='.$agent_call_timeout.$tmp_last; + } + else { + //add confirm + $tmp_agent_contact = $tmp_first.','.$tmp_confirm.$tmp_last; + } + } + } + + $v_agents .= "prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + $x=0; + foreach ($result as &$row) { + $agent_name = $row["agent_name"]; + $queue_name = $row["queue_name"]; + $tier_level = $row["tier_level"]; + $tier_position = $row["tier_position"]; + if ($x > 0) { + $v_tiers .= "\n"; + $v_tiers .= " "; + } + $v_tiers .= ""; + $x++; + } + + //get the contents of the template + $file_contents = file_get_contents($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/conf/autoload_configs/callcenter.conf.xml"); + + //add the Call Center Queues, Agents and Tiers to the XML config + $file_contents = str_replace("{v_queues}", $v_queues, $file_contents); + unset ($v_queues); + + $file_contents = str_replace("{v_agents}", $v_agents, $file_contents); + unset ($v_agents); + + $file_contents = str_replace("{v_tiers}", $v_tiers, $file_contents); + unset ($v_tiers); + + //write the XML config file + $fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/callcenter.conf.xml","w"); + fwrite($fout, $file_contents); + fclose($fout); + + //syncrhonize the configuration + save_dialplan_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + } + } +} + +if (!function_exists('switch_conf_xml')) { + function switch_conf_xml() { + //get the global variables + global $db, $domain_uuid; + + //get the contents of the template + $file_contents = file_get_contents($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/conf/autoload_configs/switch.conf.xml"); + + //prepare the php variables + if (stristr(PHP_OS, 'WIN')) { + $bindir = getenv(PHPRC); + $v_mailer_app ='"'. $bindir."\php". '" -f '.$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."\secure\\v_mailto.php -- "; + $v_mailer_app = sprintf("'%s'", $v_mailer_app); + $v_mailer_app_args = ""; + } + else { + if (file_exists(PHP_BINDIR.'/php')) { define("PHP_BIN", "php"); } + $v_mailer_app = PHP_BINDIR."/".PHP_BIN." ".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/secure/v_mailto.php"; + $v_mailer_app = sprintf('"%s"', $v_mailer_app); + $v_mailer_app_args = "-t"; + } + + //replace the values in the template + $file_contents = str_replace("{v_mailer_app}", $v_mailer_app, $file_contents); + unset ($v_mailer_app); + + //replace the values in the template + $file_contents = str_replace("{v_mailer_app_args}", $v_mailer_app_args, $file_contents); + unset ($v_mailer_app_args); + + //write the XML config file + $fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/switch.conf.xml","w"); + fwrite($fout, $file_contents); + fclose($fout); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + } +} + +if (!function_exists('xml_cdr_conf_xml')) { + function xml_cdr_conf_xml() { + + //get the global variables + global $db, $domain_uuid; + + //get the contents of the template + $file_contents = file_get_contents($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/includes/templates/conf/autoload_configs/xml_cdr.conf.xml"); + + //replace the values in the template + $file_contents = str_replace("{v_http_protocol}", "http", $file_contents); + $file_contents = str_replace("{domain_name}", "127.0.0.1", $file_contents); + $file_contents = str_replace("{v_project_path}", PROJECT_PATH, $file_contents); + + $v_user = generate_password(); + $file_contents = str_replace("{v_user}", $v_user, $file_contents); + unset ($v_user); + + $v_pass = generate_password(); + $file_contents = str_replace("{v_pass}", $v_pass, $file_contents); + unset ($v_pass); + + //write the XML config file + $fout = fopen($_SESSION['switch']['conf']['dir']."/autoload_configs/xml_cdr.conf.xml","w"); + fwrite($fout, $file_contents); + fclose($fout); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + } +} + +if (!function_exists('save_sip_profile_xml')) { + function save_sip_profile_xml() { + + //get the global variables + global $db, $domain_uuid; + + //get the sip profiles from the database + $sql = "select * from v_sip_profiles "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(); + $result_count = count($result); + unset ($prep_statement, $sql); + if ($result_count > 0) { + foreach($result as $row) { + $sip_profile_uuid = $row['sip_profile_uuid']; + $sip_profile_name = $row['sip_profile_name']; + + //get the xml sip profile template + if ($sip_profile_name == "internal" || $sip_profile_name == "external" || $sip_profile_name == "internal-ipv6") { + $file_contents = file_get_contents($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/sip_profiles/resources/xml/sip_profiles/".$sip_profile_name.".xml"); + } + else { + $file_contents = file_get_contents($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/sip_profiles/resources/xml/sip_profiles/default.xml"); + } + + //get the sip profile settings + $sql = "select * from v_sip_profile_settings "; + $sql .= "where sip_profile_uuid = '$sip_profile_uuid' "; + $sql .= "and sip_profile_setting_enabled = 'true' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(); + $sip_profile_settings = ''; + foreach ($result as &$row) { + $sip_profile_settings .= " \n"; + } + unset ($prep_statement); + + //replace the values in the template + $file_contents = str_replace("{v_sip_profile_name}", $sip_profile_name, $file_contents); + $file_contents = str_replace("{v_sip_profile_settings}", $sip_profile_settings, $file_contents); + + //write the XML config file + if (is_readable($_SESSION['switch']['conf']['dir']."/sip_profiles/")) { + $fout = fopen($_SESSION['switch']['conf']['dir']."/sip_profiles/".$sip_profile_name.".xml","w"); + fwrite($fout, $file_contents); + fclose($fout); + } + + //if the directory does not exist then create it + if (!is_readable($_SESSION['switch']['conf']['dir']."/sip_profiles/".$sip_profile_name)) { mkdir($_SESSION['switch']['conf']['dir']."/sip_profiles/".$sip_profile_name,0775,true); } + + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + //apply settings reminder + $_SESSION["reload_xml"] = true; + } +} + +if (!function_exists('save_switch_xml')) { + function save_switch_xml() { + if (is_readable($_SESSION['switch']['dialplan']['dir'])) { + save_dialplan_xml(); + } + if (is_readable($_SESSION['switch']['extensions']['dir'])) { + save_extension_xml(); + } + if (is_readable($_SESSION['switch']['conf']['dir'])) { + save_setting_xml(); + save_module_xml(); + save_var_xml(); + save_call_center_xml(); + save_gateway_xml(); + save_ivr_menu_xml(); + save_sip_profile_xml(); + } + if (is_readable($_SESSION['switch']['scripts']['dir'])) { + save_hunt_group_xml(); + } + } +} + +?> \ No newline at end of file diff --git a/includes/menu.php b/includes/menu.php new file mode 100644 index 0000000000..02f82b2fe0 --- /dev/null +++ b/includes/menu.php @@ -0,0 +1,80 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +require_once "root.php"; +require_once "includes/require.php"; + +//define the variable + $v_menu = ''; + +//force the menu to generate on every page load + //$_SESSION["menu"] = ''; + +//build the menu if the session menu has no length + if (!isset($_SESSION["menu"])) { + $_SESSION["menu"] = ''; + } + if (strlen($_SESSION["menu"]) == 0) { + $menuwidth = '110'; + //echo " \n"; + //echo " "; + + $v_menu = ""; + $v_menu .= " \n"; + //$v_menu .= " \n"; + $v_menu .= "\n"; + + $v_menu .= "\n"; + $v_menu .= "
    \n"; + $v_menu .= "\n"; + + require_once "includes/classes/menu.php"; + $menu = new menu; + $menu->db = $db; + $menu->menu_uuid = $_SESSION['domain']['menu']['uuid']; + $v_menu .= $menu->build_html("", "main"); + unset($menu); + + $v_menu .= "
    \n"; + $_SESSION["menu"] = $v_menu; + } + else { + //echo "from session"; + } + +//testing + //echo $_SESSION["menu"]; +?> diff --git a/includes/paging.php b/includes/paging.php new file mode 100644 index 0000000000..2cf53e6179 --- /dev/null +++ b/includes/paging.php @@ -0,0 +1,102 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +function paging($num_rows, $param, $rows_per_page) { + + if (strlen($rows_per_page)==0) { + $rows_per_page = "5"; //default number of rows per page + } + + +// by default we show first page + $pagenum = 0; + + // if $_get['page'] defined, use it as page number + if(isset($_GET['page'])) { + $pagenum = $_GET['page']; + } + + // counting the offset + $offset = ($pagenum - 1) * $rows_per_page; + + // how many pages we have when using paging? + $maxpage = ceil($num_rows/$rows_per_page); + + // print the link to access each page + $self = $_SERVER['PHP_SELF']; + $nav = ''; + for($page = 1; $page <= $maxpage; $page++){ + if ($page == $pagenum) { + $nav .= " $page "; // no need to create a link to current page + } + else { + $nav .= " $page \n"; + } + } + + if ($pagenum > 0) { + //echo "currently middepage
    "; + $page = $pagenum - 1; + $prev = "\n"; + $first = "\n"; + + } + else { + //echo "currently on the first page
    "; + $prev = "\n"; + //$first = "\n"; + } + + if (($pagenum + 1) < $maxpage) { + //echo "middle page
    "; + $page = $pagenum + 1; + $next = "\n"; + $last = "\n"; + + } + else { + //echo "last page
    "; + $last = "\n"; + $next = "\n"; + //$last = "\n"; + + } + + $returnearray = array(); + if ($maxpage > 1) { + //$returnearray[] = $first . $prev ." Page $pagenum of $maxpage " . $next . $last; + $returnearray[] = "
    ".$prev ." " .$next. "
    \n"; + } + else { + $returnearray[] = ""; + } + $returnearray[] = $rows_per_page; + $returnearray[] = $offset; + + return $returnearray; + +} +?> diff --git a/includes/persistform.php b/includes/persistform.php new file mode 100644 index 0000000000..d4466d13ae --- /dev/null +++ b/includes/persistform.php @@ -0,0 +1,46 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +function persistform($formarray) { + // Remember Form Input Values + if(is_array($formarray)) { + $content .= "
    \n"; + foreach($formarray as $key => $val) { + if($key == "XID" || $key == "ACT" || $key == "RET") continue; + if ($key != "persistform") { //clears the persistform value + $content .= "\n"; + } + } + $content .= "\n"; //sets persistform to yes + $content .= "\n"; + $content .= "
    \n"; + } + return $content; +} +//persistform($_POST); +//persistform($_GET); + +?> diff --git a/includes/persistformvar.php b/includes/persistformvar.php new file mode 100644 index 0000000000..21ea89fd14 --- /dev/null +++ b/includes/persistformvar.php @@ -0,0 +1,47 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +function persistformvar($formarray) { + // Remember Form Input Values + if(is_array($formarray)) { + $content .= "
    \n"; + foreach($formarray as $key => $val) { + if($key == "XID" || $key == "ACT" || $key == "RET") continue; + if ($key != "persistform") { //clears the persistform value + $content .= "\n"; + } + } + $content .= "\n"; //sets persistform to yes + $content .= "\n"; + $content .= "
    \n"; + } + echo $content; + //return $content; +} +//persistformvar($_POST); +//persistformvar($_GET); + +?> diff --git a/includes/phpsvnclient/definitions.php b/includes/phpsvnclient/definitions.php new file mode 100644 index 0000000000..2aec0ddc5a --- /dev/null +++ b/includes/phpsvnclient/definitions.php @@ -0,0 +1,81 @@ + + + +'); + +define("PHPSVN_NORMAL_REQUEST", +' + + + + + + +'); + +// +// + +define("PHPSVN_VERSION_REQUEST",''); +define("PHPSVN_LOGS_REQUEST",' %d%d'); + +define("SVN_LAST_MODIFIED","lp1:getlastmodified"); +define("SVN_URL","D:href"); +define("SVN_RELATIVE_URL","lp3:baseline-relative-path"); +define("SVN_FILE_ID","lp3:repository-uuid"); +define("SVN_STATUS","D:status"); +define("SVN_IN_FILE","D:propstat"); +define("SVN_FILE","D:response"); + +define("SVN_LOGS_BEGINGS","S:log-item"); +define("SVN_LOGS_VERSION","D:version-name"); +define("SVN_LOGS_AUTHOR","D:creator-displayname"); +define("SVN_LOGS_DATE","S:date"); + +// file changes. Note that we grouping ALL changed files together, +// so we will list deleted and renamed files here as well +define("SVN_LOGS_MODIFIED_FILES","S:modified-path"); +define("SVN_LOGS_ADDED_FILES","S:added-path"); +define("SVN_LOGS_DELETED_FILES","S:deleted-path"); +define("SVN_LOGS_RENAMED_FILES","S:replaced-path"); + +define("SVN_LOGS_COMMENT","D:comment"); + +define("NOT_FOUND", 2); +define("AUTH_REQUIRED", 3); +define("UNKNOWN_ERROR",4); +define("NO_ERROR",1) +?> diff --git a/includes/phpsvnclient/http.php b/includes/phpsvnclient/http.php new file mode 100644 index 0000000000..59d80e4d23 --- /dev/null +++ b/includes/phpsvnclient/http.php @@ -0,0 +1,1985 @@ +"01", + "Feb"=>"02", + "Mar"=>"03", + "Apr"=>"04", + "May"=>"05", + "Jun"=>"06", + "Jul"=>"07", + "Aug"=>"08", + "Sep"=>"09", + "Oct"=>"10", + "Nov"=>"11", + "Dec"=>"12"); + var $session=''; + var $connection_close=0; + + /* Private methods - DO NOT CALL */ + + Function Tokenize($string,$separator="") + { + if(!strcmp($separator,"")) + { + $separator=$string; + $string=$this->next_token; + } + for($character=0;$characternext_token=substr($string,$found+1); + return(substr($string,0,$found)); + } + else + { + $this->next_token=""; + return($string); + } + } + + Function CookieEncode($value, $name) + { + return($name ? str_replace("=", "%25", $value) : str_replace(";", "%3B", $value)); + } + + Function SetError($error) + { + return($this->error=$error); + } + + Function SetPHPError($error, &$php_error_message) + { + if(IsSet($php_error_message) + && strlen($php_error_message)) + $error.=": ".$php_error_message; + return($this->SetError($error)); + } + + Function SetDataAccessError($error,$check_connection=0) + { + $this->error=$error; + if(!$this->use_curl + && function_exists("socket_get_status")) + { + $status=socket_get_status($this->connection); + if($status["timed_out"]) + $this->error.=": data access time out"; + elseif($status["eof"]) + { + if($check_connection) + $this->error=""; + else + $this->error.=": the server disconnected"; + } + } + } + + Function OutputDebug($message) + { + $message.="\n"; + if($this->html_debug) + $message=str_replace("\n","
    \n",HtmlEntities($message)); + echo $message; + flush(); + } + + Function GetLine() + { + for($line="";;) + { + if($this->use_curl) + { + $eol=strpos($this->response,"\n",$this->read_response); + $data=($eol ? substr($this->response,$this->read_response,$eol+1-$this->read_response) : ""); + $this->read_response+=strlen($data); + } + else + { + if(feof($this->connection)) + { + $this->SetDataAccessError("reached the end of data while reading from the HTTP server connection"); + return(0); + } + $data=fgets($this->connection,100); + } + if(GetType($data)!="string" + || strlen($data)==0) + { + $this->SetDataAccessError("it was not possible to read line from the HTTP server"); + return(0); + } + $line.=$data; + $length=strlen($line); + if($length + && !strcmp(substr($line,$length-1,1),"\n")) + { + $length-=(($length>=2 && !strcmp(substr($line,$length-2,1),"\r")) ? 2 : 1); + $line=substr($line,0,$length); + if($this->debug) + $this->OutputDebug("S $line"); + return($line); + } + } + } + + Function PutLine($line) + { + if($this->debug) + $this->OutputDebug("C $line"); + if(!fputs($this->connection,$line."\r\n")) + { + $this->SetDataAccessError("it was not possible to send a line to the HTTP server"); + return(0); + } + return(1); + } + + Function PutData($data) + { + if(strlen($data)) + { + if($this->debug) + $this->OutputDebug('C '.$data); + if(!fputs($this->connection,$data)) + { + $this->SetDataAccessError("it was not possible to send data to the HTTP server"); + return(0); + } + } + return(1); + } + + Function FlushData() + { + if(!fflush($this->connection)) + { + $this->SetDataAccessError("it was not possible to send data to the HTTP server"); + return(0); + } + return(1); + } + + Function ReadChunkSize() + { + if($this->remaining_chunk==0) + { + $debug=$this->debug; + if(!$this->debug_response_body) + $this->debug=0; + $line=$this->GetLine(); + $this->debug=$debug; + if(GetType($line)!="string") + return($this->SetError("4 could not read chunk start: ".$this->error)); + $this->remaining_chunk=hexdec($line); + } + return(""); + } + + Function ReadBytes($length) + { + if($this->use_curl) + { + $bytes=substr($this->response,$this->read_response,min($length,strlen($this->response)-$this->read_response)); + $this->read_response+=strlen($bytes); + if($this->debug + && $this->debug_response_body + && strlen($bytes)) + $this->OutputDebug("S ".$bytes); + } + else + { + if($this->chunked) + { + for($bytes="",$remaining=$length;$remaining;) + { + if(strlen($this->ReadChunkSize())) + return(""); + if($this->remaining_chunk==0) + { + $this->last_chunk_read=1; + break; + } + $ask=min($this->remaining_chunk,$remaining); + $chunk=@fread($this->connection,$ask); + $read=strlen($chunk); + if($read==0) + { + $this->SetDataAccessError("it was not possible to read data chunk from the HTTP server"); + return(""); + } + if($this->debug + && $this->debug_response_body) + $this->OutputDebug("S ".$chunk); + $bytes.=$chunk; + $this->remaining_chunk-=$read; + $remaining-=$read; + if($this->remaining_chunk==0) + { + if(feof($this->connection)) + return($this->SetError("reached the end of data while reading the end of data chunk mark from the HTTP server")); + $data=@fread($this->connection,2); + if(strcmp($data,"\r\n")) + { + $this->SetDataAccessError("it was not possible to read end of data chunk from the HTTP server"); + return(""); + } + } + } + } + else + { + $bytes=@fread($this->connection,$length); + if(strlen($bytes)) + { + if($this->debug + && $this->debug_response_body) + $this->OutputDebug("S ".$bytes); + } + else + $this->SetDataAccessError("it was not possible to read data from the HTTP server", $this->connection_close); + } + } + return($bytes); + } + + Function EndOfInput() + { + if($this->use_curl) + return($this->read_response>=strlen($this->response)); + if($this->chunked) + return($this->last_chunk_read); + return(feof($this->connection)); + } + + Function Resolve($domain, &$ip, $server_type) + { +// if(ereg('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$domain)) + if(preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/',$domain)) + $ip=$domain; + else + { + if($this->debug) + $this->OutputDebug('Resolving '.$server_type.' server domain "'.$domain.'"...'); + if(!strcmp($ip=@gethostbyname($domain),$domain)) + $ip=""; + } + if(strlen($ip)==0 + || (strlen($this->exclude_address) + && !strcmp(@gethostbyname($this->exclude_address),$ip))) + return($this->SetError("could not resolve the host domain \"".$domain."\"")); + return(''); + } + + Function Connect($host_name, $host_port, $ssl, $server_type = 'HTTP') + { + $domain=$host_name; + $port = $host_port; + if(strlen($error = $this->Resolve($domain, $ip, $server_type))) + return($error); + if(strlen($this->socks_host_name)) + { + switch($this->socks_version) + { + case '4': + $version = 4; + break; + case '5': + $version = 5; + break; + default: + return('it was not specified a supported SOCKS protocol version'); + break; + } + $host_ip = $ip; + $port = $this->socks_host_port; + $host_server_type = $server_type; + $server_type = 'SOCKS'; + if(strlen($error = $this->Resolve($this->socks_host_name, $ip, $server_type))) + return($error); + } + if($this->debug) + $this->OutputDebug('Connecting to '.$server_type.' server IP '.$ip.' port '.$port.'...'); + if($ssl) + $ip="ssl://".$ip; + if(($this->connection=($this->timeout ? @fsockopen($ip, $port, $errno, $error, $this->timeout) : @fsockopen($ip, $port, $errno)))==0) + { + switch($errno) + { + case -3: + return($this->SetError("-3 socket could not be created")); + case -4: + return($this->SetError("-4 dns lookup on hostname \"".$host_name."\" failed")); + case -5: + return($this->SetError("-5 connection refused or timed out")); + case -6: + return($this->SetError("-6 fdopen() call failed")); + case -7: + return($this->SetError("-7 setvbuf() call failed")); + default: + return($this->SetPHPError($errno." could not connect to the host \"".$host_name."\"",$php_errormsg)); + } + } + else + { + if($this->data_timeout + && function_exists("socket_set_timeout")) + socket_set_timeout($this->connection,$this->data_timeout,0); + if(strlen($this->socks_host_name)) + { + if($this->debug) + $this->OutputDebug('Connected to the SOCKS server '.$this->socks_host_name); + $send_error = 'it was not possible to send data to the SOCKS server'; + $receive_error = 'it was not possible to receive data from the SOCKS server'; + switch($version) + { + case 4: + $command = 1; + if(!fputs($this->connection, chr($version).chr($command).pack('nN', $host_port, ip2long($host_ip)).$this->user.Chr(0))) + $error = $this->SetDataAccessError($send_error); + else + { + $response = fgets($this->connection, 9); + if(strlen($response) != 8) + $error = $this->SetDataAccessError($receive_error); + else + { + $socks_errors = array( + "\x5a"=>'', + "\x5b"=>'request rejected', + "\x5c"=>'request failed because client is not running identd (or not reachable from the server)', + "\x5d"=>'request failed because client\'s identd could not confirm the user ID string in the request', + ); + $error_code = $response[1]; + $error = (IsSet($socks_errors[$error_code]) ? $socks_errors[$error_code] : 'unknown'); + if(strlen($error)) + $error = 'SOCKS error: '.$error; + } + } + break; + case 5: + if($this->debug) + $this->OutputDebug('Negotiating the authentication method ...'); + $methods = 1; + $method = 0; + if(!fputs($this->connection, chr($version).chr($methods).chr($method))) + $error = $this->SetDataAccessError($send_error); + else + { + $response = fgets($this->connection, 3); + if(strlen($response) != 2) + $error = $this->SetDataAccessError($receive_error); + elseif(Ord($response[1]) != $method) + $error = 'the SOCKS server requires an authentication method that is not yet supported'; + else + { + if($this->debug) + $this->OutputDebug('Connecting to '.$host_server_type.' server IP '.$host_ip.' port '.$host_port.'...'); + $command = 1; + $address_type = 1; + if(!fputs($this->connection, chr($version).chr($command)."\x00".chr($address_type).pack('Nn', ip2long($host_ip), $host_port))) + $error = $this->SetDataAccessError($send_error); + else + { + $response = fgets($this->connection, 11); + if(strlen($response) != 10) + $error = $this->SetDataAccessError($receive_error); + else + { + $socks_errors = array( + "\x00"=>'', + "\x01"=>'general SOCKS server failure', + "\x02"=>'connection not allowed by ruleset', + "\x03"=>'Network unreachable', + "\x04"=>'Host unreachable', + "\x05"=>'Connection refused', + "\x06"=>'TTL expired', + "\x07"=>'Command not supported', + "\x08"=>'Address type not supported' + ); + $error_code = $response[1]; + $error = (IsSet($socks_errors[$error_code]) ? $socks_errors[$error_code] : 'unknown'); + if(strlen($error)) + $error = 'SOCKS error: '.$error; + } + } + } + } + break; + default: + $error = 'support for SOCKS protocol version '.$this->socks_version.' is not yet implemented'; + break; + } + if(strlen($error)) + { + fclose($this->connection); + return($error); + } + } + if($this->debug) + $this->OutputDebug("Connected to $host_name"); + if(strlen($this->proxy_host_name) + && !strcmp(strtolower($this->protocol), 'https')) + { + if(function_exists('stream_socket_enable_crypto') + && in_array('ssl', stream_get_transports())) + $this->state = "ConnectedToProxy"; + else + { + $this->OutputDebug("It is not possible to start SSL after connecting to the proxy server. If the proxy refuses to forward the SSL request, you may need to upgrade to PHP 5.1 or later with OpenSSL support enabled."); + $this->state="Connected"; + } + } + else + $this->state="Connected"; + return(""); + } + } + + Function Disconnect() + { + if($this->debug) + $this->OutputDebug("Disconnected from ".$this->host_name); + if($this->use_curl) + { + curl_close($this->connection); + $this->response=""; + } + else + fclose($this->connection); + $this->state="Disconnected"; + return(""); + } + + /* Public methods */ + + Function GetRequestArguments($url, &$arguments) + { + if(strlen($this->error)) + return($this->error); + $arguments=array(); + $parameters=@parse_url($url); + + if(!$parameters) + return($this->SetError("it was not specified a valid URL")); + if(!IsSet($parameters["scheme"])) + return($this->SetError("it was not specified the protocol type argument")); + switch(strtolower($parameters["scheme"])) + { + case "http": + case "https": + $arguments["Protocol"]=$parameters["scheme"]; + break; + default: + return($parameters["scheme"]." connection scheme is not yet supported"); + } + if(!IsSet($parameters["host"])) + return($this->SetError("it was not specified the connection host argument")); + $arguments["HostName"]=$parameters["host"]; + $arguments["Headers"]=array("Host"=>$parameters["host"].(IsSet($parameters["port"]) ? ":".$parameters["port"] : "")); + if(IsSet($parameters["user"])) + { + $arguments["AuthUser"]=UrlDecode($parameters["user"]); + if(!IsSet($parameters["pass"])) + $arguments["AuthPassword"]=""; + } + if(IsSet($parameters["pass"])) + { + if(!IsSet($parameters["user"])) + $arguments["AuthUser"]=""; + $arguments["AuthPassword"]=UrlDecode($parameters["pass"]); + } + if(IsSet($parameters["port"])) + { + if(strcmp($parameters["port"],strval(intval($parameters["port"])))) + return($this->SetError("it was not specified a valid connection host argument")); + $arguments["HostPort"]=intval($parameters["port"]); + } + else + $arguments["HostPort"]=0; + $arguments["RequestURI"]=(IsSet($parameters["path"]) ? $parameters["path"] : "/").(IsSet($parameters["query"]) ? "?".$parameters["query"] : ""); + if(strlen($this->user_agent)) + $arguments["Headers"]["User-Agent"]=$this->user_agent; + return(""); + } + + Function Open($arguments) + { + if(strlen($this->error)) + return($this->error); + if($this->state!="Disconnected") + return("1 already connected"); + if(IsSet($arguments["HostName"])) + $this->host_name=$arguments["HostName"]; + if(IsSet($arguments["HostPort"])) + $this->host_port=$arguments["HostPort"]; + if(IsSet($arguments["ProxyHostName"])) + $this->proxy_host_name=$arguments["ProxyHostName"]; + if(IsSet($arguments["ProxyHostPort"])) + $this->proxy_host_port=$arguments["ProxyHostPort"]; + if(IsSet($arguments["SOCKSHostName"])) + $this->socks_host_name=$arguments["SOCKSHostName"]; + if(IsSet($arguments["SOCKSHostPort"])) + $this->socks_host_port=$arguments["SOCKSHostPort"]; + if(IsSet($arguments["SOCKSVersion"])) + $this->socks_version=$arguments["SOCKSVersion"]; + if(IsSet($arguments["Protocol"])) + $this->protocol=$arguments["Protocol"]; + switch(strtolower($this->protocol)) + { + case "http": + $default_port=80; + break; + case "https": + $default_port=443; + break; + default: + return($this->SetError("2 it was not specified a valid connection protocol")); + } + if(strlen($this->proxy_host_name)==0) + { + if(strlen($this->host_name)==0) + return($this->SetError("2 it was not specified a valid hostname")); + $host_name=$this->host_name; + $host_port=($this->host_port ? $this->host_port : $default_port); + $server_type = 'HTTP'; + } + else + { + $host_name=$this->proxy_host_name; + $host_port=$this->proxy_host_port; + $server_type = 'HTTP proxy'; + } + $ssl=(strtolower($this->protocol)=="https" && strlen($this->proxy_host_name)==0); + if($ssl + && strlen($this->socks_host_name)) + return($this->SetError('establishing SSL connections via a SOCKS server is not yet supported')); + $this->use_curl=($ssl && $this->prefer_curl && function_exists("curl_init")); + if($this->debug) + $this->OutputDebug("Connecting to ".$this->host_name); + if($this->use_curl) + { + $error=(($this->connection=curl_init($this->protocol."://".$this->host_name.($host_port==$default_port ? "" : ":".strval($host_port))."/")) ? "" : "Could not initialize a CURL session"); + if(strlen($error)==0) + { + if(IsSet($arguments["SSLCertificateFile"])) + curl_setopt($this->connection,CURLOPT_SSLCERT,$arguments["SSLCertificateFile"]); + if(IsSet($arguments["SSLCertificatePassword"])) + curl_setopt($this->connection,CURLOPT_SSLCERTPASSWD,$arguments["SSLCertificatePassword"]); + if(IsSet($arguments["SSLKeyFile"])) + curl_setopt($this->connection,CURLOPT_SSLKEY,$arguments["SSLKeyFile"]); + if(IsSet($arguments["SSLKeyPassword"])) + curl_setopt($this->connection,CURLOPT_SSLKEYPASSWD,$arguments["SSLKeyPassword"]); + } + $this->state="Connected"; + } + else + { + $error=""; + if(strlen($this->proxy_host_name) + && (IsSet($arguments["SSLCertificateFile"]) + || IsSet($arguments["SSLCertificateFile"]))) + $error="establishing SSL connections using certificates or private keys via non-SSL proxies is not supported"; + else + { + if($ssl) + { + if(IsSet($arguments["SSLCertificateFile"])) + $error="establishing SSL connections using certificates is only supported when the cURL extension is enabled"; + elseif(IsSet($arguments["SSLKeyFile"])) + $error="establishing SSL connections using a private key is only supported when the cURL extension is enabled"; + else + { + $version=explode(".",function_exists("phpversion") ? phpversion() : "3.0.7"); + $php_version=intval($version[0])*1000000+intval($version[1])*1000+intval($version[2]); + if($php_version<4003000) + $error="establishing SSL connections requires at least PHP version 4.3.0 or having the cURL extension enabled"; + elseif(!function_exists("extension_loaded") + || !extension_loaded("openssl")) + $error="establishing SSL connections requires the OpenSSL extension enabled"; + } + } + if(strlen($error)==0) + $error=$this->Connect($host_name, $host_port, $ssl, $server_type); + } + } + if(strlen($error)) + return($this->SetError($error)); + $this->session=md5(uniqid("")); + return(""); + } + + Function Close() + { + if($this->state=="Disconnected") + return("1 already disconnected"); + $error=$this->Disconnect(); + if(strlen($error)==0) + $this->state="Disconnected"; + return($error); + } + + Function PickCookies(&$cookies,$secure) + { + if(IsSet($this->cookies[$secure])) + { + $now=gmdate("Y-m-d H-i-s"); + for($domain=0,Reset($this->cookies[$secure]);$domaincookies[$secure]);Next($this->cookies[$secure]),$domain++) + { + $domain_pattern=Key($this->cookies[$secure]); + $match=strlen($this->request_host)-strlen($domain_pattern); + if($match>=0 + && !strcmp($domain_pattern,substr($this->request_host,$match)) + && ($match==0 + || $domain_pattern[0]=="." + || $this->request_host[$match-1]==".")) + { + for(Reset($this->cookies[$secure][$domain_pattern]),$path_part=0;$path_partcookies[$secure][$domain_pattern]);Next($this->cookies[$secure][$domain_pattern]),$path_part++) + { + $path=Key($this->cookies[$secure][$domain_pattern]); + if(strlen($this->request_uri)>=strlen($path) + && substr($this->request_uri,0,strlen($path))==$path) + { + for(Reset($this->cookies[$secure][$domain_pattern][$path]),$cookie=0;$cookiecookies[$secure][$domain_pattern][$path]);Next($this->cookies[$secure][$domain_pattern][$path]),$cookie++) + { + $cookie_name=Key($this->cookies[$secure][$domain_pattern][$path]); + $expires=$this->cookies[$secure][$domain_pattern][$path][$cookie_name]["expires"]; + if($expires=="" + || strcmp($now,$expires)<0) + $cookies[$cookie_name]=$this->cookies[$secure][$domain_pattern][$path][$cookie_name]; + } + } + } + } + } + } + } + + Function GetFileDefinition($file, &$definition) + { + $name=""; + if(IsSet($file["FileName"])) + $name=basename($file["FileName"]); + if(IsSet($file["Name"])) + $name=$file["Name"]; + if(strlen($name)==0) + return("it was not specified the file part name"); + if(IsSet($file["Content-Type"])) + { + $content_type=$file["Content-Type"]; + $type=$this->Tokenize(strtolower($content_type),"/"); + $sub_type=$this->Tokenize(""); + switch($type) + { + case "text": + case "image": + case "audio": + case "video": + case "application": + case "message": + break; + case "automatic": + switch($sub_type) + { + case "name": + switch(GetType($dot=strrpos($name,"."))=="integer" ? strtolower(substr($name,$dot)) : "") + { + case ".xls": + $content_type="application/excel"; + break; + case ".hqx": + $content_type="application/macbinhex40"; + break; + case ".doc": + case ".dot": + case ".wrd": + $content_type="application/msword"; + break; + case ".pdf": + $content_type="application/pdf"; + break; + case ".pgp": + $content_type="application/pgp"; + break; + case ".ps": + case ".eps": + case ".ai": + $content_type="application/postscript"; + break; + case ".ppt": + $content_type="application/powerpoint"; + break; + case ".rtf": + $content_type="application/rtf"; + break; + case ".tgz": + case ".gtar": + $content_type="application/x-gtar"; + break; + case ".gz": + $content_type="application/x-gzip"; + break; + case ".php": + case ".php3": + $content_type="application/x-httpd-php"; + break; + case ".js": + $content_type="application/x-javascript"; + break; + case ".ppd": + case ".psd": + $content_type="application/x-photoshop"; + break; + case ".swf": + case ".swc": + case ".rf": + $content_type="application/x-shockwave-flash"; + break; + case ".tar": + $content_type="application/x-tar"; + break; + case ".zip": + $content_type="application/zip"; + break; + case ".mid": + case ".midi": + case ".kar": + $content_type="audio/midi"; + break; + case ".mp2": + case ".mp3": + case ".mpga": + $content_type="audio/mpeg"; + break; + case ".ra": + $content_type="audio/x-realaudio"; + break; + case ".wav": + $content_type="audio/wav"; + break; + case ".bmp": + $content_type="image/bitmap"; + break; + case ".gif": + $content_type="image/gif"; + break; + case ".iff": + $content_type="image/iff"; + break; + case ".jb2": + $content_type="image/jb2"; + break; + case ".jpg": + case ".jpe": + case ".jpeg": + $content_type="image/jpeg"; + break; + case ".jpx": + $content_type="image/jpx"; + break; + case ".png": + $content_type="image/png"; + break; + case ".tif": + case ".tiff": + $content_type="image/tiff"; + break; + case ".wbmp": + $content_type="image/vnd.wap.wbmp"; + break; + case ".xbm": + $content_type="image/xbm"; + break; + case ".css": + $content_type="text/css"; + break; + case ".txt": + $content_type="text/plain"; + break; + case ".htm": + case ".html": + $content_type="text/html"; + break; + case ".xml": + $content_type="text/xml"; + break; + case ".mpg": + case ".mpe": + case ".mpeg": + $content_type="video/mpeg"; + break; + case ".qt": + case ".mov": + $content_type="video/quicktime"; + break; + case ".avi": + $content_type="video/x-ms-video"; + break; + case ".eml": + $content_type="message/rfc822"; + break; + default: + $content_type="application/octet-stream"; + break; + } + break; + default: + return($content_type." is not a supported automatic content type detection method"); + } + break; + default: + return($content_type." is not a supported file content type"); + } + } + else + $content_type="application/octet-stream"; + $definition=array( + "Content-Type"=>$content_type, + "NAME"=>$name + ); + if(IsSet($file["FileName"])) + { + if(GetType($length=@filesize($file["FileName"]))!="integer") + { + $error="it was not possible to determine the length of the file ".$file["FileName"]; + if(IsSet($php_errormsg) + && strlen($php_errormsg)) + $error.=": ".$php_errormsg; + if(!file_exists($file["FileName"])) + $error="it was not possible to access the file ".$file["FileName"]; + return($error); + } + $definition["FILENAME"]=$file["FileName"]; + $definition["Content-Length"]=$length; + } + elseif(IsSet($file["Data"])) + $definition["Content-Length"]=strlen($definition["DATA"]=$file["Data"]); + else + return("it was not specified a valid file name"); + return(""); + } + + Function ConnectFromProxy($arguments, &$headers) + { + if(!$this->PutLine('CONNECT '.$this->host_name.':'.($this->host_port ? $this->host_port : 443).' HTTP/1.0') + || (strlen($this->user_agent) + && !$this->PutLine('User-Agent: '.$this->user_agent)) + || (IsSet($arguments['Headers']['Proxy-Authorization']) + && !$this->PutLine('Proxy-Authorization: '.$arguments['Headers']['Proxy-Authorization'])) + || !$this->PutLine('')) + { + $this->Disconnect(); + return($this->error); + } + $this->state = "ConnectSent"; + if(strlen($error=$this->ReadReplyHeadersResponse($headers))) + return($error); + $proxy_authorization=""; + while(!strcmp($this->response_status, "100")) + { + $this->state="ConnectSent"; + if(strlen($error=$this->ReadReplyHeadersResponse($headers))) + return($error); + } + switch($this->response_status) + { + case "200": + if(!@stream_socket_enable_crypto($this->connection, 1, STREAM_CRYPTO_METHOD_SSLv23_CLIENT)) + { + $this->SetPHPError('it was not possible to start a SSL encrypted connection via this proxy', $php_errormsg); + $this->Disconnect(); + return($this->error); + } + $this->state = "Connected"; + break; + case "407": + if(strlen($error=$this->Authenticate($headers, -1, $proxy_authorization, $this->proxy_request_user, $this->proxy_request_password, $this->proxy_request_realm, $this->proxy_request_workstation))) + return($error); + break; + default: + return($this->SetError("unable to send request via proxy")); + } + return(""); + } + + Function SendRequest($arguments) + { + if(strlen($this->error)) + return($this->error); + if(IsSet($arguments["ProxyUser"])) + $this->proxy_request_user=$arguments["ProxyUser"]; + elseif(IsSet($this->proxy_user)) + $this->proxy_request_user=$this->proxy_user; + if(IsSet($arguments["ProxyPassword"])) + $this->proxy_request_password=$arguments["ProxyPassword"]; + elseif(IsSet($this->proxy_password)) + $this->proxy_request_password=$this->proxy_password; + if(IsSet($arguments["ProxyRealm"])) + $this->proxy_request_realm=$arguments["ProxyRealm"]; + elseif(IsSet($this->proxy_realm)) + $this->proxy_request_realm=$this->proxy_realm; + if(IsSet($arguments["ProxyWorkstation"])) + $this->proxy_request_workstation=$arguments["ProxyWorkstation"]; + elseif(IsSet($this->proxy_workstation)) + $this->proxy_request_workstation=$this->proxy_workstation; + switch($this->state) + { + case "Disconnected": + return($this->SetError("1 connection was not yet established")); + case "Connected": + $connect = 0; + break; + case "ConnectedToProxy": + if(strlen($error = $this->ConnectFromProxy($arguments, $headers))) + return($error); + $connect = 1; + break; + default: + return($this->SetError("2 can not send request in the current connection state")); + } + if(IsSet($arguments["RequestMethod"])) + $this->request_method=$arguments["RequestMethod"]; + if(IsSet($arguments["User-Agent"])) + $this->user_agent=$arguments["User-Agent"]; + if(!IsSet($arguments["Headers"]["User-Agent"]) + && strlen($this->user_agent)) + $arguments["Headers"]["User-Agent"]=$this->user_agent; + if(strlen($this->request_method)==0) + return($this->SetError("3 it was not specified a valid request method")); + if(IsSet($arguments["RequestURI"])) + $this->request_uri=$arguments["RequestURI"]; + if(strlen($this->request_uri)==0 + || substr($this->request_uri,0,1)!="/") + return($this->SetError("4 it was not specified a valid request URI")); + $this->request_arguments=$arguments; + $this->request_headers=(IsSet($arguments["Headers"]) ? $arguments["Headers"] : array()); + $body_length=0; + $this->request_body=""; + $get_body=1; + if($this->request_method=="POST" + || $this->request_method=="PUT") + { + if(IsSet($arguments['StreamRequest'])) + { + $get_body = 0; + $this->request_headers["Transfer-Encoding"]="chunked"; + } + elseif(IsSet($arguments["PostFiles"]) + || ($this->force_multipart_form_post + && IsSet($arguments["PostValues"]))) + { + $boundary="--".md5(uniqid(time())); + $this->request_headers["Content-Type"]="multipart/form-data; boundary=".$boundary.(IsSet($arguments["CharSet"]) ? "; charset=".$arguments["CharSet"] : ""); + $post_parts=array(); + if(IsSet($arguments["PostValues"])) + { + $values=$arguments["PostValues"]; + if(GetType($values)!="array") + return($this->SetError("5 it was not specified a valid POST method values array")); + for(Reset($values),$value=0;$value$headers,"DATA"=>$data); + $body_length+=strlen($headers)+strlen($data)+strlen("\r\n"); + } + } + $body_length+=strlen("--".$boundary."--\r\n"); + $files=(IsSet($arguments["PostFiles"]) ? $arguments["PostFiles"] : array()); + Reset($files); + $end=(GetType($input=Key($files))!="string"); + for(;!$end;) + { + if(strlen($error=$this->GetFileDefinition($files[$input],$definition))) + return("3 ".$error); + $headers="--".$boundary."\r\nContent-Disposition: form-data; name=\"".$input."\"; filename=\"".$definition["NAME"]."\"\r\nContent-Type: ".$definition["Content-Type"]."\r\n\r\n"; + $part=count($post_parts); + $post_parts[$part]=array("HEADERS"=>$headers); + if(IsSet($definition["FILENAME"])) + { + $post_parts[$part]["FILENAME"]=$definition["FILENAME"]; + $data=""; + } + else + $data=$definition["DATA"]; + $post_parts[$part]["DATA"]=$data; + $body_length+=strlen($headers)+$definition["Content-Length"]+strlen("\r\n"); + Next($files); + $end=(GetType($input=Key($files))!="string"); + } + $get_body=0; + } + elseif(IsSet($arguments["PostValues"])) + { + $values=$arguments["PostValues"]; + if(GetType($values)!="array") + return($this->SetError("5 it was not specified a valid POST method values array")); + for(Reset($values),$value=0;$value0) + $this->request_body.="&"; + $this->request_body.=UrlEncode($k)."=".UrlEncode($values[$k][$v]); + } + } + else + { + if($value>0) + $this->request_body.="&"; + $this->request_body.=UrlEncode($k)."=".UrlEncode($values[$k]); + } + } + $this->request_headers["Content-Type"]="application/x-www-form-urlencoded".(IsSet($arguments["CharSet"]) ? "; charset=".$arguments["CharSet"] : ""); + $get_body=0; + } + } + if($get_body + && (IsSet($arguments["Body"]) + || IsSet($arguments["BodyStream"]))) + { + if(IsSet($arguments["Body"])) + $this->request_body=$arguments["Body"]; + else + { + $stream=$arguments["BodyStream"]; + $this->request_body=""; + for($part=0; $partrequest_body.=$stream[$part]["Data"]; + elseif(IsSet($stream[$part]["File"])) + { + if(!($file=@fopen($stream[$part]["File"],"rb"))) + return($this->SetPHPError("could not open upload file ".$stream[$part]["File"], $php_errormsg)); + while(!feof($file)) + { + if(GetType($block=@fread($file,$this->file_buffer_length))!="string") + { + $error=$this->SetPHPError("could not read body stream file ".$stream[$part]["File"], $php_errormsg); + fclose($file); + return($error); + } + $this->request_body.=$block; + } + fclose($file); + } + else + return("5 it was not specified a valid file or data body stream element at position ".$part); + } + } + if(!IsSet($this->request_headers["Content-Type"])) + $this->request_headers["Content-Type"]="application/octet-stream".(IsSet($arguments["CharSet"]) ? "; charset=".$arguments["CharSet"] : ""); + } + if(IsSet($arguments["AuthUser"])) + $this->request_user=$arguments["AuthUser"]; + elseif(IsSet($this->user)) + $this->request_user=$this->user; + if(IsSet($arguments["AuthPassword"])) + $this->request_password=$arguments["AuthPassword"]; + elseif(IsSet($this->password)) + $this->request_password=$this->password; + if(IsSet($arguments["AuthRealm"])) + $this->request_realm=$arguments["AuthRealm"]; + elseif(IsSet($this->realm)) + $this->request_realm=$this->realm; + if(IsSet($arguments["AuthWorkstation"])) + $this->request_workstation=$arguments["AuthWorkstation"]; + elseif(IsSet($this->workstation)) + $this->request_workstation=$this->workstation; + if(strlen($this->proxy_host_name)==0 + || $connect) + $request_uri=$this->request_uri; + else + { + switch(strtolower($this->protocol)) + { + case "http": + $default_port=80; + break; + case "https": + $default_port=443; + break; + } + $request_uri=strtolower($this->protocol)."://".$this->host_name.(($this->host_port==0 || $this->host_port==$default_port) ? "" : ":".$this->host_port).$this->request_uri; + } + if($this->use_curl) + { + $version=(GetType($v=curl_version())=="array" ? (IsSet($v["version"]) ? $v["version"] : "0.0.0") : (ereg("^libcurl/([0-9]+\\.[0-9]+\\.[0-9]+)",$v,$m) ? $m[1] : "0.0.0")); + $curl_version=100000*intval($this->Tokenize($version,"."))+1000*intval($this->Tokenize("."))+intval($this->Tokenize("")); + $protocol_version=($curl_version<713002 ? "1.0" : $this->protocol_version); + } + else + $protocol_version=$this->protocol_version; + $this->request=$this->request_method." ".$request_uri." HTTP/".$protocol_version; + if($body_length + || ($body_length=strlen($this->request_body))) + $this->request_headers["Content-Length"]=$body_length; + for($headers=array(),$host_set=0,Reset($this->request_headers),$header=0;$headerrequest_headers);Next($this->request_headers),$header++) + { + $header_name=Key($this->request_headers); + $header_value=$this->request_headers[$header_name]; + if(GetType($header_value)=="array") + { + for(Reset($header_value),$value=0;$valuerequest_headers))=="host") + { + $this->request_host=strtolower($header_value); + $host_set=1; + } + } + if(!$host_set) + { + $headers[]="Host: ".$this->host_name; + $this->request_host=strtolower($this->host_name); + } + if(count($this->cookies)) + { + $cookies=array(); + $this->PickCookies($cookies,0); + if(strtolower($this->protocol)=="https") + $this->PickCookies($cookies,1); + if(count($cookies)) + { + $h=count($headers); + $headers[$h]="Cookie:"; + for(Reset($cookies),$cookie=0;$cookieuse_curl) + { + if(IsSet($arguments['StreamRequest'])) + return($this->SetError("Streaming request data is not supported when using Curl")); + if($body_length + && strlen($this->request_body)==0) + { + for($request_body="",$success=1,$part=0;$partSetPHPError("could not open upload file ".$post_parts[$part]["FILENAME"], $php_errormsg); + $success=0; + break; + } + while(!feof($file)) + { + if(GetType($block=@fread($file,$this->file_buffer_length))!="string") + { + $this->SetPHPError("could not read upload file", $php_errormsg); + $success=0; + break; + } + $request_body.=$block; + } + fclose($file); + if(!$success) + break; + } + $request_body.="\r\n"; + } + $request_body.="--".$boundary."--\r\n"; + } + else + $request_body=$this->request_body; + curl_setopt($this->connection,CURLOPT_HEADER,1); + curl_setopt($this->connection,CURLOPT_RETURNTRANSFER,1); + if($this->timeout) + curl_setopt($this->connection,CURLOPT_TIMEOUT,$this->timeout); + curl_setopt($this->connection,CURLOPT_SSL_VERIFYPEER,0); + curl_setopt($this->connection,CURLOPT_SSL_VERIFYHOST,0); + $request=$this->request."\r\n".implode("\r\n",$headers)."\r\n\r\n".$request_body; + curl_setopt($this->connection,CURLOPT_CUSTOMREQUEST,$request); + if($this->debug) + $this->OutputDebug("C ".$request); + if(!($success=(strlen($this->response=curl_exec($this->connection))!=0))) + { + $error=curl_error($this->connection); + $this->SetError("Could not execute the request".(strlen($error) ? ": ".$error : "")); + } + } + else + { + if(($success=$this->PutLine($this->request))) + { + for($header=0;$headerPutLine($headers[$header])) + break; + } + if($success + && ($success=$this->PutLine(""))) + { + if(IsSet($arguments['StreamRequest'])) + $next_state = "SendingRequestBody"; + elseif($body_length) + { + if(strlen($this->request_body)) + $success=$this->PutData($this->request_body); + else + { + for($part=0;$partPutData($post_parts[$part]["HEADERS"])) + || !($success=$this->PutData($post_parts[$part]["DATA"]))) + break; + if(IsSet($post_parts[$part]["FILENAME"])) + { + if(!($file=@fopen($post_parts[$part]["FILENAME"],"rb"))) + { + $this->SetPHPError("could not open upload file ".$post_parts[$part]["FILENAME"], $php_errormsg); + $success=0; + break; + } + while(!feof($file)) + { + if(GetType($block=@fread($file,$this->file_buffer_length))!="string") + { + $this->SetPHPError("could not read upload file", $php_errormsg); + $success=0; + break; + } + if(!($success=$this->PutData($block))) + break; + } + fclose($file); + if(!$success) + break; + } + if(!($success=$this->PutLine(""))) + break; + } + if($success) + $success=$this->PutLine("--".$boundary."--"); + } + if($success) + $sucess=$this->FlushData(); + } + } + } + } + if(!$success) + return($this->SetError("5 could not send the HTTP request: ".$this->error)); + $this->state=$next_state; + return(""); + } + + Function SetCookie($name, $value, $expires="" , $path="/" , $domain="" , $secure=0, $verbatim=0) + { + if(strlen($this->error)) + return($this->error); + if(strlen($name)==0) + return($this->SetError("it was not specified a valid cookie name")); + if(strlen($path)==0 + || strcmp($path[0],"/")) + return($this->SetError($path." is not a valid path for setting cookie ".$name)); + if($domain=="" + || !strpos($domain,".",$domain[0]=="." ? 1 : 0)) + return($this->SetError($domain." is not a valid domain for setting cookie ".$name)); + $domain=strtolower($domain); + if(!strcmp($domain[0],".")) + $domain=substr($domain,1); + if(!$verbatim) + { + $name=$this->CookieEncode($name,1); + $value=$this->CookieEncode($value,0); + } + $secure=intval($secure); + $this->cookies[$secure][$domain][$path][$name]=array( + "name"=>$name, + "value"=>$value, + "domain"=>$domain, + "path"=>$path, + "expires"=>$expires, + "secure"=>$secure + ); + return(""); + } + + Function SendRequestBody($data, $end_of_data) + { + if(strlen($this->error)) + return($this->error); + switch($this->state) + { + case "Disconnected": + return($this->SetError("1 connection was not yet established")); + case "Connected": + case "ConnectedToProxy": + return($this->SetError("2 request was not sent")); + case "SendingRequestBody": + break; + case "RequestSent": + return($this->SetError("3 request body was already sent")); + default: + return($this->SetError("4 can not send the request body in the current connection state")); + } + $length = strlen($data); + if($length) + { + $size = dechex($length)."\r\n"; + if(!$this->PutData($size) + || !$this->PutData($data)) + return($this->error); + } + if($end_of_data) + { + $size = "0\r\n"; + if(!$this->PutData($size)) + return($this->error); + $this->state = "RequestSent"; + } + return(""); + } + + Function ReadReplyHeadersResponse(&$headers) + { + $headers=array(); + if(strlen($this->error)) + return($this->error); + switch($this->state) + { + case "Disconnected": + return($this->SetError("1 connection was not yet established")); + case "Connected": + return($this->SetError("2 request was not sent")); + case "ConnectedToProxy": + return($this->SetError("2 connection from the remote server from the proxy was not yet established")); + case "SendingRequestBody": + return($this->SetError("4 request body data was not completely sent")); + case "ConnectSent": + $connect = 1; + break; + case "RequestSent": + $connect = 0; + break; + default: + return($this->SetError("3 can not get request headers in the current connection state")); + } + $this->content_length=$this->read_length=$this->read_response=$this->remaining_chunk=0; + $this->content_length_set=$this->chunked=$this->last_chunk_read=$chunked=0; + $this->connection_close=0; + for($this->response_status="";;) + { + $line=$this->GetLine(); + if(GetType($line)!="string") + return($this->SetError("4 could not read request reply: ".$this->error)); + if(strlen($this->response_status)==0) + { +// if(!eregi($match="^http/[0-9]+\\.[0-9]+[ \t]+([0-9]+)[ \t]*(.*)\$",$line,$matches)) + if(!preg_match("~^http/[0-9]+\\.[0-9]+[ \t]+([0-9]+)[ \t]*(.*)\$~i",$line,$matches)) + return($this->SetError("3 it was received an unexpected HTTP response status")); + $this->response_status=$matches[1]; + $this->response_message=$matches[2]; + } + if($line=="") + { + if(strlen($this->response_status)==0) + return($this->SetError("3 it was not received HTTP response status")); + $this->state=($connect ? "GotConnectHeaders" : "GotReplyHeaders"); + break; + } + $header_name=strtolower($this->Tokenize($line,":")); + $header_value=Trim(Chop($this->Tokenize("\r\n"))); + if(IsSet($headers[$header_name])) + { + if(GetType($headers[$header_name])=="string") + $headers[$header_name]=array($headers[$header_name]); + $headers[$header_name][]=$header_value; + } + else + $headers[$header_name]=$header_value; + if(!$connect) + { + switch($header_name) + { + case "content-length": + $this->content_length=intval($headers[$header_name]); + $this->content_length_set=1; + break; + case "transfer-encoding": + $encoding=$this->Tokenize($header_value,"; \t"); + if(!$this->use_curl + && !strcmp($encoding,"chunked")) + $chunked=1; + break; + case "set-cookie": + if($this->support_cookies) + { + if(GetType($headers[$header_name])=="array") + $cookie_headers=$headers[$header_name]; + else + $cookie_headers=array($headers[$header_name]); + for($cookie=0;$cookieTokenize($cookie_headers[$cookie],"=")); + $cookie_value=$this->Tokenize(";"); + $domain=$this->request_host; + $path="/"; + $expires=""; + $secure=0; + while(($name=trim(UrlDecode($this->Tokenize("="))))!="") + { + $value=UrlDecode($this->Tokenize(";")); + switch($name) + { + case "domain": + $domain=$value; + break; + case "path": + $path=$value; + break; + case "expires": + if(ereg("^((Mon|Monday|Tue|Tuesday|Wed|Wednesday|Thu|Thursday|Fri|Friday|Sat|Saturday|Sun|Sunday), )?([0-9]{2})\\-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\-([0-9]{2,4}) ([0-9]{2})\\:([0-9]{2})\\:([0-9]{2}) GMT\$",$value,$matches)) + { + $year=intval($matches[5]); + if($year<1900) + $year+=($year<70 ? 2000 : 1900); + $expires="$year-".$this->months[$matches[4]]."-".$matches[3]." ".$matches[6].":".$matches[7].":".$matches[8]; + } + break; + case "secure": + $secure=1; + break; + } + } + if(strlen($this->SetCookie($cookie_name, $cookie_value, $expires, $path , $domain, $secure, 1))) + $this->error=""; + } + } + break; + case "connection": + $this->connection_close=!strcmp(strtolower($header_value),"close"); + break; + } + } + } + $this->chunked=$chunked; + if($this->content_length_set) + $this->connection_close=0; + return(""); + } + + Function Redirect(&$headers) + { + if($this->follow_redirect) + { + if(!IsSet($headers["location"]) + || (GetType($headers["location"])!="array" + && strlen($location=$headers["location"])==0) + || (GetType($headers["location"])=="array" + && strlen($location=$headers["location"][0])==0)) + return($this->SetError("3 it was received a redirect without location URL")); + if(strcmp($location[0],"/")) + { + $location_arguments=parse_url($location); + if(!IsSet($location_arguments["scheme"])) + $location=((GetType($end=strrpos($this->request_uri,"/"))=="integer" && $end>1) ? substr($this->request_uri,0,$end) : "")."/".$location; + } + if(!strcmp($location[0],"/")) + $location=$this->protocol."://".$this->host_name.($this->host_port ? ":".$this->host_port : "").$location; + $error=$this->GetRequestArguments($location,$arguments); + if(strlen($error)) + return($this->SetError("could not process redirect url: ".$error)); + $arguments["RequestMethod"]="GET"; + if(strlen($error=$this->Close())==0 + && strlen($error=$this->Open($arguments))==0 + && strlen($error=$this->SendRequest($arguments))==0) + { + $this->redirection_level++; + if($this->redirection_level>$this->redirection_limit) + $error="it was exceeded the limit of request redirections"; + else + $error=$this->ReadReplyHeaders($headers); + $this->redirection_level--; + } + if(strlen($error)) + return($this->SetError($error)); + } + return(""); + } + + Function Authenticate(&$headers, $proxy, &$proxy_authorization, &$user, &$password, &$realm, &$workstation) + { + if($proxy) + { + $authenticate_header="proxy-authenticate"; + $authorization_header="Proxy-Authorization"; + $authenticate_status="407"; + $authentication_mechanism=$this->proxy_authentication_mechanism; + } + else + { + $authenticate_header="www-authenticate"; + $authorization_header="Authorization"; + $authenticate_status="401"; + $authentication_mechanism=$this->authentication_mechanism; + } + if(IsSet($headers[$authenticate_header])) + { + if(function_exists("class_exists") + && !class_exists("sasl_client_class")) + return($this->SetError("the SASL client class needs to be loaded to be able to authenticate".($proxy ? " with the proxy server" : "")." and access this site")); + if(GetType($headers[$authenticate_header])=="array") + $authenticate=$headers[$authenticate_header]; + else + $authenticate=array($headers[$authenticate_header]); + for($response="", $mechanisms=array(),$m=0;$mTokenize($authenticate[$m]," "); + $response=$this->Tokenize(""); + if(strlen($authentication_mechanism)) + { + if(!strcmp($authentication_mechanism,$mechanism)) + { + $mechanisms[]=$mechanism; + break; + } + } + else + $mechanisms[]=$mechanism; + } + $sasl=new sasl_client_class; + if(IsSet($user)) + $sasl->SetCredential("user",$user); + if(IsSet($password)) + $sasl->SetCredential("password",$password); + if(IsSet($realm)) + $sasl->SetCredential("realm",$realm); + if(IsSet($workstation)) + $sasl->SetCredential("workstation",$workstation); + $sasl->SetCredential("uri",$this->request_uri); + $sasl->SetCredential("method",$this->request_method); + $sasl->SetCredential("session",$this->session); + do + { + $status=$sasl->Start($mechanisms,$message,$interactions); + } + while($status==SASL_INTERACT); + switch($status) + { + case SASL_CONTINUE: + break; + case SASL_NOMECH: + return($this->SetError(($proxy ? "proxy " : "")."authentication error: ".(strlen($authentication_mechanism) ? "authentication mechanism ".$authentication_mechanism." may not be used: " : "").$sasl->error)); + default: + return($this->SetError("Could not start the SASL ".($proxy ? "proxy " : "")."authentication client: ".$sasl->error)); + } + if($proxy >= 0) + { + for(;;) + { + if(strlen($error=$this->ReadReplyBody($body,$this->file_buffer_length))) + return($error); + if(strlen($body)==0) + break; + } + } + $authorization_value=$sasl->mechanism.(IsSet($message) ? " ".($sasl->encode_response ? base64_encode($message) : $message) : ""); + $request_arguments=$this->request_arguments; + $arguments=$request_arguments; + $arguments["Headers"][$authorization_header]=$authorization_value; + if(!$proxy + && strlen($proxy_authorization)) + $arguments["Headers"]["Proxy-Authorization"]=$proxy_authorization; + if(strlen($error=$this->Close()) + || strlen($error=$this->Open($arguments))) + return($this->SetError($error)); + $authenticated=0; + if(IsSet($message)) + { + if($proxy < 0) + { + if(strlen($error=$this->ConnectFromProxy($arguments, $headers))) + return($this->SetError($error)); + } + else + { + if(strlen($error=$this->SendRequest($arguments)) + || strlen($error=$this->ReadReplyHeadersResponse($headers))) + return($this->SetError($error)); + } + if(!IsSet($headers[$authenticate_header])) + $authenticate=array(); + elseif(GetType($headers[$authenticate_header])=="array") + $authenticate=$headers[$authenticate_header]; + else + $authenticate=array($headers[$authenticate_header]); + for($mechanism=0;$mechanismTokenize($authenticate[$mechanism]," "),$sasl->mechanism)) + { + $response=$this->Tokenize(""); + break; + } + } + switch($this->response_status) + { + case $authenticate_status: + break; + case "301": + case "302": + case "303": + case "307": + if($proxy >= 0) + return($this->Redirect($headers)); + default: + if(intval($this->response_status/100)==2) + { + if($proxy) + $proxy_authorization=$authorization_value; + $authenticated=1; + break; + } + if($proxy + && !strcmp($this->response_status,"401")) + { + $proxy_authorization=$authorization_value; + $authenticated=1; + break; + } + return($this->SetError(($proxy ? "proxy " : "")."authentication error: ".$this->response_status." ".$this->response_message)); + } + } + for(;!$authenticated;) + { + do + { + $status=$sasl->Step($response,$message,$interactions); + } + while($status==SASL_INTERACT); + switch($status) + { + case SASL_CONTINUE: + $authorization_value=$sasl->mechanism.(IsSet($message) ? " ".($sasl->encode_response ? base64_encode($message) : $message) : ""); + $arguments=$request_arguments; + $arguments["Headers"][$authorization_header]=$authorization_value; + if(!$proxy + && strlen($proxy_authorization)) + $arguments["Headers"]["Proxy-Authorization"]=$proxy_authorization; + if($proxy < 0) + { + if(strlen($error=$this->ConnectFromProxy($arguments, $headers))) + return($this->SetError($error)); + } + else + { + if(strlen($error=$this->SendRequest($arguments)) + || strlen($error=$this->ReadReplyHeadersResponse($headers))) + return($this->SetError($error)); + } + switch($this->response_status) + { + case $authenticate_status: + if(GetType($headers[$authenticate_header])=="array") + $authenticate=$headers[$authenticate_header]; + else + $authenticate=array($headers[$authenticate_header]); + for($response="",$mechanism=0;$mechanismTokenize($authenticate[$mechanism]," "),$sasl->mechanism)) + { + $response=$this->Tokenize(""); + break; + } + } + if($proxy >= 0) + { + for(;;) + { + if(strlen($error=$this->ReadReplyBody($body,$this->file_buffer_length))) + return($error); + if(strlen($body)==0) + break; + } + } + $this->state="Connected"; + break; + case "301": + case "302": + case "303": + case "307": + if($proxy >= 0) + return($this->Redirect($headers)); + default: + if(intval($this->response_status/100)==2) + { + if($proxy) + $proxy_authorization=$authorization_value; + $authenticated=1; + break; + } + if($proxy + && !strcmp($this->response_status,"401")) + { + $proxy_authorization=$authorization_value; + $authenticated=1; + break; + } + return($this->SetError(($proxy ? "proxy " : "")."authentication error: ".$this->response_status." ".$this->response_message)); + } + break; + default: + return($this->SetError("Could not process the SASL ".($proxy ? "proxy " : "")."authentication step: ".$sasl->error)); + } + } + } + return(""); + } + + Function ReadReplyHeaders(&$headers) + { + if(strlen($error=$this->ReadReplyHeadersResponse($headers))) + return($error); + $proxy_authorization=""; + while(!strcmp($this->response_status, "100")) + { + $this->state="RequestSent"; + if(strlen($error=$this->ReadReplyHeadersResponse($headers))) + return($error); + } + switch($this->response_status) + { + case "301": + case "302": + case "303": + case "307": + if(strlen($error=$this->Redirect($headers))) + return($error); + break; + case "407": + if(strlen($error=$this->Authenticate($headers, 1, $proxy_authorization, $this->proxy_request_user, $this->proxy_request_password, $this->proxy_request_realm, $this->proxy_request_workstation))) + return($error); + if(strcmp($this->response_status,"401")) + return(""); + case "401": + return($this->Authenticate($headers, 0, $proxy_authorization, $this->request_user, $this->request_password, $this->request_realm, $this->request_workstation)); + } + return(""); + } + + Function ReadReplyBody(&$body,$length) + { + $body=""; + if(strlen($this->error)) + return($this->error); + switch($this->state) + { + case "Disconnected": + return($this->SetError("1 connection was not yet established")); + case "Connected": + case "ConnectedToProxy": + return($this->SetError("2 request was not sent")); + case "RequestSent": + if(($error=$this->ReadReplyHeaders($headers))!="") + return($error); + break; + case "GotReplyHeaders": + break; + default: + return($this->SetError("3 can not get request headers in the current connection state")); + } + if($this->content_length_set) + $length=min($this->content_length-$this->read_length,$length); + if($length>0 + && !$this->EndOfInput() + && ($body=$this->ReadBytes($length))=="") + { + if(strlen($this->error)) + return($this->SetError("4 could not get the request reply body: ".$this->error)); + } + $this->read_length+=strlen($body); + return(""); + } + + Function SaveCookies(&$cookies, $domain='', $secure_only=0, $persistent_only=0) + { + $now=gmdate("Y-m-d H-i-s"); + $cookies=array(); + for($secure_cookies=0,Reset($this->cookies);$secure_cookiescookies);Next($this->cookies),$secure_cookies++) + { + $secure=Key($this->cookies); + if(!$secure_only + || $secure) + { + for($cookie_domain=0,Reset($this->cookies[$secure]);$cookie_domaincookies[$secure]);Next($this->cookies[$secure]),$cookie_domain++) + { + $domain_pattern=Key($this->cookies[$secure]); + $match=strlen($domain)-strlen($domain_pattern); + if(strlen($domain)==0 + || ($match>=0 + && !strcmp($domain_pattern,substr($domain,$match)) + && ($match==0 + || $domain_pattern[0]=="." + || $domain[$match-1]=="."))) + { + for(Reset($this->cookies[$secure][$domain_pattern]),$path_part=0;$path_partcookies[$secure][$domain_pattern]);Next($this->cookies[$secure][$domain_pattern]),$path_part++) + { + $path=Key($this->cookies[$secure][$domain_pattern]); + for(Reset($this->cookies[$secure][$domain_pattern][$path]),$cookie=0;$cookiecookies[$secure][$domain_pattern][$path]);Next($this->cookies[$secure][$domain_pattern][$path]),$cookie++) + { + $cookie_name=Key($this->cookies[$secure][$domain_pattern][$path]); + $expires=$this->cookies[$secure][$domain_pattern][$path][$cookie_name]["expires"]; + if((!$persistent_only + && strlen($expires)==0) + || (strlen($expires) + && strcmp($now,$expires)<0)) + $cookies[$secure][$domain_pattern][$path][$cookie_name]=$this->cookies[$secure][$domain_pattern][$path][$cookie_name]; + } + } + } + } + } + } + } + + Function SavePersistentCookies(&$cookies, $domain='', $secure_only=0) + { + $this->SaveCookies($cookies, $domain, $secure_only, 1); + } + + Function GetPersistentCookies(&$cookies, $domain='', $secure_only=0) + { + $this->SavePersistentCookies($cookies, $domain, $secure_only); + } + + Function RestoreCookies($cookies, $clear=1) + { + $new_cookies=($clear ? array() : $this->cookies); + for($secure_cookies=0, Reset($cookies); $secure_cookiesSetError("invalid cookie secure value type (".serialize($secure).")")); + for($cookie_domain=0,Reset($cookies[$secure]);$cookie_domainSetError("invalid cookie domain value type (".serialize($domain_pattern).")")); + for(Reset($cookies[$secure][$domain_pattern]),$path_part=0;$path_partSetError("invalid cookie path value type (".serialize($path).")")); + for(Reset($cookies[$secure][$domain_pattern][$path]),$cookie=0;$cookieSetError("invalid cookie expiry value type (".serialize($expires).")")); + $new_cookies[$secure][$domain_pattern][$path][$cookie_name]=array( + "name"=>$cookie_name, + "value"=>$value, + "domain"=>$domain_pattern, + "path"=>$path, + "expires"=>$expires, + "secure"=>$secure + ); + } + } + } + } + $this->cookies=$new_cookies; + return(""); + } +}; + +?> diff --git a/includes/phpsvnclient/phpsvnclient.php b/includes/phpsvnclient/phpsvnclient.php new file mode 100644 index 0000000000..3322596ab7 --- /dev/null +++ b/includes/phpsvnclient/phpsvnclient.php @@ -0,0 +1,709 @@ + + * @license BSD License + */ +class phpsvnclient { + /** + * SVN Repository URL + * + * @var string + * @access private + */ + private $_url; + /** + * Cache, for don't request the same thing in a + * short period of time. + * + * @var string + * @access private + */ + private $_cache; + /** + * HTTP Client object + * + * @var object + * @access private + */ + private $_http; + /** + * Respository Version. + * + * @access private + * @var interger + */ + private $_repVersion; + /** + * Password + * + * @access private + * @var string + */ + private $pass; + /** + * Password + * + * @access private + * @var string + */ + private $user; + /** + * Last error number + * + * Possible values are NOT_ERROR, NOT_FOUND, AUTH_REQUIRED, UNKOWN_ERROR + * + * @access public + * @var integer + */ + public $errNro; + + private $storeDirectoryFiles = array(); + private $lastDirectoryFiles; + + public function phpsvnclient($url = 'http://fusionpbx.googlecode.com/svn/', $user = false, $pass = false) { + $this->__construct($url, $user, $pass); + register_shutdown_function(array(&$this, '__destruct')); + } + + public function __construct($url = 'http://fusionpbx.googlecode.com/svn/trunk/fusionpbx/', $user = false, $pass = false) { + $http = & $this->_http; + $http = new http_class; + $http->user_agent = "FusionPBXphpsvnclient (http://fusionpbx.com/)"; + + $this->_url = $url; + $this->user = $user; + $this->pass = $pass; + } + +/** + * Public Functions + */ + + /** + * checkOut + */ + public function checkOut($folder = '/', $outPath = '.') { + while($outPath[strlen($outPath) - 1] == '/' && strlen($outPath) > 1) + $outPath = substr($outPath, 0, -1); + $tree = $this->getDirectoryTree($folder); + if(!file_exists($outPath)){ + mkdir($outPath, 0777, TRUE); + } + foreach($tree as $file) { + $path = $file['path']; + $tmp = strstr(trim($path, '/'), trim($folder, '/')); + $createPath = $outPath . '/' . ($tmp ? substr($tmp, strlen(trim($folder, '/'))) : ""); + if(trim($path, '/') == trim($folder, '/')) + continue; + if($file['type'] == 'directory' && !is_dir($createPath)){ + mkdir($createPath); + }elseif($file['type'] == 'file') { + $contents = $this->getFile($path); + $hOut = fopen($createPath, 'w'); + fwrite($hOut, $contents); + fclose($hOut); + } + } + } + + /** + * rawDirectoryDump + * + * This method dumps SVN data for $folder + * in the version $version of the repository. + * + * @param string $folder Folder to get data + * @param integer $version Repository version, -1 means actual + * @return array SVN data dump. + */ + public function rawDirectoryDump($folder='/',$version=-1) { + $actVersion = $this->getVersion(); + if ( $version == -1 || $version > $actVersion) { + $version = $actVersion; + } + $url = $this->cleanURL($this->_url . "/!svn/bc/" . $version . "/" . $folder . "/"); + $this->initQuery($args, "PROPFIND", $url); + $args['Body'] = PHPSVN_NORMAL_REQUEST; + $args['Headers']['Content-Length'] = strlen(PHPSVN_NORMAL_REQUEST); + + if ( ! $this->Request($args, $headers, $body) ) { + return false; + } + $xml2Array = new xml2Array(); + return $xml2Array->xmlParse($body); + } + +// +// use this to get node of tree by path with '/' terminator +// +function get_value_by_path($__xml_tree, $__tag_path) +{ + $tmp_arr =& $__xml_tree; + print_r($tmp_arr); + $tag_path = explode('/', $__tag_path); + foreach($tag_path as $tag_name) + { + $res = false; + foreach($tmp_arr as $key => $node) + { + if(is_int($key) && $node['name'] == $tag_name) + { + $tmp_arr = $node; + $res = true; + break; + } + } + if(!$res) + return false; + } + return $tmp_arr; +} + + +function my_xml2array($__url) +{ + $xml_values = array(); + $contents = $__url;//file_get_contents($__url); + $parser = xml_parser_create(''); + if(!$parser) + return false; + + xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, 'UTF-8'); + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); + xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); + xml_parse_into_struct($parser, trim($contents), $xml_values); + xml_parser_free($parser); + if (!$xml_values) + return array(); + + $xml_array = array(); + $last_tag_ar =& $xml_array; + $parents = array(); + $last_counter_in_tag = array(1=>0); + foreach ($xml_values as $data) + { + switch($data['type']) + { + case 'open': + $last_counter_in_tag[$data['level']+1] = 0; + $new_tag = array('name' => $data['tag']); + if(isset($data['attributes'])) + $new_tag['attributes'] = $data['attributes']; + if(isset($data['value']) && trim($data['value'])) + $new_tag['value'] = trim($data['value']); + $last_tag_ar[$last_counter_in_tag[$data['level']]] = $new_tag; + $parents[$data['level']] =& $last_tag_ar; + $last_tag_ar =& $last_tag_ar[$last_counter_in_tag[$data['level']]++]; + break; + case 'complete': + $new_tag = array('name' => $data['tag']); + if(isset($data['attributes'])) + $new_tag['attributes'] = $data['attributes']; + if(isset($data['value']) && trim($data['value'])) + $new_tag['value'] = trim($data['value']); + + $last_count = count($last_tag_ar)-1; + $last_tag_ar[$last_counter_in_tag[$data['level']]++] = $new_tag; + break; + case 'close': + $last_tag_ar =& $parents[$data['level']]; + break; + default: + break; + }; + } + return $xml_array; +} + + /** + * getDirectoryFiles + * + * This method returns all the files in $folder + * in the version $version of the repository. + * + * @param string $folder Folder to get files + * @param integer $version Repository version, -1 means actual + * @return array List of files. */ + public function getDirectoryFiles($folder='/', $version=-1) { + if ($arrOutput = $this->rawDirectoryDump($folder, $version)) { +// echo '
    ';
    +//			print_r($arrOutput);
    +//			echo '
    '; + $files = array(); + foreach($arrOutput['children'] as $key=>$value) { + //echo $key . ' => ' . $value . '
    '; + array_walk_recursive($value, array($this, 'storeDirectoryFiles')); + array_push($files, $this->storeDirectoryFiles); + unset($this->storeDirectoryFiles); + } + return $files; + } + return false; + } + + /** + * getDirectoryTree + * + * This method returns the complete tree of files and directories + * in $folder from the version $version of the repository. Can also be used + * to get the info for a single file or directory + * + * @param string $folder Folder to get tree + * @param integer $version Repository version, -1 means actual + * @param boolean $recursive Whether to get the tree recursively, or just + * the specified directory/file. + * + * @return array List of files and directories. + */ + public function getDirectoryTree($folder='/',$version=-1, $recursive=true) { + $directoryTree = array(); + + if (!($arrOutput = $this->getDirectoryFiles($folder, $version))) + return false; + + if (!$recursive) + return $arrOutput[0]; + + while(count($arrOutput) && is_array($arrOutput)) { + $array = array_shift($arrOutput); + + array_push($directoryTree, $array); + + if(trim($array['path'], '/') == trim($folder, '/')) + continue; + + if ($array['type'] == 'directory') { + $walk = $this->getDirectoryFiles($array['path'], $version); + array_shift($walk); + //$walk = array_reverse($walk); + + foreach($walk as $step) { + array_unshift($arrOutput, $step); + } + } + } + return $directoryTree; + } + + /** + * Returns file contents + * + * @param string $file File pathname + * @param integer $version File Version + * @return string File content and information, false on error, or if a + * directory is requested + */ + public function getFile($file,$version=-1) { + $actVersion = $this->getVersion(); + if ( $version == -1 || $version > $actVersion) { + $version = $actVersion; + } + + // check if this is a directory... if so, return false, otherwise we + // get the HTML output of the directory listing from the SVN server. + // This is maybe a bit heavy since it makes another connection to the + // SVN server. Maybe add this as an option/parameter? ES 23/06/08 + $fileInfo = $this->getDirectoryTree($file, $version, false); + if ($fileInfo["type"] == "directory") + return false; + + $url = $this->cleanURL($this->_url."/!svn/bc/".$version."/".$file."/"); + $this->initQuery($args,"GET",$url); + if ( ! $this->Request($args, $headers, $body) ) + return false; + + return $body; + } + + /** + * Get changes logs of a file. + * + * Get repository change logs between version + * $vini and $vend. + * + * @param integer $vini Initial Version + * @param integer $vend End Version + * @return Array Respository Logs + */ + public function getRepositoryLogs($vini=0,$vend=-1) { + return $this->getFileLogs("/",$vini,$vend); + } + + /** + * Get changes logs of a file. + * + * Get repository change of a file between version + * $vini and $vend. + * + * @param + * @param integer $vini Initial Version + * @param integer $vend End Version + * @return Array Respository Logs + */ + public function getFileLogs($file, $vini=0,$vend=-1) { + $fileLogs = array(); + + $actVersion = $this->getVersion(); + if ( $vend == -1 || $vend > $actVersion) + $vend = $actVersion; + + if ( $vini < 0) $vini=0; + if ( $vini > $vend) $vini = $vend; + + $url = $this->cleanURL($this->_url."/!svn/bc/".$actVersion."/".$file."/"); + $this->initQuery($args,"REPORT",$url); + $args['Body'] = sprintf(PHPSVN_LOGS_REQUEST,$vini,$vend); + $args['Headers']['Content-Length'] = strlen($args['Body']); + $args['Headers']['Depth']=1; + + if ( ! $this->Request($args, $headers, $body) ) + return false; + + $xml2Array = new xml2Array(); + $arrOutput = $xml2Array->xmlParse($body); +// array_shift($arrOutput['children']); + + foreach($arrOutput['children'] as $value) { + $array=array(); + foreach($value['children'] as $entry) { + if ($entry['name'] == 'D:VERSION-NAME') $array['version'] = $entry['tagData']; + if ($array['version'] == $vini) continue 2; + if ($entry['name'] == 'D:CREATOR-DISPLAYNAME') $array['author'] = $entry['tagData']; + if ($entry['name'] == 'S:DATE') $array['date'] = $entry['tagData']; + if ($entry['name'] == 'D:COMMENT') $array['comment'] = $entry['tagData']; + + if (($entry['name'] == 'S:ADDED-PATH') || + ($entry['name'] == 'S:MODIFIED-PATH') || + ($entry['name'] == 'S:DELETED-PATH')) { + // For backward compatability + $array['files'][] = $entry['tagData']; + + if ($entry['name'] == 'S:ADDED-PATH') $array['add_files'][] = $entry['tagData']; + if ($entry['name'] == 'S:MODIFIED-PATH') $array['mod_files'][] = $entry['tagData']; + if ($entry['name'] == 'S:DELETED-PATH') $array['del_files'][] = $entry['tagData']; + } + } + array_push($fileLogs,$array); + } + + return $fileLogs; + } + + + /** + * Get the repository version + * + * @return integer Repository version + * @access public + */ + public function getVersion() { + if ( $this->_repVersion > 0) return $this->_repVersion; + + $this->_repVersion = -1; $this->initQuery($args,"PROPFIND",$this->cleanURL($this->_url."/!svn/vcc/default") ); + $args['Body'] = PHPSVN_VERSION_REQUEST; + $args['Headers']['Content-Length'] = strlen(PHPSVN_NORMAL_REQUEST); + $args['Headers']['Depth']=0; + + if ( !$this->Request($args, $tmp, $body) ) { + return $this->_repVersion; + } + + $parser=new xml_parser_class; + $parser->Parse( $body,true); + $enable=false; + foreach($parser->structure as $value) { + if ( $enable ) { + $t = explode("/",$value); + + // start from the end and move backwards until we find a non-blank entry + $index = count($t) - 1; + while ($t[$index] == ""){ + $index--; + } + + // check the last non-empty element to see if it's numeric. If so, it's the revision number + if (is_numeric($t[$index])) { + $this->_repVersion = $t[$index]; + break; + } + else { + // If there was no number, this was the wrong D:href, so disable 'til we find the next one. + $enable = false; + continue; + } + } + if ( is_array($value) && $value['Tag'] == 'D:href') $enable = true; + } + return $this->_repVersion; + } + +/** + * Deprecated functions for backward comatability + */ + + /** + * Set URL + * + * Set the project repository URL. + * + * @param string $url URL of the project. + * @access public + */ + public function setRepository($url) { + $this->_url = $url; + } + /** + * Old method; there's a typo in the name. This is now a wrapper for setRepository + */ + public function setRespository($url) { + return $this->setRepository($url); + } + /** + * Add Authentication settings + * + * @param string $user Username + * @param string $pass Password + */ + public function setAuth($user,$pass) { + $this->user = $user; + $this->pass = $pass; + } + +/** + * Private Functions + */ + /** + * Callback for array_walk_recursive in public function getDirectoryFiles + * + * @access private + */ + private function storeDirectoryFiles($item, $key) { + if ($key == 'name') { + switch ($item) { + case 'D:HREF': + case 'LP1:GETLASTMODIFIED': + case 'LP2:BASELINE-RELATIVE-PATH': + case 'LP3:BASELINE-RELATIVE-PATH': + case 'LP3:MD5-CHECKSUM': + case 'LP1:VERSION-NAME': + case 'LP1:GETCONTENTLENGTH': + case 'D:STATUS': + $this->lastDirectoryFiles = $item; + break; + default: + break; + } + } elseif (($key == 'tagData') && ($this->lastDirectoryFiles != '')) { + + // Unsure if the 1st of two D:HREF's always returns the result we want, but for now... + if (($this->lastDirectoryFiles == 'D:HREF') && (isset($this->storeDirectoryFiles['type']))) return; + + // Dump into the array + $ldf = $this->lastDirectoryFiles; + switch ($ldf) { + case 'D:HREF': + $var = 'type'; + break; + case 'LP1:GETLASTMODIFIED': + $var = 'last_mod'; +// $var = "$ldf"; + break; + case 'LP2:BASELINE-RELATIVE-PATH': + case 'LP3:BASELINE-RELATIVE-PATH': + $var = 'path'; +// $var = "$ldf"; + break; + case 'LP3:MD5-CHECKSUM': + $var = 'md5'; +// $var = "$ldf"; + break; +/* case 'LP1:VERSION-NAME': + $var = 'version'; + break; + case 'LP1:GETCONTENTLENGTH': + $var = 'size'; + break; +*/ case 'D:STATUS': +// return; + $var = 'status'; +// $var = "$ldf"; + break; + default: + //$var = "$ldf"; + break; + + } + $this->storeDirectoryFiles[$var] = $item; + $this->lastDirectoryFiles = ''; + // Detect 'type' as either a 'directory' or 'file' + if ( (isset($this->storeDirectoryFiles['type'])) && + //(isset($this->storeDirectoryFiles['last-mod'])) && + (isset($this->storeDirectoryFiles['path'])) + && (isset($this->storeDirectoryFiles['status'])) + ) { + $this->storeDirectoryFiles['path'] = str_replace(' ', '%20', $this->storeDirectoryFiles['path']); //Hack to make filenames with spaces work. + $len = strlen($this->storeDirectoryFiles['path']); + if ( substr($this->storeDirectoryFiles['type'],strlen($this->storeDirectoryFiles['type']) - $len) == $this->storeDirectoryFiles['path'] ) { + $this->storeDirectoryFiles['type'] = 'file'; + } else { + $this->storeDirectoryFiles['type'] = 'directory'; + } + } + + } else { + $this->lastDirectoryFiles = ''; + } + } + + /** + * Prepare HTTP CLIENT object + * + * @param array &$arguments Byreferences variable. + * @param string $method Method for the request (GET,POST,PROPFIND, REPORT,ETC). + * @param string $url URL for the action. + * @access private + */ + private function initQuery(&$arguments,$method, $url) { + $http = & $this->_http; + $http->GetRequestArguments($url,$arguments); + if ( isset($this->user) && isset($this->pass)) { + $arguments["Headers"]["Authorization"] = " Basic ".base64_encode($this->user.":".$this->pass); + } + $arguments["RequestMethod"]=$method; + $arguments["Headers"]["Content-Type"] = "text/xml"; + $arguments["Headers"]["Depth"] = 1; + } + + /** + * Open a connection, send request, read header + * and body. + * + * @param Array $args Connetion's argument + * @param Array &$headers Array with the header response. + * @param string &$body Body response. + * @return boolean True is query success + * @access private + */ + private function Request($args, &$headers, &$body) { + $args['RequestURI'] = str_replace(' ', '%20', $args['RequestURI']); //Hack to make filenames with spaces work. + $http = & $this->_http; + $http->Open($args); + $http->SendRequest($args); + $http->ReadReplyHeaders($headers); +// echo "
    \n";
    +//		print_r($http);
    +//		echo "
    \n";
    +		if ($http->response_status[0] != 2) {
    +			switch( $http->response_status ) {
    +				case 404:
    +					$this->errNro=NOT_FOUND;
    +					break;
    +				case 401:
    +					$this->errNro=AUTH_REQUIRED;
    +					break;
    +				default:
    +					$this->errNro=UNKNOWN_ERROR;
    +			}
    +			$http->close();
    +			return false;
    +		}
    +		$this->errNro = NO_ERROR;
    +		$body='';
    +		$tbody='';
    +		for(;;) {
    +			$error=$http->ReadReplyBody($tbody,1000);
    +			if($error!="" || strlen($tbody)==0) break;
    +			$body.=($tbody);
    +		}
    +		$http->close();
    +		return true;
    +	}
    +
    +	/**
    +	 *  Clean URL
    +	 *
    +	 *  Delete "//" on URL requests.
    +	 *
    +	 *  @param string $url URL
    +	 *  @return string New cleaned URL.
    +	 *  @access private
    +	 */
    +	private function cleanURL($url) {
    +		return preg_replace("/((^:)\/\/)/", "//", $url);
    +	}
    +}
    +?>
    +
    diff --git a/includes/phpsvnclient/xml2Array.php b/includes/phpsvnclient/xml2Array.php
    new file mode 100644
    index 0000000000..1c21d957b2
    --- /dev/null
    +++ b/includes/phpsvnclient/xml2Array.php
    @@ -0,0 +1,56 @@
    +
    +Usage
    + Grab some XML data, either from a file, URL, etc. however you want.
    + Assume storage in $strYourXML;
    +
    + $arrOutput = new xml2Array($strYourXML);
    + print_r($arrOutput); //print it out, or do whatever!
    +*/
    +class xml2Array {
    +   
    +	private $arrOutput = array();
    +	private $resParser;
    +	private $strXmlData;
    +
    +	public function xmlParse($strInputXML) {
    +		$this->resParser = xml_parser_create ();
    +		xml_set_object($this->resParser,$this);
    +		xml_set_element_handler($this->resParser, "tag_open", "tagClosed");
    +		xml_set_character_data_handler($this->resParser, "tagData");
    +       
    +		$this->strXmlData = xml_parse($this->resParser,$strInputXML );
    +		if(!$this->strXmlData) {
    +			die(sprintf("XML error: %s at line %d",
    +				xml_error_string(xml_get_error_code($this->resParser)),
    +				xml_get_current_line_number($this->resParser)));
    +		}
    +
    +		xml_parser_free($this->resParser);
    +		// Changed by Deadpan110
    +		//return $this->arrOutput;
    +		return $this->arrOutput[0];
    +	}
    +
    +	private function tag_open($parser, $name, $attrs) {
    +		$tag=array("name"=>$name,"attrs"=>$attrs);
    +		array_push($this->arrOutput,$tag);
    +	}
    +
    +	private function tagData($parser, $tagData) {
    +		if(trim($tagData)) {
    +			if(isset($this->arrOutput[count($this->arrOutput)-1]['tagData'])) {
    +				$this->arrOutput[count($this->arrOutput)-1]['tagData'] .= $tagData;
    +			} else {
    +				$this->arrOutput[count($this->arrOutput)-1]['tagData'] = $tagData;
    +			}
    +		}
    +	}
    +
    +	private function tagClosed($parser, $name) {
    +		$this->arrOutput[count($this->arrOutput)-2]['children'][] = $this->arrOutput[count($this->arrOutput)-1];
    +		array_pop($this->arrOutput);
    +	}
    +}
    +?>
    \ No newline at end of file
    diff --git a/includes/phpsvnclient/xml_parser.php b/includes/phpsvnclient/xml_parser.php
    new file mode 100644
    index 0000000000..15e02e0f6a
    --- /dev/null
    +++ b/includes/phpsvnclient/xml_parser.php
    @@ -0,0 +1,427 @@
    +error,""))
    +		$xml_parser_handlers[$parser]->StartElement($xml_parser_handlers[$parser],$name,$attrs);
    +}
    +
    +Function xml_parser_end_element_handler($parser,$name)
    +{
    +  global $xml_parser_handlers;
    +
    +	if(!strcmp($xml_parser_handlers[$parser]->error,""))
    +		$xml_parser_handlers[$parser]->EndElement($xml_parser_handlers[$parser],$name);
    +}
    +
    +Function xml_parser_character_data_handler($parser,$data)
    +{
    +  global $xml_parser_handlers;
    +
    +	if(!strcmp($xml_parser_handlers[$parser]->error,""))
    +		$xml_parser_handlers[$parser]->CharacterData($xml_parser_handlers[$parser],$data);
    +}
    +
    +class xml_parser_handler_class
    +{
    +	var $xml_parser;
    +	var $error_number=0;
    +	var $error="";
    +	var $error_code=0;
    +	var $error_line,$error_column,$error_byte_index;
    +	var $structure=array();
    +	var $positions=array();
    +	var $path="";
    +	var $store_positions=0;
    +	var $simplified_xml=0;
    +	var $fail_on_non_simplified_xml=0;
    +
    +	Function SetError(&$object,$error_number,$error)
    +	{
    +		$object->error_number=$error_number;
    +		$object->error=$error;
    +		$object->error_line=xml_get_current_line_number($object->xml_parser);
    +		$object->error_column=xml_get_current_column_number($object->xml_parser);
    +		$object->error_byte_index=xml_get_current_byte_index($object->xml_parser);
    +	}
    +
    +	Function SetElementData(&$object,$path,&$data)
    +	{
    +		$object->structure[$path]=$data;
    +		if($object->store_positions)
    +		{
    +			$object->positions[$path]=array(
    +				"Line"=>xml_get_current_line_number($object->xml_parser),
    +				"Column"=>xml_get_current_column_number($object->xml_parser),
    +				"Byte"=>xml_get_current_byte_index($object->xml_parser)
    +			);
    +		}
    +	}
    +
    +	Function StartElement(&$object,$name,&$attrs)
    +	{
    +		if(strcmp($this->path,""))
    +		{
    +			$element=$object->structure[$this->path]["Elements"];
    +			$object->structure[$this->path]["Elements"]++;
    +			$this->path.=",$element";
    +		}
    +		else
    +		{
    +			$element=0;
    +			$this->path="0";
    +		}
    +		$data=array(
    +			"Tag"=>$name,
    +			"Elements"=>0
    +		);
    +		if($object->simplified_xml)
    +		{
    +			if($object->fail_on_non_simplified_xml
    +			&& count($attrs)>0)
    +			{
    +				$this->SetError($object,2,"Simplified XML can not have attributes in tags");
    +				return;
    +			}
    +		}
    +		else
    +			$data["Attributes"]=$attrs;
    +		$this->SetElementData($object,$this->path,$data);
    +	}
    +
    +	Function EndElement(&$object,$name)
    +	{
    +		$this->path=(($position=strrpos($this->path,",")) ? substr($this->path,0,$position) : "");
    +	}
    +
    +	Function CharacterData(&$object,$data)
    +	{
    +		$element=$object->structure[$this->path]["Elements"];
    +		$previous=$this->path.",".strval($element-1);
    +		if($element>0
    +		&& GetType($object->structure[$previous])=="string")
    +			$object->structure[$previous].=$data;
    +		else
    +		{
    +			$this->SetElementData($object,$this->path.",$element",$data);
    +			$object->structure[$this->path]["Elements"]++;
    +		}
    +	}
    +};
    +
    +class xml_parser_class
    +{
    +	var $xml_parser=0;
    +	var $parser_handler;
    +	var $error="";
    +	var $error_number=0;
    +	var $error_line=0;
    +	var $error_column=0;
    +	var $error_byte_index=0;
    +	var $error_code=0;
    +	var $stream_buffer_size=4096;
    +	var $structure=array();
    +	var $positions=array();
    +	var $store_positions=0;
    +	var $case_folding=0;
    +	var $target_encoding="ISO-8859-1";
    +	var $simplified_xml=0;
    +	var $fail_on_non_simplified_xml=0;
    +
    +	Function xml_parser_start_element_handler($parser,$name,$attrs)
    +	{
    +		if(!strcmp($this->error,""))
    +			$this->parser_handler->StartElement($this,$name,$attrs);
    +	}
    +
    +	Function xml_parser_end_element_handler($parser,$name)
    +	{
    +		if(!strcmp($this->error,""))
    +			$this->parser_handler->EndElement($this,$name);
    +	}
    +
    +	Function xml_parser_character_data_handler($parser,$data)
    +	{
    +		if(!strcmp($this->error,""))
    +			$this->parser_handler->CharacterData($this,$data);
    +	}
    +
    +	Function SetErrorPosition($error_number,$error,$line,$column,$byte_index)
    +	{
    +		$this->error_number=$error_number;
    +		$this->error=$error;
    +		$this->error_line=$line;
    +		$this->error_column=$column;
    +		$this->error_byte_index=$byte_index;
    +	}
    +
    +	Function SetError($error_number,$error)
    +	{
    +		$this->error_number=$error_number;
    +		$this->error=$error;
    +		if($this->xml_parser)
    +		{
    +			$line=xml_get_current_line_number($this->xml_parser);
    +			$column=xml_get_current_column_number($this->xml_parser);
    +			$byte_index=xml_get_current_byte_index($this->xml_parser);
    +		}
    +		else
    +		{
    +			$line=$column=1;
    +			$byte_index=0;
    +		}
    +		$this->SetErrorPosition($error_number,$error,$line,$column,$byte_index);
    +	}
    +
    +	Function Parse($data,$end_of_data)
    +	{
    +		global $xml_parser_handlers;
    +
    +		if(strcmp($this->error,""))
    +			return($this->error);
    +		if(!$this->xml_parser)
    +		{
    +			if(!function_exists("xml_parser_create"))
    +			{
    +				$this->SetError(1,"XML support is not available in this PHP configuration");
    +				return($this->error);
    +			}
    +			if(!($this->xml_parser=xml_parser_create()))
    +			{
    +				$this->SetError(1,"Could not create the XML parser");
    +				return($this->error);
    +			}
    +			xml_parser_set_option($this->xml_parser,XML_OPTION_CASE_FOLDING,$this->case_folding);
    +			xml_parser_set_option($this->xml_parser,XML_OPTION_TARGET_ENCODING,$this->target_encoding);
    +			if(function_exists("xml_set_object"))
    +			{
    +				xml_set_object($this->xml_parser,$this);
    +				$this->parser_handler=new xml_parser_handler_class;
    +				$this->structure=array();
    +				$this->positions=array();
    +			}
    +			else
    +			{
    +				$xml_parser_handlers[$this->xml_parser]=new xml_parser_handler_class;
    +				$xml_parser_handlers[$this->xml_parser]->xml_parser=$this->xml_parser;
    +				$xml_parser_handlers[$this->xml_parser]->store_positions=$this->store_positions;
    +				$xml_parser_handlers[$this->xml_parser]->simplified_xml=$this->simplified_xml;
    +				$xml_parser_handlers[$this->xml_parser]->fail_on_non_simplified_xml=$this->fail_on_non_simplified_xml;
    +			}
    +			xml_set_element_handler($this->xml_parser,"xml_parser_start_element_handler","xml_parser_end_element_handler");
    +			xml_set_character_data_handler($this->xml_parser,"xml_parser_character_data_handler");
    +		}
    +		$parser_ok=xml_parse($this->xml_parser,$data,$end_of_data);
    +		if(!function_exists("xml_set_object"))
    +			$this->error=$xml_parser_handlers[$this->xml_parser]->error;
    +		if(!strcmp($this->error,""))
    +		{
    +			if($parser_ok)
    +			{
    +				if($end_of_data)
    +				{
    +					if(function_exists("xml_set_object"))
    +						Unset($this->parser_handler);
    +					else
    +					{
    +						$this->structure=$xml_parser_handlers[$this->xml_parser]->structure;
    +						$this->positions=$xml_parser_handlers[$this->xml_parser]->positions;
    +						Unset($xml_parser_handlers[$this->xml_parser]);
    +					}
    +					xml_parser_free($this->xml_parser);
    +					$this->xml_parser=0;
    +				}
    +			}
    +			else
    +				$this->SetError(2,"Could not parse data: ".xml_error_string($this->error_code=xml_get_error_code($this->xml_parser)));
    +		}
    +		else
    +		{
    +			if(!function_exists("xml_set_object"))
    +			{
    +				$this->error_number=$xml_parser_handlers[$this->xml_parser]->error_number;
    +				$this->error_code=$xml_parser_handlers[$this->xml_parser]->error_code;
    +				$this->error_line=$xml_parser_handlers[$this->xml_parser]->error_line;
    +				$this->error_column=$xml_parser_handlers[$this->xml_parser]->error_column;
    +				$this->error_byte_index=$xml_parser_handlers[$this->xml_parser]->error_byte_index;
    +			}			
    +		}
    +		return($this->error);
    +	}
    +
    +	Function VerifyWhiteSpace($path)
    +	{
    +		if($this->store_positions)
    +		{
    +			$line=$parser->positions[$path]["Line"];
    +			$column=$parser->positions[$path]["Column"];
    +			$byte_index=$parser->positions[$path]["Byte"];
    +		}
    +		else
    +		{
    +			$line=$column=1;
    +			$byte_index=0;
    +		}
    +		if(!IsSet($this->structure[$path]))
    +		{
    +			$this->SetErrorPosition(2,"element path does not exist",$line,$column,$byte_index);
    +			return($this->error);
    +		}
    +		if(GetType($this->structure[$path])!="string")
    +		{
    +			$this->SetErrorPosition(2,"element is not data",$line,$column,$byte_index);
    +			return($this->error);
    +		}
    +		$data=$this->structure[$path];
    +		for($previous_return=0,$position=0;$positionSetErrorPosition(2,"data is not white space",$line,$column,$byte_index);
    +					return($this->error);
    +			}
    +		}
    +		return("");
    +	}
    +
    +	Function ParseStream($stream)
    +	{
    +		if(strcmp($this->error,""))
    +			return($this->error);
    +		do
    +		{
    +			if(!($data=@fread($stream,$this->stream_buffer_size)))
    +			{
    +				if(!feof($stream))
    +				{
    +					$this->SetError(3,"Could not read from input stream".(IsSet($php_errormsg) ? ': '.$php_errormsg : ''));
    +					break;
    +				}
    +			}
    +			if(strcmp($error=$this->Parse($data,feof($stream)),""))
    +				break;
    +		}
    +		while(!feof($stream));
    +		return($this->error);
    +	}
    +
    +	Function ParseFile($file)
    +	{
    +		if(!file_exists($file))
    +			return("the XML file to parse ($file) does not exist");
    +		if(!($definition=@fopen($file,"r")))
    +			return("could not open the XML file ($file)".(IsSet($php_errormsg) ? ': '.$php_errormsg : ''));
    +		$error=$this->ParseStream($definition);
    +		fclose($definition);
    +		return($error);
    +	}
    +};
    +
    +Function XMLParseFile(&$parser,$file,$store_positions,$cache="",$case_folding=0,$target_encoding="ISO-8859-1",$simplified_xml=0,$fail_on_non_simplified_xml=0)
    +{
    +	if(!file_exists($file))
    +		return("the XML file to parse ($file) does not exist");
    +	if(strcmp($cache,""))
    +	{
    +		if(file_exists($cache)
    +		&& filemtime($file)<=filemtime($cache))
    +		{
    +			if(($cache_file=@fopen($cache,"r")))
    +			{
    +				if(function_exists("set_file_buffer"))
    +					set_file_buffer($cache_file,0);
    +				if(!($cache_contents=@fread($cache_file,filesize($cache))))
    +					$error="could not read from the XML cache file $cache".(IsSet($php_errormsg) ? ': '.$php_errormsg : '');
    +				else
    +					$error="";
    +				fclose($cache_file);
    +				if(!strcmp($error,""))
    +				{
    +					if(GetType($parser=unserialize($cache_contents))=="object"
    +					&& IsSet($parser->structure))
    +					{
    +						if(!IsSet($parser->simplified_xml))
    +							$parser->simplified_xml=0;
    +						if(($simplified_xml
    +						|| !$parser->simplified_xml)
    +						&& (!$store_positions
    +						|| $parser->store_positions))
    +						{
    +							return("");
    +						}
    +					}
    +					else
    +						$error="it was not specified a valid cache object in XML file ($cache)";
    +				}
    +			}
    +			else
    +				$error="could not open cache XML file ($cache)".(IsSet($php_errormsg) ? ': '.$php_errormsg : '');
    +			if(strcmp($error,""))
    +				return($error);
    +		}
    +	}
    +	$parser=new xml_parser_class;
    +	$parser->store_positions=$store_positions;
    +	$parser->case_folding=$case_folding;
    +	$parser->target_encoding=$target_encoding;
    +	$parser->simplified_xml=$simplified_xml;
    +	$parser->fail_on_non_simplified_xml=$fail_on_non_simplified_xml;
    +	if(!strcmp($error=$parser->ParseFile($file),"")
    +	&& strcmp($cache,""))
    +	{
    +		if(($cache_file=@fopen($cache,"w")))
    +		{
    +			if(function_exists("set_file_buffer"))
    +				set_file_buffer($cache_file,0);
    +			if(!@fwrite($cache_file,serialize($parser))
    +			|| !@fclose($cache_file))
    +				$error="could to write to the XML cache file ($cache)".(IsSet($php_errormsg) ? ': '.$php_errormsg : '');
    +			if(strcmp($error,""))
    +				unlink($cache);
    +		}
    +		else
    +			$error="could not open for writing to the cache file ($cache)".(IsSet($php_errormsg) ? ': '.$php_errormsg : '');
    +	}
    +	return($error);
    +}
    +
    +?>
    \ No newline at end of file
    diff --git a/includes/pop3/mime_parser.php b/includes/pop3/mime_parser.php
    new file mode 100644
    index 0000000000..455041581e
    --- /dev/null
    +++ b/includes/pop3/mime_parser.php
    @@ -0,0 +1,2439 @@
    +
    +
    +
    +	net.manuellemos.mimeparser
    +
    +	@(#) $Id: mime_parser.php,v 1.68 2010/04/08 22:58:13 mlemos Exp $
    +	Copyright  (C) Manuel Lemos 2006 - 2008
    +	MIME parser
    +	Manuel Lemos
    +	mlemos-at-acm.org
    +
    +	
    +		en
    +		Parse MIME encapsulated e-mail message data compliant with
    +			the RFC 2822 or aggregated in mbox format.
    +		Use the function Decode function
    +			to retrieve the structure of the messages to be parsed. Adjust its
    +			parameters to tell how to return the decoded body data.
    +			Use the SaveBody parameter to make the body parts be saved
    +			to files when the message is larger than the available memory. Use
    +			the SkipBody parameter to just retrieve the message
    +			structure without returning the body data.
    +			If the message data is an archive that may contain multiple messages
    +			aggregated in the mbox format, set the variable
    +			mbox to 1.
    +	
    +
    +{/metadocument}
    +*/
    +
    +class mime_parser_class
    +{
    +/*
    +{metadocument}
    +	
    +		error
    +		STRING
    +		
    +		
    +			Store the message that is returned when an error
    +				occurs.
    +			Check this variable to understand what happened when a call to
    +				any of the class functions has failed.
    +				This class uses cumulative error handling. This means that if one
    +				class functions that may fail is called and this variable was
    +				already set to an error message due to a failure in a previous call
    +				to the same or other function, the function will also fail and does
    +				not do anything.
    +				This allows programs using this class to safely call several
    +				functions that may fail and only check the failure condition after
    +				the last function call.
    +				Just set this variable to an empty string to clear the error
    +				condition.
    +		
    +	
    +{/metadocument}
    +*/
    +	var $error='';
    +
    +/*
    +{metadocument}
    +	
    +		error_position
    +		INTEGER
    +		-1
    +		
    +			Point to the position of the message data or file that
    +				refers to the last error that occurred.
    +			Check this variable to determine the relevant position of the
    +				message when a parsing error occurs.
    +		
    +	
    +{/metadocument}
    +*/
    +	var $error_position = -1;
    +
    +/*
    +{metadocument}
    +	
    +		mbox
    +		BOOLEAN
    +		0
    +		
    +			Specify whether the message data to parse is a single RFC
    +				2822 message or it is an archive that contain multiple messages in
    +				the mbox format.
    +			Set this variable to 1 if it is
    +				it is intended to parse an mbox message archive.
    + mbox archives may contain multiple messages. Each message starts + with the header From. Since all valid RFC 2822 headers + must with a colon, the class will fail to parse a mbox archive if + this variable is set to 0.
    +
    +
    +{/metadocument} +*/ + var $mbox = 0; + +/* +{metadocument} + + decode_headers + BOOLEAN + 1 + + Specify whether the message headers should be decoded. + Set this variable to 1 if it is + necessary to decode message headers that may have non-ASCII + characters and use other character set encodings. + + +{/metadocument} +*/ + var $decode_headers = 1; + +/* +{metadocument} + + decode_bodies + BOOLEAN + 1 + + Specify whether the message body parts should be decoded. + Set this variable to 1 if it is + necessary to parse the message bodies and extract its part + structure. + + +{/metadocument} +*/ + var $decode_bodies = 1; + +/* +{metadocument} + + extract_addresses + BOOLEAN + 1 + + Specify whether the message headers that usually contain + e-mail addresses should be parsed and the addresses should be + extracted by the Decode function. + Set this variable to 1 if it is + necessary to extract the e-mail addresses contained in certain + message headers. + The headers to be parsed are defined by the + address_headers variable. + The parsed addresses are returned by the + ExtractedAddresses entry of the + Decode + decoded + argument of the + Decode function. + + +{/metadocument} +*/ + var $extract_addresses = 1; + +/* +{metadocument} + + address_headers + HASH + + + Specify which headers contain addresses that should be + parsed and extracted. + Change this variable if you need to extract e-mail addresses + from a different list of message headers. + It must be set to an associative array with keys set to the names + of the headers to be parsed including the colon. The array values + must be set to a boolean flag to tell whether the headers with the + respective name should be parsed. The header names must be in lower + case. + By default the class addresses from the headers: + from:, to:, + cc:, bcc:, + return-path:, + reply-to: and + disposition-notification-to:. + + +{/metadocument} +*/ + var $address_headers = array( + 'from:' => 1, + 'to:' => 1, + 'cc:' => 1, + 'bcc:' => 1, + 'return-path:'=>1, + 'reply-to:'=>1, + 'disposition-notification-to:'=>1 + ); + +/* +{metadocument} + + message_buffer_length + INTEGER + 8000 + + Maximum length of the chunks of message data that the class + parse at one time. + Adjust this value according to the available memory. + + +{/metadocument} +*/ + var $message_buffer_length = 8000; + +/* +{metadocument} + + ignore_syntax_errors + BOOLEAN + 1 + + Specify whether the class should ignore syntax errors in + malformed messages. + Set this variable to 0 if it is + necessary to verify whether message data may be corrupted due to + to eventual bugs in the program that generated the + message. + Currently the class only ignores some types of syntax errors. + Other syntax errors may still cause the + Decode to fail. + + +{/metadocument} +*/ + var $ignore_syntax_errors=1; + +/* +{metadocument} + + warnings + HASH + + + Return a list of positions of the original message that + contain syntax errors. + Check this variable to retrieve eventual message syntax + errors that were ignored when the + ignore_syntax_errors is set to + 1. + The indexes of this array are the positions of the errors. The + array values are the corresponding syntax error messages. + + +{/metadocument} +*/ + var $warnings=array(); + +/* +{metadocument} + + track_lines + BOOLEAN + 0 + + Tell the class to keep track the position of each message + line. + Set this variable to 1 if you + need to determine the line and column number associated to a given + position of the parsed message. + + +{/metadocument} +*/ + var $track_lines = 0; + + /* Private variables */ + var $state = MIME_PARSER_START; + var $buffer = ''; + var $buffer_position = 0; + var $offset = 0; + var $parts = array(); + var $part_position = 0; + var $headers = array(); + var $body_parser; + var $body_parser_state = MIME_PARSER_BODY_DONE; + var $body_buffer = ''; + var $body_buffer_position = 0; + var $body_offset = 0; + var $current_header = ''; + var $file; + var $body_file; + var $position = 0; + var $body_part_number = 1; + var $next_token = ''; + var $lines = array(); + var $line_offset = 0; + var $last_line = 1; + var $last_carriage_return = 0; + + /* Private functions */ + + Function SetError($error) + { + $this->error = $error; + return(0); + } + + Function SetErrorWithContact($error) + { + return($this->SetError($error.'. Please contact the author Manuel Lemos and send a copy of this message to let him add support for this kind of messages')); + } + + Function SetPositionedError($error, $position) + { + $this->error_position = $position; + return($this->SetError($error)); + } + + Function SetPositionedWarning($error, $position) + { + if(!$this->ignore_syntax_errors) + return($this->SetPositionedError($error, $position)); + $this->warnings[$position]=$error; + return(1); + } + + Function SetPHPError($error, &$php_error_message) + { + if(IsSet($php_error_message) + && strlen($php_error_message)) + $error .= ': '.$php_error_message; + return($this->SetError($error)); + } + + Function ResetParserState() + { + $this->error=''; + $this->error_position = -1; + $this->state = MIME_PARSER_START; + $this->buffer = ''; + $this->buffer_position = 0; + $this->offset = 0; + $this->parts = array(); + $this->part_position = 0; + $this->headers = array(); + $this->body_parser_state = MIME_PARSER_BODY_DONE; + $this->body_buffer = ''; + $this->body_buffer_position = 0; + $this->body_offset = 0; + $this->current_header = ''; + $this->position = 0; + $this->body_part_number = 1; + $this->next_token = ''; + $this->lines = ($this->track_lines ? array(0 => 0) : array()); + $this->line_offset = 0; + $this->last_line = 0; + $this->last_carriage_return = 0; + } + + Function Tokenize($string,$separator="") + { + if(!strcmp($separator,"")) + { + $separator=$string; + $string=$this->next_token; + } + for($character=0;$characternext_token=substr($string,$found+1); + return(substr($string,0,$found)); + } + else + { + $this->next_token=''; + return($string); + } + } + + Function ParseStructuredHeader($value, &$type, &$parameters, &$character_sets, &$languages) + { + $type = strtolower(trim($this->Tokenize($value, ';'))); + $p = trim($this->Tokenize('')); + $parameters = $character_sets = $languages = array(); + while(strlen($p)) + { + $parameter = trim(strtolower($this->Tokenize($p, '='))); + $remaining = trim($this->Tokenize('')); + if(strlen($remaining) + && !strcmp($remaining[0], '"') + && (GetType($quote = strpos($remaining, '"', 1)) == 'integer')) + { + $value = substr($remaining, 1, $quote - 1); + $p = trim(substr($remaining, $quote + 1)); + if(strlen($p) > 0 + && !strcmp($p[0], ';')) + $p = substr($p, 1); + } + else + { + $value = trim($this->Tokenize($remaining, ';')); + $p = trim($this->Tokenize('')); + } + if(($l=strlen($parameter)) + && !strcmp($parameter[$l - 1],'*')) + { + $parameter=$this->Tokenize($parameter, '*'); + if(IsSet($parameters[$parameter]) + && IsSet($character_sets[$parameter])) + $value = $parameters[$parameter] . UrlDecode($value); + else + { + $character_sets[$parameter] = strtolower($this->Tokenize($value, '\'')); + $languages[$parameter] = $this->Tokenize('\''); + $value = UrlDecode($this->Tokenize('')); + } + } + $parameters[$parameter] = $value; + } + } + + Function FindStringLineBreak($string, $position, &$break, &$line_break) + { + if(GetType($line_break=strpos($string, $break="\n", $position))=='integer') + { + if(GetType($new_line_break=strpos($string, "\n", $position))=='integer') + { + if($new_line_break < $line_break) + { + $break = "\n"; + $line_break = $new_line_break; + return(1); + } + } + if($line_break>$position + && $string[$line_break-1]=="\r") + { + $line_break--; + $break="\r\n"; + } + return(1); + } + return(GetType($line_break=strpos($string, $break="\r", $position))=='integer'); + } + + Function FindLineBreak($position, &$break, &$line_break) + { + if(GetType($line_break=strpos($this->buffer, $break="\r", $position))=='integer') + { + if(GetType($new_line_break=strpos($this->buffer, "\n", $position))=='integer') + { + if($new_line_break < $line_break) + { + $break = "\n"; + $line_break = $new_line_break; + return(1); + } + } + if(($n = $line_break + 1) < strlen($this->buffer) + && $this->buffer[$n]=="\n") + $break="\r\n"; + return(1); + } + return(GetType($line_break=strpos($this->buffer, $break="\n", $position))=='integer'); + } + + Function FindBodyLineBreak($position, &$break, &$line_break) + { + if(GetType($line_break=strpos($this->body_buffer, $break="\r", $position))=='integer') + { + if(GetType($new_line_break=strpos($this->body_buffer, "\n", $position))=='integer') + { + if($new_line_break < $line_break) + { + $break = "\n"; + $line_break = $new_line_break; + return(1); + } + } + if(($n = $line_break + 1) < strlen($this->body_buffer) + && $this->body_buffer[$n]=="\n") + $break="\r\n"; + return(1); + } + return(GetType($line_break=strpos($this->body_buffer, $break="\n", $position))=='integer'); + } + + Function ParseHeaderString($body, &$position, &$headers) + { + $l = strlen($body); + $headers = array(); + for(;$position < $l;) + { + if($this->FindStringLineBreak($body, $position, $break, $line_break)) + { + $line = substr($body, $position, $line_break - $position); + $position = $line_break + strlen($break); + } + else + { + $line = substr($body, $position); + $position = $l; + } + if(strlen($line)==0) + break; + $h = strtolower(strtok($line,':')); + $headers[$h] = trim(strtok('')); + } + } + + Function ParsePart($end, &$part, &$need_more_data) + { + $need_more_data = 0; + switch($this->state) + { + case MIME_PARSER_START: + $part=array( + 'Type'=>'MessageStart', + 'Position'=>$this->offset + $this->buffer_position + ); + $this->state = MIME_PARSER_HEADER; + break; + case MIME_PARSER_HEADER: + if($this->FindLineBreak($this->buffer_position, $break, $line_break)) + { + $next = $line_break + strlen($break); + if(!strcmp($break,"\r") + && strlen($this->buffer) == $next + && !$end) + { + $need_more_data = 1; + break; + } + if($line_break==$this->buffer_position) + { + $part=array( + 'Type'=>'BodyStart', + 'Position'=>$this->offset + $this->buffer_position + ); + $this->buffer_position = $next; + $this->state = MIME_PARSER_BODY; + break; + } + } + if(GetType($colon=strpos($this->buffer, ':', $this->buffer_position))=='integer') + { + if(GetType($space=strpos(substr($this->buffer, $this->buffer_position, $colon - $this->buffer_position), ' '))=='integer') + { + if((!$this->mbox + || strcmp(substr($this->buffer, $this->buffer_position, $space), 'From')) + && !$this->SetPositionedWarning('invalid header name line', $this->buffer_position)) + return(0); + $next = $this->buffer_position + $space + 1; + } + else + $next = $colon+1; + } + else + { + $need_more_data = 1; + break; + } + $part=array( + 'Type'=>'HeaderName', + 'Name'=>substr($this->buffer, $this->buffer_position, $next - $this->buffer_position), + 'Position'=>$this->offset + $this->buffer_position + ); + $this->buffer_position = $next; + $this->state = MIME_PARSER_HEADER_VALUE; + break; + case MIME_PARSER_HEADER_VALUE: + $position = $this->buffer_position; + $value = ''; + for(;;) + { + if($this->FindLineBreak($position, $break, $line_break)) + { + $next = $line_break + strlen($break); + $line = substr($this->buffer, $position, $line_break - $position); + if(strlen($this->buffer) == $next) + { + if(!$end) + { + $need_more_data = 1; + break 2; + } + $value .= $line; + $part=array( + 'Type'=>'HeaderValue', + 'Value'=>$value, + 'Position'=>$this->offset + $this->buffer_position + ); + $this->buffer_position = $next; + $this->state = MIME_PARSER_END; + break ; + } + else + { + $character = $this->buffer[$next]; + if(!strcmp($character, ' ') + || !strcmp($character, "\t")) + { + $value .= $line; + $position = $next + 1; + } + else + { + $value .= $line; + $part=array( + 'Type'=>'HeaderValue', + 'Value'=>$value, + 'Position'=>$this->offset + $this->buffer_position + ); + $this->buffer_position = $next; + $this->state = MIME_PARSER_HEADER; + break 2; + } + } + } + else + { + if(!$end) + { + $need_more_data = 1; + break; + } + else + { + $value .= substr($this->buffer, $position); + $part=array( + 'Type'=>'HeaderValue', + 'Value'=>$value, + 'Position'=>$this->offset + $this->buffer_position + ); + $this->buffer_position = strlen($this->buffer); + $this->state = MIME_PARSER_END; + break; + } + } + } + break; + case MIME_PARSER_BODY: + if($this->mbox) + { + $add = 0; + $append=''; + if($this->FindLineBreak($this->buffer_position, $break, $line_break)) + { + $next = $line_break + strlen($break); + $following = $next + strlen($break); + if($following >= strlen($this->buffer) + || GetType($line=strpos($this->buffer, $break, $following))!='integer') + { + if(!$end) + { + $need_more_data = 1; + break; + } + } + $start = substr($this->buffer, $next, strlen($break.'From ')); + if(!strcmp($break.'From ', $start)) + { + if($line_break == $this->buffer_position) + { + $part=array( + 'Type'=>'MessageEnd', + 'Position'=>$this->offset + $this->buffer_position + ); + $this->buffer_position = $following; + $this->state = MIME_PARSER_START; + break; + } + else + $add = strlen($break); + $next = $line_break; + } + elseif(($indent = strspn($this->buffer, '>', $next)) > 0) + { + $start = substr($this->buffer, $next + $indent, strlen('From ')); + if(!strcmp('From ', $start)) + { + $part=array( + 'Type'=>'BodyData', + 'Data'=>substr($this->buffer, $this->buffer_position, $next - $this->buffer_position), + 'Position'=>$this->offset + $this->buffer_position + ); + $this->buffer_position = $next + 1; + break; + } + } + } + else + { + if(!$end) + { + $need_more_data = 1; + break; + } + $next = strlen($this->buffer); + $append="\r\n"; + } + if($next > $this->buffer_position) + { + $part=array( + 'Type'=>'BodyData', + 'Data'=>substr($this->buffer, $this->buffer_position, $next + $add - $this->buffer_position).$append, + 'Position'=>$this->offset + $this->buffer_position + ); + } + elseif($end) + { + $part=array( + 'Type'=>'MessageEnd', + 'Position'=>$this->offset + $this->buffer_position + ); + $this->state = MIME_PARSER_END; + } + $this->buffer_position = $next; + } + else + { + if(strlen($this->buffer)-$this->buffer_position) + { + $data=substr($this->buffer, $this->buffer_position, strlen($this->buffer) - $this->buffer_position); + $end_line = (!strcmp(substr($data,-1),"\n") || !strcmp(substr($data,-1),"\r")); + if($end + && !$end_line) + { + $data.="\n"; + $end_line = 1; + } + $offset = $this->offset + $this->buffer_position; + $this->buffer_position = strlen($this->buffer); + $need_more_data = !$end; + if(!$end_line) + { + if(GetType($line_break=strrpos($data, "\n"))=='integer' + || GetType($line_break=strrpos($data, "\r"))=='integer') + { + $line_break++; + $this->buffer_position -= strlen($data) - $line_break; + $data = substr($data, 0, $line_break); + } + } + $part=array( + 'Type'=>'BodyData', + 'Data'=>$data, + 'Position'=>$offset + ); + } + else + { + if($end) + { + $part=array( + 'Type'=>'MessageEnd', + 'Position'=>$this->offset + $this->buffer_position + ); + $this->state = MIME_PARSER_END; + } + else + $need_more_data = 1; + } + } + break; + default: + return($this->SetPositionedError($this->state.' is not a valid parser state', $this->buffer_position)); + } + return(1); + } + + Function QueueBodyParts() + { + for(;;) + { + if(!$this->body_parser->GetPart($part,$end)) + return($this->SetError($this->body_parser->error)); + if($end) + return(1); + if(!IsSet($part['Part'])) + $part['Part']=$this->headers['Boundary']; + $this->parts[]=$part; + } + } + + Function ParseParameters($value, &$first, &$parameters, $return) + { + $first = strtolower(trim(strtok($value, ';'))); + $values = trim(strtok('')); + $parameters = array(); + $return_value = ''; + while(strlen($values)) + { + $parameter = trim(strtolower(strtok($values, '='))); + $value = trim(strtok(';')); + $l = strlen($value); + if($l > 1 + && !strcmp($value[0], '"') + && !strcmp($value[$l - 1], '"')) + $value = substr($value, 1, $l - 2); + $parameters[$parameter] = $value; + if(!strcmp($parameter, $return)) + $return_value = $value; + $values = trim(strtok('')); + } + return($return_value); + } + + Function DecodePart($part) + { + switch($part['Type']) + { + case 'MessageStart': + $this->headers=array(); + break; + case 'HeaderName': + if($this->decode_bodies) + $this->current_header = strtolower($part['Name']); + break; + case 'HeaderValue': + if($this->decode_headers) + { + $value = $part['Value']; + $error = ''; + for($decoded_header = array(), $position = 0; $positionsubstr($value, $position), + 'Encoding'=>'ASCII' + ); + } + } + break; + } + $set = $encoded + 2; + if(GetType($method=strpos($value,'?', $set))!='integer') + { + $error = 'invalid header encoding syntax '.$part['Value']; + $error_position = $part['Position'] + $set; + break; + } + $encoding=strtoupper(substr($value, $set, $method - $set)); + $method += 1; + if(GetType($data=strpos($value,'?', $method))!='integer') + { + $error = 'invalid header encoding syntax '.$part['Value']; + $error_position = $part['Position'] + $set; + break; + } + $start = $data + 1; + if(GetType($end=strpos($value,'?=', $start))!='integer') + { + $error = 'invalid header encoding syntax '.$part['Value']; + $error_position = $part['Position'] + $start; + break; + } + if($encoded > $position) + { + if(count($decoded_header)) + $decoded_header[count($decoded_header)-1]['Value'].=substr($value, $position, $encoded - $position); + else + { + $decoded_header[]=array( + 'Value'=>substr($value, $position, $encoded - $position), + 'Encoding'=>'ASCII' + ); + } + } + switch(strtolower(substr($value, $method, $data - $method))) + { + case 'q': + if($end>$start) + { + for($decoded = '', $position = $start; $position < $end ; ) + { + switch($value[$position]) + { + case '=': + $h = HexDec($hex = strtolower(substr($value, $position+1, 2))); + if($end - $position < 3 + || strcmp(sprintf('%02x', $h), $hex)) + { + $warning = 'the header specified an invalid encoded character'; + $warning_position = $part['Position'] + $position + 1; + if($this->ignore_syntax_errors) + { + $this->SetPositionedWarning($warning, $warning_position); + $decoded .= '='; + $position ++; + } + else + { + $error = $warning; + $error_position = $warning_position; + break 4; + } + } + else + { + $decoded .= Chr($h); + $position += 3; + } + break; + case '_': + $decoded .= ' '; + $position++; + break; + default: + $decoded .= $value[$position]; + $position++; + break; + } + } + if(count($decoded_header) + && (!strcmp($decoded_header[$last = count($decoded_header)-1]['Encoding'], 'ASCII')) + || !strcmp($decoded_header[$last]['Encoding'], $encoding)) + { + $decoded_header[$last]['Value'].= $decoded; + $decoded_header[$last]['Encoding']= $encoding; + } + else + { + $decoded_header[]=array( + 'Value'=>$decoded, + 'Encoding'=>$encoding + ); + } + } + break; + case 'b': + $decoded=base64_decode(substr($value, $start, $end - $start)); + if($end <= $start + || GetType($decoded) != 'string' + || strlen($decoded) == 0) + { + $warning = 'the header specified an invalid base64 encoded text'; + $warning_position = $part['Position'] + $start; + if($this->ignore_syntax_errors) + $this->SetPositionedWarning($warning, $warning_position); + else + { + $error = $warning; + $error_position = $warning_position; + break 2; + } + } + if(count($decoded_header) + && (!strcmp($decoded_header[$last = count($decoded_header)-1]['Encoding'], 'ASCII')) + || !strcmp($decoded_header[$last]['Encoding'], $encoding)) + { + $decoded_header[$last]['Value'].= $decoded; + $decoded_header[$last]['Encoding']= $encoding; + } + else + { + $decoded_header[]=array( + 'Value'=>$decoded, + 'Encoding'=>$encoding + ); + } + break; + default: + $error = 'the header specified an unsupported encoding method'; + $error_position = $part['Position'] + $method; + break 2; + } + $position = $end + 2; + } + if(strlen($error)==0 + && count($decoded_header)) + $part['Decoded']=$decoded_header; + } + if($this->decode_bodies + || $this->decode_headers) + { + switch($this->current_header) + { + case 'content-type:': + $boundary = $this->ParseParameters($part['Value'], $type, $parameters, 'boundary'); + $this->headers['Type'] = $type; + if($this->decode_headers) + { + $part['MainValue'] = $type; + $part['Parameters'] = $parameters; + } + if(!strcmp(strtok($type, '/'), 'multipart')) + { + $this->headers['Multipart'] = 1; + if(strlen($boundary)) + $this->headers['Boundary'] = $boundary; + else + return($this->SetPositionedError('multipart content-type header does not specify the boundary parameter', $part['Position'])); + } + break; + case 'content-transfer-encoding:': + switch($this->headers['Encoding']=strtolower(trim($part['Value']))) + { + case 'quoted-printable': + $this->headers['QuotedPrintable'] = 1; + break; + case '7 bit': + case '8 bit': + if(!$this->SetPositionedWarning('"'.$this->headers['Encoding'].'" is an incorrect content transfer encoding type', $part['Position'])) + return(0); + case '7bit': + case '8bit': + case 'binary': + break; + case 'base64': + $this->headers['Base64']=1; + break; + default: + if(!$this->SetPositionedWarning('decoding '.$this->headers['Encoding'].' encoded bodies is not yet supported', $part['Position'])) + return(0); + } + break; + } + } + break; + case 'BodyStart': + if($this->decode_bodies + && IsSet($this->headers['Multipart'])) + { + $this->body_parser_state = MIME_PARSER_BODY_START; + $this->body_buffer = ''; + $this->body_buffer_position = 0; + } + break; + case 'MessageEnd': + if($this->decode_bodies + && IsSet($this->headers['Multipart']) + && $this->body_parser_state != MIME_PARSER_BODY_DONE) + { + if($this->body_parser_state != MIME_PARSER_BODY_DATA) + return($this->SetPositionedError('incomplete message body part', $part['Position'])); + if(!$this->SetPositionedWarning('truncated message body part', $part['Position'])) + return(0); + } + break; + case 'BodyData': + if($this->decode_bodies) + { + if(strlen($this->body_buffer)==0) + { + $this->body_buffer = $part['Data']; + $this->body_offset = $part['Position']; + } + else + $this->body_buffer .= $part['Data']; + if(IsSet($this->headers['Multipart'])) + { + $boundary = '--'.$this->headers['Boundary']; + switch($this->body_parser_state) + { + case MIME_PARSER_BODY_START: + for($position = $this->body_buffer_position; ;) + { + if(!$this->FindBodyLineBreak($position, $break, $line_break)) + return(1); + $next = $line_break + strlen($break); + if(!strcmp(rtrim(substr($this->body_buffer, $position, $line_break - $position)), $boundary)) + { + $part=array( + 'Type'=>'StartPart', + 'Part'=>$this->headers['Boundary'], + 'Position'=>$this->body_offset + $next + ); + $this->parts[]=$part; + UnSet($this->body_parser); + $this->body_parser = new mime_parser_class; + $this->body_parser->decode_bodies = 1; + $this->body_parser->decode_headers = $this->decode_headers; + $this->body_parser->mbox = 0; + $this->body_parser_state = MIME_PARSER_BODY_DATA; + $this->body_buffer = substr($this->body_buffer, $next); + $this->body_offset += $next; + $this->body_buffer_position = 0; + break; + } + else + $position = $next; + } + case MIME_PARSER_BODY_DATA: + for($position = $this->body_buffer_position; ;) + { + if(!$this->FindBodyLineBreak($position, $break, $line_break)) + { + if($position > 0) + { + if(!$this->body_parser->Parse(substr($this->body_buffer, 0, $position), 0)) + return($this->SetError($this->body_parser->error)); + if(!$this->QueueBodyParts()) + return(0); + } + $this->body_buffer = substr($this->body_buffer, $position); + $this->body_buffer_position = 0; + $this->body_offset += $position; + return(1); + } + $next = $line_break + strlen($break); + $line = rtrim(substr($this->body_buffer, $position, $line_break - $position)); + if(!strcmp($line, $boundary.'--')) + { + if(!$this->body_parser->Parse(substr($this->body_buffer, 0, $position), 1)) + return($this->SetError($this->body_parser->error)); + if(!$this->QueueBodyParts()) + return(0); + $part=array( + 'Type'=>'EndPart', + 'Part'=>$this->headers['Boundary'], + 'Position'=>$this->body_offset + $position + ); + $this->body_buffer = substr($this->body_buffer, $next); + $this->body_buffer_position = 0; + $this->body_offset += $next; + $this->body_parser_state = MIME_PARSER_BODY_DONE; + break 2; + } + elseif(!strcmp($line, $boundary)) + { + if(!$this->body_parser->Parse(substr($this->body_buffer, 0, $position), 1)) + return($this->SetError($this->body_parser->error)); + if(!$this->QueueBodyParts()) + return(0); + $part=array( + 'Type'=>'EndPart', + 'Part'=>$this->headers['Boundary'], + 'Position'=>$this->body_offset + $position + ); + $this->parts[] = $part; + $part=array( + 'Type'=>'StartPart', + 'Part'=>$this->headers['Boundary'], + 'Position'=>$this->body_offset + $next + ); + $this->parts[] = $part; + UnSet($this->body_parser); + $this->body_parser = new mime_parser_class; + $this->body_parser->decode_bodies = 1; + $this->body_parser->decode_headers = $this->decode_headers; + $this->body_parser->mbox = 0; + $this->body_buffer = substr($this->body_buffer, $next); + $this->body_buffer_position = 0; + $this->body_offset += $next; + $position=0; + continue; + } + $position = $next; + } + break; + case MIME_PARSER_BODY_DONE: + return(1); + default: + return($this->SetPositionedError($this->state.' is not a valid body parser state', $this->body_buffer_position)); + } + } + elseif(IsSet($this->headers['QuotedPrintable'])) + { + for($end = strlen($this->body_buffer), $decoded = '', $position = $this->body_buffer_position; $position < $end; ) + { + if(GetType($equal = strpos($this->body_buffer, '=', $position))!='integer') + { + $decoded .= substr($this->body_buffer, $position); + $position = $end; + break; + } + $next = $equal + 1; + switch($end - $equal) + { + case 1: + $decoded .= substr($this->body_buffer, $position, $equal - $position); + $position = $equal; + break 2; + case 2: + $decoded .= substr($this->body_buffer, $position, $equal - $position); + if(!strcmp($this->body_buffer[$next],"\n")) + $position = $end; + else + $position = $equal; + break 2; + } + if(!strcmp(substr($this->body_buffer, $next, 2), $break="\r\n") + || !strcmp($this->body_buffer[$next], $break="\n") + || !strcmp($this->body_buffer[$next], $break="\r")) + { + $decoded .= substr($this->body_buffer, $position, $equal - $position); + $position = $next + strlen($break); + continue; + } + $decoded .= substr($this->body_buffer, $position, $equal - $position); + $h = HexDec($hex=strtolower(substr($this->body_buffer, $next, 2))); + if(strcmp(sprintf('%02x', $h), $hex)) + { + if(!$this->SetPositionedWarning('the body specified an invalid quoted-printable encoded character', $this->body_offset + $next)) + return(0); + $decoded.='='; + $position=$next; + } + else + { + $decoded .= Chr($h); + $position = $equal + 3; + } + } + if(strlen($decoded)==0) + { + $this->body_buffer_position = $position; + return(1); + } + $part['Data'] = $decoded; + $this->body_buffer = substr($this->body_buffer, $position); + $this->body_buffer_position = 0; + $this->body_offset += $position; + } + elseif(IsSet($this->headers['Base64'])) + { + $part['Data'] = base64_decode($this->body_buffer_position ? substr($this->body_buffer,$this->body_buffer_position) : $this->body_buffer); + $this->body_offset += strlen($this->body_buffer) - $this->body_buffer_position; + $this->body_buffer_position = 0; + $this->body_buffer = ''; + } + else + { + $part['Data'] = substr($this->body_buffer, $this->body_buffer_position); + $this->body_buffer_position = 0; + $this->body_buffer = ''; + } + } + break; + } + $this->parts[]=$part; + return(1); + } + + Function DecodeStream($parameters, &$end_of_message, &$decoded) + { + $end_of_message = 1; + $state = MIME_MESSAGE_START; + for(;;) + { + if(!$this->GetPart($part, $end)) + return(0); + if($end) + { + if(IsSet($parameters['File'])) + { + $end_of_data = feof($this->file); + if($end_of_data) + break; + $data = @fread($this->file, $this->message_buffer_length); + if(GetType($data)!='string') + return($this->SetPHPError('could not read the message file', $php_errormsg)); + $end_of_data = feof($this->file); + } + else + { + $end_of_data=($this->position>=strlen($parameters['Data'])); + if($end_of_data) + break; + $data = substr($parameters['Data'], $this->position, $this->message_buffer_length); + $this->position += strlen($data); + $end_of_data = ($this->position >= strlen($parameters['Data'])); + } + if(!$this->Parse($data, $end_of_data)) + return(0); + continue; + } + $type = $part['Type']; + switch($state) + { + case MIME_MESSAGE_START: + switch($type) + { + case 'MessageStart': + $decoded=array( + 'Headers'=>array(), + 'Parts'=>array() + ); + $end_of_message = 0; + $state = MIME_MESSAGE_GET_HEADER_NAME; + continue 3; + case 'MessageEnd': + return($this->SetPositionedWarning('incorrectly ended body part', $part['Position'])); + } + break; + + case MIME_MESSAGE_GET_HEADER_NAME: + switch($type) + { + case 'HeaderName': + $header = strtolower($part['Name']); + $state = MIME_MESSAGE_GET_HEADER_VALUE; + continue 3; + case 'BodyStart': + $state = MIME_MESSAGE_GET_BODY; + $part_number = 0; + continue 3; + } + break; + + case MIME_MESSAGE_GET_HEADER_VALUE: + switch($type) + { + case 'HeaderValue': + $value = trim($part['Value']); + if(!IsSet($decoded['Headers'][$header])) + { + $h = 0; + $decoded['Headers'][$header]=$value; + if($this->extract_addresses + && IsSet($this->address_headers[$header])) + $decoded['HeaderPositions'][$header] = $part['Position']; + } + elseif(GetType($decoded['Headers'][$header])=='string') + { + $h = 1; + $decoded['Headers'][$header]=array($decoded['Headers'][$header], $value); + } + else + { + $h = count($decoded['Headers'][$header]); + $decoded['Headers'][$header][]=$value; + } + if(IsSet($part['Decoded']) + && (count($part['Decoded'])>1 + || strcmp($part['Decoded'][0]['Encoding'],'ASCII') + || strcmp($value, trim($part['Decoded'][0]['Value'])))) + { + $p=$part['Decoded']; + $p[0]['Value']=ltrim($p[0]['Value']); + $last=count($p)-1; + $p[$last]['Value']=rtrim($p[$last]['Value']); + $decoded['DecodedHeaders'][$header][$h]=$p; + } + switch($header) + { + case 'content-disposition:': + $filename='filename'; + break; + case 'content-type:': + if(!IsSet($decoded['FileName'])) + { + $filename='name'; + break; + } + default: + $filename=''; + break; + } + if(strlen($filename)) + { + if(IsSet($decoded['DecodedHeaders'][$header][$h]) + && count($decoded['DecodedHeaders'][$header][$h]) == 1) + { + $value = $decoded['DecodedHeaders'][$header][$h][0]['Value']; + $encoding = $decoded['DecodedHeaders'][$header][$h][0]['Encoding']; + } + else + $encoding = ''; + $this->ParseStructuredHeader($value, $type, $header_parameters, $character_sets, $languages); + if(IsSet($header_parameters[$filename])) + { + $decoded['FileName']=$header_parameters[$filename]; + if(IsSet($character_sets[$filename]) + && strlen($character_sets[$filename])) + $decoded['FileNameCharacterSet']=$character_sets[$filename]; + if(IsSet($character_sets['language']) + && strlen($character_sets['language'])) + $decoded['FileNameCharacterSet']=$character_sets[$filename]; + if(!IsSet($decoded['FileNameCharacterSet']) + && strlen($encoding)) + $decoded['FileNameCharacterSet'] = $encoding; + if(!strcmp($header, 'content-disposition:')) + $decoded['FileDisposition']=$type; + } + } + $state = MIME_MESSAGE_GET_HEADER_NAME; + continue 3; + } + break; + + case MIME_MESSAGE_GET_BODY: + switch($type) + { + case 'BodyData': + if(IsSet($parameters['SaveBody'])) + { + if(!IsSet($decoded['BodyFile'])) + { + $directory_separator=(defined('DIRECTORY_SEPARATOR') ? DIRECTORY_SEPARATOR : '/'); + $path = (strlen($parameters['SaveBody']) ? ($parameters['SaveBody'].(strcmp($parameters['SaveBody'][strlen($parameters['SaveBody'])-1], $directory_separator) ? $directory_separator : '')) : '').strval($this->body_part_number); + if(!($this->body_file = fopen($path, 'wb'))) + return($this->SetPHPError('could not create file '.$path.' to save the message body part', $php_errormsg)); + $decoded['BodyFile'] = $path; + $decoded['BodyPart'] = $this->body_part_number; + $decoded['BodyLength'] = 0; + $this->body_part_number++; + } + if(strlen($part['Data']) + && !fwrite($this->body_file, $part['Data'])) + { + $this->SetPHPError('could not save the message body part to file '.$decoded['BodyFile'], $php_errormsg); + fclose($this->body_file); + @unlink($decoded['BodyFile']); + return(0); + } + } + elseif(IsSet($parameters['SkipBody']) + && $parameters['SkipBody']) + { + if(!IsSet($decoded['BodyPart'])) + { + $decoded['BodyPart'] = $this->body_part_number; + $decoded['BodyLength'] = 0; + $this->body_part_number++; + } + } + else + { + if(IsSet($decoded['Body'])) + $decoded['Body'].=$part['Data']; + else + { + $decoded['Body']=$part['Data']; + $decoded['BodyPart'] = $this->body_part_number; + $decoded['BodyLength'] = 0; + $this->body_part_number++; + } + } + $decoded['BodyLength'] += strlen($part['Data']); + continue 3; + case 'StartPart': + if(!$this->DecodeStream($parameters, $end_of_part, $decoded_part)) + return(0); + $decoded['Parts'][$part_number]=$decoded_part; + $part_number++; + $state = MIME_MESSAGE_GET_BODY_PART; + continue 3; + case 'MessageEnd': + if(IsSet($decoded['BodyFile'])) + fclose($this->body_file); + return(1); + } + break; + + case MIME_MESSAGE_GET_BODY_PART: + switch($type) + { + case 'EndPart': + $state = MIME_MESSAGE_GET_BODY; + continue 3; + } + break; + } + return($this->SetError('unexpected decoded message part type '.$type.' in state '.$state)); + } + return(1); + } + + /* Public functions */ + + Function Parse($data, $end) + { + if(strlen($this->error)) + return(0); + if($this->state==MIME_PARSER_END) + return($this->SetError('the parser already reached the end')); + $length = strlen($data); + if($this->track_lines + && $length) + { + $line = $this->last_line; + $position = 0; + if($this->last_carriage_return) + { + if($data[0] == "\n") + ++$position; + $this->lines[++$line] = $this->line_offset + $position; + $this->last_carriage_return = 0; + } + while($position < $length) + { + $position += strcspn($data, "\r\n", $position) ; + if($position >= $length) + break; + if($data[$position] == "\r") + { + ++$position; + if($position >= $length) + { + $this->last_carriage_return = 1; + break; + } + if($data[$position] == "\n") + ++$position; + $this->lines[++$line] = $this->line_offset + $position; + } + else + { + ++$position; + $this->lines[++$line] = $this->line_offset + $position; + } + } + $this->last_line = $line; + $this->line_offset += $length; + } + $this->buffer .= $data; + do + { + Unset($part); + if(!$this->ParsePart($end, $part, $need_more_data)) + return(0); + if(IsSet($part) + && !$this->DecodePart($part)) + return(0); + } + while(!$need_more_data + && $this->state!=MIME_PARSER_END); + if($end + && $this->state!=MIME_PARSER_END) + return($this->SetError('reached a premature end of data')); + if($this->buffer_position>0) + { + $this->offset += $this->buffer_position; + $this->buffer = substr($this->buffer, $this->buffer_position); + $this->buffer_position = 0; + } + return(1); + } + + Function ParseFile($file) + { + if(strlen($this->error)) + return(0); + if(!($stream = @fopen($file, 'r'))) + return($this->SetPHPError('Could not open the file '.$file, $php_errormsg)); + for($end = 0;!$end;) + { + if(!($data = @fread($stream, $this->message_buffer_length))) + { + $this->SetPHPError('Could not read the file '.$file, $php_errormsg); + fclose($stream); + return(0); + } + $end=feof($stream); + if(!$this->Parse($data, $end)) + { + fclose($stream); + return(0); + } + } + fclose($stream); + return(1); + } + + Function GetPart(&$part, &$end) + { + $end = ($this->part_position >= count($this->parts)); + if($end) + { + if($this->part_position) + { + $this->part_position = 0; + $this->parts = array(); + } + } + else + { + $part = $this->parts[$this->part_position]; + $this->part_position ++; + } + return(1); + } + +/* +{metadocument} + + Decode + BOOLEAN + + Parse and decode message data and retrieve its structure. + Pass an array to the + Decode + parameters + + parameter to define whether the message data should be read and + parsed from a file or a data string, as well additional parsing + options. The + Decode + decoded + returns the + data structure of the parsed messages. + This function returns 1 if + the specified message data is parsed successfully. Otherwise, + check the variables error and + error_position to determine what + error occurred and the relevant message position. + + + parameters + HASH + + Associative array to specify parameters for the message + data parsing and decoding operation. Here follows the list of + supported parameters that should be used as indexes of the + array: + File + Name of the file from which the message data will be read. It + may be the name of a file stream or a remote URL, as long as + your PHP installation is configured to allow accessing remote + files with the fopen() function. + Data + String that specifies the message data. This should be used + as alternative data source for passing data available in memory, + like for instance messages stored in a database that was queried + dynamically and the message data was fetched into a string + variable. + SaveBody + If this parameter is specified, the message body parts are saved + to files. The path of the directory where the files are saved is + defined by this parameter value. The information about the + message body part structure is returned by the + Decode + decoded + argument, but it just returns the body data part + file name instead of the actual body data. It is recommended for + retrieving messages larger than the available memory. The names + of the body part files are numbers starting from + 1. + SkipBody + If this parameter is set to 1, the + message body parts are skipped. This means the information about + the message body part structure is returned by the + Decode + decoded + but it does not return any body data. It is + recommended just for parsing messages without the need to + retrieve the message body part data. + + + + decoded + ARRAY + + + Retrieve the structure of the parsed message headers and + body data. + The argument is used to return by reference an array of message + structure definitions. Each array entry refers to the structure + of each message that is found and parsed successfully. + Each message entry consists of an associative array with several + entries that describe the message structure. Here follows the + list of message structure entries names and the meaning of the + respective values: + Headers + Associative array that returns the list of all the message + headers. The array entries are the header names mapped to + lower case, including the end colon. The array values are the + respective header raw values without any start or trailing white + spaces. Long header values split between multiple message lines + are gathered in single string without line breaks. If an header + with the same name appears more than once in the message, the + respective value is an array with the values of all of the + header occurrences. + DecodedHeaders + Associative array that returns the list of all the encoded + message headers when the + decode_headers variable is set. The + array entries are the header names mapped to lower case, + including the end colon. The array values are also arrays that + list only the occurrences of the header that originally were + encoded. Each entry of the decoded header array contains more + associative arrays that describe each part of the decoded + header. Each of those associative arrays have an entry named + Value that contains the decoded header part value, and + another entry named Encoding that specifies the + character set encoding of the value in upper case. + ExtractedAddresses + If the extract_addresses variable + is set to 1, this entry is set to an + associative array with the addresses found in the headers + specified by the address_headers + variable. + The parsed addresses found on each header are returned as an + array with the format of the + addresses + rfc822_addresses_class.html#argument_ParseAddressList_addresses + argument of the + ParseAddressList + rfc822_addresses_class.html#function_ParseAddressList + function of the + RFC 822 addresses + rfc822_addresses_class.html + class. + Parts + If this message content type is multipart, this entry is an + array that describes each of the parts contained in the message + body. Each message part is described by an associative array + with the same structure of a complete message + definition. + Body + String with the decoded data contained in the message body. If + the SaveBody or SkipBody parameters are + defined, the Body entry is not set. + BodyFile + Name of the file to which the message body data was saved when + the SaveBody parameter is defined. + BodyLength + Length of the current decoded body part. + BodyPart + Number of the current message body part. + FileName + Name of the file for body parts composed from + files. + FileNameCharacterSet + Character set encoding for file parts with names that may + include non-ASCII characters. + FileNameLanguage + Language of file parts with names that may include non-ASCII + characters. + FileDisposition + Disposition of parts that files. It may be either + inline for file parts to be + displayed with the message, or + attachment otherwise. + + + +{/metadocument} +*/ + Function Decode($parameters, &$decoded) + { + if(IsSet($parameters['File'])) + { + if(!($this->file = @fopen($parameters['File'], 'r'))) + return($this->SetPHPError('could not open the message file to decode '.$parameters['File'], $php_errormsg)); + } + elseif(IsSet($parameters['Data'])) + $this->position = 0; + else + return($this->SetError('it was not specified a valid message to decode')); + $this->warnings = $decoded = array(); + $this->ResetParserState(); + $addresses = new rfc822_addresses_class; + $addresses->ignore_syntax_errors = $this->ignore_syntax_errors; + for($message = 0; ($success = $this->DecodeStream($parameters, $end_of_message, $decoded_message)) && !$end_of_message; $message++) + { + if($this->extract_addresses) + { + $headers = $decoded_message['Headers']; + $positions = (IsSet($decoded_message['HeaderPositions']) ? $decoded_message['HeaderPositions'] : array()); + $th = count($headers); + for(Reset($headers), $h = 0; $h<$th; Next($headers), ++$h) + { + $header = Key($headers); + if(IsSet($this->address_headers[$header]) + && $this->address_headers[$header]) + { + $values = (GetType($headers[$header]) == 'array' ? $headers[$header] : array($headers[$header])); + $p = (GetType($positions[$header]) == 'array' ? $positions[$header] : array($positions[$header])); + $tv = count($values); + for($v = 0; $v<$tv; ++$v) + { + if($addresses->ParseAddressList($values[$v], $a)) + { + if($v==0) + $decoded_message['ExtractedAddresses'][$header] = $a; + else + { + $tl = count($a); + for($l = 0; $l<$tl; ++$l) + $decoded_message['ExtractedAddresses'][$header][] = $a[$l]; + } + $tw = count($addresses->warnings); + for($w = 0, Reset($addresses->warnings); $w < $tw; Next($addresses->warnings), $w++) + { + $warning = Key($addresses->warnings); + if(!$this->SetPositionedWarning('Address extraction warning from header '.$header.' '.$addresses->warnings[$warning], $warning + $p[$v])) + return(0); + } + } + elseif(!$this->SetPositionedWarning('Address extraction error from header '.$header.' '.$addresses->error, $addresses->error_position + $p[$v])) + return(0); + } + } + } + UnSet($decoded_message['HeaderPositions']); + } + $decoded[$message]=$decoded_message; + } + if(IsSet($parameters['File'])) + fclose($this->file); + return($success); + } +/* +{metadocument} + + +{/metadocument} +*/ + + Function CopyAddresses($message, &$results, $header) + { + if(!IsSet($message['Headers'][$header])) + return; + if(!IsSet($message['ExtractedAddresses'][$header])) + { + $parser = new rfc822_addresses_class; + $parser->ignore_syntax_errors = $this->ignore_syntax_errors; + $values = (GetType($message['Headers'][$header]) == 'array' ? $message['Headers'][$header] : array($message['Headers'][$header])); + $tv = count($values); + $addresses = array(); + for($v = 0; $v<$tv; ++$v) + { + if($parser->ParseAddressList($values[$v], $a)) + { + if($v==0) + $addresses = $a; + else + { + $tl = count($a); + for($l = 0; $l<$tl; ++$l) + $addresses[] = $a[$l]; + } + } + } + } + else + $addresses = $message['ExtractedAddresses'][$header]; + if(count($addresses)) + $results[ucfirst(substr($header, 0, strlen($header) -1))] = $addresses; + } + + Function ReadMessageBody($message, &$body, $prefix) + { + if(IsSet($message[$prefix])) + $body = $message[$prefix]; + elseif(IsSet($message[$prefix.'File'])) + { + $path = $message[$prefix.'File']; + if(!($file = @fopen($path, 'rb'))) + return($this->SetPHPError('could not open the message body file '.$path, $php_errormsg)); + for($body = '', $end = 0;!$end;) + { + if(!($data = @fread($file, $this->message_buffer_length))) + { + $this->SetPHPError('Could not open the message body file '.$path, $php_errormsg); + fclose($stream); + return(0); + } + $end=feof($file); + $body.=$data; + } + fclose($file); + } + else + $body = ''; + return(1); + } +/* +{metadocument} + + Analyze + BOOLEAN + + Analyze a parsed message to describe its contents. + Pass an array to the + Analyze + message + + parameter with the decoded message array structure returned by the + Decode function. The + Analyze + results + returns details about the type of message that was + analyzed and its contents. + This function returns 1 if + the specified message is analyzed successfully. Otherwise, + check the variables error and + error_position to determine what + error occurred. + + + message + HASH + + Pass an associative array with the definition of an + individual message returned by the + Decode + decoded + argument of the + Decode function.. + + + + results + HASH + + + Returns an associative array with the results of the + analysis. Some types of entries are returned for all types of + analyzed messages. Other entries are specific to each type of + message. + Type + Type of message that was analyzed. Currently it supports the + types: binary, text, html, + video, image, audio, zip, + pdf, postscript, ms-word, + ms-excel, ms-powerpoint, ms-tnef, + odf-writer, signature, report-type, + delivery-status and message. + SubType + Name of the variant of the message type format. + Description + Human readable description in English of the message type. + + + + From message headers: + Encoding + Character set encoding of the message part. + Subject + The message subject. + SubjectEncoding + Character set encoding of the message subject. + Date + The message date. + From + To + Cc + Bcc + Array of e-mail addresses found in the From, + To, Cc, Bcc. + Each of the entries consists of an associative array with an + entry named address with the e-mail address and + optionally another named name with the associated + name. + + + For content message parts: + + Data + String of data of the message part. + DataFile + File with data of the message part. + DataLength + Length of the data of the message part. + + + + For message with embedded files: + + FileName + Original name of the file. + ContentID + Content identifier of the file to be used in references from + other message parts. + For instance, an HTML message may reference images embedded in + the message using URLs that start with the + cid: followed by the content + identifier of the embedded image file part. + Disposition + Information of whether the embedded file should be displayed + inline when the message is presented, or it is an attachment + file. + + + For composite message: + + Attachments + List of files attached to the message. + Alternative + List of alternative message parts that can be displayed if the + main message type is not supported by the program displaying + the message. + Related + List of message parts related with the main message type. + It may list for instance embedded images or CSS files related + with an HTML message type. + + + For bounced messages or other types of delivery status report + messages: + + Recipients + List of recipients of the original message. + Each entry contains an associative array that may have the + entries: Recipient with the original recipient address, + Action with the name action that triggered the delivery + status report, Status with the code of the status of + the message delivery. + Response + Human readable response sent by the server the originated the + report. + + + + +{/metadocument} +*/ + Function Analyze($message, &$results) + { + $results = array(); + if(!IsSet($message['Headers']['content-type:'])) + $content_type = 'text/plain'; + elseif(count($message['Headers']['content-type:']) == 1) + $content_type = $message['Headers']['content-type:']; + else + { + if(!$this->SetPositionedWarning('message contains multiple content-type headers', 0)) + return(0); + $content_type = $message['Headers']['content-type:'][0]; + } + $disposition = $this->ParseParameters($content_type, $content_type, $parameters, 'disposition'); + $type = $this->Tokenize($content_type, '/'); + $sub_type = $this->Tokenize(';'); + $copy_body = 1; + $tolerate_unrecognized = 1; + switch($type) + { + case 'multipart': + $tolerate_unrecognized = 0; + $copy_body = 0; + $lp = count($message['Parts']); + if($lp == 0) + return($this->SetError($this->decode_bodies ? 'No parts were found in the '.$content_type.' part message' : 'It is not possible to analyze multipart messages without parsing the contained message parts. Please set the decode_bodies variable to 1 before parsing the message')); + $parts = array(); + for($p = 0; $p < $lp; ++$p) + { + if(!$this->Analyze($message['Parts'][$p], $parts[$p])) + return(0); + } + switch($sub_type) + { + case 'alternative': + $p = $lp; + $results = $parts[--$p]; + for(--$p ; $p >=0 ; --$p) + $results['Alternative'][] = $parts[$p]; + break; + + case 'related': + $results = $parts[0]; + for($p = 1; $p < $lp; ++$p) + $results['Related'][] = $parts[$p]; + break; + + case 'mixed': + $results = $parts[0]; + for($p = 1; $p < $lp; ++$p) + $results['Attachments'][] = $parts[$p]; + break; + + case 'report': + if(IsSet($parameters['report-type'])) + { + switch($parameters['report-type']) + { + case 'delivery-status': + for($p = 1; $p < $lp; ++$p) + { + if(!strcmp($parts[$p]['Type'], $parameters['report-type'])) + { + $results = $parts[$p]; + break; + } + } + if(!$this->ReadMessageBody($parts[0], $body, 'Data')) + return(0); + if(strlen($body)) + $results['Response'] = $body; + break; + } + } + $results['Type'] = $parameters['report-type']; + break; + + case 'signed': + if($lp != 2) + return($this->SetError('this '.$content_type.' message does not have just 2 parts')); + if(strcmp($parts[1]['Type'], 'signature')) + { + $this->SetErrorWithContact('this '.$content_type.' message does not contain a signature'); + $this->error = ''; + } + $results = $parts[0]; + $results['Signature'] = $parts[1]; + break; + + case 'appledouble': + if($lp != 2) + return($this->SetError('this '.$content_type.' message does not have just 2 parts')); + if(strcmp($parts[0]['Type'], 'applefile')) + { + $this->SetErrorWithContact('this '.$content_type.' message does not contain an Apple file header'); + $this->error = ''; + } + $results = $parts[1]; + $results['AppleFileHeader'] = $parts[0]; + break; + + } + break; + case 'text': + switch($sub_type) + { + case 'plain': + $results['Type'] = 'text'; + $results['Description'] = 'Text message'; + break; + case 'html': + $results['Type'] = 'html'; + $results['Description'] = 'HTML message'; + break; + default: + $results['Type'] = $type; + $results['SubType'] = $sub_type; + $results['Description'] = 'Text file in the '.strtoupper($sub_type).' format'; + break; + } + break; + case 'video': + $results['Type'] = $type; + $results['SubType'] = $sub_type; + $results['Description'] = 'Video file in the '.strtoupper($sub_type).' format'; + break; + case 'image': + $results['Type'] = $type; + $results['SubType'] = $sub_type; + $results['Description'] = 'Image file in the '.strtoupper($sub_type).' format'; + break; + case 'audio': + $results['Type'] = $type; + $results['SubType'] = $sub_type; + $results['Description'] = 'Audio file in the '.strtoupper($sub_type).' format'; + break; + case 'application': + switch($sub_type) + { + case 'octet-stream': + case 'x-msdownload': + $results['Type'] = 'binary'; + $results['Description'] = 'Binary file'; + break; + case 'pdf': + $results['Type'] = $sub_type; + $results['Description'] = 'Document in PDF format'; + break; + case 'postscript': + $results['Type'] = $sub_type; + $results['Description'] = 'Document in Postscript format'; + break; + case 'msword': + $results['Type'] = 'ms-word'; + $results['Description'] = 'Word processing document in Microsoft Word format'; + break; + case 'vnd.ms-powerpoint': + $results['Type'] = 'ms-powerpoint'; + $results['Description'] = 'Presentation in Microsoft PowerPoint format'; + break; + case 'vnd.ms-excel': + $results['Type'] = 'ms-excel'; + $results['Description'] = 'Spreadsheet in Microsoft Excel format'; + break; + case 'x-compressed': + if(!IsSet($parameters['name']) + || GetType($dot = strpos($parameters['name'], '.'))!='integer' + || strcmp($extension = strtolower(substr($parameters['name'], $dot + 1)), 'zip')) + break; + case 'zip': + case 'x-zip': + case 'x-zip-compressed': + $results['Type'] = 'zip'; + $results['Description'] = 'ZIP archive with compressed files'; + break; + case 'ms-tnef': + $results['Type'] = $sub_type; + $results['Description'] = 'Microsoft Exchange data usually sent by Microsoft Outlook'; + break; + case 'pgp-signature': + $results['Type'] = 'signature'; + $results['SubType'] = $sub_type; + $results['Description'] = 'Message signature for PGP'; + break; + case 'x-pkcs7-signature': + case 'pkcs7-signature': + $results['Type'] = 'signature'; + $results['SubType'] = $sub_type; + $results['Description'] = 'PKCS message signature'; + break; + case 'vnd.oasis.opendocument.text': + $results['Type'] = 'odf-writer'; + $results['Description'] = 'Word processing document in ODF text format used by OpenOffice Writer'; + break; + case 'applefile': + $results['Type'] = 'applefile'; + $results['Description'] = 'Apple file resource header'; + break; + } + break; + case 'message': + $tolerate_unrecognized = 0; + switch($sub_type) + { + case 'delivery-status': + $results['Type'] = $sub_type; + $results['Description'] = 'Notification of the status of delivery of a message'; + if(!$this->ReadMessageBody($message, $body, 'Body')) + return(0); + if(($l = strlen($body))) + { + $position = 0; + $this->ParseHeaderString($body, $position, $headers); + $recipients = array(); + for(;$position<$l;) + { + $this->ParseHeaderString($body, $position, $headers); + if(count($headers)) + { + $r = count($recipients); + if(IsSet($headers['action'])) + $recipients[$r]['Action'] = $headers['action']; + if(IsSet($headers['status'])) + $recipients[$r]['Status'] = $headers['status']; + if(IsSet($headers['original-recipient'])) + { + strtok($headers['original-recipient'], ';'); + $recipients[$r]['Address'] = trim(strtok('')); + } + elseif(IsSet($headers['final-recipient'])) + { + strtok($headers['final-recipient'], ';'); + $recipients[$r]['Address'] = trim(strtok('')); + } + } + } + $results['Recipients'] = $recipients; + } + $copy_body = 0; + break; + case 'rfc822': + $results['Type'] = 'message'; + $results['Description'] = 'E-mail message'; + break; + } + break; + default: + $tolerate_unrecognized = 0; + break; + } + if(!IsSet($results['Type'])) + { + $this->SetErrorWithContact($content_type.' message parts are not yet recognized'); + $results['Type'] = $this->error; + $this->error = ''; + } + if(IsSet($parameters['charset'])) + $results['Encoding'] = strtolower($parameters['charset']); + if(IsSet($message['Headers']['subject:'])) + { + if(IsSet($message['DecodedHeaders']['subject:']) + && count($message['DecodedHeaders']['subject:']) == 1 + && count($message['DecodedHeaders']['subject:'][0]) == 1) + { + $results['Subject'] = $message['DecodedHeaders']['subject:'][0][0]['Value']; + $results['SubjectEncoding'] = strtolower($message['DecodedHeaders']['subject:'][0][0]['Encoding']); + } + else + $results['Subject'] = $message['Headers']['subject:']; + } + if(IsSet($message['Headers']['date:'])) + { + if(IsSet($message['DecodedHeaders']['date:']) + && count($message['DecodedHeaders']['date:']) == 1 + && count($message['DecodedHeaders']['date:'][0]) == 1) + $results['Date'] = $message['DecodedHeaders']['date:'][0][0]['Value']; + else + $results['Date'] = $message['Headers']['date:']; + } + $l = count($this->address_headers); + for(Reset($this->address_headers), $h = 0; $h<$l; Next($this->address_headers), ++$h) + $this->CopyAddresses($message, $results, Key($this->address_headers)); + if($copy_body) + { + if(IsSet($message['Body'])) + $results['Data'] = $message['Body']; + elseif(IsSet($message['BodyFile'])) + $results['DataFile'] = $message['BodyFile']; + elseif(IsSet($message['BodyLength'])) + $results['DataLength'] = $message['BodyLength']; + if(IsSet($message['FileName'])) + $results['FileName'] = $message['FileName']; + if(IsSet($message['FileDisposition'])) + $results['FileDisposition'] = $message['FileDisposition']; + if(IsSet($message['Headers']['content-id:'])) + { + $content_id = trim($message['Headers']['content-id:']); + $l = strlen($content_id); + if(!strcmp($content_id[0], '<') + && !strcmp($content_id[$l - 1], '>')) + $results['ContentID'] = substr($content_id, 1, $l - 2); + } + } + return(1); + } +/* +{metadocument} + + +{/metadocument} +*/ + +/* +{metadocument} + + GetPositionLine + BOOLEAN + + Get the line number of the document that corresponds to a + given position. + Pass the document offset number as the position to be + located. Make sure the track_lines + variable is set to 1 before parsing + the document. + This function returns 1 if + the track_lines variable is set to + 1 and it was given a valid positive + position number that does not exceed the position of the last + parsed document line. + + + position + INTEGER + + Position of the line to be located. + + + + line + INTEGER + + + Returns the number of the line that corresponds to the + given document position. + + + + column + INTEGER + + + Returns the number of the column of the line that + corresponds to the given document position. + + + +{/metadocument} +*/ + Function GetPositionLine($position, &$line, &$column) + { + if(!$this->track_lines) + return($this->SetPositionedError('line positions are not being tracked', $position)); + $bottom = 0; + $top = count($this->lines) - 1; + if($position < 0) + return($this->SetPositionedError('it was not specified a valid position', $position)); + for(;;) + { + $line = intval(($bottom + $top) / 2); + $current = $this->lines[$line]; + if($current < $position) + $bottom = $line + 1; + elseif($current > $position) + $top = $line - 1; + else + break; + if($top < $bottom) + { + $line = $top; + break; + } + } + $column = $position - $this->lines[$line] + 1; + ++$line; + return(1); + } +/* +{metadocument} + + +{/metadocument} +*/ +}; + +/* + +{metadocument} +
    +{/metadocument} + +*/ + +?> \ No newline at end of file diff --git a/includes/pop3/parse_message.php b/includes/pop3/parse_message.php new file mode 100644 index 0000000000..b3cd9ec1f6 --- /dev/null +++ b/includes/pop3/parse_message.php @@ -0,0 +1,87 @@ + + +Parsing a message with Manuel Lemos' PHP POP3 and MIME Parser classes + + +

    Parsing a message with Manuel Lemos' PHP POP3 and MIME Parser classes

    +
    +decode_bodies = 1; + + $parameters=array( + 'File'=>$message_file, + + /* Read a message from a string instead of a file */ + /* 'Data'=>'My message data string', */ + + /* Save the message body parts to a directory */ + /* 'SaveBody'=>'/tmp', */ + + /* Do not retrieve or save message body parts */ + 'SkipBody'=>1, + ); + $success=$mime->Decode($parameters, $decoded); + + + if(!$success) + echo '

    MIME message decoding error: '.HtmlSpecialChars($mime->error)."

    \n"; + else + { + echo '

    MIME message decoding successful

    '."\n"; + echo '

    Message structure

    '."\n"; + echo '
    ';
    +		var_dump($decoded[0]);
    +		echo '
    '; + if($mime->Analyze($decoded[0], $results)) + { + echo '

    Message analysis

    '."\n"; + echo '
    ';
    +			var_dump($results);
    +			echo '
    '; + } + else + echo 'MIME message analyse error: '.$mime->error."\n"; + } +?> +
    + + diff --git a/includes/pop3/pop3.php b/includes/pop3/pop3.php new file mode 100644 index 0000000000..954184495a --- /dev/null +++ b/includes/pop3/pop3.php @@ -0,0 +1,796 @@ +next_token; + } + for($character=0;$characternext_token=substr($string,$found+1); + return(substr($string,0,$found)); + } + else + { + $this->next_token=""; + return($string); + } + } + + Function SetError($error) + { + return($this->error=$error); + } + + Function OutputDebug($message) + { + $message.="\n"; + if($this->html_debug) + $message=str_replace("\n","
    \n",HtmlSpecialChars($message)); + echo $message; + flush(); + } + + Function GetLine() + { + for($line="";;) + { + if(feof($this->connection)) + return(0); + $line.=fgets($this->connection,100); + $length=strlen($line); + if($length>=2 + && substr($line,$length-2,2)=="\r\n") + { + $line=substr($line,0,$length-2); + if($this->debug) + $this->OutputDebug("S $line"); + return($line); + } + } + } + + Function PutLine($line) + { + if($this->debug) + $this->OutputDebug("C $line"); + return(fputs($this->connection,"$line\r\n")); + } + + Function OpenConnection() + { + if($this->tls) + { + $version=explode(".",function_exists("phpversion") ? phpversion() : "3.0.7"); + $php_version=intval($version[0])*1000000+intval($version[1])*1000+intval($version[2]); + if($php_version<4003000) + return("establishing TLS connections requires at least PHP version 4.3.0"); + if(!function_exists("extension_loaded") + || !extension_loaded("openssl")) + return("establishing TLS connections requires the OpenSSL extension enabled"); + } + if($this->hostname=="") + return($this->SetError("2 it was not specified a valid hostname")); + if($this->debug) + $this->OutputDebug("Connecting to ".$this->hostname." ..."); + if(($this->connection=@fsockopen(($this->tls ? "tls://" : "").$this->hostname, $this->port, $error, $error_message))==0) + { + switch($error) + { + case -3: + return($this->SetError("-3 socket could not be created")); + case -4: + return($this->SetError("-4 dns lookup on hostname \"$hostname\" failed")); + case -5: + return($this->SetError("-5 connection refused or timed out")); + case -6: + return($this->SetError("-6 fdopen() call failed")); + case -7: + return($this->SetError("-7 setvbuf() call failed")); + default: + return($this->SetError($error." could not connect to the host \"".$this->hostname."\": ".$error_message)); + } + } + return(""); + } + + Function CloseConnection() + { + if($this->debug) + $this->OutputDebug("Closing connection."); + if($this->connection!=0) + { + fclose($this->connection); + $this->connection=0; + } + } + + /* Public methods */ + + /* Open method - set the object variable $hostname to the POP3 server address. */ + + Function Open() + { + if($this->state!="DISCONNECTED") + return($this->SetError("1 a connection is already opened")); + if(($error=$this->OpenConnection())!="") + return($error); + $greeting=$this->GetLine(); + if(GetType($greeting)!="string" + || $this->Tokenize($greeting," ")!="+OK") + { + $this->CloseConnection(); + return($this->SetError("3 POP3 server greeting was not found")); + } + $this->Tokenize("<"); + $this->greeting = $this->Tokenize(">"); + $this->must_update=0; + $this->state="AUTHORIZATION"; + return(""); + } + + /* Close method - this method must be called at least if there are any + messages to be deleted */ + + Function Close() + { + if($this->state=="DISCONNECTED") + return($this->SetError("no connection was opened")); + while($this->state=='GETMESSAGE') + { + if(strlen($error=$this->GetMessage(8000, $message, $end_of_message))) + return($error); + } + if($this->must_update + || $this->quit_handshake) + { + if($this->PutLine("QUIT")==0) + return($this->SetError("Could not send the QUIT command")); + $response=$this->GetLine(); + if(GetType($response)!="string") + return($this->SetError("Could not get quit command response")); + if($this->Tokenize($response," ")!="+OK") + return($this->SetError("Could not quit the connection: ".$this->Tokenize("\r\n"))); + } + $this->CloseConnection(); + $this->state="DISCONNECTED"; + pop3_class::SetConnection(-1, $this->connection_name, $this); + return(""); + } + + /* Login method - pass the user name and password of POP account. Set + $apop to 1 or 0 wether you want to login using APOP method or not. */ + + Function Login($user,$password,$apop=0) + { + if($this->state!="AUTHORIZATION") + return($this->SetError("connection is not in AUTHORIZATION state")); + if($apop) + { + if(!strcmp($this->greeting,"")) + return($this->SetError("Server does not seem to support APOP authentication")); + if($this->PutLine("APOP $user ".md5("<".$this->greeting.">".$password))==0) + return($this->SetError("Could not send the APOP command")); + $response=$this->GetLine(); + if(GetType($response)!="string") + return($this->SetError("Could not get APOP login command response")); + if($this->Tokenize($response," ")!="+OK") + return($this->SetError("APOP login failed: ".$this->Tokenize("\r\n"))); + } + else + { + $authenticated=0; + if(strcmp($this->authentication_mechanism,"USER") + && function_exists("class_exists") + && class_exists("sasl_client_class")) + { + if(strlen($this->authentication_mechanism)) + $mechanisms=array($this->authentication_mechanism); + else + { + $mechanisms=array(); + if($this->PutLine("CAPA")==0) + return($this->SetError("Could not send the CAPA command")); + $response=$this->GetLine(); + if(GetType($response)!="string") + return($this->SetError("Could not get CAPA command response")); + if(!strcmp($this->Tokenize($response," "),"+OK")) + { + for(;;) + { + $response=$this->GetLine(); + if(GetType($response)!="string") + return($this->SetError("Could not retrieve the supported authentication methods")); + switch($this->Tokenize($response," ")) + { + case ".": + break 2; + case "SASL": + for($method=1;strlen($mechanism=$this->Tokenize(" "));$method++) + $mechanisms[]=$mechanism; + break; + } + } + } + } + $sasl=new sasl_client_class; + $sasl->SetCredential("user",$user); + $sasl->SetCredential("password",$password); + if(strlen($this->realm)) + $sasl->SetCredential("realm",$this->realm); + if(strlen($this->workstation)) + $sasl->SetCredential("workstation",$this->workstation); + do + { + $status=$sasl->Start($mechanisms,$message,$interactions); + } + while($status==SASL_INTERACT); + switch($status) + { + case SASL_CONTINUE: + break; + case SASL_NOMECH: + if(strlen($this->authentication_mechanism)) + return($this->SetError("authenticated mechanism ".$this->authentication_mechanism." may not be used: ".$sasl->error)); + break; + default: + return($this->SetError("Could not start the SASL authentication client: ".$sasl->error)); + } + if(strlen($sasl->mechanism)) + { + if($this->PutLine("AUTH ".$sasl->mechanism.(IsSet($message) ? " ".base64_encode($message) : ""))==0) + return("Could not send the AUTH command"); + $response=$this->GetLine(); + if(GetType($response)!="string") + return("Could not get AUTH command response"); + switch($this->Tokenize($response," ")) + { + case "+OK": + $response=""; + break; + case "+": + $response=base64_decode($this->Tokenize("\r\n")); + break; + default: + return($this->SetError("Authentication error: ".$this->Tokenize("\r\n"))); + } + for(;!$authenticated;) + { + do + { + $status=$sasl->Step($response,$message,$interactions); + } + while($status==SASL_INTERACT); + switch($status) + { + case SASL_CONTINUE: + if($this->PutLine(base64_encode($message))==0) + return("Could not send message authentication step message"); + $response=$this->GetLine(); + if(GetType($response)!="string") + return("Could not get authentication step message response"); + switch($this->Tokenize($response," ")) + { + case "+OK": + $authenticated=1; + break; + case "+": + $response=base64_decode($this->Tokenize("\r\n")); + break; + default: + return($this->SetError("Authentication error: ".$this->Tokenize("\r\n"))); + } + break; + default: + return($this->SetError("Could not process the SASL authentication step: ".$sasl->error)); + } + } + } + } + if(!$authenticated) + { + if($this->PutLine("USER $user")==0) + return($this->SetError("Could not send the USER command")); + $response=$this->GetLine(); + if(GetType($response)!="string") + return($this->SetError("Could not get user login entry response")); + if($this->Tokenize($response," ")!="+OK") + return($this->SetError("User error: ".$this->Tokenize("\r\n"))); + if($this->PutLine("PASS $password")==0) + return($this->SetError("Could not send the PASS command")); + $response=$this->GetLine(); + if(GetType($response)!="string") + return($this->SetError("Could not get login password entry response")); + if($this->Tokenize($response," ")!="+OK") + return($this->SetError("Password error: ".$this->Tokenize("\r\n"))); + } + } + $this->state="TRANSACTION"; + return(""); + } + + /* Statistics method - pass references to variables to hold the number of + messages in the mail box and the size that they take in bytes. */ + + Function Statistics(&$messages,&$size) + { + if($this->state!="TRANSACTION") + return($this->SetError("connection is not in TRANSACTION state")); + if($this->PutLine("STAT")==0) + return($this->SetError("Could not send the STAT command")); + $response=$this->GetLine(); + if(GetType($response)!="string") + return($this->SetError("Could not get the statistics command response")); + if($this->Tokenize($response," ")!="+OK") + return($this->SetError("Could not get the statistics: ".$this->Tokenize("\r\n"))); + $messages=$this->Tokenize(" "); + $size=$this->Tokenize(" "); + return(""); + } + + /* ListMessages method - the $message argument indicates the number of a + message to be listed. If you specify an empty string it will list all + messages in the mail box. The $unique_id flag indicates if you want + to list the each message unique identifier, otherwise it will + return the size of each message listed. If you list all messages the + result will be returned in an array. */ + + Function ListMessages($message,$unique_id) + { + if($this->state!="TRANSACTION") + return($this->SetError("connection is not in TRANSACTION state")); + if($unique_id) + $list_command="UIDL"; + else + $list_command="LIST"; + if($this->PutLine("$list_command".($message ? " ".$message : ""))==0) + return($this->SetError("Could not send the $list_command command")); + $response=$this->GetLine(); + if(GetType($response)!="string") + return($this->SetError("Could not get message list command response")); + if($this->Tokenize($response," ")!="+OK") + return($this->SetError("Could not get the message listing: ".$this->Tokenize("\r\n"))); + if($message=="") + { + for($messages=array();;) + { + $response=$this->GetLine(); + if(GetType($response)!="string") + return($this->SetError("Could not get message list response")); + if($response==".") + break; + $message=intval($this->Tokenize($response," ")); + if($unique_id) + $messages[$message]=$this->Tokenize(" "); + else + $messages[$message]=intval($this->Tokenize(" ")); + } + return($messages); + } + else + { + $message=intval($this->Tokenize(" ")); + $value=$this->Tokenize(" "); + return($unique_id ? $value : intval($value)); + } + } + + /* RetrieveMessage method - the $message argument indicates the number of + a message to be listed. Pass a reference variables that will hold the + arrays of the $header and $body lines. The $lines argument tells how + many lines of the message are to be retrieved. Pass a negative number + if you want to retrieve the whole message. */ + + Function RetrieveMessage($message,&$headers,&$body,$lines) + { + if($this->state!="TRANSACTION") + return($this->SetError("connection is not in TRANSACTION state")); + if($lines<0) + { + $command="RETR"; + $arguments="$message"; + } + else + { + $command="TOP"; + $arguments="$message $lines"; + } + if($this->PutLine("$command $arguments")==0) + return($this->SetError("Could not send the $command command")); + $response=$this->GetLine(); + if(GetType($response)!="string") + return($this->SetError("Could not get message retrieval command response")); + if($this->Tokenize($response," ")!="+OK") + return($this->SetError("Could not retrieve the message: ".$this->Tokenize("\r\n"))); + for($headers=$body=array(),$line=0;;) + { + $response=$this->GetLine(); + if(GetType($response)!="string") + return($this->SetError("Could not retrieve the message")); + switch($response) + { + case ".": + return(""); + case "": + break 2; + default: + if(substr($response,0,1)==".") + $response=substr($response,1,strlen($response)-1); + break; + } + if($this->join_continuation_header_lines + && $line>0 + && ($response[0]=="\t" + || $response[0]==" ")) + $headers[$line-1].=$response; + else + { + $headers[$line]=$response; + $line++; + } + } + for($line=0;;$line++) + { + $response=$this->GetLine(); + if(GetType($response)!="string") + return($this->SetError("Could not retrieve the message")); + switch($response) + { + case ".": + return(""); + default: + if(substr($response,0,1)==".") + $response=substr($response,1,strlen($response)-1); + break; + } + $body[$line]=$response; + } + return(""); + } + + /* OpenMessage method - the $message argument indicates the number of + a message to be opened. The $lines argument tells how many lines of + the message are to be retrieved. Pass a negative number if you want + to retrieve the whole message. */ + + Function OpenMessage($message, $lines=-1) + { + if($this->state!="TRANSACTION") + return($this->SetError("connection is not in TRANSACTION state")); + if($lines<0) + { + $command="RETR"; + $arguments="$message"; + } + else + { + $command="TOP"; + $arguments="$message $lines"; + } + if($this->PutLine("$command $arguments")==0) + return($this->SetError("Could not send the $command command")); + $response=$this->GetLine(); + if(GetType($response)!="string") + return($this->SetError("Could not get message retrieval command response")); + if($this->Tokenize($response," ")!="+OK") + return($this->SetError("Could not retrieve the message: ".$this->Tokenize("\r\n"))); + $this->state="GETMESSAGE"; + $this->message_buffer=""; + return(""); + } + + /* GetMessage method - the $count argument indicates the number of bytes + to be read from an opened message. The $message returns by reference + the data read from the message. The $end_of_message argument returns + by reference a boolean value indicated whether it was reached the end + of the message. */ + + Function GetMessage($count, &$message, &$end_of_message) + { + if($this->state!="GETMESSAGE") + return($this->SetError("connection is not in GETMESSAGE state")); + $message=""; + $end_of_message=0; + while($count>strlen($this->message_buffer) + && !$end_of_message) + { + $response=$this->GetLine(); + if(GetType($response)!="string") + return($this->SetError("Could not retrieve the message headers")); + if(!strcmp($response,".")) + { + $end_of_message=1; + $this->state="TRANSACTION"; + break; + } + else + { + if(substr($response,0,1)==".") + $response=substr($response,1,strlen($response)-1); + $this->message_buffer.=$response."\r\n"; + } + } + if($end_of_message + || $count>=strlen($this->message_buffer)) + { + $message=$this->message_buffer; + $this->message_buffer=""; + } + else + { + $message=substr($this->message_buffer, 0, $count); + $this->message_buffer=substr($this->message_buffer, $count); + } + return(""); + } + + /* DeleteMessage method - the $message argument indicates the number of + a message to be marked as deleted. Messages will only be effectively + deleted upon a successful call to the Close method. */ + + Function DeleteMessage($message) + { + if($this->state!="TRANSACTION") + return($this->SetError("connection is not in TRANSACTION state")); + if($this->PutLine("DELE $message")==0) + return($this->SetError("Could not send the DELE command")); + $response=$this->GetLine(); + if(GetType($response)!="string") + return($this->SetError("Could not get message delete command response")); + if($this->Tokenize($response," ")!="+OK") + return($this->SetError("Could not delete the message: ".$this->Tokenize("\r\n"))); + $this->must_update=1; + return(""); + } + + /* ResetDeletedMessages method - Reset the list of marked to be deleted + messages. No messages will be marked to be deleted upon a successful + call to this method. */ + + Function ResetDeletedMessages() + { + if($this->state!="TRANSACTION") + return($this->SetError("connection is not in TRANSACTION state")); + if($this->PutLine("RSET")==0) + return($this->SetError("Could not send the RSET command")); + $response=$this->GetLine(); + if(GetType($response)!="string") + return($this->SetError("Could not get reset deleted messages command response")); + if($this->Tokenize($response," ")!="+OK") + return($this->SetError("Could not reset deleted messages: ".$this->Tokenize("\r\n"))); + $this->must_update=0; + return(""); + } + + /* IssueNOOP method - Just pings the server to prevent it auto-close the + connection after an idle timeout (tipically 10 minutes). Not very + useful for most likely uses of this class. It's just here for + protocol support completeness. */ + + Function IssueNOOP() + { + if($this->state!="TRANSACTION") + return($this->SetError("connection is not in TRANSACTION state")); + if($this->PutLine("NOOP")==0) + return($this->SetError("Could not send the NOOP command")); + $response=$this->GetLine(); + if(GetType($response)!="string") + return($this->SetError("Could not NOOP command response")); + if($this->Tokenize($response," ")!="+OK") + return($this->SetError("Could not issue the NOOP command: ".$this->Tokenize("\r\n"))); + return(""); + } + + Function &SetConnection($set, &$current_name, &$pop3) + { + static $connections = array(); + + if($set>0) + { + $current_name = strval(count($connections)); + $connections[$current_name] = &$pop3; + } + elseif($set<0) + { + $connections[$current_name] = ''; + $current_name = ''; + } + elseif(IsSet($connections[$current_name]) + && GetType($connections[$current_name])!='string') + { + $connection = &$connections[$current_name]; + return($connection); + } + return($pop3); + } + + /* GetConnectionName method - Retrieve the name associated to an + established POP3 server connection to use as virtual host name for + use in POP3 stream wrapper URLs. */ + Function GetConnectionName(&$connection_name) + { + if($this->state!="TRANSACTION") + return($this->SetError("cannot get the name of a POP3 connection that was not established and the user has logged in")); + if(strlen($this->connection_name) == 0) + pop3_class::SetConnection(1, $this->connection_name, $this); + $connection_name = $this->connection_name; + return(''); + } +}; + +class pop3_stream +{ + var $opened = 0; + var $report_errors = 1; + var $read = 0; + var $buffer = ""; + var $end_of_message=1; + var $previous_connection = 0; + var $pop3; + + Function SetError($error) + { + if($this->report_errors) + trigger_error($error); + return(FALSE); + } + + Function ParsePath($path, &$url) + { + if(!$this->previous_connection) + { + if(IsSet($url["host"])) + $this->pop3->hostname=$url["host"]; + if(IsSet($url["port"])) + $this->pop3->port=intval($url["port"]); + if(IsSet($url["scheme"]) + && !strcmp($url["scheme"],"pop3s")) + $this->pop3->tls=1; + if(!IsSet($url["user"])) + return($this->SetError("it was not specified a valid POP3 user")); + if(!IsSet($url["pass"])) + return($this->SetError("it was not specified a valid POP3 password")); + if(!IsSet($url["path"])) + return($this->SetError("it was not specified a valid mailbox path")); + } + if(IsSet($url["query"])) + { + parse_str($url["query"],$query); + if(IsSet($query["debug"])) + $this->pop3->debug = intval($query["debug"]); + if(IsSet($query["html_debug"])) + $this->pop3->html_debug = intval($query["html_debug"]); + if(!$this->previous_connection) + { + if(IsSet($query["tls"])) + $this->pop3->tls = intval($query["tls"]); + if(IsSet($query["realm"])) + $this->pop3->realm = UrlDecode($query["realm"]); + if(IsSet($query["workstation"])) + $this->pop3->workstation = UrlDecode($query["workstation"]); + if(IsSet($query["authentication_mechanism"])) + $this->pop3->realm = UrlDecode($query["authentication_mechanism"]); + } + if(IsSet($query["quit_handshake"])) + $this->pop3->quit_handshake = intval($query["quit_handshake"]); + } + return(TRUE); + } + + Function stream_open($path, $mode, $options, &$opened_path) + { + $this->report_errors = (($options & STREAM_REPORT_ERRORS) !=0); + if(strcmp($mode, "r")) + return($this->SetError("the message can only be opened for reading")); + $url=parse_url($path); + $host = $url['host']; + $pop3 = &pop3_class::SetConnection(0, $host, $this->pop3); + if(IsSet($pop3)) + { + $this->pop3 = &$pop3; + $this->previous_connection = 1; + } + else + $this->pop3=new pop3_class; + if(!$this->ParsePath($path, $url)) + return(FALSE); + $message=substr($url["path"],1); + if(strcmp(intval($message), $message) + || $message<=0) + return($this->SetError("it was not specified a valid message to retrieve")); + if(!$this->previous_connection) + { + if(strlen($error=$this->pop3->Open())) + return($this->SetError($error)); + $this->opened = 1; + $apop = (IsSet($url["query"]["apop"]) ? intval($url["query"]["apop"]) : 0); + if(strlen($error=$this->pop3->Login(UrlDecode($url["user"]), UrlDecode($url["pass"]),$apop))) + { + $this->stream_close(); + return($this->SetError($error)); + } + } + if(strlen($error=$this->pop3->OpenMessage($message,-1))) + { + $this->stream_close(); + return($this->SetError($error)); + } + $this->end_of_message=FALSE; + if($options & STREAM_USE_PATH) + $opened_path=$path; + $this->read = 0; + $this->buffer = ""; + return(TRUE); + } + + Function stream_eof() + { + if($this->read==0) + return(FALSE); + return($this->end_of_message); + } + + Function stream_read($count) + { + if($count<=0) + return($this->SetError("it was not specified a valid length of the message to read")); + if($this->end_of_message) + return(""); + if(strlen($error=$this->pop3->GetMessage($count, $read, $this->end_of_message))) + return($this->SetError($error)); + $this->read += strlen($read); + return($read); + } + + Function stream_close() + { + while(!$this->end_of_message) + $this->stream_read(8000); + if($this->opened) + { + $this->pop3->Close(); + $this->opened = 0; + } + } +}; + +?> \ No newline at end of file diff --git a/includes/pop3/rfc822_addresses.php b/includes/pop3/rfc822_addresses.php new file mode 100644 index 0000000000..293c789ce6 --- /dev/null +++ b/includes/pop3/rfc822_addresses.php @@ -0,0 +1,903 @@ + + + + net.manuellemos.mimeparser + + @(#) $Id: rfc822_addresses.php,v 1.13 2010/04/08 20:09:23 mlemos Exp $ + Copyright (C) Manuel Lemos 2006 - 2008 + RFC 822 e-mail addresses parser + Manuel Lemos + mlemos-at-acm.org + + + en + Parse e-mail addresses from headers of + http://www.ietf.org/rfc/rfc822.txt + RFC 822 + compliant e-mail messages. + Use the function ParseAddressList + function to retrieve the list of e-mail addresses contained in + e-mail message headers like From, To, Cc + or Bcc. + + +{/metadocument} +*/ + +class rfc822_addresses_class +{ + /* Private variables */ + + var $v = ''; + + /* Public variables */ + +/* +{metadocument} + + error + STRING + + + Store the message that is returned when an error + occurs. + Check this variable to understand what happened when a call to + any of the class functions has failed. + This class uses cumulative error handling. This means that if one + class functions that may fail is called and this variable was + already set to an error message due to a failure in a previous call + to the same or other function, the function will also fail and does + not do anything. + This allows programs using this class to safely call several + functions that may fail and only check the failure condition after + the last function call. + Just set this variable to an empty string to clear the error + condition. + + +{/metadocument} +*/ + var $error = ''; + +/* +{metadocument} + + error_position + INTEGER + -1 + + Point to the position of the message data or file that + refers to the last error that occurred. + Check this variable to determine the relevant position of the + message when a parsing error occurs. + + +{/metadocument} +*/ + var $error_position = -1; + +/* +{metadocument} + + ignore_syntax_errors + BOOLEAN + 1 + + Specify whether the class should ignore syntax errors in + malformed addresses. + Set this variable to 0 if it is + necessary to verify whether message data may be corrupted due to + to eventual bugs in the program that generated the + message. + Currently the class only ignores some types of syntax errors. + Other syntax errors may still cause the + ParseAddressList to fail. + + +{/metadocument} +*/ + var $ignore_syntax_errors=1; + +/* +{metadocument} + + warnings + HASH + + + Return a list of positions of the original message that + contain syntax errors. + Check this variable to retrieve eventual message syntax + errors that were ignored when the + ignore_syntax_errors is set to + 1. + The indexes of this array are the positions of the errors. The + array values are the corresponding syntax error messages. + + +{/metadocument} +*/ + var $warnings=array(); + + /* Private functions */ + + Function SetError($error) + { + $this->error = $error; + return(0); + } + + Function SetPositionedError($error, $position) + { + $this->error_position = $position; + return($this->SetError($error)); + } + + Function SetWarning($warning, $position) + { + $this->warnings[$position]=$warning; + return(1); + } + + Function SetPositionedWarning($error, $position) + { + if(!$this->ignore_syntax_errors) + return($this->SetPositionedError($error, $position)); + return($this->SetWarning($error, $position)); + } + + Function QDecode($p, &$value, &$encoding) + { + $encoding = $charset = null; + $s = 0; + $decoded = ''; + $l = strlen($value); + while($s < $l) + { + if(GetType($q = strpos($value, '=?', $s)) != 'integer') + { + if($s == 0) + return(1); + if($s < $l) + $decoded .= substr($value, $s); + break; + } + if($s < $q) + $decoded .= substr($value, $s, $q - $s); + $q += 2; + if(GetType($c = strpos($value, '?', $q)) != 'integer' + || $q == $c) + return($this->SetPositionedWarning('invalid Q-encoding character set', $p + $q)); + if(IsSet($charset)) + { + $another_charset = strtolower(substr($value, $q, $c - $q)); + if(strcmp($charset, $another_charset) + && strcmp($another_charset, 'ascii')) + return($this->SetWarning('it is not possible to decode an encoded value using mixed character sets into a single value', $p + $q)); + } + else + { + $charset = strtolower(substr($value, $q, $c - $q)); + if(!strcmp($charset, 'ascii')) + $charset = null; + } + ++$c; + if(GetType($t = strpos($value, '?', $c)) != 'integer' + || $c==$t) + return($this->SetPositionedWarning('invalid Q-encoding type', $p + $c)); + $type = strtolower(substr($value, $c, $t - $c)); + ++$t; + if(GetType($e = strpos($value, '?=', $t)) != 'integer') + return($this->SetPositionedWarning('invalid Q-encoding encoded data', $p + $e)); + switch($type) + { + case 'q': + for($s = $t; $s<$e;) + { + switch($b = $value[$s]) + { + case '=': + $h = HexDec($hex = strtolower(substr($value, $s + 1, 2))); + if($s + 3 > $e + || strcmp(sprintf('%02x', $h), $hex)) + return($this->SetPositionedWarning('invalid Q-encoding q encoded data', $p + $s)); + $decoded .= chr($h); + $s += 3; + break; + + case '_': + $decoded .= ' '; + ++$s; + break; + + default: + $decoded .= $b; + ++$s; + } + } + break; + + case 'b': + if($e <= $t + || strlen($binary = base64_decode($data = substr($value, $t, $e - $t))) == 0 + || GetType($binary) != 'string') + return($this->SetPositionedWarning('invalid Q-encoding b encoded data', $p + $t)); + $decoded .= $binary; + $s = $e; + break; + + default: + return($this->SetPositionedWarning('Q-encoding '.$type.' is not yet supported', $p + $c)); + } + $s += 2; + } + $value = $decoded; + $encoding = $charset; + return(1); + } + + Function ParseCText(&$p, &$c_text) + { + $c_text = null; + $v = $this->v; + if($pv; + if($p>strlen($v) + || GetType(strchr("\t\r\n \"\\\0", $c = $v[$p])) == 'string') + return(1); + if(Ord($c) >= 128) + { + if(!$this->ignore_syntax_errors) + return(1); + $this->SetPositionedWarning('it was used an unencoded 8 bit character', $p); + } + $q_text = $c; + ++$p; + return(1); + } + + Function ParseQuotedPair(&$p, &$quoted_pair) + { + $quoted_pair = null; + $v = $this->v; + $l = strlen($v); + if($p+1 < $l + && !strcmp($v[$p], '\\') + && GetType(strchr("\r\n\0", $c = $v[$p + 1])) != 'string' + && Ord($c)<128) + { + $quoted_pair = $c; + $p += 2; + } + return(1); + } + + Function ParseCContent(&$p, &$c_content) + { + $c_content = null; + $c = $p; + if(!$this->ParseQuotedPair($c, $content)) + return(0); + if(!IsSet($content)) + { + if(!$this->ParseCText($c, $content)) + return(0); + if(!IsSet($content)) + { + if(!$this->ParseComment($c, $content)) + return(0); + if(!IsSet($content)) + return(1); + } + } + $c_content = $content; + $p = $c; + return(1); + } + + Function SkipWhiteSpace(&$p) + { + $v = $this->v; + $l = strlen($v); + for(;$p<$l; ++$p) + { + switch($v[$p]) + { + case ' ': + case "\n": + case "\r": + case "\t": + break; + default: + return(1); + } + } + return(1); + } + + Function ParseComment(&$p, &$comment) + { + $comment = null; + $v = $this->v; + $l = strlen($v); + $c = $p; + if($c >= $l + || strcmp($v[$c], '(')) + return(1); + ++$c; + for(; $c < $l;) + { + if(!$this->SkipWhiteSpace($c)) + return(0); + if(!$this->ParseCContent($c, $c_content)) + return(0); + if(!IsSet($c_content)) + break; + } + if(!$this->SkipWhiteSpace($c)) + return(0); + if($c >= $l + || strcmp($v[$c], ')')) + return(1); + ++$c; + $comment = substr($v, $p, $c - $p); + $p = $c; + return(1); + } + + Function SkipCommentGetWhiteSpace(&$p, &$space) + { + $v = $this->v; + $l = strlen($v); + for($space = '';$p<$l;) + { + switch($w = $v[$p]) + { + case ' ': + case "\n": + case "\r": + case "\t": + ++$p; + $space .= $w; + break; + case '(': + if(!$this->ParseComment($p, $comment)) + return(0); + default: + return(1); + } + } + return(1); + } + + Function SkipCommentWhiteSpace(&$p) + { + $v = $this->v; + $l = strlen($v); + for(;$p<$l;) + { + switch($w = $v[$p]) + { + case ' ': + case "\n": + case "\r": + case "\t": + ++$p; + break; + case '(': + if(!$this->ParseComment($p, $comment)) + return(0); + default: + return(1); + } + } + return(1); + } + + Function ParseQContent(&$p, &$q_content) + { + $q_content = null; + $q = $p; + if(!$this->ParseQuotedPair($q, $content)) + return(0); + if(!IsSet($content)) + { + if(!$this->ParseQText($q, $content)) + return(0); + if(!IsSet($content)) + return(1); + } + $q_content = $content; + $p = $q; + return(1); + } + + Function ParseAtom(&$p, &$atom, $dot) + { + $atom = null; + $v = $this->v; + $l = strlen($v); + $a = $p; + if(!$this->SkipCommentGetWhiteSpace($a, $space)) + return(0); + $match = '/^([-'.($dot ? '.' : '').'A-Za-z0-9!#$&\'*+\\/=?^_{|}~]+)/'; + for($s = $a;$a < $l;) + { + if(preg_match($match, substr($this->v, $a), $m)) + $a += strlen($m[1]); + elseif(Ord($v[$a]) < 128) + break; + elseif(!$this->SetPositionedWarning('it was used an unencoded 8 bit character', $a)) + return(0); + else + ++$a; + } + if($s == $a) + return(1); + $atom = $space.substr($this->v, $s, $a - $s); + if(!$this->SkipCommentGetWhiteSpace($a, $space)) + return(0); + $atom .= $space; + $p = $a; + return(1); + } + + Function ParseQuotedString(&$p, &$quoted_string) + { + $quoted_string = null; + $v = $this->v; + $l = strlen($v); + $s = $p; + if(!$this->SkipCommentWhiteSpace($s)) + return(0); + if($s >= $l + || strcmp($v[$s], '"')) + return(1); + ++$s; + for($string = '';$s < $l;) + { + $w = $s; + if(!$this->SkipWhiteSpace($s)) + return(0); + if($w != $s) + $string .= substr($v, $w, $s - $w); + if(!$this->ParseQContent($s, $q_content)) + return(0); + if(!IsSet($q_content)) + break; + $string .= $q_content; + } + $w = $s; + if(!$this->SkipWhiteSpace($s)) + return(0); + if($w != $s) + $string .= substr($v, $w, $s - $w); + if($s >= $l + || strcmp($v[$s], '"')) + return(1); + ++$s; + if(!$this->SkipCommentWhiteSpace($s)) + return(0); + $quoted_string = $string; + $p = $s; + return(1); + } + + Function ParseWord(&$p, &$word) + { + $word = null; + if(!$this->ParseQuotedString($p, $word)) + return(0); + if(IsSet($word)) + return(1); + if(!$this->ParseAtom($p, $word, 0)) + return(0); + return(1); + } + + Function ParseObsPhrase(&$p, &$obs_phrase) + { + $obs_phrase = null; + $v = $this->v; + $l = strlen($v); + $ph = $p; + if(!$this->ParseWord($ph, $word)) + return(0); + $string = $word; + for(;;) + { + if(!$this->ParseWord($ph, $word)) + return(0); + if(IsSet($word)) + { + $string .= $word; + continue; + } + $w = $ph; + if(!$this->SkipCommentGetWhiteSpace($ph, $space)) + return(0); + if($w != $ph) + { + $string .= $space; + continue; + } + if($ph >= $l + || strcmp($v[$ph], '.')) + break; + $string .= '.'; + ++$ph; + } + $obs_phrase = $string; + $p = $ph; + return(1); + } + + Function ParsePhrase(&$p, &$phrase) + { + $phrase = null; + if(!$this->ParseObsPhrase($p, $phrase)) + return(0); + if(IsSet($phrase)) + return(1); + $ph = $p; + if(!$this->ParseWord($ph, $word)) + return(0); + $string = $word; + for(;;) + { + if(!$this->ParseWord($ph, $word)) + return(0); + if(!IsSet($word)) + break; + $string .= $word; + } + $phrase = $string; + $p = $ph; + return(1); + } + + Function ParseAddrSpec(&$p, &$addr_spec) + { + $addr_spec = null; + $v = $this->v; + $l = strlen($v); + $a = $p; + if(!$this->ParseQuotedString($a, $local_part)) + return(0); + if(!IsSet($local_part)) + { + if(!$this->ParseAtom($a, $local_part, 1)) + return(0); + $local_part = trim($local_part); + } + if($a >= $l + || strcmp($v[$a], '@')) + return(1); + ++$a; + if(!$this->ParseAtom($a, $domain, 1)) + return(0); + if(!IsSet($domain)) + return(1); + $addr_spec = $local_part.'@'.trim($domain); + $p = $a; + return(1); + } + + Function ParseAngleAddr(&$p, &$addr) + { + $addr = null; + $v = $this->v; + $l = strlen($v); + $a = $p; + if(!$this->SkipCommentWhiteSpace($a)) + return(0); + if($a >= $l + || strcmp($v[$a], '<')) + return(1); + ++$a; + if(!$this->ParseAddrSpec($a, $addr_spec)) + return(0); + if($a >= $l + || strcmp($v[$a], '>')) + return(1); + ++$a; + if(!$this->SkipCommentWhiteSpace($a)) + return(0); + $addr = $addr_spec; + $p = $a; + return(1); + } + + Function ParseName(&$p, &$address) + { + $address = null; + $a = $p; + if(!$this->ParsePhrase($a, $display_name)) + return(0); + if(IsSet($display_name)) + { + if(!$this->QDecode($p, $display_name, $encoding)) + return(0); + $address['name'] = trim($display_name); + if(IsSet($encoding)) + $address['encoding'] = $encoding; + } + $p = $a; + return(1); + } + + Function ParseNameAddr(&$p, &$address) + { + $address = null; + $a = $p; + if(!$this->ParsePhrase($a, $display_name)) + return(0); + if(!$this->ParseAngleAddr($a, $addr)) + return(0); + if(!IsSet($addr)) + return(1); + $address = array('address'=>$addr); + if(IsSet($display_name)) + { + if(!$this->QDecode($p, $display_name, $encoding)) + return(0); + $address['name'] = trim($display_name); + if(IsSet($encoding)) + $address['encoding'] = $encoding; + } + $p = $a; + return(1); + } + + Function ParseAddrNameAddr(&$p, &$address) + { + $address = null; + $a = $p; + if(!$this->ParseAddrSpec($a, $display_name)) + return(0); + if(!IsSet($display_name)) + return(1); + if(!$this->ParseAngleAddr($a, $addr)) + return(0); + if(!IsSet($addr)) + return(1); + if(!$this->QDecode($p, $display_name, $encoding)) + return(0); + $address = array( + 'address'=>$addr, + 'name' => trim($display_name) + ); + if(IsSet($encoding)) + $address['encoding'] = $encoding; + $p = $a; + return(1); + } + + Function ParseMailbox(&$p, &$address) + { + $address = null; + if($this->ignore_syntax_errors) + { + $a = $p; + if(!$this->ParseAddrNameAddr($p, $address)) + return(0); + if(IsSet($address)) + return($this->SetPositionedWarning('it was specified an unquoted address as name', $a)); + } + if(!$this->ParseNameAddr($p, $address)) + return(0); + if(IsSet($address)) + return(1); + if(!$this->ParseAddrSpec($p, $addr_spec)) + return(0); + if(IsSet($addr_spec)) + { + $address = array('address'=>$addr_spec); + return(1); + } + $a = $p; + if($this->ignore_syntax_errors + && $this->ParseName($p, $address) + && IsSet($address)) + return($this->SetPositionedWarning('it was specified a name without an address', $a)); + return(1); + } + + Function ParseMailboxGroup(&$p, &$mailbox_group) + { + $v = $this->v; + $l = strlen($v); + $g = $p; + if(!$this->ParseMailbox($g, $address)) + return(0); + if(!IsSet($address)) + return(1); + $addresses = array($address); + for(;$g < $l;) + { + if(strcmp($v[$g], ',')) + break; + ++$g; + if(!$this->ParseMailbox($g, $address)) + return(0); + if(!IsSet($address)) + return(1); + $addresses[] = $address; + } + $mailbox_group = $addresses; + $p = $g; + return(1); + } + + Function ParseGroup(&$p, &$address) + { + $address = null; + $v = $this->v; + $l = strlen($v); + $g = $p; + if(!$this->ParsePhrase($g, $display_name)) + return(0); + if(!IsSet($display_name) + || $g >= $l + || strcmp($v[$g], ':')) + return(1); + ++$g; + if(!$this->ParseMailboxGroup($g, $mailbox_group)) + return(0); + if(!IsSet($mailbox_group)) + { + if(!$this->SkipCommentWhiteSpace($g)) + return(0); + $mailbox_group = array(); + } + if($g >= $l + || strcmp($v[$g], ';')) + return(1); + $c = ++$g; + if($this->SkipCommentWhiteSpace($g) + && $g > $c + && !$this->SetPositionedWarning('it were used invalid comments after a group of addresses', $c)) + return(0); + if(!$this->QDecode($p, $display_name, $encoding)) + return(0); + $address = array( + 'name'=>$display_name, + 'group'=>$mailbox_group + ); + if(IsSet($encoding)) + $address['encoding'] = $encoding; + $p = $g; + return(1); + } + + Function ParseAddress(&$p, &$address) + { + $address = null; + if(!$this->ParseGroup($p, $address)) + return(0); + if(!IsSet($address)) + { + if(!$this->ParseMailbox($p, $address)) + return(0); + } + return(1); + } + + /* Public functions */ + +/* +{metadocument} + + ParseAddressList + BOOLEAN + + Parse and extract e-mail addresses eventually from headers + of an e-mail message. + Pass a string value with a list of e-mail addresses to the + + ParseAddressList + value + . The + ParseAddressList + addresses + returns the list of e-mail addresses found. + This function returns 1 if + the specified value is parsed successfully. Otherwise, + check the variables error and + error_position to determine what + error occurred and the relevant value position. + + + value + STRING + + String with a list of e-mail addresses to parse. + + + + addresses + ARRAY + + + Return the list of parsed e-mail addresses. + Each entry in the list is an associative array. + For normal addresses, this associative array has the entry + address set to the e-mail address. + If the address has an associated name, it is stored in the + entry name. + For address groups, there is the entry + name. + The group addresses list are stored in the entry + group as an array. The structure of + the group addresses list array is the same as this addresses + list array argument. + + + +{/metadocument} +*/ + Function ParseAddressList($value, &$addresses) + { + $this->warnings = array(); + $addresses = array(); + $this->v = $v = $value; + $l = strlen($v); + $p = 0; + if(!$this->ParseAddress($p, $address)) + return(0); + if(!IsSet($address)) + return($this->SetPositionedError('it was not specified a valid address', $p)); + $addresses[] = $address; + while($p < $l) + { + if(strcmp($v[$p], ',') + && !$this->SetPositionedWarning('multiple addresses must be separated by commas: ', $p)) + return(0); + ++$p; + if(!$this->ParseAddress($p, $address)) + return(0); + if(!IsSet($address)) + return($this->SetPositionedError('it was not specified a valid address after comma', $p)); + $addresses[] = $address; + } + return(1); + } +/* +{metadocument} + + +{/metadocument} +*/ + +}; + +/* + +{metadocument} + +{/metadocument} + +*/ + +?> \ No newline at end of file diff --git a/includes/qr/qrcode.php b/includes/qr/qrcode.php new file mode 100644 index 0000000000..e36e6aa2e3 --- /dev/null +++ b/includes/qr/qrcode.php @@ -0,0 +1,1470 @@ +typeNumber = 1; + $this->errorCorrectLevel = QR_ERROR_CORRECT_LEVEL_H; + $this->qrDataList = array(); + } + + function getTypeNumber() { + return $this->typeNumber; + } + + function setTypeNumber($typeNumber) { + $this->typeNumber = $typeNumber; + } + + function getErrorCorrectLevel() { + return $this->errorCorrectLevel; + } + + function setErrorCorrectLevel($errorCorrectLevel) { + $this->errorCorrectLevel = $errorCorrectLevel; + } + + function addData($data, $mode = 0) { + + if ($mode == 0) { + $mode = QRUtil::getMode($data); + } + + switch($mode) { + case QR_MODE_NUMBER : + $this->addDataImpl(new QRNumber($data) ); + break; + + case QR_MODE_ALPHA_NUM : + $this->addDataImpl(new QRAlphaNum($data) ); + break; + + case QR_MODE_8BIT_BYTE : + $this->addDataImpl(new QR8BitByte($data) ); + break; + + case QR_MODE_KANJI : + $this->addDataImpl(new QRKanji($data) ); + break; + + default : + trigger_error("mode:$mode", E_USER_ERROR); + } + } + + function clearData() { + $qrDataList = array(); + } + + function addDataImpl(&$qrData) { + $this->qrDataList[] = $qrData; + } + + function getDataCount() { + return count($this->qrDataList); + } + + function getData($index) { + return $this->qrDataList[$index]; + } + + function isDark($row, $col) { + if ($this->modules[$row][$col] !== null) { + return $this->modules[$row][$col]; + } else { + return false; + } + } + + function getModuleCount() { + return $this->moduleCount; + } + + function make() { + $this->makeImpl(false, $this->getBestMaskPattern() ); + } + + function getBestMaskPattern() { + $minLostPoint = 0; + $pattern = 0; + for ($i = 0; $i < 8; $i++) { + $this->makeImpl(true, $i); + $lostPoint = QRUtil::getLostPoint($this); + if ($i == 0 || $minLostPoint > $lostPoint) { + $minLostPoint = $lostPoint; + $pattern = $i; + } + } + return $pattern; + } + + function createNullArray($length) { + $nullArray = array(); + for ($i = 0; $i < $length; $i++) { + $nullArray[] = null; + } + return $nullArray; + } + + function makeImpl($test, $maskPattern) { + $this->moduleCount = $this->typeNumber * 4 + 17; + + $this->modules = array(); + for ($i = 0; $i < $this->moduleCount; $i++) { + $this->modules[] = QRCode::createNullArray($this->moduleCount); + } + + $this->setupPositionProbePattern(0, 0); + $this->setupPositionProbePattern($this->moduleCount - 7, 0); + $this->setupPositionProbePattern(0, $this->moduleCount - 7); + $this->setupPositionAdjustPattern(); + $this->setupTimingPattern(); + $this->setupTypeInfo($test, $maskPattern); + if ($this->typeNumber >= 7) { + $this->setupTypeNumber($test); + } + $dataArray = $this->qrDataList; + + $data = QRCode::createData($this->typeNumber, $this->errorCorrectLevel, $dataArray); + + $this->mapData($data, $maskPattern); + } + + function mapData(&$data, $maskPattern) { + + $inc = -1; + $row = $this->moduleCount - 1; + $bitIndex = 7; + $byteIndex = 0; + + for ($col = $this->moduleCount - 1; $col > 0; $col -= 2) { + if ($col == 6) $col--; + while (true) { + for ($c = 0; $c < 2; $c++) { + if ($this->modules[$row][$col - $c] === null) { + $dark = false; + if ($byteIndex < count($data) ) { + $dark = ( ( ($data[$byteIndex] >> $bitIndex) & 1) == 1); + } + + $mask = QRUtil::getMask($maskPattern, $row, $col - $c); + + if ($mask) { + $dark = !$dark; + } + + $this->modules[$row][$col - $c] = $dark; + $bitIndex--; + + if ($bitIndex == -1) { + $byteIndex++; + $bitIndex = 7; + } + } + } + $row += $inc; + + if ($row < 0 || $this->moduleCount <= $row) { + $row -= $inc; + $inc = -$inc; + break; + } + } + } + } + + function setupPositionAdjustPattern() { + $pos = QRUtil::getPatternPosition($this->typeNumber); + for ($i = 0; $i < count($pos); $i++) { + for ($j = 0; $j < count($pos); $j++) { + $row = $pos[$i]; + $col = $pos[$j]; + + if ($this->modules[$row][$col] !== null) { + continue; + } + + for ($r = -2; $r <= 2; $r++) { + for ($c = -2; $c <= 2; $c++) { + if ($r == -2 || $r == 2 || $c == -2 || $c == 2 + || ($r == 0 && $c == 0) ) { + $this->modules[$row + $r][$col + $c] = true; + } else { + $this->modules[$row + $r][$col + $c] = false; + } + } + } + } + } + } + + function setupPositionProbePattern($row, $col) { + + for ($r = -1; $r <= 7; $r++) { + + for ($c = -1; $c <= 7; $c++) { + + if ($row + $r <= -1 || $this->moduleCount <= $row + $r + || $col + $c <= -1 || $this->moduleCount <= $col + $c) { + continue; + } + + if ( (0 <= $r && $r <= 6 && ($c == 0 || $c == 6) ) + || (0 <= $c && $c <= 6 && ($r == 0 || $r == 6) ) + || (2 <= $r && $r <= 4 && 2 <= $c && $c <= 4) ) { + $this->modules[$row + $r][$col + $c] = true; + } else { + $this->modules[$row + $r][$col + $c] = false; + } + } + } + } + + function setupTimingPattern() { + + for ($r = 8; $r < $this->moduleCount - 8; $r++) { + if ($this->modules[$r][6] !== null) { + continue; + } + $this->modules[$r][6] = ($r % 2 == 0); + } + + for ($c = 8; $c < $this->moduleCount - 8; $c++) { + if ($this->modules[6][$c] !== null) { + continue; + } + $this->modules[6][$c] = ($c % 2 == 0); + } + } + + function setupTypeNumber($test) { + + $bits = QRUtil::getBCHTypeNumber($this->typeNumber); + + for ($i = 0; $i < 18; $i++) { + $mod = (!$test && ( ($bits >> $i) & 1) == 1); + $this->modules[floor($i / 3)][$i % 3 + $this->moduleCount - 8 - 3] = $mod; + } + + for ($i = 0; $i < 18; $i++) { + $mod = (!$test && ( ($bits >> $i) & 1) == 1); + $this->modules[$i % 3 + $this->moduleCount - 8 - 3][floor($i / 3)] = $mod; + } + } + + function setupTypeInfo($test, $maskPattern) { + + $data = ($this->errorCorrectLevel << 3) | $maskPattern; + $bits = QRUtil::getBCHTypeInfo($data); + + for ($i = 0; $i < 15; $i++) { + + $mod = (!$test && ( ($bits >> $i) & 1) == 1); + + if ($i < 6) { + $this->modules[$i][8] = $mod; + } else if ($i < 8) { + $this->modules[$i + 1][8] = $mod; + } else { + $this->modules[$this->moduleCount - 15 + $i][8] = $mod; + } + } + + for ($i = 0; $i < 15; $i++) { + + $mod = (!$test && ( ($bits >> $i) & 1) == 1); + + if ($i < 8) { + $this->modules[8][$this->moduleCount - $i - 1] = $mod; + } else if ($i < 9) { + $this->modules[8][15 - $i - 1 + 1] = $mod; + } else { + $this->modules[8][15 - $i - 1] = $mod; + } + } + + $this->modules[$this->moduleCount - 8][8] = !$test; + } + + function createData($typeNumber, $errorCorrectLevel, $dataArray) { + + $rsBlocks = QRRSBlock::getRSBlocks($typeNumber, $errorCorrectLevel); + + $buffer = new QRBitBuffer(); + + for ($i = 0; $i < count($dataArray); $i++) { + $data = $dataArray[$i]; + $buffer->put($data->getMode(), 4); + $buffer->put($data->getLength(), $data->getLengthInBits($typeNumber) ); + $data->write($buffer); + } + + $totalDataCount = 0; + for ($i = 0; $i < count($rsBlocks); $i++) { + $totalDataCount += $rsBlocks[$i]->getDataCount(); + } +/* + if ($buffer->getLengthInBits() > $totalDataCount * 8) { + trigger_error("code length overflow. (" + . $buffer->getLengthInBits() + . ">" + . $totalDataCount * 8 + . ")", E_USER_ERROR); + } +*/ + // end code. + if ($buffer->getLengthInBits() + 4 <= $totalDataCount * 8) { + $buffer->put(0, 4); + } + + // padding + while ($buffer->getLengthInBits() % 8 != 0) { + $buffer->putBit(false); + } + + // padding + while (true) { + + if ($buffer->getLengthInBits() >= $totalDataCount * 8) { + break; + } + $buffer->put(QR_PAD0, 8); + + if ($buffer->getLengthInBits() >= $totalDataCount * 8) { + break; + } + $buffer->put(QR_PAD1, 8); + } + + return QRCode::createBytes($buffer, $rsBlocks); + } + + function createBytes(&$buffer, &$rsBlocks) { + + $offset = 0; + + $maxDcCount = 0; + $maxEcCount = 0; + + $dcdata = QRCode::createNullArray(count($rsBlocks) ); + $ecdata = QRCode::createNullArray(count($rsBlocks) ); + + for ($r = 0; $r < count($rsBlocks); $r++) { + + $dcCount = $rsBlocks[$r]->getDataCount(); + $ecCount = $rsBlocks[$r]->getTotalCount() - $dcCount; + + $maxDcCount = max($maxDcCount, $dcCount); + $maxEcCount = max($maxEcCount, $ecCount); + + $dcdata[$r] = QRCode::createNullArray($dcCount); + for ($i = 0; $i < count($dcdata[$r]); $i++) { + $bdata = $buffer->getBuffer(); + $dcdata[$r][$i] = 0xff & $bdata[$i + $offset]; + } + $offset += $dcCount; + + $rsPoly = QRUtil::getErrorCorrectPolynomial($ecCount); + $rawPoly = new QRPolynomial($dcdata[$r], $rsPoly->getLength() - 1); + + $modPoly = $rawPoly->mod($rsPoly); + $ecdata[$r] = QRCode::createNullArray($rsPoly->getLength() - 1); + for ($i = 0; $i < count($ecdata[$r]); $i++) { + $modIndex = $i + $modPoly->getLength() - count($ecdata[$r]); + $ecdata[$r][$i] = ($modIndex >= 0)? $modPoly->get($modIndex) : 0; + } + } + + $totalCodeCount = 0; + for ($i = 0; $i < count($rsBlocks); $i++) { + $totalCodeCount += $rsBlocks[$i]->getTotalCount(); + } + + $data = QRCode::createNullArray($totalCodeCount); + + $index = 0; + + for ($i = 0; $i < $maxDcCount; $i++) { + for ($r = 0; $r < count($rsBlocks); $r++) { + if ($i < count($dcdata[$r]) ) { + $data[$index++] = $dcdata[$r][$i]; + } + } + } + + for ($i = 0; $i < $maxEcCount; $i++) { + for ($r = 0; $r < count($rsBlocks); $r++) { + if ($i < count($ecdata[$r]) ) { + $data[$index++] = $ecdata[$r][$i]; + } + } + } + + return $data; + } + + function getMinimumQRCode($data, $errorCorrectLevel) { + + $mode = QRUtil::getMode($data); + + $qr = new QRCode(); + $qr->setErrorCorrectLevel($errorCorrectLevel); + $qr->addData($data, $mode); + + $qrData = $qr->getData(0); + $length = $qrData->getLength(); + + for ($typeNumber = 1; $typeNumber <= 10; $typeNumber++) { + if ($length <= QRUtil::getMaxLength($typeNumber, $mode, $errorCorrectLevel) ) { + $qr->setTypeNumber($typeNumber); + break; + } + } + + $qr->make(); + + return $qr; + } + + function createImage($size = 2, $margin = 2) { + + $image_size = $this->getModuleCount() * $size + $margin * 2; + + $image = imagecreatetruecolor($image_size, $image_size); + + $black = imagecolorallocate($image, 0, 0, 0); + $white = imagecolorallocate($image, 255, 255, 255); + + imagefilledrectangle($image, 0, 0, $image_size, $image_size, $white); + + for ($r = 0; $r < $this->getModuleCount(); $r++) { + for ($c = 0; $c < $this->getModuleCount(); $c++) { + if ($this->isDark($r, $c) ) { + + imagefilledrectangle($image, + $margin + $c * $size, + $margin + $r * $size, + $margin + ($c + 1) * $size - 1, + $margin + ($r + 1) * $size - 1, + $black); + } + } + } + + return $image; + } + + + function printHTML($size = "2px") { + + $style = "border-style:none;border-collapse:collapse;margin:0px;padding:0px;"; + + print(""); + + for ($r = 0; $r < $this->getModuleCount(); $r++) { + + print(""); + + for ($c = 0; $c < $this->getModuleCount(); $c++) { + $color = $this->isDark($r, $c)? "#000000" : "#ffffff"; + print(""); + } + + print(""); + } + + print("
    "); + } +} + +//--------------------------------------------------------------- +// QRUtil +//--------------------------------------------------------------- + +$QR_PATTERN_POSITION_TABLE = array( + array(), + array(6, 18), + array(6, 22), + array(6, 26), + array(6, 30), + array(6, 34), + array(6, 22, 38), + array(6, 24, 42), + array(6, 26, 46), + array(6, 28, 50), + array(6, 30, 54), + array(6, 32, 58), + array(6, 34, 62), + array(6, 26, 46, 66), + array(6, 26, 48, 70), + array(6, 26, 50, 74), + array(6, 30, 54, 78), + array(6, 30, 56, 82), + array(6, 30, 58, 86), + array(6, 34, 62, 90), + array(6, 28, 50, 72, 94), + array(6, 26, 50, 74, 98), + array(6, 30, 54, 78, 102), + array(6, 28, 54, 80, 106), + array(6, 32, 58, 84, 110), + array(6, 30, 58, 86, 114), + array(6, 34, 62, 90, 118), + array(6, 26, 50, 74, 98, 122), + array(6, 30, 54, 78, 102, 126), + array(6, 26, 52, 78, 104, 130), + array(6, 30, 56, 82, 108, 134), + array(6, 34, 60, 86, 112, 138), + array(6, 30, 58, 86, 114, 142), + array(6, 34, 62, 90, 118, 146), + array(6, 30, 54, 78, 102, 126, 150), + array(6, 24, 50, 76, 102, 128, 154), + array(6, 28, 54, 80, 106, 132, 158), + array(6, 32, 58, 84, 110, 136, 162), + array(6, 26, 54, 82, 110, 138, 166), + array(6, 30, 58, 86, 114, 142, 170) +); + +$QR_MAX_LENGTH = array( + array( array(41, 25, 17, 10), array(34, 20, 14, 8), array(27, 16, 11, 7), array(17, 10, 7, 4) ), + array( array(77, 47, 32, 20), array(63, 38, 26, 16), array(48, 29, 20, 12), array(34, 20, 14, 8) ), + array( array(127, 77, 53, 32), array(101, 61, 42, 26), array(77, 47, 32, 20), array(58, 35, 24, 15) ), + array( array(187, 114, 78, 48), array(149, 90, 62, 38), array(111, 67, 46, 28), array(82, 50, 34, 21) ), + array( array(255, 154, 106, 65), array(202, 122, 84, 52), array(144, 87, 60, 37), array(106, 64, 44, 27) ), + array( array(322, 195, 134, 82), array(255, 154, 106, 65), array(178, 108, 74, 45), array(139, 84, 58, 36) ), + array( array(370, 224, 154, 95), array(293, 178, 122, 75), array(207, 125, 86, 53), array(154, 93, 64, 39) ), + array( array(461, 279, 192, 118), array(365, 221, 152, 93), array(259, 157, 108, 66), array(202, 122, 84, 52) ), + array( array(552, 335, 230, 141), array(432, 262, 180, 111), array(312, 189, 130, 80), array(235, 143, 98, 60) ), + array( array(652, 395, 271, 167), array(513, 311, 213, 131), array(364, 221, 151, 93), array(288, 174, 119, 74) ) +); + + +define("QR_G15", (1 << 10) | (1 << 8) | (1 << 5) + | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0) ); + +define("QR_G18", (1 << 12) | (1 << 11) | (1 << 10) + | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0) ); + +define("QR_G15_MASK", (1 << 14) | (1 << 12) | (1 << 10) + | (1 << 4) | (1 << 1) ); + +class QRUtil { + + function getPatternPosition($typeNumber) { + global $QR_PATTERN_POSITION_TABLE; + return $QR_PATTERN_POSITION_TABLE[$typeNumber - 1]; + } + + function getMaxLength($typeNumber, $mode, $errorCorrectLevel) { + + global $QR_MAX_LENGTH; + + $t = $typeNumber - 1; + $e = 0; + $m = 0; + + switch($errorCorrectLevel) { + case QR_ERROR_CORRECT_LEVEL_L : $e = 0; break; + case QR_ERROR_CORRECT_LEVEL_M : $e = 1; break; + case QR_ERROR_CORRECT_LEVEL_Q : $e = 2; break; + case QR_ERROR_CORRECT_LEVEL_H : $e = 3; break; + default : + trigger_error("e:$errorCorrectLevel", E_USER_ERROR); + } + + switch($mode) { + case QR_MODE_NUMBER : $m = 0; break; + case QR_MODE_ALPHA_NUM : $m = 1; break; + case QR_MODE_8BIT_BYTE : $m = 2; break; + case QR_MODE_KANJI : $m = 3; break; + default : + trigger_error("m:$mode", E_USER_ERROR); + } + + return $QR_MAX_LENGTH[$t][$e][$m]; + } + + function getErrorCorrectPolynomial($errorCorrectLength) { + + $a = new QRPolynomial(array(1) ); + + for ($i = 0; $i < $errorCorrectLength; $i++) { + $a = $a->multiply(new QRPolynomial(array(1, QRMath::gexp($i) ) ) ); + } + + return $a; + } + + function getMask($maskPattern, $i, $j) { + + switch ($maskPattern) { + + case QR_MASK_PATTERN000 : return ($i + $j) % 2 == 0; + case QR_MASK_PATTERN001 : return $i % 2 == 0; + case QR_MASK_PATTERN010 : return $j % 3 == 0; + case QR_MASK_PATTERN011 : return ($i + $j) % 3 == 0; + case QR_MASK_PATTERN100 : return (floor($i / 2) + floor($j / 3) ) % 2 == 0; + case QR_MASK_PATTERN101 : return ($i * $j) % 2 + ($i * $j) % 3 == 0; + case QR_MASK_PATTERN110 : return ( ($i * $j) % 2 + ($i * $j) % 3) % 2 == 0; + case QR_MASK_PATTERN111 : return ( ($i * $j) % 3 + ($i + $j) % 2) % 2 == 0; + + default : + trigger_error("mask:$maskPattern", E_USER_ERROR); + } + } + + function getLostPoint($qrCode) { + + $moduleCount = $qrCode->getModuleCount(); + + $lostPoint = 0; + + + // LEVEL1 + + for ($row = 0; $row < $moduleCount; $row++) { + + for ($col = 0; $col < $moduleCount; $col++) { + + $sameCount = 0; + $dark = $qrCode->isDark($row, $col); + + for ($r = -1; $r <= 1; $r++) { + + if ($row + $r < 0 || $moduleCount <= $row + $r) { + continue; + } + + for ($c = -1; $c <= 1; $c++) { + + if ($col + $c < 0 || $moduleCount <= $col + $c) { + continue; + } + + if ($r == 0 && $c == 0) { + continue; + } + + if ($dark == $qrCode->isDark($row + $r, $col + $c) ) { + $sameCount++; + } + } + } + + if ($sameCount > 5) { + $lostPoint += (3 + $sameCount - 5); + } + } + } + + // LEVEL2 + + for ($row = 0; $row < $moduleCount - 1; $row++) { + for ($col = 0; $col < $moduleCount - 1; $col++) { + $count = 0; + if ($qrCode->isDark($row, $col ) ) $count++; + if ($qrCode->isDark($row + 1, $col ) ) $count++; + if ($qrCode->isDark($row, $col + 1) ) $count++; + if ($qrCode->isDark($row + 1, $col + 1) ) $count++; + if ($count == 0 || $count == 4) { + $lostPoint += 3; + } + } + } + + // LEVEL3 + + for ($row = 0; $row < $moduleCount; $row++) { + for ($col = 0; $col < $moduleCount - 6; $col++) { + if ($qrCode->isDark($row, $col) + && !$qrCode->isDark($row, $col + 1) + && $qrCode->isDark($row, $col + 2) + && $qrCode->isDark($row, $col + 3) + && $qrCode->isDark($row, $col + 4) + && !$qrCode->isDark($row, $col + 5) + && $qrCode->isDark($row, $col + 6) ) { + $lostPoint += 40; + } + } + } + + for ($col = 0; $col < $moduleCount; $col++) { + for ($row = 0; $row < $moduleCount - 6; $row++) { + if ($qrCode->isDark($row, $col) + && !$qrCode->isDark($row + 1, $col) + && $qrCode->isDark($row + 2, $col) + && $qrCode->isDark($row + 3, $col) + && $qrCode->isDark($row + 4, $col) + && !$qrCode->isDark($row + 5, $col) + && $qrCode->isDark($row + 6, $col) ) { + $lostPoint += 40; + } + } + } + + // LEVEL4 + + $darkCount = 0; + + for ($col = 0; $col < $moduleCount; $col++) { + for ($row = 0; $row < $moduleCount; $row++) { + if ($qrCode->isDark($row, $col) ) { + $darkCount++; + } + } + } + + $ratio = abs(100 * $darkCount / $moduleCount / $moduleCount - 50) / 5; + $lostPoint += $ratio * 10; + + return $lostPoint; + } + + function getMode($s) { + if (QRUtil::isAlphaNum($s) ) { + if (QRUtil::isNumber($s) ) { + return QR_MODE_NUMBER; + } + return QR_MODE_ALPHA_NUM; + } else if (QRUtil::isKanji($s) ) { + return QR_MODE_KANJI; + } else { + return QR_MODE_8BIT_BYTE; + } + } + + function isNumber($s) { + for ($i = 0; $i < strlen($s); $i++) { + $c = ord($s[$i]); + if (!(QRUtil::toCharCode('0') <= $c && $c <= QRUtil::toCharCode('9') ) ) { + return false; + } + } + return true; + } + + function isAlphaNum($s) { + for ($i = 0; $i < strlen($s); $i++) { + $c = ord($s[$i]); + if (!(QRUtil::toCharCode('0') <= $c && $c <= QRUtil::toCharCode('9') ) + && !(QRUtil::toCharCode('A') <= $c && $c <= QRUtil::toCharCode('Z') ) + && strpos(" $%*+-./:", $s[$i]) === false) { + return false; + } + } + return true; + } + + function isKanji($s) { + + $data = $s; + + $i = 0; + + while ($i + 1 < strlen($data) ) { + + $c = ( (0xff & ord($data[$i]) ) << 8) | (0xff & ord($data[$i + 1]) ); + + if (!(0x8140 <= $c && $c <= 0x9FFC) && !(0xE040 <= $c && $c <= 0xEBBF) ) { + return false; + } + + $i += 2; + } + + if ($i < strlen($data) ) { + return false; + } + + return true; + } + + function toCharCode($s) { + return ord($s[0]); + } + + function getBCHTypeInfo($data) { + $d = $data << 10; + while (QRUtil::getBCHDigit($d) - QRUtil::getBCHDigit(QR_G15) >= 0) { + $d ^= (QR_G15 << (QRUtil::getBCHDigit($d) - QRUtil::getBCHDigit(QR_G15) ) ); + } + return ( ($data << 10) | $d) ^ QR_G15_MASK; + } + + function getBCHTypeNumber($data) { + $d = $data << 12; + while (QRUtil::getBCHDigit($d) - QRUtil::getBCHDigit(QR_G18) >= 0) { + $d ^= (QR_G18 << (QRUtil::getBCHDigit($d) - QRUtil::getBCHDigit(QR_G18) ) ); + } + return ($data << 12) | $d; + } + + function getBCHDigit($data) { + + $digit = 0; + + while ($data != 0) { + $digit++; + $data >>= 1; + } + + return $digit; + } +} + +//--------------------------------------------------------------- +// QRRSBlock +//--------------------------------------------------------------- + +$QR_RS_BLOCK_TABLE = array( + + // L + // M + // Q + // H + + // 1 + array(1, 26, 19), + array(1, 26, 16), + array(1, 26, 13), + array(1, 26, 9), + + // 2 + array(1, 44, 34), + array(1, 44, 28), + array(1, 44, 22), + array(1, 44, 16), + + // 3 + array(1, 70, 55), + array(1, 70, 44), + array(2, 35, 17), + array(2, 35, 13), + + // 4 + array(1, 100, 80), + array(2, 50, 32), + array(2, 50, 24), + array(4, 25, 9), + + // 5 + array(1, 134, 108), + array(2, 67, 43), + array(2, 33, 15, 2, 34, 16), + array(2, 33, 11, 2, 34, 12), + + // 6 + array(2, 86, 68), + array(4, 43, 27), + array(4, 43, 19), + array(4, 43, 15), + + // 7 + array(2, 98, 78), + array(4, 49, 31), + array(2, 32, 14, 4, 33, 15), + array(4, 39, 13, 1, 40, 14), + + // 8 + array(2, 121, 97), + array(2, 60, 38, 2, 61, 39), + array(4, 40, 18, 2, 41, 19), + array(4, 40, 14, 2, 41, 15), + + // 9 + array(2, 146, 116), + array(3, 58, 36, 2, 59, 37), + array(4, 36, 16, 4, 37, 17), + array(4, 36, 12, 4, 37, 13), + + // 10 + array(2, 86, 68, 2, 87, 69), + array(4, 69, 43, 1, 70, 44), + array(6, 43, 19, 2, 44, 20), + array(6, 43, 15, 2, 44, 16) + +); + +class QRRSBlock { + + var $totalCount; + var $dataCount; + + function QRRSBlock($totalCount, $dataCount) { + $this->totalCount = $totalCount; + $this->dataCount = $dataCount; + } + + function getDataCount() { + return $this->dataCount; + } + + function getTotalCount() { + return $this->totalCount; + } + + function getRSBlocks($typeNumber, $errorCorrectLevel) { + + $rsBlock = QRRSBlock::getRsBlockTable($typeNumber, $errorCorrectLevel); + $length = count($rsBlock) / 3; + + $list = array(); + + for ($i = 0; $i < $length; $i++) { + + $count = $rsBlock[$i * 3 + 0]; + $totalCount = $rsBlock[$i * 3 + 1]; + $dataCount = $rsBlock[$i * 3 + 2]; + + for ($j = 0; $j < $count; $j++) { + $list[] = new QRRSBlock($totalCount, $dataCount); + } + } + + return $list; + } + + function getRsBlockTable($typeNumber, $errorCorrectLevel) { + + global $QR_RS_BLOCK_TABLE; + + switch($errorCorrectLevel) { + case QR_ERROR_CORRECT_LEVEL_L : + return $QR_RS_BLOCK_TABLE[($typeNumber - 1) * 4 + 0]; + case QR_ERROR_CORRECT_LEVEL_M : + return $QR_RS_BLOCK_TABLE[($typeNumber - 1) * 4 + 1]; + case QR_ERROR_CORRECT_LEVEL_Q : + return $QR_RS_BLOCK_TABLE[($typeNumber - 1) * 4 + 2]; + case QR_ERROR_CORRECT_LEVEL_H : + return $QR_RS_BLOCK_TABLE[($typeNumber - 1) * 4 + 3]; + default : + trigger_error("tn:$typeNumber/ecl:$errorCorrectLevel", E_USER_ERROR); + } + } +} + +//--------------------------------------------------------------- +// QRNumber +//--------------------------------------------------------------- + +class QRNumber extends QRData { + + function QRNumber($data) { + QRData::QRData(QR_MODE_NUMBER, $data); + } + + function write(&$buffer) { + + $data = $this->getData(); + + $i = 0; + + while ($i + 2 < strlen($data) ) { + $num = QRNumber::parseInt(substr($data, $i, 3) ); + $buffer->put($num, 10); + $i += 3; + } + + if ($i < strlen($data) ) { + + if (strlen($data) - $i == 1) { + $num = QRNumber::parseInt(substr($data, $i, $i + 1) ); + $buffer->put($num, 4); + } else if (strlen($data) - $i == 2) { + $num = QRNumber::parseInt(substr($data, $i, $i + 2) ); + $buffer->put($num, 7); + } + } + } + + function getLength() { + return strlen($this->getData() ); + } + + function parseInt($s) { + + $num = 0; + for ($i = 0; $i < strlen($s); $i++) { + $num = $num * 10 + QRNumber::parseIntAt(ord($s[$i]) ); + } + return $num; + } + + function parseIntAt($c) { + + if (QRUtil::toCharCode('0') <= $c && $c <= QRUtil::toCharCode('9') ) { + return $c - QRUtil::toCharCode('0'); + } + + trigger_error("illegal char : $c", E_USER_ERROR); + } +} + +//--------------------------------------------------------------- +// QRKanji +//--------------------------------------------------------------- + +class QRKanji extends QRData { + + function QRKanji($data) { + QRData::QRData(QR_MODE_KANJI, $data); + } + + function write(&$buffer) { + + $data = $this->getData(); + + $i = 0; + + while ($i + 1 < strlen($data) ) { + + $c = ( (0xff & ord($data[$i]) ) << 8) | (0xff & ord($data[$i + 1]) ); + + if (0x8140 <= $c && $c <= 0x9FFC) { + $c -= 0x8140; + } else if (0xE040 <= $c && $c <= 0xEBBF) { + $c -= 0xC140; + } else { + trigger_error("illegal char at " . ($i + 1) . "/$c", E_USER_ERROR); + } + + $c = ( ($c >> 8) & 0xff) * 0xC0 + ($c & 0xff); + + $buffer->put($c, 13); + + $i += 2; + } + + if ($i < strlen($data) ) { + trigger_error("illegal char at " . ($i + 1), E_USER_ERROR); + } + } + + function getLength() { + return floor(strlen($this->getData() ) / 2); + } +} + +//--------------------------------------------------------------- +// QRAlphaNum +//--------------------------------------------------------------- + +class QRAlphaNum extends QRData { + + function QRAlphaNum($data) { + QRData::QRData(QR_MODE_ALPHA_NUM, $data); + } + + function write(&$buffer) { + + $i = 0; + $c = $this->getData(); + + while ($i + 1 < strlen($c) ) { + $buffer->put(QRAlphaNum::getCode(ord($c[$i]) ) * 45 + + QRAlphaNum::getCode(ord($c[$i + 1]) ), 11); + $i += 2; + } + + if ($i < strlen($c) ) { + $buffer->put(QRAlphaNum::getCode(ord($c[$i])), 6); + } + } + + function getLength() { + return strlen($this->getData() ); + } + + function getCode($c) { + + if (QRUtil::toCharCode('0') <= $c + && $c <= QRUtil::toCharCode('9') ) { + return $c - QRUtil::toCharCode('0'); + } else if (QRUtil::toCharCode('A') <= $c + && $c <= QRUtil::toCharCode('Z') ) { + return $c - QRUtil::toCharCode('A') + 10; + } else { + switch ($c) { + case QRUtil::toCharCode(' ') : return 36; + case QRUtil::toCharCode('$') : return 37; + case QRUtil::toCharCode('%') : return 38; + case QRUtil::toCharCode('*') : return 39; + case QRUtil::toCharCode('+') : return 40; + case QRUtil::toCharCode('-') : return 41; + case QRUtil::toCharCode('.') : return 42; + case QRUtil::toCharCode('/') : return 43; + case QRUtil::toCharCode(':') : return 44; + default : + trigger_error("illegal char : $c", E_USER_ERROR); + } + } + + } +} + +//--------------------------------------------------------------- +// QR8BitByte +//--------------------------------------------------------------- + +class QR8BitByte extends QRData { + + function QR8BitByte($data) { + QRData::QRData(QR_MODE_8BIT_BYTE, $data); + } + + function write(&$buffer) { + + $data = $this->getData(); + for ($i = 0; $i < strlen($data); $i++) { + $buffer->put(ord($data[$i]), 8); + } + } + + function getLength() { + return strlen($this->getData() ); + } +} + +//--------------------------------------------------------------- +// QRData +//--------------------------------------------------------------- + +class QRData { + + var $mode; + + var $data; + + function QRData($mode, $data) { + $this->mode = $mode; + $this->data = $data; + } + + function getMode() { + return $this->mode; + } + + function getData() { + return $this->data; + } + + function getLength() { + trigger_error("not implemented.", E_USER_ERROR); + } + + function write(&$buffer) { + trigger_error("not implemented.", E_USER_ERROR); + } + + function getLengthInBits($type) { + + if (1 <= $type && $type < 10) { + + // 1 - 9 + + switch($this->mode) { + case QR_MODE_NUMBER : return 10; + case QR_MODE_ALPHA_NUM : return 9; + case QR_MODE_8BIT_BYTE : return 8; + case QR_MODE_KANJI : return 8; + default : + trigger_error("mode:$this->mode", E_USER_ERROR); + } + + } else if ($type < 27) { + + // 10 - 26 + + switch($this->mode) { + case QR_MODE_NUMBER : return 12; + case QR_MODE_ALPHA_NUM : return 11; + case QR_MODE_8BIT_BYTE : return 16; + case QR_MODE_KANJI : return 10; + default : + trigger_error("mode:$this->mode", E_USER_ERROR); + } + + } else if ($type < 41) { + + // 27 - 40 + + switch($this->mode) { + case QR_MODE_NUMBER : return 14; + case QR_MODE_ALPHA_NUM : return 13; + case QR_MODE_8BIT_BYTE : return 16; + case QR_MODE_KANJI : return 12; + default : + trigger_error("mode:$this->mode", E_USER_ERROR); + } + + } else { + trigger_error("mode:$this->mode", E_USER_ERROR); + } + } + +} + +//--------------------------------------------------------------- +// QRMath +//--------------------------------------------------------------- + +$QR_MATH_EXP_TABLE = null; +$QR_MATH_LOG_TABLE = null; + +class QRMath { + + function init() { + + global $QR_MATH_EXP_TABLE; + global $QR_MATH_LOG_TABLE; + + $QR_MATH_EXP_TABLE = QRMath::createNumArray(256); + + for ($i = 0; $i < 8; $i++) { + $QR_MATH_EXP_TABLE[$i] = 1 << $i; + } + + for ($i = 8; $i < 256; $i++) { + $QR_MATH_EXP_TABLE[$i] = $QR_MATH_EXP_TABLE[$i - 4] + ^ $QR_MATH_EXP_TABLE[$i - 5] + ^ $QR_MATH_EXP_TABLE[$i - 6] + ^ $QR_MATH_EXP_TABLE[$i - 8]; + } + + $QR_MATH_LOG_TABLE = QRMath::createNumArray(256); + + for ($i = 0; $i < 255; $i++) { + $QR_MATH_LOG_TABLE[$QR_MATH_EXP_TABLE[$i] ] = $i; + } + } + + function createNumArray($length) { + $num_array = array(); + for ($i = 0; $i < $length; $i++) { + $num_array[] = 0; + } + return $num_array; + } + + function glog($n) { + global $QR_MATH_LOG_TABLE; + if ($n < 1) { + trigger_error("log($n)", E_USER_ERROR); + } + return $QR_MATH_LOG_TABLE[$n]; + } + + function gexp($n) { + global $QR_MATH_EXP_TABLE; + while ($n < 0) { + $n += 255; + } + while ($n >= 256) { + $n -= 255; + } + return $QR_MATH_EXP_TABLE[$n]; + } +} + +// init static table +QRMath::init(); + +//--------------------------------------------------------------- +// QRPolynomial +//--------------------------------------------------------------- + +class QRPolynomial { + + var $num; + + function QRPolynomial($num, $shift = 0) { + $offset = 0; + + while ($offset < count($num) && $num[$offset] == 0) { + $offset++; + } + + $this->num = QRMath::createNumArray(count($num) - $offset + $shift); + for ($i = 0; $i < count($num) - $offset; $i++) { + $this->num[$i] = $num[$i + $offset]; + } + } + + function get($index) { + return $this->num[$index]; + } + + function getLength() { + return count($this->num); + } + + // PHP5 + function __toString() { + return $this->toString(); + } + + function toString() { + $buffer = ""; + for ($i = 0; $i < $this->getLength(); $i++) { + if ($i > 0) { + $buffer .= ","; + } + $buffer .= $this->get($i); + } + return $buffer; + } + + function toLogString() { + $buffer = ""; + for ($i = 0; $i < $this->getLength(); $i++) { + if ($i > 0) { + $buffer .= ","; + } + $buffer .= QRMath::glog($this->get(i) ); + } + return $buffer; + } + + function multiply($e) { + $num = QRMath::createNumArray($this->getLength() + $e->getLength() - 1); + for ($i = 0; $i < $this->getLength(); $i++) { + for ($j = 0; $j < $e->getLength(); $j++) { + $num[$i + $j] ^= QRMath::gexp(QRMath::glog($this->get($i) ) + QRMath::glog($e->get($j) ) ); + } + } + return new QRPolynomial($num); + } + + function mod($e) { + if ($this->getLength() - $e->getLength() < 0) { + return $this; + } + $ratio = QRMath::glog($this->get(0) ) - QRMath::glog($e->get(0) ); + $num = QRMath::createNumArray($this->getLength() ); + for ($i = 0; $i < $this->getLength(); $i++) { + $num[$i] = $this->get($i); + } + for ($i = 0; $i < $e->getLength(); $i++) { + $num[$i] ^= QRMath::gexp(QRMath::glog($e->get($i) ) + $ratio); + } + $newPolynomial = new QRPolynomial($num); + return $newPolynomial->mod($e); + } +} + +//--------------------------------------------------------------- +// Mode +//--------------------------------------------------------------- + +define("QR_MODE_NUMBER", 1 << 0); +define("QR_MODE_ALPHA_NUM", 1 << 1); +define("QR_MODE_8BIT_BYTE", 1 << 2); +define("QR_MODE_KANJI", 1 << 3); + +//--------------------------------------------------------------- +// MaskPattern +//--------------------------------------------------------------- + +define("QR_MASK_PATTERN000", 0); +define("QR_MASK_PATTERN001", 1); +define("QR_MASK_PATTERN010", 2); +define("QR_MASK_PATTERN011", 3); +define("QR_MASK_PATTERN100", 4); +define("QR_MASK_PATTERN101", 5); +define("QR_MASK_PATTERN110", 6); +define("QR_MASK_PATTERN111", 7); + +//--------------------------------------------------------------- +// ErrorCorrectLevel + +// 7%. +define("QR_ERROR_CORRECT_LEVEL_L", 1); +// 15%. +define("QR_ERROR_CORRECT_LEVEL_M", 0); +// 25%. +define("QR_ERROR_CORRECT_LEVEL_Q", 3); +// 30%. +define("QR_ERROR_CORRECT_LEVEL_H", 2); + + +//--------------------------------------------------------------- +// QRBitBuffer +//--------------------------------------------------------------- + +class QRBitBuffer { + var $buffer; + var $length; + + function QRBitBuffer() { + $this->buffer = array(); + $this->length = 0; + } + + function getBuffer() { + return $this->buffer; + } + + function getLengthInBits() { + return $this->length; + } + + function __toString() { + $buffer = ""; + for ($i = 0; $i < $this->getLengthInBits(); $i++) { + $buffer .= $this->get($i)? '1' : '0'; + } + return $buffer; + } + + function get($index) { + $bufIndex = floor($index / 8); + return ( ($this->buffer[$bufIndex] >> (7 - $index % 8) ) & 1) == 1; + } + + function put($num, $length) { + for ($i = 0; $i < $length; $i++) { + $this->putBit( ( ($num >> ($length - $i - 1) ) & 1) == 1); + } + } + + function putBit($bit) { + $bufIndex = floor($this->length / 8); + if (count($this->buffer) <= $bufIndex) { + $this->buffer[] = 0; + } + if ($bit) { + $this->buffer[$bufIndex] |= (0x80 >> ($this->length % 8) ); + } + $this->length++; + } +} + +?> \ No newline at end of file diff --git a/includes/recaptchalib.php b/includes/recaptchalib.php new file mode 100644 index 0000000000..e18ddb8856 --- /dev/null +++ b/includes/recaptchalib.php @@ -0,0 +1,276 @@ + $value ) + $req .= $key . '=' . urlencode( stripslashes($value) ) . '&'; + + // Cut the last '&' + $req=substr($req,0,strlen($req)-1); + return $req; +} + + + +/** + * Submits an HTTP POST to a reCAPTCHA server + * @param string $host + * @param string $path + * @param array $data + * @param int port + * @return array response + */ +function _recaptcha_http_post($host, $path, $data, $port = 80) { + + $req = _recaptcha_qsencode ($data); + + $http_request = "POST $path HTTP/1.0\r\n"; + $http_request .= "Host: $host\r\n"; + $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n"; + $http_request .= "Content-Length: " . strlen($req) . "\r\n"; + $http_request .= "User-Agent: reCAPTCHA/PHP\r\n"; + $http_request .= "\r\n"; + $http_request .= $req; + + $response = ''; + if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) { + die ('Could not open socket'); + } + + fwrite($fs, $http_request); + + while ( !feof($fs) ) + $response .= fgets($fs, 1160); // One TCP-IP packet + fclose($fs); + $response = explode("\r\n\r\n", $response, 2); + + return $response; +} + + + +/** + * Gets the challenge HTML (javascript and non-javascript version). + * This is called from the browser, and the resulting reCAPTCHA HTML widget + * is embedded within the HTML form it was called from. + * @param string $pubkey A public key for reCAPTCHA + * @param string $error The error given by reCAPTCHA (optional, default is null) + * @param boolean $use_ssl Should the request be made over ssl? (optional, default is false) + + * @return string - The HTML to be embedded in the user's form. + */ +function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false) +{ + if ($pubkey == null || $pubkey == '') { + die ("To use reCAPTCHA you must get an API key from https://www.google.com/recaptcha/admin/create"); + } + + if ($use_ssl) { + $server = RECAPTCHA_API_SECURE_SERVER; + } else { + $server = RECAPTCHA_API_SERVER; + } + + $errorpart = ""; + if ($error) { + $errorpart = "&error=" . $error; + } + return ' + + '; +} + + + + +/** + * A ReCaptchaResponse is returned from recaptcha_check_answer() + */ +class ReCaptchaResponse { + var $is_valid; + var $error; +} + + +/** + * Calls an HTTP POST function to verify if the user's guess was correct + * @param string $privkey + * @param string $remoteip + * @param string $challenge + * @param string $response + * @param array $extra_params an array of extra variables to post to the server + * @return ReCaptchaResponse + */ +function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array()) +{ + if ($privkey == null || $privkey == '') { + die ("To use reCAPTCHA you must get an API key from https://www.google.com/recaptcha/admin/create"); + } + + if ($remoteip == null || $remoteip == '') { + die ("For security reasons, you must pass the remote ip to reCAPTCHA"); + } + + + + //discard spam submissions + if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) { + $recaptcha_response = new ReCaptchaResponse(); + $recaptcha_response->is_valid = false; + $recaptcha_response->error = 'incorrect-captcha-sol'; + return $recaptcha_response; + } + + $response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify", + array ( + 'privatekey' => $privkey, + 'remoteip' => $remoteip, + 'challenge' => $challenge, + 'response' => $response + ) + $extra_params + ); + + $answers = explode ("\n", $response [1]); + $recaptcha_response = new ReCaptchaResponse(); + + if (trim ($answers [0]) == 'true') { + $recaptcha_response->is_valid = true; + } + else { + $recaptcha_response->is_valid = false; + $recaptcha_response->error = $answers [1]; + } + return $recaptcha_response; + +} + +/** + * gets a URL where the user can sign up for reCAPTCHA. If your application + * has a configuration page where you enter a key, you should provide a link + * using this function. + * @param string $_SESSION['domain_name'] The domain where the page is hosted + * @param string $app_name The name of your application + */ +function recaptcha_get_signup_url ($domain_name = null, $app_name = null) { + return "https://www.google.com/recaptcha/admin/create?" . _recaptcha_qsencode (array ('domains' => $domain_name, 'app' => $app_name)); +} + +function _recaptcha_aes_pad($val) { + $block_size = 16; + $numpad = $block_size - (strlen ($val) % $block_size); + return str_pad($val, strlen ($val) + $numpad, chr($numpad)); +} + +/* Mailhide related code */ + +function _recaptcha_aes_encrypt($val,$ky) { + if (! function_exists ("mcrypt_encrypt")) { + die ("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed."); + } + $mode=MCRYPT_MODE_CBC; + $enc=MCRYPT_RIJNDAEL_128; + $val=_recaptcha_aes_pad($val); + return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); +} + + +function _recaptcha_mailhide_urlbase64 ($x) { + return strtr(base64_encode ($x), '+/', '-_'); +} + +/* gets the reCAPTCHA Mailhide url for a given email, public key and private key */ +function recaptcha_mailhide_url($pubkey, $privkey, $email) { + if ($pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null) { + die ("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " . + "you can do so at http://www.google.com/recaptcha/mailhide/apikey"); + } + + + $ky = pack('H*', $privkey); + $cryptmail = _recaptcha_aes_encrypt ($email, $ky); + + return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail); +} + +/** + * gets the parts of the email to expose to the user. + * eg, given johndoe@example,com return ["john", "example.com"]. + * the email is then displayed as john...@example.com + */ +function _recaptcha_mailhide_email_parts ($email) { + $arr = preg_split("/@/", $email ); + + if (strlen ($arr[0]) <= 4) { + $arr[0] = substr ($arr[0], 0, 1); + } else if (strlen ($arr[0]) <= 6) { + $arr[0] = substr ($arr[0], 0, 3); + } else { + $arr[0] = substr ($arr[0], 0, 4); + } + return $arr; +} + +/** + * Gets html to display an email address given a public an private key. + * to get a key, go to: + * + * http://www.google.com/recaptcha/mailhide/apikey + */ +function recaptcha_mailhide_html($pubkey, $privkey, $email) { + $emailparts = _recaptcha_mailhide_email_parts ($email); + $url = recaptcha_mailhide_url ($pubkey, $privkey, $email); + + return htmlentities($emailparts[0]) . "...@" . htmlentities ($emailparts [1]); + +} + +?> \ No newline at end of file diff --git a/includes/require.php b/includes/require.php new file mode 100644 index 0000000000..202b61ea85 --- /dev/null +++ b/includes/require.php @@ -0,0 +1,32 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +include "includes/config.php"; +require_once "includes/lib_php.php"; +require "includes/lib_pdo.php"; +require_once "includes/lib_functions.php"; +require_once "includes/lib_switch.php"; +?> \ No newline at end of file diff --git a/includes/root.php b/includes/root.php new file mode 100644 index 0000000000..7286b67f62 --- /dev/null +++ b/includes/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + if (!defined("PATH_SEPARATOR")) { + if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); } + } + +// make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); + //echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."
    \n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
    \n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
    \n"; + +// if the project directory exists then add it to the include path otherwise add the document root to the include path + if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){ + define('PROJECT_PATH', '/fusionpbx'); + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' ); + } + else { + define('PROJECT_PATH', ''); + set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] ); + } + +?> \ No newline at end of file diff --git a/includes/securedownload.php b/includes/securedownload.php new file mode 100644 index 0000000000..eec57dbc23 --- /dev/null +++ b/includes/securedownload.php @@ -0,0 +1,91 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +include "root.php"; +require_once "includes/require.php"; +require_once "includes/checkauth.php"; + +//clears if file exists cache +clearstatcache(); + + +function getDownloadFilename($strfile) { + // Get download file name and path + //$basedir = "c:\\products\\"; + //$basedir = "/home/wwwbeta/secure/files/"; + $basedir = "c:/www/demo.netprofx.com/secure/files/"; + // Build and return download file name + return $basedir . $strfile; +} + +function DownloadFile($filename) { + // Check filename + if (empty($filename) || !file_exists($filename)) { + echo "Error: file doesn't exist or is empty.
    \n $filename"; + return FALSE; + } + + $file_extension = strtolower(substr(strrchr($filename,"."),1)); + switch ($file_extension) { + case "pdf": $ctype="application/pdf"; break; + case "exe": $ctype="application/octet-stream"; break; + case "zip": $ctype="application/zip"; break; + case "doc": $ctype="application/msword"; break; + case "xls": $ctype="application/vnd.ms-excel"; break; + case "ppt": $ctype="application/vnd.ms-powerpoint"; break; + case "gif": $ctype="image/gif"; break; + case "png": $ctype="image/png"; break; + case "jpe": case "jpeg": + case "jpg": $ctype="image/jpg"; break; + default: $ctype="application/force-download"; + } + + //if (!file_exists($filename)) { + // die("NO FILE HERE
    $filename"); + //} + + // Create download file name to be displayed to user + $saveasname = basename($filename); + + header("Expires: 0"); + header("Pragma: public"); + header("Expires: 0"); + header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); + header("Cache-Control: private",false); + header("Content-Type: $ctype"); + header("Content-Disposition: attachment; filename=\"".basename($filename)."\";"); + header("Content-Transfer-Encoding: binary"); + header("Content-Length: ".@filesize($filename)); + + set_time_limit(0); + @readfile($filename) or die("File not found."); + + // Done + return TRUE; +} + + + +?> diff --git a/includes/templates/conf/autoload_configs/.htaccess b/includes/templates/conf/autoload_configs/.htaccess new file mode 100644 index 0000000000..d776d84a77 --- /dev/null +++ b/includes/templates/conf/autoload_configs/.htaccess @@ -0,0 +1,3 @@ + + Deny from all + \ No newline at end of file diff --git a/includes/templates/conf/autoload_configs/abstraction.conf.xml b/includes/templates/conf/autoload_configs/abstraction.conf.xml new file mode 100644 index 0000000000..d4b1dfd274 --- /dev/null +++ b/includes/templates/conf/autoload_configs/abstraction.conf.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/includes/templates/conf/autoload_configs/acl.conf.xml b/includes/templates/conf/autoload_configs/acl.conf.xml new file mode 100644 index 0000000000..0c117d07bf --- /dev/null +++ b/includes/templates/conf/autoload_configs/acl.conf.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/alsa.conf.xml b/includes/templates/conf/autoload_configs/alsa.conf.xml new file mode 100644 index 0000000000..e589acaacf --- /dev/null +++ b/includes/templates/conf/autoload_configs/alsa.conf.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/blacklist.conf.xml b/includes/templates/conf/autoload_configs/blacklist.conf.xml new file mode 100644 index 0000000000..a981ebbdb0 --- /dev/null +++ b/includes/templates/conf/autoload_configs/blacklist.conf.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/includes/templates/conf/autoload_configs/callcenter.conf.xml b/includes/templates/conf/autoload_configs/callcenter.conf.xml new file mode 100644 index 0000000000..54e7e78c56 --- /dev/null +++ b/includes/templates/conf/autoload_configs/callcenter.conf.xml @@ -0,0 +1,23 @@ + + + + + + + + {v_queues} + + + + + + + {v_agents} + + + + + {v_tiers} + + + \ No newline at end of file diff --git a/includes/templates/conf/autoload_configs/cdr_csv.conf.xml b/includes/templates/conf/autoload_configs/cdr_csv.conf.xml new file mode 100644 index 0000000000..8d796c68f0 --- /dev/null +++ b/includes/templates/conf/autoload_configs/cdr_csv.conf.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/cdr_mongodb.conf.xml b/includes/templates/conf/autoload_configs/cdr_mongodb.conf.xml new file mode 100644 index 0000000000..ce366d1bd0 --- /dev/null +++ b/includes/templates/conf/autoload_configs/cdr_mongodb.conf.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/cdr_pg_csv.conf.xml b/includes/templates/conf/autoload_configs/cdr_pg_csv.conf.xml new file mode 100644 index 0000000000..4fec817b45 --- /dev/null +++ b/includes/templates/conf/autoload_configs/cdr_pg_csv.conf.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/cdr_sqlite.conf.xml b/includes/templates/conf/autoload_configs/cdr_sqlite.conf.xml new file mode 100644 index 0000000000..872c04c4fb --- /dev/null +++ b/includes/templates/conf/autoload_configs/cdr_sqlite.conf.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/cepstral.conf.xml b/includes/templates/conf/autoload_configs/cepstral.conf.xml new file mode 100644 index 0000000000..cf431de700 --- /dev/null +++ b/includes/templates/conf/autoload_configs/cepstral.conf.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/includes/templates/conf/autoload_configs/cidlookup.conf.xml b/includes/templates/conf/autoload_configs/cidlookup.conf.xml new file mode 100644 index 0000000000..a30f9f5c10 --- /dev/null +++ b/includes/templates/conf/autoload_configs/cidlookup.conf.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/conference.conf.xml b/includes/templates/conf/autoload_configs/conference.conf.xml new file mode 100644 index 0000000000..a33be22d05 --- /dev/null +++ b/includes/templates/conf/autoload_configs/conference.conf.xml @@ -0,0 +1,226 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/console.conf.xml b/includes/templates/conf/autoload_configs/console.conf.xml new file mode 100644 index 0000000000..2d9e3e8de5 --- /dev/null +++ b/includes/templates/conf/autoload_configs/console.conf.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/db.conf.xml b/includes/templates/conf/autoload_configs/db.conf.xml new file mode 100644 index 0000000000..abc6c0c152 --- /dev/null +++ b/includes/templates/conf/autoload_configs/db.conf.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/includes/templates/conf/autoload_configs/dialplan_directory.conf.xml b/includes/templates/conf/autoload_configs/dialplan_directory.conf.xml new file mode 100644 index 0000000000..e4edcd6b15 --- /dev/null +++ b/includes/templates/conf/autoload_configs/dialplan_directory.conf.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/dingaling.conf.xml b/includes/templates/conf/autoload_configs/dingaling.conf.xml new file mode 100644 index 0000000000..e68c8b4b44 --- /dev/null +++ b/includes/templates/conf/autoload_configs/dingaling.conf.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/directory.conf.xml b/includes/templates/conf/autoload_configs/directory.conf.xml new file mode 100644 index 0000000000..748b2337c4 --- /dev/null +++ b/includes/templates/conf/autoload_configs/directory.conf.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/distributor.conf.xml b/includes/templates/conf/autoload_configs/distributor.conf.xml new file mode 100644 index 0000000000..a03b1ee810 --- /dev/null +++ b/includes/templates/conf/autoload_configs/distributor.conf.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/easyroute.conf.xml b/includes/templates/conf/autoload_configs/easyroute.conf.xml new file mode 100644 index 0000000000..350a50989b --- /dev/null +++ b/includes/templates/conf/autoload_configs/easyroute.conf.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/enum.conf.xml b/includes/templates/conf/autoload_configs/enum.conf.xml new file mode 100644 index 0000000000..0304d0dacd --- /dev/null +++ b/includes/templates/conf/autoload_configs/enum.conf.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/erlang_event.conf.xml b/includes/templates/conf/autoload_configs/erlang_event.conf.xml new file mode 100644 index 0000000000..62deb84f67 --- /dev/null +++ b/includes/templates/conf/autoload_configs/erlang_event.conf.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/event_multicast.conf.xml b/includes/templates/conf/autoload_configs/event_multicast.conf.xml new file mode 100644 index 0000000000..eac0392607 --- /dev/null +++ b/includes/templates/conf/autoload_configs/event_multicast.conf.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/event_socket.conf.xml b/includes/templates/conf/autoload_configs/event_socket.conf.xml new file mode 100644 index 0000000000..5ea2e09788 --- /dev/null +++ b/includes/templates/conf/autoload_configs/event_socket.conf.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/fax.conf.xml b/includes/templates/conf/autoload_configs/fax.conf.xml new file mode 100644 index 0000000000..c7d825665e --- /dev/null +++ b/includes/templates/conf/autoload_configs/fax.conf.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/fifo.conf.xml b/includes/templates/conf/autoload_configs/fifo.conf.xml new file mode 100644 index 0000000000..b1db4dd2bd --- /dev/null +++ b/includes/templates/conf/autoload_configs/fifo.conf.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/hash.conf.xml b/includes/templates/conf/autoload_configs/hash.conf.xml new file mode 100644 index 0000000000..95b7928775 --- /dev/null +++ b/includes/templates/conf/autoload_configs/hash.conf.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/includes/templates/conf/autoload_configs/httapi.conf.xml b/includes/templates/conf/autoload_configs/httapi.conf.xml new file mode 100644 index 0000000000..c2fe584a02 --- /dev/null +++ b/includes/templates/conf/autoload_configs/httapi.conf.xml @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/http_cache.conf.xml b/includes/templates/conf/autoload_configs/http_cache.conf.xml new file mode 100644 index 0000000000..4f05269658 --- /dev/null +++ b/includes/templates/conf/autoload_configs/http_cache.conf.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/ivr.conf.xml b/includes/templates/conf/autoload_configs/ivr.conf.xml new file mode 100644 index 0000000000..bd4e73dedf --- /dev/null +++ b/includes/templates/conf/autoload_configs/ivr.conf.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/includes/templates/conf/autoload_configs/java.conf.xml b/includes/templates/conf/autoload_configs/java.conf.xml new file mode 100644 index 0000000000..3d1a3b5e5b --- /dev/null +++ b/includes/templates/conf/autoload_configs/java.conf.xml @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/lcr.conf.xml b/includes/templates/conf/autoload_configs/lcr.conf.xml new file mode 100644 index 0000000000..9d106d4890 --- /dev/null +++ b/includes/templates/conf/autoload_configs/lcr.conf.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/local_stream.conf.xml b/includes/templates/conf/autoload_configs/local_stream.conf.xml new file mode 100644 index 0000000000..94a5665392 --- /dev/null +++ b/includes/templates/conf/autoload_configs/local_stream.conf.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/logfile.conf.xml b/includes/templates/conf/autoload_configs/logfile.conf.xml new file mode 100644 index 0000000000..65bea552bd --- /dev/null +++ b/includes/templates/conf/autoload_configs/logfile.conf.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/lua.conf.xml b/includes/templates/conf/autoload_configs/lua.conf.xml new file mode 100644 index 0000000000..1eb594f0b5 --- /dev/null +++ b/includes/templates/conf/autoload_configs/lua.conf.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/memcache.conf.xml b/includes/templates/conf/autoload_configs/memcache.conf.xml new file mode 100644 index 0000000000..dc0173f986 --- /dev/null +++ b/includes/templates/conf/autoload_configs/memcache.conf.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/includes/templates/conf/autoload_configs/modules.conf.xml b/includes/templates/conf/autoload_configs/modules.conf.xml new file mode 100644 index 0000000000..de4bc40897 --- /dev/null +++ b/includes/templates/conf/autoload_configs/modules.conf.xml @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/mongo.conf.xml b/includes/templates/conf/autoload_configs/mongo.conf.xml new file mode 100644 index 0000000000..8423645e95 --- /dev/null +++ b/includes/templates/conf/autoload_configs/mongo.conf.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/nibblebill.conf.xml b/includes/templates/conf/autoload_configs/nibblebill.conf.xml new file mode 100644 index 0000000000..ed1c9332c8 --- /dev/null +++ b/includes/templates/conf/autoload_configs/nibblebill.conf.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/opal.conf.xml b/includes/templates/conf/autoload_configs/opal.conf.xml new file mode 100644 index 0000000000..1133227499 --- /dev/null +++ b/includes/templates/conf/autoload_configs/opal.conf.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/osp.conf.xml b/includes/templates/conf/autoload_configs/osp.conf.xml new file mode 100644 index 0000000000..b320dbba88 --- /dev/null +++ b/includes/templates/conf/autoload_configs/osp.conf.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/perl.conf.xml b/includes/templates/conf/autoload_configs/perl.conf.xml new file mode 100644 index 0000000000..b2435000ff --- /dev/null +++ b/includes/templates/conf/autoload_configs/perl.conf.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/pocketsphinx.conf.xml b/includes/templates/conf/autoload_configs/pocketsphinx.conf.xml new file mode 100644 index 0000000000..3bf7d5e575 --- /dev/null +++ b/includes/templates/conf/autoload_configs/pocketsphinx.conf.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/portaudio.conf.xml b/includes/templates/conf/autoload_configs/portaudio.conf.xml new file mode 100644 index 0000000000..02c21ef449 --- /dev/null +++ b/includes/templates/conf/autoload_configs/portaudio.conf.xml @@ -0,0 +1,218 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/post_load_modules.conf.xml b/includes/templates/conf/autoload_configs/post_load_modules.conf.xml new file mode 100644 index 0000000000..8f4e132fa4 --- /dev/null +++ b/includes/templates/conf/autoload_configs/post_load_modules.conf.xml @@ -0,0 +1,4 @@ + + + + diff --git a/includes/templates/conf/autoload_configs/presence_map.conf.xml b/includes/templates/conf/autoload_configs/presence_map.conf.xml new file mode 100644 index 0000000000..8a9d1dde5a --- /dev/null +++ b/includes/templates/conf/autoload_configs/presence_map.conf.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/includes/templates/conf/autoload_configs/python.conf.xml b/includes/templates/conf/autoload_configs/python.conf.xml new file mode 100644 index 0000000000..d3a8fdc755 --- /dev/null +++ b/includes/templates/conf/autoload_configs/python.conf.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/redis.conf.xml b/includes/templates/conf/autoload_configs/redis.conf.xml new file mode 100644 index 0000000000..1a1f474036 --- /dev/null +++ b/includes/templates/conf/autoload_configs/redis.conf.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/includes/templates/conf/autoload_configs/rss.conf.xml b/includes/templates/conf/autoload_configs/rss.conf.xml new file mode 100644 index 0000000000..f8c4f6d2b4 --- /dev/null +++ b/includes/templates/conf/autoload_configs/rss.conf.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/includes/templates/conf/autoload_configs/rtmp.conf.xml b/includes/templates/conf/autoload_configs/rtmp.conf.xml new file mode 100644 index 0000000000..d5d278810e --- /dev/null +++ b/includes/templates/conf/autoload_configs/rtmp.conf.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/sangoma_codec.conf.xml b/includes/templates/conf/autoload_configs/sangoma_codec.conf.xml new file mode 100644 index 0000000000..eed9d673e1 --- /dev/null +++ b/includes/templates/conf/autoload_configs/sangoma_codec.conf.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/shout.conf.xml b/includes/templates/conf/autoload_configs/shout.conf.xml new file mode 100644 index 0000000000..3f381e6278 --- /dev/null +++ b/includes/templates/conf/autoload_configs/shout.conf.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/skinny.conf.xml b/includes/templates/conf/autoload_configs/skinny.conf.xml new file mode 100644 index 0000000000..6a878fcd71 --- /dev/null +++ b/includes/templates/conf/autoload_configs/skinny.conf.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/includes/templates/conf/autoload_configs/sofia.conf.xml b/includes/templates/conf/autoload_configs/sofia.conf.xml new file mode 100644 index 0000000000..a5e8614322 --- /dev/null +++ b/includes/templates/conf/autoload_configs/sofia.conf.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/spandsp.conf.xml b/includes/templates/conf/autoload_configs/spandsp.conf.xml new file mode 100644 index 0000000000..6f062cc731 --- /dev/null +++ b/includes/templates/conf/autoload_configs/spandsp.conf.xml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/spidermonkey.conf.xml b/includes/templates/conf/autoload_configs/spidermonkey.conf.xml new file mode 100644 index 0000000000..2e6dc6a166 --- /dev/null +++ b/includes/templates/conf/autoload_configs/spidermonkey.conf.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/switch.conf.xml b/includes/templates/conf/autoload_configs/switch.conf.xml new file mode 100644 index 0000000000..044a618eeb --- /dev/null +++ b/includes/templates/conf/autoload_configs/switch.conf.xml @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/includes/templates/conf/autoload_configs/syslog.conf.xml b/includes/templates/conf/autoload_configs/syslog.conf.xml new file mode 100644 index 0000000000..636a12c8c1 --- /dev/null +++ b/includes/templates/conf/autoload_configs/syslog.conf.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/timezones.conf.xml b/includes/templates/conf/autoload_configs/timezones.conf.xml new file mode 100644 index 0000000000..85c805ff25 --- /dev/null +++ b/includes/templates/conf/autoload_configs/timezones.conf.xml @@ -0,0 +1,551 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/tts_commandline.conf.xml b/includes/templates/conf/autoload_configs/tts_commandline.conf.xml new file mode 100644 index 0000000000..eb816431be --- /dev/null +++ b/includes/templates/conf/autoload_configs/tts_commandline.conf.xml @@ -0,0 +1,15 @@ + + + + + + diff --git a/includes/templates/conf/autoload_configs/unicall.conf.xml b/includes/templates/conf/autoload_configs/unicall.conf.xml new file mode 100644 index 0000000000..eeaa0782f7 --- /dev/null +++ b/includes/templates/conf/autoload_configs/unicall.conf.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/unimrcp.conf.xml b/includes/templates/conf/autoload_configs/unimrcp.conf.xml new file mode 100644 index 0000000000..45dda798a1 --- /dev/null +++ b/includes/templates/conf/autoload_configs/unimrcp.conf.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/voicemail.conf.xml b/includes/templates/conf/autoload_configs/voicemail.conf.xml new file mode 100644 index 0000000000..a484fdfc46 --- /dev/null +++ b/includes/templates/conf/autoload_configs/voicemail.conf.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/voicemail_ivr.conf.xml b/includes/templates/conf/autoload_configs/voicemail_ivr.conf.xml new file mode 100644 index 0000000000..529509a495 --- /dev/null +++ b/includes/templates/conf/autoload_configs/voicemail_ivr.conf.xml @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/xml_cdr.conf.xml b/includes/templates/conf/autoload_configs/xml_cdr.conf.xml new file mode 100644 index 0000000000..336ea33486 --- /dev/null +++ b/includes/templates/conf/autoload_configs/xml_cdr.conf.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/xml_curl.conf.xml b/includes/templates/conf/autoload_configs/xml_curl.conf.xml new file mode 100644 index 0000000000..30951d83c8 --- /dev/null +++ b/includes/templates/conf/autoload_configs/xml_curl.conf.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/xml_rpc.conf.xml b/includes/templates/conf/autoload_configs/xml_rpc.conf.xml new file mode 100644 index 0000000000..714a909907 --- /dev/null +++ b/includes/templates/conf/autoload_configs/xml_rpc.conf.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/includes/templates/conf/autoload_configs/zeroconf.conf.xml b/includes/templates/conf/autoload_configs/zeroconf.conf.xml new file mode 100644 index 0000000000..84c1a46171 --- /dev/null +++ b/includes/templates/conf/autoload_configs/zeroconf.conf.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/includes/templates/conf/chatplan/default.xml b/includes/templates/conf/chatplan/default.xml new file mode 100644 index 0000000000..62f3f020ea --- /dev/null +++ b/includes/templates/conf/chatplan/default.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/includes/templates/conf/dialplan/default.xml b/includes/templates/conf/dialplan/default.xml new file mode 100644 index 0000000000..350a85e97c --- /dev/null +++ b/includes/templates/conf/dialplan/default.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/includes/templates/conf/dialplan/default/00_ladspa.xml.noload b/includes/templates/conf/dialplan/default/00_ladspa.xml.noload new file mode 100644 index 0000000000..a26b193ef5 --- /dev/null +++ b/includes/templates/conf/dialplan/default/00_ladspa.xml.noload @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/dialplan/default/00_pizza_demo.xml.noload b/includes/templates/conf/dialplan/default/00_pizza_demo.xml.noload new file mode 100644 index 0000000000..e7fcca204a --- /dev/null +++ b/includes/templates/conf/dialplan/default/00_pizza_demo.xml.noload @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/includes/templates/conf/dialplan/default/01_Talking_Clock.xml.noload b/includes/templates/conf/dialplan/default/01_Talking_Clock.xml.noload new file mode 100644 index 0000000000..bc5077053a --- /dev/null +++ b/includes/templates/conf/dialplan/default/01_Talking_Clock.xml.noload @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/dialplan/default/01_example.com.xml.noload b/includes/templates/conf/dialplan/default/01_example.com.xml.noload new file mode 100644 index 0000000000..bd61cd2788 --- /dev/null +++ b/includes/templates/conf/dialplan/default/01_example.com.xml.noload @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/dialplan/features.xml b/includes/templates/conf/dialplan/features.xml new file mode 100644 index 0000000000..ac0d5eb73a --- /dev/null +++ b/includes/templates/conf/dialplan/features.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/dialplan/public.xml b/includes/templates/conf/dialplan/public.xml new file mode 100644 index 0000000000..4935b1f10d --- /dev/null +++ b/includes/templates/conf/dialplan/public.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/dialplan/public/00_inbound_did.xml.noload b/includes/templates/conf/dialplan/public/00_inbound_did.xml.noload new file mode 100644 index 0000000000..d40b3ab2c9 --- /dev/null +++ b/includes/templates/conf/dialplan/public/00_inbound_did.xml.noload @@ -0,0 +1,18 @@ + + + + + + + + + + diff --git a/includes/templates/conf/dialplan/skinny-patterns.xml b/includes/templates/conf/dialplan/skinny-patterns.xml new file mode 100644 index 0000000000..7817323aa9 --- /dev/null +++ b/includes/templates/conf/dialplan/skinny-patterns.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/dialplan/skinny-patterns/20-Demo.xml b/includes/templates/conf/dialplan/skinny-patterns/20-Demo.xml new file mode 100644 index 0000000000..f69658128f --- /dev/null +++ b/includes/templates/conf/dialplan/skinny-patterns/20-Demo.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/includes/templates/conf/dialplan/skinny-patterns/20-Local_extension.xml b/includes/templates/conf/dialplan/skinny-patterns/20-Local_extension.xml new file mode 100644 index 0000000000..9ad5651328 --- /dev/null +++ b/includes/templates/conf/dialplan/skinny-patterns/20-Local_extension.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/includes/templates/conf/dialplan/skinny-patterns/90-External.xml b/includes/templates/conf/dialplan/skinny-patterns/90-External.xml new file mode 100644 index 0000000000..50d6c37f24 --- /dev/null +++ b/includes/templates/conf/dialplan/skinny-patterns/90-External.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/includes/templates/conf/dialplan/skinny-patterns/99-Default_Drop.xml b/includes/templates/conf/dialplan/skinny-patterns/99-Default_Drop.xml new file mode 100644 index 0000000000..897fd8fb94 --- /dev/null +++ b/includes/templates/conf/dialplan/skinny-patterns/99-Default_Drop.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/includes/templates/conf/directory/default.xml b/includes/templates/conf/directory/default.xml new file mode 100644 index 0000000000..8af7aea135 --- /dev/null +++ b/includes/templates/conf/directory/default.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/directory/default/brian.xml.noload b/includes/templates/conf/directory/default/brian.xml.noload new file mode 100644 index 0000000000..05fe0c8324 --- /dev/null +++ b/includes/templates/conf/directory/default/brian.xml.noload @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/directory/default/default.xml.noload b/includes/templates/conf/directory/default/default.xml.noload new file mode 100644 index 0000000000..05eb1b4001 --- /dev/null +++ b/includes/templates/conf/directory/default/default.xml.noload @@ -0,0 +1,22 @@ + + + + + + + + + + + + diff --git a/includes/templates/conf/directory/default/example.com.xml.noload b/includes/templates/conf/directory/default/example.com.xml.noload new file mode 100644 index 0000000000..42a33ddbf3 --- /dev/null +++ b/includes/templates/conf/directory/default/example.com.xml.noload @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/templates/conf/directory/default/skinny-example.xml.noload b/includes/templates/conf/directory/default/skinny-example.xml.noload new file mode 100644 index 0000000000..357eb72f12 --- /dev/null +++ b/includes/templates/conf/directory/default/skinny-example.xml.noload @@ -0,0 +1,35 @@ + + + + + + + + + + +