00001 <?php
00002 require_once("GenieGate/View.php");
00010 class GenieGate_View_FlatFile extends GenieGate_View {
00011 var $DBH;
00012 var $METHOD;
00013 var $FORMAT = array(PASSWD => "export_passwd",
00014 GROUP => "export_group",
00015 TAB => "export_tab");
00016
00017 function GenieGate_View_FlatFile($dbh,$format){
00018 $this->DBH = $dbh;
00019 $method = $this->FORMAT[$format];
00020 if($method) {
00021 $this->METHOD = $method;
00022 }else{
00023 $this->METHOD = "export_tab";
00024 }
00025 }
00026
00027 function display(){
00028 $method = $this->METHOD;
00029 $this->$method();
00030 }
00031 function export_tab(){
00032 $sql = "SELECT uid,created,name,email,password,confirm FROM ua_users";
00033 $rs = mysql_query($sql,$this->DBH) or die(mysql_error($this->DBH));
00034 if($rs){
00035 while( list($uid,$created,$name,$email,$password,$confirm) = mysql_fetch_row($rs)){
00036 echo "$uid\t$created\t$name\t$email\t$password\t$confirm\n";
00037 }
00038 }
00039 }
00040 function export_passwd() {
00041 $sql = "SELECT uid,password FROM ua_users";
00042 $rs = mysql_query($sql,$this->DBH) or die(mysql_error($this->DBH));
00043 if($rs){
00044 while( list($uid,$passwd) = mysql_fetch_row($rs)){
00045 $p = crypt($passwd,$passwd);
00046 echo "$uid:$p\n";
00047 }
00048 }
00049 }
00050
00051 function export_group() {
00052 $sql = "select gid,uid from ua_members order by gid";
00053 $rs = mysql_query($sql,$this->DBH) or die(mysql_error($this->DBH));
00054 if($rs){
00055 while( list($gid,$uid) = mysql_fetch_row($rs)){
00056 if(strlen($uid)){
00057 if($gid != $last_gid){
00058 if($users){
00059 echo "$last_gid:" . ltrim($users) . "\n";
00060 $users = "";
00061 }
00062 $last_gid = $gid;
00063 }
00064 $users .= " $uid";
00065 }
00066 }
00067 if($users){
00068 echo "$last_gid:" . ltrim($users) . "\n";
00069 }
00070 }
00071 }
00072 }
00073
00074 ?>