Produced by Araxis Merge on 8/16/2019 12:02:04 PM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Direct_DSM.zip\Direct_DSM\webmail\application\controllers | Adminpanel.php | Tue Aug 13 17:30:08 2019 UTC |
| 2 | Direct_DSM.zip\Direct_DSM\webmail\application\controllers | Adminpanel.php | Fri Aug 16 14:41:25 2019 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 2366 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | <?php if ( ! defined ('BASEPATH ')) exit(' No direct script acc ess allowe d'); | |
| 2 | ||
| 3 | require_on ce APPPATH .'controll ers/restri cted_contr oller.php' ; | |
| 4 | ||
| 5 | class Admi nPanel ext ends Restr icted_cont roller { | |
| 6 | ||
| 7 | fu nction __c onstruct() { | |
| 8 | pare nt::__cons truct(); | |
| 9 | $thi s->verify_ permission ("adminpan el"); | |
| 10 | } | |
| 11 | ||
| 12 | ||
| 13 | pu blic funct ion index( ) | |
| 14 | { | |
| 15 | if($ this->has_ permission ("reports" )){ | |
| 16 | redire ct("adminp anel/repor ts"); | |
| 17 | } | |
| 18 | else if($this- >has_permi ssion("log s")){ | |
| 19 | redire ct("adminp anel/logs" ); | |
| 20 | } | |
| 21 | else if($this- >has_permi ssion("man age_users" )){ | |
| 22 | redire ct("adminp anel/manag e_users"); | |
| 23 | } | |
| 24 | else if($this- >has_permi ssion("man age_groups ")){ | |
| 25 | redire ct("adminp anel/manag e_groups") ; | |
| 26 | } | |
| 27 | else if($this- >has_permi ssion("con tact_list" )){ | |
| 28 | redire ct("adminp anel/globa l_contacts "); | |
| 29 | } | |
| 30 | else if($this- >has_permi ssion("dis tribution_ lists")){ | |
| 31 | redire ct("adminp anel/distr ibution_li sts"); | |
| 32 | } | |
| 33 | else if($this- >has_permi ssion("the mes")){ | |
| 34 | redire ct("adminp anel/theme s"); | |
| 35 | } | |
| 36 | else { | |
| 37 | redire ct("auth") ; | |
| 38 | } | |
| 39 | } | |
| 40 | ||
| 41 | ||
| 42 | /* load log view */ | |
| 43 | fu nction log s($action = 'logins' , $value = NULL) { | |
| 44 | $thi s->verify_ permission ("logs"); | |
| 45 | $dat a = $this- >log_view( $action,$v alue); | |
| 46 | $thi s->load->v iew("admin panel/logs ",$data); | |
| 47 | } | |
| 48 | ||
| 49 | /* This funct ion displa ys the exp ort form v iew, meant for use w ith modal window or pop-up */ | |
| 50 | pu blic funct ion export _form($log ) { | |
| 51 | $thi s->load->v iew('admin panel/expo rt_form',a rray('log' =>$log)); | |
| 52 | } | |
| 53 | ||
| 54 | /* This func tion expor ts a log f or a given time peri od to csv format | |
| 55 | * / | |
| 56 | pu blic funct ion export ($log) { | |
| 57 | $thi s->verify_ permission ("logs"); | |
| 58 | $thi s->load->l ibrary('lo cale'); | |
| 59 | $tim ezone_abbr ev = $this ->locale-> timezone_a bbr_from_n ame(date_d efault_tim ezone_get( )); | |
| 60 | ||
| 61 | $sta rt_date = $this->inp ut->post(" start_date ",TRUE); | |
| 62 | $end _date = $t his->input ->post("en d_date",TR UE); | |
| 63 | $sta rt_udate = strtotime ($start_da te); | |
| 64 | $end _udate = s trtotime($ end_date) ? strtotim e($end_dat e) + 86400 : strtoti me($end_da te); | |
| 65 | $thi s->load->m odel('webm ailmodel') ; | |
| 66 | $log _query = $ this->webm ailmodel-> get_log_ex port($log, $start_uda te,$end_ud ate); | |
| 67 | ||
| 68 | if($ log == "lo gins") { | |
| 69 | $this- >verify_pe rmission(" logs_login s"); | |
| 70 | if($lo g_query) { | |
| 71 | head er('Conten t-Type: ap plication/ download') ; | |
| 72 | header(" Content-Tr ansfer-Enc oding: bin ary"); | |
| 73 | header(' Content-Di sposition: attachmen t; filenam e="logins. csv"'); | |
| 74 | echo "FO R OFFICIAL USE ONLY\ n"; | |
| 75 | echo "Lo g Date"; | |
| 76 | if(isset ($timezone _abbrev)) { echo ' ( ' . $timez one_abbrev . ')'; } | |
| 77 | echo ",U sername,IP Address,L ogin Succe ss,Error M essage\n"; | |
| 78 | for($i = 0; $i < $ log_query- >num_rows( ); $i++) { | |
| 79 | $row = $lo g_query->r ow_array($ i); | |
| 80 | foreach($r ow as $key => $val) { $row[$ke y] = str_r eplace("\" ","\"\"",$ val); } | |
| 81 | if($row["s uccess"]) { $success = "Succes s"; } else { $succes s = "Failu re"; } | |
| 82 | echo date( "m/d/y h:i :s A",$row ["login_ti me"]) . ", \"" . $row ["username "] . "\"," . $row["i p_address" ] . "," . $success . ",\"" . $ row["error _msg"] . " \"\n"; | |
| 83 | } | |
| 84 | } | |
| 85 | } | |
| 86 | else if($log = = "sent_ma il") { | |
| 87 | $this- >verify_pe rmission(" logs_sent_ mail"); | |
| 88 | if($lo g_query) { | |
| 89 | header(' Content-Ty pe: applic ation/down load'); | |
| 90 | header(" Content-Tr ansfer-Enc oding: bin ary"); | |
| 91 | head er('Conten t-Disposit ion: attac hment; fil ename="sen t_mail.csv "'); | |
| 92 | echo "FO R OFFICIAL USE ONLY\ n"; | |
| 93 | echo "Lo g Date"; | |
| 94 | if(isset ($timezone _abbrev)) { echo ' ( ' . $timez one_abbrev . ')'; } | |
| 95 | echo ",S ender,Reci pient(s),M essage Siz e (KB),Sen d Success\ n"; | |
| 96 | for($i = 0; $i < $ log_query- >num_rows( ); $i++) { | |
| 97 | $row = $lo g_query->r ow_array($ i); | |
| 98 | if($row["s uccess"]) { $success = "Succes s"; } else { $succes s = "Failu re"; } | |
| 99 | echo date( "m/d/y h:i :s A",$row ["time"]) . ",\"" . $this->san itize_expo rt($row["s ender"]) . "\",\"" . implode(" , ",$this- >sanitize_ export($th is->json-> decode($ro w["recipie nt"]))) . "\"," . $r ow["size"] . "," . $ success . "\n"; | |
| 100 | } | |
| 101 | } | |
| 102 | } | |
| 103 | else if($log = = "receive d_mail") { | |
| 104 | $this- >verify_pe rmission(" logs_recei ved_mail") ; | |
| 105 | if($lo g_query) { | |
| 106 | header(' Content-Ty pe: applic ation/down load'); | |
| 107 | header(" Content-Tr ansfer-Enc oding: bin ary"); | |
| 108 | head er('Conten t-Disposit ion: attac hment; fil ename="rec eived_mail .csv"'); | |
| 109 | echo "FO R OFFICIAL USE ONLY\ n"; | |
| 110 | echo "Lo g Date"; | |
| 111 | if(isset ($timezone _abbrev)) { echo ' ( ' . $timez one_abbrev . ')'; } | |
| 112 | echo ",S ender,Reci pient(s),M essage Siz e (KB),Rec eipt Succe ss\n"; | |
| 113 | for($i = 0; $i < $ log_query- >num_rows( ); $i++) { | |
| 114 | $row = $lo g_query->r ow_array($ i); | |
| 115 | if($row["s uccess"]) { $success = "Succes s"; } else { $succes s = "Failu re"; } | |
| 116 | echo date( "m/d/y h:i :s A",$row ["time"]) . ",\"" . $this->san itize_expo rt($row["s ender"]) . "\",\"" . implode(" , ",$this- >sanitize_ export($th is->json-> decode($ro w["recipie nt"]))) . "\"," . $r ow["size"] . "," . $ success . "\n"; | |
| 117 | } | |
| 118 | } | |
| 119 | } | |
| 120 | else if($log = = "edit") { | |
| 121 | $this- >verify_pe rmission(" logs_edit" ); | |
| 122 | if($lo g_query) { | |
| 123 | header(' Content-Ty pe: applic ation/down load'); | |
| 124 | header(" Content-Tr ansfer-Enc oding: bin ary"); | |
| 125 | head er('Conten t-Disposit ion: attac hment; fil ename="edi t_log.csv" '); | |
| 126 | echo "FO R OFFICIAL USE ONLY\ n"; | |
| 127 | echo "Lo g Date"; | |
| 128 | if(isset ($timezone _abbrev)) { echo ' ( ' . $timez one_abbrev . ')'; } | |
| 129 | echo ",T arget,Acto r,Action\n "; | |
| 130 | for($i = 0; $i < $ log_query- >num_rows( ); $i++) { | |
| 131 | $row = $lo g_query->r ow_array($ i); | |
| 132 | $target_id _query = $ this->db-> query("SEL ECT user_n ame FROM u sers WHERE user_id=" . $this-> db->escape ($row["tar get_user_i d"])); | |
| 133 | $actor_id_ query = $t his->db->q uery("SELE CT user_na me FROM us ers WHERE user_id=" . $this->d b->escape( $row["acto r_user_id" ])); | |
| 134 | if($target _id_query && $actor_ id_query) { | |
| 135 | $t arget_id_r ow = $targ et_id_quer y->row_arr ay(); | |
| 136 | $a ctor_id_ro w = $actor _id_query- >row_array (); | |
| 137 | $t arget_name = isset($ target_id_ row ["user _name"]) ? $target_i d_row ["us er_name"] : "Unknown User"; | |
| 138 | $a ctor_name = isset($a ctor_id_ro w ["user_n ame"]) ? $ actor_id_r ow ["user_ name"] : " Unknown Us er"; | |
| 139 | ec ho date("m /d/y h:i:s A",$row[" edit_datet ime"]) . " ,\"" . $th is->saniti ze_export( $target_na me) . "\", \"" . $thi s->sanitiz e_export($ actor_name ) . "\"," . $this->s anitize_ex port($row[ "edit_acti on"]) . "\ n"; | |
| 140 | } | |
| 141 | } | |
| 142 | } | |
| 143 | } | |
| 144 | else if($log = = "feedbac k") { | |
| 145 | $this- >verify_pe rmission(" logs_feedb ack"); | |
| 146 | if($lo g_query) { | |
| 147 | header(' Content-Ty pe: applic ation/down load'); | |
| 148 | header(" Content-Tr ansfer-Enc oding: bin ary"); | |
| 149 | head er('Conten t-Disposit ion: attac hment; fil ename="fee dback.csv" '); | |
| 150 | echo "FO R OFFICIAL USE ONLY\ n"; | |
| 151 | echo "Lo g Date"; | |
| 152 | if(isset ($timezone _abbrev)) { echo ' ( ' . $timez one_abbrev . ')'; } | |
| 153 | echo ",U sername,Fe edback Typ e,Feedback Comments\ n"; | |
| 154 | for($i = 0; $i < $ log_query- >num_rows( ); $i++) { | |
| 155 | $row = $lo g_query->r ow_array($ i); | |
| 156 | $actor_id_ query = $t his->db->q uery("SELE CT user_na me FROM us ers WHERE user_id=" . $this->d b->escape( $row["user _id"])); | |
| 157 | if($actor_ id_query) { | |
| 158 | $a ctor_id_ro w = $actor _id_query- >row_array (); | |
| 159 | $a ctor_name = isset($a ctor_id_ro w["user_na me"]) ? $a ctor_id_ro w["user_na me"] : "Un known User "; | |
| 160 | ec ho date("m /d/y h:i:s A",$row[" feedback_d atetime"]) . ",\"" . $this->sa nitize_exp ort($actor _name) . " \",\"" . $ this->sani tize_expor t($row["fe edback_typ e"]) . "\" ," . $this ->sanitize _export($r ow["feedba ck_comment s"]) . "\n "; | |
| 161 | } | |
| 162 | } | |
| 163 | } | |
| 164 | } | |
| 165 | else { show_40 4(); } | |
| 166 | } | |
| 167 | /* This func tion loads statistic s from the database into html tables whi ch are the n converte d into | |
| 168 | * chart vis ualization s by a jqu ery librar y | |
| 169 | * / | |
| 170 | pu blic funct ion chart( $chart = N ULL) { | |
| 171 | $dat a["title"] = PORTAL_ TITLE_PREF IX . "Admi n Panel"; | |
| 172 | if(i s_null($ch art)) { $c hart = "se nt_message s"; } | |
| 173 | swit ch ($chart ) { | |
| 174 | case " sent_messa ges": | |
| 175 | $this->ver ify_permis sion("repo rts_sent_m essages"); | |
| 176 | //create t otal messa ges sent p er day cha rt | |
| 177 | $stmt = $t his->db->q uery("SELE CT time AS date, COU NT(time) A S msg_coun t FROM mai l_log WHER E inbound_ outbound=0 AND time BETWEEN (d atediff(ss , '1970010 1', GetUtc Date()) - 518400) AN D (datedif f(ss, '197 00101', Ge tUtcDate() )) GROUP B Y time"); | |
| 178 | $i = 0; | |
| 179 | $chartdata = array() ; | |
| 180 | $results = array(); | |
| 181 | foreach($s tmt->resul t_array() as $row) { | |
| 182 | $d ate = date ("m/d", $r ow['date'] ); | |
| 183 | $c ount = $ro w['msg_cou nt']; | |
| 184 | if (array_key _exists($d ate,$resul ts)) { $re sults[$dat e] = $resu lts[$date] + $count; } | |
| 185 | el se { $resu lts[$date] = $count; } | |
| 186 | } | |
| 187 | foreach($r esults as $key => $r ow) { | |
| 188 | $c hartdata[$ i]["date"] = $key; | |
| 189 | $c hartdata[$ i]["count" ] = $row; | |
| 190 | $i ++; | |
| 191 | } | |
| 192 | //add date s with no records to chart | |
| 193 | $j = 0; | |
| 194 | for($i = (date("U" ) - (86400 *6)); $i < = date("U" ); $i = $i + 86400) { | |
| 195 | if(isset($ chartdata[ $j]) && $c hartdata[$ j]["date"] != date(" m/d",$i)) { array_sp lice($char tdata,$j,0 ,array(arr ay("date" => date("m /d",$i), " count" => 0))); } | |
| 196 | else if(!i sset($char tdata[$j]) ){ $chartd ata[$j]["d ate"] = da te("m/d",$ i); $chart data[$j][" count"] = 0; } | |
| 197 | $j++; | |
| 198 | } | |
| 199 | $data['c hart_title '] = 'Mess ages Sent Daily Char t'; | |
| 200 | $data["c hart"] = $ this->mark up_for_jqu ery_chart( "line","Me ssages Sen t Daily",$ chartdata, "sent_dai ly_chart", "650px","3 25px"); | |
| 201 | $data['h idden_char t'] = '<ta ble><capti on>Table r epresentin g data in Messages S ent Daily chart</cap tion><tr>< th>Date</t h><th>Mess ages Sent< /th></tr>' ; | |
| 202 | foreach( $chartdata as $cdata ) { | |
| 203 | $data['hid den_chart' ] .= '<tr> <td>' . $c data['date '] . '</td ><td>' . $ cdata['cou nt'] . '</ td></tr>'; | |
| 204 | } | |
| 205 | $data['h idden_char t'] .= '</ table>'; | |
| 206 | break; | |
| 207 | case " message_su ccess": | |
| 208 | $this->v erify_perm ission("re ports_mess age_succes s"); | |
| 209 | //create success v s fail sen t messages chart | |
| 210 | $stmt = $this->db- >query("SE LECT SUM(C ASE WHEN s uccess = 1 THEN 1 EL SE 0 END) AS success , SUM(CASE WHEN succ ess = 0 TH EN 1 ELSE 0 END) AS fail FROM mail_log W HERE inbou nd_outboun d=0"); | |
| 211 | $chartda ta = array (); | |
| 212 | foreach( $stmt->res ult_array( ) as $row) { | |
| 213 | $chartdata ["success" ]["label"] = "Succee ded"; | |
| 214 | $chartdata ["success" ]["val"] = empty($ro w['success ']) ? 0 : $row['succ ess']; | |
| 215 | $chartdata ["fail"][" label"] = "Failed"; | |
| 216 | $chartdata ["fail"][" val"] = em pty($row[' fail']) ? 0 : $row[' fail']; | |
| 217 | } | |
| 218 | $data['c hart_title '] = 'Send Success/F ailure Cha rt'; | |
| 219 | $data["c hart"] = $ this->mark up_for_jqu ery_chart( "pie","Sen d Success/ Failure",$ chartdata, "success_ fail_chart ", "650px" ,"325px"," ['#0162A2' ,'#FFA500' ]"); | |
| 220 | $data['h idden_char t'] = '<ta ble>'; | |
| 221 | $data['h idden_char t'] .= '<c aption>Tab le represe nting data in Send S uccess/Fai lure chart </caption> '; | |
| 222 | $data['h idden_char t'] .= '<t r><th scop e="col">Da ta Type</t h><th scop e="col">' . $chartda ta['succes s']['label '] . '</th ><th scope ="col">' . $chartdat a['fail'][ 'label'] . '</th></t r>'; | |
| 223 | $data['h idden_char t'] .= '<t r><th scop e="row">Co unt</th><t d>'.$chart data['succ ess']['val '].'</td>< td>'.$char tdata['fai l']['val'] .'</td></t r>'; | |
| 224 | $data['h idden_char t'] .= '<t r><th scop e="row">Pe rcentage o f Total</t h><td>'.$t his->_calc MessagePer centage($c hartdata, 'success') .'</td><td >'.$this-> _calcMessa gePercenta ge($chartd ata, 'fail ').'</td>< /tr>'; | |
| 225 | $data['h idden_char t'] .= '</ table>'; | |
| 226 | break; | |
| 227 | case " average_si ze": | |
| 228 | $this->v erify_perm ission("re ports_aver age_size") ; | |
| 229 | //create average m essage siz e per day chart | |
| 230 | $stmt = $this->db- >query("SE LECT time AS date, A VG(size) A S msg_size FROM mail _log WHERE inbound_o utbound=0 AND time B ETWEEN (da tediff(ss, '19700101 ', GetUtcD ate()) - 5 18400) AND (datediff (ss, '1970 0101', Get UtcDate()) ) GROUP BY time"); | |
| 231 | $chartda ta = array (); | |
| 232 | $results = array() ; | |
| 233 | foreach( $stmt->res ult_array( ) as $row) { | |
| 234 | $d ate = date ("m/d", $r ow['date'] ); | |
| 235 | $s ize = $row ['msg_size ']; | |
| 236 | if (array_key _exists($d ate,$resul ts)) { | |
| 237 | $res ults[$date ]['size'] = $results [$date]['s ize'] + $s ize; | |
| 238 | $res ults[$date ]['count'] = $result s[$date][' count'] + 1; | |
| 239 | } | |
| 240 | el se { $resu lts[$date] ['size'] = $size; $r esults[$da te]['count '] = 1; } | |
| 241 | } | |
| 242 | $i = 0; | |
| 243 | foreach( $results a s $key => $row) { | |
| 244 | $chartdata [$i]["date "] = $key; | |
| 245 | $chartdata [$i]["size "] = round (($row['si ze'] / $ro w['count'] ),2); | |
| 246 | $i++; | |
| 247 | } | |
| 248 | //add da tes with n o records to chart | |
| 249 | $j = 0; | |
| 250 | for($i = (date("U" ) - (86400 *6)); $i < = date("U" ); $i = $i + 86400) { | |
| 251 | if(isset($ chartdata[ $j]) && $c hartdata[$ j]["date"] != date(" m/d",$i)) { array_sp lice($char tdata,$j,0 ,array(arr ay("date" => date("m /d",$i), " size" => 0 ))); } | |
| 252 | else if(!i sset($char tdata[$j]) ){ $chartd ata[$j]["d ate"] = da te("m/d",$ i); $chart data[$j][" size"] = 0 ; } | |
| 253 | $j++; | |
| 254 | } | |
| 255 | $data['c hart_title '] = 'Avg. Daily Mes sage Size (KB) Chart '; | |
| 256 | $data["c hart"] = $ this->mark up_for_jqu ery_chart( "line","Av g. Daily M essage Siz e (KB)",$c hartdata, "avg_size_ chart","65 0px","325p x"); | |
| 257 | $data['h idden_char t'] = '<ta ble><capti on>Table r epresentin g data in Average Da ily Messag e Size cha rt</captio n><tr><th> Date</th>< th>Size (K B)</th></t r>'; | |
| 258 | foreach( $chartdata as $cdata ) { | |
| 259 | $data['hid den_chart' ] .= '<tr> <td>' . $c data['date '] . '</td ><td>' . $ cdata['siz e'] . '</t d></tr>'; | |
| 260 | } | |
| 261 | $data['h idden_char t'] .= '</ table>'; | |
| 262 | break; | |
| 263 | case " unique_log ins": | |
| 264 | $this->v erify_perm ission("re ports_uniq ue_logins" ); | |
| 265 | //create unique lo gins per d ay chart | |
| 266 | $stmt = $this->db- >query("SE LECT login _time AS d ate, usern ame, ip_ad dress FROM logins WH ERE succes s=1 AND (l ogin_time BETWEEN (d atediff(ss , '1970010 1', GetUtc Date()) - 518400) AN D (datedif f(ss, '197 00101', Ge tUtcDate() )))"); | |
| 267 | $chartda ta = array (); | |
| 268 | $results = array() ; | |
| 269 | foreach( $stmt->res ult_array( ) as $row) { | |
| 270 | $d ate = date ("m/d", $r ow['date'] ); | |
| 271 | $u sername = $row['user name']; | |
| 272 | $i p = $row[' ip_address ']; | |
| 273 | $u ser_ip = $ username . '#' . $ip ; | |
| 274 | if (array_key _exists($d ate,$resul ts)) { | |
| 275 | if(a rray_key_e xists($use r_ip,$resu lts[$date] )) { | |
| 276 | $resul ts[$date][ $user_ip][ 'count'] = $results[ $date][$us er_ip]['co unt'] + 1; | |
| 277 | } | |
| 278 | else { $result s[$date][$ user_ip][' count'] = 1; } | |
| 279 | } | |
| 280 | el se { | |
| 281 | $res ults[$date ][$user_ip ]['count'] = 1; | |
| 282 | } | |
| 283 | } | |
| 284 | foreach( $results a s $date => $logins) { | |
| 285 | $day_count = 0; | |
| 286 | foreach($l ogins as $ user_ip) { | |
| 287 | $d ay_count++ ; | |
| 288 | } | |
| 289 | $results[$ date]['cou nt'] = $da y_count; | |
| 290 | } | |
| 291 | $i = 0; | |
| 292 | foreach( $results a s $key => $row) { | |
| 293 | $chartdata [$i]["date "] = $key; | |
| 294 | $chartdata [$i]["coun t"] = $row ['count']; | |
| 295 | $i++; | |
| 296 | } | |
| 297 | ||
| 298 | //add da tes with n o records to chart | |
| 299 | $j = 0; | |
| 300 | for($i = (date("U" ) - (86400 *6)); $i < = date("U" ); $i = $i + 86400) { | |
| 301 | if(isset($ chartdata[ $j]) && $c hartdata[$ j]["date"] != date(" m/d",$i)) { array_sp lice($char tdata,$j,0 ,array(arr ay("date" => date("m /d",$i), " count" => 0))); } | |
| 302 | else if(!i sset($char tdata[$j]) ){ $chartd ata[$j]["d ate"] = da te("m/d",$ i); $chart data[$j][" count"] = 0; } | |
| 303 | $j++; | |
| 304 | } | |
| 305 | $data['c hart_title '] = 'Uniq ue Success ful Logins Daily Cha rt'; | |
| 306 | $data["c hart"] = $ this->mark up_for_jqu ery_chart( "bar","Uni que Succes sful Login s Daily",$ chartdata, "unique_l ogin_chart ","650px", "325px","[ 'blue']"); | |
| 307 | $data['h idden_char t'] = '<ta ble><capti on>Table r epresentin g data in Unique Suc cessful Lo gins Daily chart</ca ption><tr> <th>Date</ th><th>Log in Count</ th></tr>'; | |
| 308 | foreach( $chartdata as $cdata ) { | |
| 309 | $data['hid den_chart' ] .= '<tr> <td>' . $c data['date '] . '</td ><td>' . $ cdata['cou nt'] . '</ td></tr>'; | |
| 310 | } | |
| 311 | $data['h idden_char t'] .= '</ table>'; | |
| 312 | break; | |
| 313 | case " login_succ ess": | |
| 314 | $this->v erify_perm ission("re ports_logi n_success" ); | |
| 315 | //create success v s fail log in chart | |
| 316 | $stmt = $this->db- >query("SE LECT SUM(C ASE WHEN s uccess = 1 THEN 1 EL SE 0 END) AS success , SUM(CASE WHEN succ ess = 0 TH EN 1 ELSE 0 END) AS fail FROM logins"); | |
| 317 | $chartda ta = array (); | |
| 318 | foreach( $stmt->res ult_array( ) as $row) { | |
| 319 | $chartdata ["success" ]["label"] = "Succee ded"; | |
| 320 | $chartdata ["success" ]["val"] = $row['suc cess']; | |
| 321 | $chartdata ["fail"][" label"] = "Failed"; | |
| 322 | $chartdata ["fail"][" val"] = $r ow['fail'] ; | |
| 323 | } | |
| 324 | $data['c hart_title '] = 'Logi n Success/ Failure Ch art'; | |
| 325 | $data["c hart"] = $ this->mark up_for_jqu ery_chart( "pie","Log in Success /Failure", $chartdata , "login_s uccess_fai l_chart", "650px","3 25px","['# 0162A2','# FFA500']") ; | |
| 326 | $data['h idden_char t'] = '<ta ble>'; | |
| 327 | $data['h idden_char t'] .= '<c aption>Tab le represe nting data in Login Success/Fa ilure char t</caption >'; | |
| 328 | $data['h idden_char t'] .= '<t r><th scop e="col">Da ta Type</t h><th scop e="col">' . $chartda ta['succes s']['label '] . '</th ><th scope ="col">' . $chartdat a['fail'][ 'label'] . '</th></t r>'; | |
| 329 | $data['h idden_char t'] .= '<t r><th scop e="row">Co unt</th><t d>' . $cha rtdata['su ccess']['v al'] . '</ td><td>' . $chartdat a['fail'][ 'val'] . ' </td></tr> '; | |
| 330 | $data['h idden_char t'] .= '<t r><th scop e="row">Pe rcentage o f Total</t h><td>' . round((($c hartdata[' success'][ 'val']/($c hartdata[' success'][ 'val']+$ch artdata['f ail']['val ']))*100), 2).'%'.'</ td><td>' . round((($ chartdata[ 'fail']['v al']/($cha rtdata['su ccess']['v al']+$char tdata['fai l']['val'] ))*100),2) .'%'. '</t d></tr>'; | |
| 331 | $data['h idden_char t'] .= '</ table>'; | |
| 332 | break; | |
| 333 | case " login_erro rs": | |
| 334 | $this->v erify_perm ission("re ports_logi n_errors") ; | |
| 335 | //create failed lo gin error chart | |
| 336 | $stmt = $this->db- >query("SE LECT TOP(5 ) username , error_ms g FROM log ins WHERE success = 0 ORDER BY login_tim e DESC"); | |
| 337 | $chartda ta = array (); | |
| 338 | $i = 0; | |
| 339 | foreach( $stmt->res ult_array( ) as $row) { | |
| 340 | $chartdata [$i]["user name"] = $ row['usern ame']; | |
| 341 | $chartdata [$i]["erro r"] = $row ['error_ms g']; | |
| 342 | $i++; | |
| 343 | } | |
| 344 | $data['c hart_title '] = 'Rece nt Login F ailure Rea sons Chart '; | |
| 345 | $data["c hart"] = $ this->mark up_for_jqu ery_chart( "table","R ecent Logi n Failure Reasons",$ chartdata, "failed_l ogin_chart ", "650px" ,"325px"," ",FALSE); | |
| 346 | $data['h idden_char t'] = ''; | |
| 347 | break; | |
| 348 | case " attachment _types": | |
| 349 | $this->v erify_perm ission("re ports_atta chment_typ es"); | |
| 350 | //create unique at tachment t ypes chart | |
| 351 | $stmt = $this->db- >query("SE LECT attac hment_type s FROM mai l_log"); | |
| 352 | $chartda ta = array (); | |
| 353 | foreach( $stmt->res ult_array( ) as $row) { | |
| 354 | if(strlen( trim($row[ "attachmen t_types"]) ) > 0) { | |
| 355 | $c ounts = ar ray_count_ values(exp lode(" ",t rim($row[" attachment _types"])) ); | |
| 356 | fo reach($cou nts as $ke y => $coun t) { | |
| 357 | if(! array_key_ exists($ke y,$chartda ta)) { | |
| 358 | $chart data[$key] ["type"] = $key; | |
| 359 | $chart data[$key] ["count"] = $count; | |
| 360 | } | |
| 361 | else { | |
| 362 | $chart data[$key] ["type"] = $key; | |
| 363 | $chart data[$key] ["count"] = $chartda ta[$key][" count"] + $count; | |
| 364 | } | |
| 365 | } | |
| 366 | } | |
| 367 | else if(st rlen(trim( $row["atta chment_typ es"])) == 0) { | |
| 368 | if (!array_ke y_exists(" none",$cha rtdata)) { | |
| 369 | $cha rtdata["no ne"]["type "] = "none "; | |
| 370 | $cha rtdata["no ne"]["coun t"] = 0; | |
| 371 | } | |
| 372 | el se { | |
| 373 | $cha rtdata["no ne"]["type "] = "none "; | |
| 374 | $cha rtdata["no ne"]["coun t"] = $cha rtdata["no ne"]["coun t"] + 1; | |
| 375 | } | |
| 376 | } | |
| 377 | } | |
| 378 | $data['c hart_title '] = 'Uniq ue Attachm ent Type V olumes Cha rt'; | |
| 379 | $data["c hart"] = $ this->mark up_for_jqu ery_chart( "bar","Uni que Attach ment Type Volumes",$ chartdata, "unique_at tachments_ chart","65 0px","325p x","['blue ']"); | |
| 380 | $data['h idden_char t'] = '<ta ble><capti on>Table r epresentin g data in Unique Att achment Ty pe Volumes chart</ca ption><tr> <th>Type</ th><th>Att achment Co unt</th></ tr>'; | |
| 381 | foreach( $chartdata as $cdata ) { | |
| 382 | $data['hid den_chart' ] .= '<tr> <td>' . $c data['type '] . '</td ><td>' . $ cdata['cou nt'] . '</ td></tr>'; | |
| 383 | } | |
| 384 | $data['h idden_char t'] .= '</ table>'; | |
| 385 | break; | |
| 386 | defaul t: | |
| 387 | $data["c hart"] = " Unrecogniz ed chart t ype"; | |
| 388 | break; | |
| 389 | } | |
| 390 | //lo ad view | |
| 391 | $thi s->load->v iew("admin panel/char t",$data); | |
| 392 | } | |
| 393 | ||
| 394 | pu blic funct ion report s() { | |
| 395 | $thi s->verify_ permission ("reports" ); | |
| 396 | $dat a["title"] = PORTAL_ TITLE_PREF IX . "Admi n Panel"; | |
| 397 | $thi s->load->v iew("admin panel/repo rts",$data ); | |
| 398 | } | |
| 399 | ||
| 400 | pu blic funct ion archiv e_setting( $action = NULL) { | |
| 401 | $thi s->verify_ permission ("archive_ settings") ; | |
| 402 | if(i s_null($ac tion)) { | |
| 403 | ||
| 404 | $data[ "title"] = PORTAL_TI TLE_PREFIX . "Archiv e Settings "; | |
| 405 | $messa ge_archive _settings = $this->d b->query(" SELECT TOP 1 * FROM dbo.archiv e_settings ")->result (); | |
| 406 | $data[ 'message_a rchive_set tings'] = $message_a rchive_set tings; | |
| 407 | ||
| 408 | $this- >load->vie w("adminpa nel/archiv e_settings ",$data); | |
| 409 | } | |
| 410 | ||
| 411 | } | |
| 412 | ||
| 413 | pu blic funct ion themes ($action = NULL) { | |
| 414 | $thi s->verify_ permission ("themes") ; | |
| 415 | if(i s_null($ac tion)) { | |
| 416 | ||
| 417 | $data[ "title"] = PORTAL_TI TLE_PREFIX . "Admin Panel"; | |
| 418 | $get_t hemes = $t his->db->q uery("SELE CT * FROM themes"); | |
| 419 | $data[ "themes"] = array(); | |
| 420 | if($ge t_themes) { | |
| 421 | for($i = 0; $i < $ get_themes ->num_rows (); $i++) { | |
| 422 | array_push ($data["th emes"],$ge t_themes-> row_array( $i)); | |
| 423 | } | |
| 424 | } | |
| 425 | $this- >load->vie w("adminpa nel/themes ",$data); | |
| 426 | } | |
| 427 | //TO -DO: These else stat ements on failure sh ould lead to error m essage giv en to user | |
| 428 | else if($actio n == "load _theme") { | |
| 429 | $theme _id = $thi s->input-> post("them e_id",TRUE ); | |
| 430 | $check _theme = $this->db- >query("SE LECT theme _id FROM t hemes WHER E theme_id = " . $th is->db->es cape($them e_id)); | |
| 431 | if($ch eck_theme- >num_rows( ) > 0) { | |
| 432 | $update_ default_th eme = $thi s->db->que ry("UPDATE themes SE T theme_is _default=0 WHERE the me_id !=" . $this->d b->escape( $theme_id) ); | |
| 433 | if($upda te_default _theme) { | |
| 434 | $update_de fault_them e = $this- >db->query ("UPDATE t hemes SET theme_is_d efault=1 W HERE theme _id=" . $t his->db->e scape($the me_id)); | |
| 435 | if($update _default_t heme) { | |
| 436 | $u pdate_them e = $this- >db->query ("UPDATE u sers SET u ser_theme= " . $this- >db->escap e($theme_i d)); | |
| 437 | if ($update_t heme) { | |
| 438 | redi rect("admi npanel/the mes"); | |
| 439 | } | |
| 440 | el se { redir ect("admin panel/them es"); } | |
| 441 | } | |
| 442 | else { red irect("adm inpanel/th emes"); } | |
| 443 | } | |
| 444 | } | |
| 445 | else { redirect( "adminpane l/themes") ; } | |
| 446 | } | |
| 447 | else { show_40 4(); } | |
| 448 | } | |
| 449 | ||
| 450 | ||
| 451 | // This funct ion loads the webmai l ldap use rs for the user to p ick from w hen decidi ng who to share the contact wi th. | |
| 452 | pu blic funct ion contac t_list_sea rch($input =null) { | |
| 453 | $pro perties = array('dis playname', 'mail','ui d'); | |
| 454 | $per son_result = $this-> ldap->sear ch(rawurld ecode($inp ut),null,$ properties ); | |
| 455 | ||
| 456 | arra y_walk_rec ursive($pe rson_resul t, functio n (&$value ) { | |
| 457 | $value = htmlent ities($val ue); | |
| 458 | }); | |
| 459 | //so rt result array (nat ural order , case ins ensitive) | |
| 460 | usor t($person_ result, fu nction( $e l1, $el2) { return s trnatcasec mp( $el1[' displaynam e'], $el2[ 'displayna me']); }); | |
| 461 | ||
| 462 | echo $this->js on->encode ($person_r esult); | |
| 463 | } | |
| 464 | ||
| 465 | pu blic funct ion distri bution_lis ts() { | |
| 466 | $thi s->paginat e_distribu tion_lists (1); | |
| 467 | } | |
| 468 | ||
| 469 | pu blic funct ion pagina te_distrib ution_list s($page) { | |
| 470 | $thi s->verify_ permission ("distribu tion_lists "); | |
| 471 | $lis ts = $this ->public_d istributio n_list_mod el->find(a rray()); | |
| 472 | $dat a['list_co unt'] = co unt($lists ); | |
| 473 | $dat a['page'] = $page; | |
| 474 | $dat a['lists'] = array_s lice($list s,(($page- 1)*ADMINPA NEL_DISPLA Y_PER_PAGE ),ADMINPAN EL_DISPLAY _PER_PAGE) ; | |
| 475 | //so rt array b y keys, us ing natura l order (i .e. test1, test2, .. . , test10 vs. test1 , test10, test2) | |
| 476 | ukso rt($data[' lists'], f unction($a , $b) { re turn strna tcasecmp($ a,$b); }); | |
| 477 | ||
| 478 | $dat a['title'] = PORTAL_ TITLE_PREF IX . 'Admi n Panel'; //set titl e of page | |
| 479 | $thi s->load->v iew('admin panel/mana ge_lists/i ndex',$dat a); | |
| 480 | } | |
| 481 | ||
| 482 | pu blic funct ion distri bution_lis ts_removed () { | |
| 483 | $thi s->paginat e_distribu tion_lists _removed(1 ); | |
| 484 | } | |
| 485 | ||
| 486 | pu blic funct ion pagina te_distrib ution_list s_removed( $page) { | |
| 487 | $thi s->verify_ permission ("distribu tion_lists "); | |
| 488 | $lis ts = $this ->public_d istributio n_list_mod el->find_d eleted(arr ay()); | |
| 489 | $dat a['list_co unt'] = co unt($lists ); | |
| 490 | $dat a['page'] = $page; | |
| 491 | $dat a['lists'] = array_s lice($list s,(($page- 1)*ADMINPA NEL_DISPLA Y_PER_PAGE ),ADMINPAN EL_DISPLAY _PER_PAGE) ; | |
| 492 | $dat a['title'] = PORTAL_ TITLE_PREF IX . 'Admi n Panel'; //set titl e of page | |
| 493 | $thi s->load->v iew('admin panel/mana ge_lists/r emoved',$d ata); | |
| 494 | } | |
| 495 | ||
| 496 | /** | |
| 497 | * dis plays the edit form. for savin g, see edi t_distribu tion_lists () | |
| 498 | * @pa ram $id | |
| 499 | */ | |
| 500 | public function distributi on_lists_e dit($id) { | |
| 501 | $thi s->verify_ permission ("distribu tion_lists "); | |
| 502 | $thi s->_distri bution_lis ts_edit( | |
| 503 | $id, | |
| 504 | 'public_ distributi on_list_mo del', | |
| 505 | array( | |
| 506 | 'act ive_tab' = > '/adminp anel/distr ibution_li sts/', | |
| 507 | 'for m' => 'adm inpanel/ed it_distrib ution_list ' | |
| 508 | ) | |
| 509 | ); | |
| 510 | } | |
| 511 | ||
| 512 | // displays t he edit fo rm - for s ave, see d istributio n_lists_ed it_removed () | |
| 513 | pu blic funct ion distri bution_lis ts_edit_re moved($id) { | |
| 514 | $thi s->verify_ permission ("distribu tion_lists "); | |
| 515 | $thi s->_distri bution_lis ts_edit( | |
| 516 | $id, | |
| 517 | 'deleted _public_di stribution _list_mode l', | |
| 518 | array( | |
| 519 | 'act ive_tab' = > '/adminp anel/distr ibution_li sts/', | |
| 520 | 'for m' => 'adm inpanel/ed it_removed _distribut ion_list' | |
| 521 | ) | |
| 522 | ); | |
| 523 | } | |
| 524 | ||
| 525 | /* * | |
| 526 | * Displays & submits f orm to cre ate public distribut ion lists. | |
| 527 | */ | |
| 528 | pu blic funct ion create _distribut ion_list() { | |
| 529 | $thi s->verify_ permission ("distribu tion_lists _create"); | |
| 530 | $thi s->load->l ibrary('au dit'); | |
| 531 | $tit le = PORTA L_TITLE_PR EFIX . 'Ad min Panel' ; | |
| 532 | $for m_data = a rray(); | |
| 533 | $val idation_er rors = arr ay(); | |
| 534 | $err or = ''; | |
| 535 | ||
| 536 | if(! empty($_PO ST)){ | |
| 537 | $list_ display_na me = $this ->input->p ost('list_ display_na me',TRUE); | |
| 538 | $list_ descriptio n = $this- >input->po st('list_d escription ',TRUE); | |
| 539 | ||
| 540 | //set valdiation rules | |
| 541 | if($th is->form_v alidation- >run('dist ribution_l ist') === TRUE) { | |
| 542 | $attribu tes = arra y( | |
| 543 | 'name' => $list_disp lay_name, | |
| 544 | 'cn' => $l ist_displa y_name, | |
| 545 | 'descripti on' => $li st_descrip tion, | |
| 546 | ); | |
| 547 | $id = $t his->publi c_distribu tion_list_ model->cre ate($attri butes); | |
| 548 | if($this ->public_d istributio n_list_mod el->format ted_like_a n_id($id)) { | |
| 549 | $list = $t his->publi c_distribu tion_list_ model->fin d_one(arra y('cn'=> $ list_displ ay_name)); | |
| 550 | $this->aud it->log_ev ent('edit' ,array(0,$ this->user ->id,'Crea ted list: ' . $list_ display_na me. ' ('.$ list['id'] .')',date( 'U'))); | |
| 551 | redirect(' adminpanel /distribut ion_lists/ list/'.$id ); | |
| 552 | }else{ | |
| 553 | $error = ' Something went wrong and your distributi on list wa s not crea ted. Plea se try aga in in a mo ment. '. | |
| 554 | 'If you conti nue to see this erro r, please contact a site admin istrator.' ; | |
| 555 | } | |
| 556 | } | |
| 557 | else { | |
| 558 | //valida tion fails | |
| 559 | $form_da ta = $this ->input->p ost(NULL,T RUE); | |
| 560 | $form_da ta['list_d isplay_nam e']=html_e ntity_deco de($form_d ata['list_ display_na me'],ENT_Q UOTES); | |
| 561 | $form_da ta['list_d escription ']=html_en tity_decod e($form_da ta['list_d escription '],ENT_QUO TES); | |
| 562 | if(is_ar ray($form_ data)) { | |
| 563 | foreach($f orm_data a s $key => $input) { | |
| 564 | if (strlen(fo rm_error($ key)) > 0) { $valida tion_error s[$key] = form_error ($key); } | |
| 565 | } | |
| 566 | $this->ses sion->set_ flashdata( 'validatio n_errors', $validatio n_errors); | |
| 567 | } | |
| 568 | } | |
| 569 | } | |
| 570 | $thi s->load->v iew('admin panel/mana ge_lists/c reate',com pact('erro r', 'form_ data', 'ti tle', 'val idation_er rors')); | |
| 571 | } | |
| 572 | ||
| 573 | // saves the edit form - for the form setu p, see dis tribution_ lists_edit () | |
| 574 | pu blic funct ion edit_d istributio n_list() { | |
| 575 | retu rn $this-> _edit_dist ribution_l ist('publi c_distribu tion_list_ model'); | |
| 576 | } | |
| 577 | ||
| 578 | // saves the edit form - for the form setu p, see dis tribution_ lists_edit _removed() | |
| 579 | pu blic funct ion edit_r emoved_dis tribution_ list() { | |
| 580 | retu rn $this-> _edit_dist ribution_l ist('delet ed_public_ distributi on_list_mo del'); | |
| 581 | } | |
| 582 | ||
| 583 | pu blic funct ion remove _distribut ion_list($ list_id) { | |
| 584 | $thi s->verify_ permission ("distribu tion_lists "); | |
| 585 | if($ this->publ ic_distrib ution_list _model->ex ists($list _id)) { | |
| 586 | $list = $this->p ublic_dist ribution_l ist_model- >find_one( $list_id); | |
| 587 | $this- >public_di stribution _list_mode l->delete( $list_id); | |
| 588 | $this- >load->lib rary('audi t'); | |
| 589 | if($li st !== nul l){ | |
| 590 | $this->a udit->log_ event('edi t',array(0 ,$this->us er->id,'Re moved list : ' . $lis t['name']. ' ('.$lis t_id.')',d ate('U'))) ; | |
| 591 | } | |
| 592 | } | |
| 593 | else { show_40 4(); } | |
| 594 | redi rect('admi npanel/dis tribution_ lists'); | |
| 595 | } | |
| 596 | ||
| 597 | pu blic funct ion restor e_distribu tion_list( $list_id) { | |
| 598 | $thi s->verify_ permission ("distribu tion_lists "); | |
| 599 | if($ this->publ ic_distrib ution_list _model->ex ists_delet ed($list_i d)) { | |
| 600 | $this- >public_di stribution _list_mode l->restore _deleted($ list_id); | |
| 601 | $list = $this->p ublic_dist ribution_l ist_model- >find_one( $list_id); | |
| 602 | $this- >load->lib rary('audi t'); | |
| 603 | if($li st !== nul l){ | |
| 604 | $this->a udit->log_ event('edi t',array(0 ,$this->us er->id,'Re stored lis t: ' . $li st['name'] . ' ('.$li st_id.')', date('U')) ); | |
| 605 | } | |
| 606 | } | |
| 607 | else { show_40 4(); } | |
| 608 | redi rect('admi npanel/dis tribution_ lists/remo ved'); | |
| 609 | } | |
| 610 | ||
| 611 | /* This func tion displ ays the ad d user to group form view, mea nt for use with a mo dal window or pop-up */ | |
| 612 | pu blic funct ion add_us er_to_grou p_form($gr oup,$activ e) { | |
| 613 | $thi s->verify_ permission ("manage_g roups"); | |
| 614 | $thi s->load->v iew('admin panel/mana ge_groups/ add_user_f orm',array ('group'=> $group,'ac tive'=>$ac tive)); | |
| 615 | } | |
| 616 | ||
| 617 | ||
| 618 | pu blic funct ion id_req uired($str , $field) { | |
| 619 | swit ch($field) { | |
| 620 | case ' piv': | |
| 621 | $this->f orm_valida tion->set_ message('i d_required ', 'The %s field is required w hen the ED IPI field is not pro vided.'); | |
| 622 | return ( strlen(tri m($str)) < = 0) ? FAL SE : TRUE; | |
| 623 | break; | |
| 624 | case ' edipi': | |
| 625 | $this->f orm_valida tion->set_ message('i d_required ', 'The %s field is required w hen the PI V ID field is not pr ovided.'); | |
| 626 | return ( strlen(tri m($str)) < = 0) ? FAL SE : TRUE; | |
| 627 | break; | |
| 628 | defaul t: | |
| 629 | return F ALSE; | |
| 630 | break; | |
| 631 | } | |
| 632 | } | |
| 633 | ||
| 634 | pu blic funct ion update _archive_s etting() { | |
| 635 | $thi s->form_va lidation-> set_rules( "archive_a ge","Messa ge Age for Archive", "required| is_natural _no_zero", "xss_clean "); | |
| 636 | $thi s->form_va lidation-> set_rules( "frequency ","Frequen cy","requi red","xss_ clean"); | |
| 637 | $fre quency = $ this->inpu t->post("f requency", TRUE); | |
| 638 | $arc hive_age = $this->in put->post( "archive_a ge",TRUE); | |
| 639 | $arc hive_age_u nit = $thi s->input-> post("arch ive_age_un it",TRUE); | |
| 640 | if($ this->form _validatio n->run() = = true) { | |
| 641 | $frequ ency = $th is->input- >post("fre quency",TR UE); | |
| 642 | $archi ve_age = $ this->inpu t->post("a rchive_age ",TRUE); | |
| 643 | $frequ ency_array = array(' none', 'da ily', 'wee kly', 'biw eekly', 'm onthly', ' bimonthly' , 'six_mon ths', 'yea rly'); | |
| 644 | $archi ve_age_uni t_array = array('day ', 'week', 'month', 'year'); | |
| 645 | ||
| 646 | if(in_ array($fre quency, $f requency_a rray) && i n_array($a rchive_age _unit, $ar chive_age_ unit_array )) { | |
| 647 | $message _archive_s etting_id = $this->d b->query(" SELECT TOP 1 id FROM dbo.archi ve_setting s")->resul t(); | |
| 648 | $message _archive_s etting_id = $message _archive_s etting_id[ 0]->id; | |
| 649 | $update = $this->d b->query(" UPDATE dbo .archive_s ettings SE T frequenc y = " . $t his->db->e scape($fre quency) . ", archive _age = " . $this->db ->escape($ archive_ag e) . ", ar chive_age_ unit = " . $this->db ->escape($ archive_ag e_unit) . " WHERE id = " . $th is->db->es cape($mess age_archiv e_setting_ id)); | |
| 650 | } | |
| 651 | ||
| 652 | redire ct('/admin panel/arch ive_settin g'); | |
| 653 | } | |
| 654 | else { | |
| 655 | $form_ data = $th is->input- >post(NULL ,TRUE); | |
| 656 | $valid ation_erro rs = array (); | |
| 657 | if(is_ array($for m_data)) { | |
| 658 | foreach( $form_data as $key = > $input) { | |
| 659 | if(strlen( form_error ($key)) > 0) { $vali dation_err ors[$key] = form_err or($key); } | |
| 660 | } | |
| 661 | $this->s ession->se t_flashdat a('validat ion_errors ',$validat ion_errors ); | |
| 662 | } | |
| 663 | redire ct('/admin panel/arch ive_settin g'); | |
| 664 | } | |
| 665 | } | |
| 666 | ||
| 667 | pu blic funct ion ajax_g roup_membe r_search($ input = NU LL,$sizeli mit = NULL , $echo = TRUE) { | |
| 668 | if(! is_null($s izelimit)) { $proper ties = NUL L; } | |
| 669 | else { $prope rties = ar ray('displ ayname','o bjectclass ','mail',' uid','give nname','in itials','s n','physic aldelivery officename ','o','dep artmentnum ber','mobi le','telep honenumber ','title') ;} | |
| 670 | ||
| 671 | //on ly allow e choing of JSON data if request ed with AJ AX | |
| 672 | if(I S_AJAX) { | |
| 673 | if($ec ho) { echo $this->js on->encode ($this->ld ap->search (rawurldec ode($input ),$sizelim it,$proper ties,'(&(u serPasswor d=*)(|(dis playName=' .$input.'* )(uid='.$i nput.'*))) ')); } | |
| 674 | } | |
| 675 | //if not echoi ng, allow return | |
| 676 | if(! $echo) { r eturn $thi s->json->e ncode($thi s->ldap->s earch(rawu rldecode($ input),$si zelimit,$p roperties, '(&(userPa ssword=*)( |(displayN ame='.$inp ut.'*)(uid ='.$input. '*)))')); } | |
| 677 | } | |
| 678 | ||
| 679 | ////////// ////////// ////////// ////////// ////////// ////////// //////// | |
| 680 | // PROTECT ED METHODS | |
| 681 | // Helper methods fo r this con troller wh ich are no t web-acce ssible. | |
| 682 | ////////// ////////// ////////// ////////// ////////// ////////// //////// | |
| 683 | ||
| 684 | // helper met hod to dis play the e dit form f or active & removed distros | |
| 685 | pr otected fu nction _di stribution _lists_edi t($id, $mo del, $data ) { | |
| 686 | ||
| 687 | if(!$thi s->is->non empty_stri ng($model) ) { | |
| 688 | return $th is->error- >should_be _a_nonempt y_string($ model); | |
| 689 | } | |
| 690 | ||
| 691 | // f irst, chec k to make sure we ha ve a valid list id | |
| 692 | $thi s->load->m odel($mode l,'list_mo del'); | |
| 693 | if(! $this->lis t_model->f ormatted_l ike_an_id( $id)) { | |
| 694 | show_404() ; | |
| 695 | } | |
| 696 | $lis t = $this- >list_mode l->find_on e(array('i d'=>$id)); | |
| 697 | if(e mpty($list )) { | |
| 698 | show_404() ; | |
| 699 | } | |
| 700 | ||
| 701 | // l oad data f or form | |
| 702 | $dat a['title'] = PORTAL_ TITLE_PREF IX . 'Admi n Panel'; | |
| 703 | $dat a['list_id '] = $id; | |
| 704 | $dat a['list'] = $list; | |
| 705 | $dat a['address es'] = $th is->list_m odel->addr esses_for_ list($list ); | |
| 706 | $dat a['form_da ta'] = arr ay( | |
| 707 | 'list_disp lay_name' => $list[' name'], | |
| 708 | 'list_de scription' => $list[ 'descripti on'] | |
| 709 | ); | |
| 710 | ||
| 711 | // s et up the options fo r the mult iselect | |
| 712 | $uui d = 0; | |
| 713 | $use r_options = array(); | |
| 714 | fore ach($this- >get_user_ search() a s $user){ | |
| 715 | $email = strtolo wer(trim($ user['id'] )); | |
| 716 | $user_ options[$e mail] = $u ser['name' ] . ' (' . $email . ')' . $uui d; | |
| 717 | $uuid+ +; | |
| 718 | } | |
| 719 | ||
| 720 | $ext ernal_addr esses = ar ray_diff($ data['addr esses'], a rray_keys( $user_opti ons)); | |
| 721 | fore ach($exter nal_addres ses as $ex ternal_add ress){ | |
| 722 | $user_ options[$e xternal_ad dress] = $ external_a ddress; | |
| 723 | } | |
| 724 | ||
| 725 | natc asesort($u ser_option s); | |
| 726 | ||
| 727 | // P opulate cu rrent pers onal distr ibution li st | |
| 728 | $cur PDL = arra y(); | |
| 729 | fore ach(array_ keys($user _options) as $email) { | |
| 730 | if(in_ array($ema il, $data[ 'addresses ']) ){ | |
| 731 | $curPDL[ $email] = $user_opti ons[$email ]; | |
| 732 | unset($u ser_option s[$email]) ; | |
| 733 | } | |
| 734 | } | |
| 735 | $dat a['user_op tions'] = $user_opti ons; | |
| 736 | $dat a['curPDL' ] = $curPD L; | |
| 737 | $thi s->load->v iew('admin panel/mana ge_lists/e dit_list', $data); | |
| 738 | } | |
| 739 | ||
| 740 | // helper me thod used by both me thods that save edit forms for distros ( edit_distr ibution_li st && edit _removed_d istributio n_list) | |
| 741 | pr otected fu nction _ed it_distrib ution_list ($model) { | |
| 742 | ||
| 743 | if(!$thi s->is->non empty_stri ng($model) ) { | |
| 744 | return $th is->error- >should_be _a_nonempt y_string($ model); | |
| 745 | } | |
| 746 | $thi s->load->m odel($mode l,'list_mo del'); | |
| 747 | ||
| 748 | $lis t_display_ name = $th is->input- >post('lis t_display_ name',TRUE ); | |
| 749 | $lis t_descript ion = $thi s->input-> post('list _descripti on',TRUE); | |
| 750 | $lis t_members = $this->i nput->post ('selected _users',TR UE); | |
| 751 | $lis t_id = $th is->input- >post('lis t_id',TRUE ); | |
| 752 | ||
| 753 | if(! is_array($ list_membe rs) || emp ty($list_m embers)) { | |
| 754 | //if no members, g ive empty array | |
| 755 | $list_memb ers = arra y(); | |
| 756 | } | |
| 757 | ||
| 758 | if($ this->form _validatio n->run('di stribution _list') == = TRUE) { | |
| 759 | // fir st, update display n ame and de scription | |
| 760 | $attri butes = ar ray( | |
| 761 | 'cn' => $list_disp lay_name, | |
| 762 | 'descrip tion' => $ list_descr iption, | |
| 763 | ); | |
| 764 | $this->l ist_model- >update($l ist_id,$at tributes); | |
| 765 | ||
| 766 | // nex t, update addresses | |
| 767 | $addre sses_in_li st = $this ->list_mod el->addres ses_for_li st($list_i d); | |
| 768 | $addre sses_to_ad d = array_ diff($list _members,$ addresses_ in_list); | |
| 769 | $addre sses_to_re move = arr ay_diff($a ddresses_i n_list,$li st_members ); | |
| 770 | foreac h($address es_to_add as $addres s) { | |
| 771 | $this-> list_model ->add_addr ess_to_lis t($list_id ,$address) ; | |
| 772 | } | |
| 773 | foreac h($address es_to_remo ve as $add ress) { | |
| 774 | $this-> list_model ->remove_a ddress_fro m_list($li st_id,$add ress); | |
| 775 | } | |
| 776 | // we are done u pdating th e list. re fresh the page | |
| 777 | $this- >session-> set_flashd ata('dist_ update_suc cess', tru e); | |
| 778 | redirect ("adminpan el/distrib ution_list s/list/" . $list_id) ; | |
| 779 | } | |
| 780 | else { | |
| 781 | // val idation fa iled | |
| 782 | $form_ data = $th is->input- >post(NULL ,TRUE); | |
| 783 | $valid ation_erro rs = array (); | |
| 784 | if(is_ array($for m_data)) { | |
| 785 | foreach( $form_data as $key = > $input) { | |
| 786 | if(strlen( form_error ($key)) > 0) { | |
| 787 | $valid ation_erro rs[$key] = form_erro r($key); | |
| 788 | } | |
| 789 | } | |
| 790 | echo jso n_encode($ validation _errors); | |
| 791 | } | |
| 792 | } | |
| 793 | } | |
| 794 | ||
| 795 | pr otected fu nction log _view($act ion = NULL , $value = NULL) { | |
| 796 | $dat a["title"] = PORTAL_ TITLE_PREF IX . "Admi n Panel"; | |
| 797 | $thi s->load->l ibrary('lo cale'); | |
| 798 | $tim ezone_abbr ev = $this ->locale-> timezone_a bbr_from_n ame(date_d efault_tim ezone_get( )); | |
| 799 | if($ action == "logins") { | |
| 800 | $this- >verify_pe rmission(" logs_login s"); | |
| 801 | $data[ "active_ta b"] = "log ins"; | |
| 802 | if(is_ null($valu e)) { $pag e_start = 0; $page = 1; } | |
| 803 | else { $page = $ value; $pa ge_start = (($page-1 )*ADMINPAN EL_LOG_DIS PLAY_PER_P AGE); } | |
| 804 | $login s = $this- >db->query ("SELECT * FROM (SEL ECT ROW_NU MBER() OVE R (ORDER B Y login_ti me DESC) A S RowNum, * FROM log ins) AS ro ws WHERE R owNum > " . ($page_s tart) . " AND RowNum <= " . ($ page_start + ADMINPA NEL_LOG_DI SPLAY_PER_ PAGE) . " ORDER BY R owNum"); | |
| 805 | $log_c ount_query = $this-> db->query( "SELECT CO UNT(id) AS login_cou nt FROM lo gins"); | |
| 806 | if($lo gins && $l og_count_q uery) { | |
| 807 | $row = $ log_count_ query->row _array(); | |
| 808 | $log_cou nt = $row[ "login_cou nt"]; | |
| 809 | $view_st r = "<span style=\"f loat: righ t;\"><a hr ef=\"javas cript:expo rtCSV('log ins');\">E xport</a>< /span>"; | |
| 810 | $view_st r .= "<h2> System Log s → Login Logs </h2>"; | |
| 811 | $view_st r .= $this ->generate _paginatio n($page,$l og_count,A DMINPANEL_ LOG_DISPLA Y_PER_PAGE ,'/adminpa nel/logs/l ogins/'); | |
| 812 | $view_st r .= "<tab le class=\ "log\">"; | |
| 813 | $view_st r .= '<cap tion class ="hidden_c ontext">Lo g of Login Records</ caption>'; | |
| 814 | $view_st r .= "<tr> <th>Log Da te"; | |
| 815 | if(isset ($timezone _abbrev)) { $view_st r .= ' (' . $timezon e_abbrev . ')'; } | |
| 816 | $view_st r .= "</th ><th>Usern ame</th><t h>IP Addre ss</th><th >Login Suc cess</th>< th>Error M essage</th ></tr>"; | |
| 817 | for($i = 0; $i < $ logins->nu m_rows(); $i++) { | |
| 818 | $row = $lo gins->row_ array($i); | |
| 819 | if($row["s uccess"]) { $success = "Succes s"; } else { $succes s = "Failu re"; } | |
| 820 | $view_str .= "<tr><t d>" . html entities(d ate("m/d/y h:i:s A", $row["logi n_time"])) . "</td>< td>" . htm lentities( $row["user name"]) . "</td><td> " . htmlen tities($ro w["ip_addr ess"]) . " </td><td>" . $succes s . "</td> <td>" . ht mlentities ($row["err or_msg"]) . "</td></ tr>"; | |
| 821 | } | |
| 822 | $view_st r .= "</ta ble>"; | |
| 823 | } | |
| 824 | } | |
| 825 | else if($actio n == "sent _mail") { | |
| 826 | $this- >verify_pe rmission(" logs_sent_ mail"); | |
| 827 | $data[ "active_ta b"] = "sen t_mail"; | |
| 828 | if(is_ null($valu e)) { $pag e_start = 0; $page = 1; } | |
| 829 | else { $page = $ value; $pa ge_start = (($page-1 )*ADMINPAN EL_LOG_DIS PLAY_PER_P AGE); } | |
| 830 | $sent_ mail = $th is->db->qu ery("SELEC T * FROM ( SELECT ROW _NUMBER() OVER (ORDE R BY time DESC) AS R owNum, * F ROM mail_l og WHERE i nbound_out bound=0) A S rows WHE RE inbound _outbound = 0 AND Ro wNum > " . ($page_st art) . " A ND RowNum <= " . ($p age_start + ADMINPAN EL_LOG_DIS PLAY_PER_P AGE) . " O RDER BY Ro wNum"); | |
| 831 | $log_c ount_query = $this-> db->query( "SELECT CO UNT(id) AS sent_coun t FROM mai l_log WHER E inbound_ outbound=0 "); | |
| 832 | if($se nt_mail && $log_coun t_query) { | |
| 833 | $row = $ log_count_ query->row _array(); | |
| 834 | $log_cou nt = $row[ "sent_coun t"]; | |
| 835 | $view_st r = "<span style=\"f loat: righ t;\"><a hr ef=\"javas cript:expo rtCSV('sen t_mail');\ ">Export</ a></span>" ; | |
| 836 | $view_st r .= "<h2> System Log s → Sent Mail Logs</h2>" ; | |
| 837 | $view_st r .= $this ->generate _paginatio n($page,$l og_count,A DMINPANEL_ LOG_DISPLA Y_PER_PAGE ,'/adminpa nel/logs/s ent_mail/' ); | |
| 838 | $view_st r .= "<tab le class=\ "log\">"; | |
| 839 | $view_st r .= '<cap tion class ="hidden_c ontext">Lo g of Sent Mail</capt ion>'; | |
| 840 | $view_st r .= "<tr> <th>Log Da te"; | |
| 841 | if(isset ($timezone _abbrev)) { $view_st r .= ' (' . $timezon e_abbrev . ')'; } | |
| 842 | $view_st r .="</th> <th>Sender </th><th>R ecipient(s )</th><th> Message Si ze (KB)</t h><th>Send Success</ th></tr>"; | |
| 843 | for($i = 0; $i < $ sent_mail- >num_rows( ); $i++) { | |
| 844 | $row = $se nt_mail->r ow_array($ i); | |
| 845 | if($row["s uccess"]) { $success = "Succes s"; } else { $succes s = "Failu re"; } | |
| 846 | $view_str .= "<tr><t d>" . html entities(d ate("m/d/y h:i:s A", $row["time "])) . "</ td><td>" . htmlentit ies($row[" sender"]) . "</td><t d>" . html entities(i mplode(", ",$this->j son->decod e($row["re cipient"]) )) . "</td ><td>" . $ row["size" ] . "</td> <td>" . $s uccess . " </td></tr> "; | |
| 847 | } | |
| 848 | $view_st r .= "</ta ble>"; | |
| 849 | } | |
| 850 | } | |
| 851 | else if($actio n == "rece ived_mail" ) { | |
| 852 | $this- >verify_pe rmission(" logs_recei ved_mail") ; | |
| 853 | $data[ "active_ta b"] = "rec eived_mail "; | |
| 854 | if(is_ null($valu e)) { $pag e_start = 0; $page = 1; } | |
| 855 | else { $page = $ value; $pa ge_start = (($page-1 )*ADMINPAN EL_LOG_DIS PLAY_PER_P AGE); } | |
| 856 | $sent_ mail = $th is->db->qu ery("SELEC T * FROM ( SELECT ROW _NUMBER() OVER (ORDE R BY time DESC) AS R owNum, * F ROM mail_l og WHERE i nbound_out bound=1) A S rows WHE RE inbound _outbound = 1 AND Ro wNum > " . ($page_st art) . " A ND RowNum <= " . ($p age_start + ADMINPAN EL_LOG_DIS PLAY_PER_P AGE) . " O RDER BY Ro wNum"); | |
| 857 | $log_c ount_query = $this-> db->query( "SELECT CO UNT(id) AS sent_coun t FROM mai l_log WHER E inbound_ outbound=1 "); | |
| 858 | if($se nt_mail && $log_coun t_query) { | |
| 859 | $row = $ log_count_ query->row _array(); | |
| 860 | $log_cou nt = $row[ "sent_coun t"]; | |
| 861 | $view_st r = "<span style=\"f loat: righ t;\"><a hr ef=\"javas cript:expo rtCSV('rec eived_mail ');\">Expo rt</a></sp an>"; | |
| 862 | $view_st r .= "<h2> System Log s → Received M ail Logs</ h2>"; | |
| 863 | $view_st r .= $this ->generate _paginatio n($page,$l og_count,A DMINPANEL_ LOG_DISPLA Y_PER_PAGE ,'/adminpa nel/logs/r eceived_ma il/'); | |
| 864 | $view_st r .= "<tab le class=\ "log\">"; | |
| 865 | $view_st r .= '<cap tion class ="hidden_c ontext">Lo g of Recei ved Mail</ caption>'; | |
| 866 | $view_st r .= "<tr> <th>Log Da te"; | |
| 867 | if(isset ($timezone _abbrev)) { $view_st r .= ' (' . $timezon e_abbrev . ')'; } | |
| 868 | $view_st r .="</th> <th>Sender </th><th>R ecipient(s )</th><th> Message Si ze (KB)</t h><th>Rece ipt Succes s</th></tr >"; | |
| 869 | for($i = 0; $i < $ sent_mail- >num_rows( ); $i++) { | |
| 870 | $row = $se nt_mail->r ow_array($ i); | |
| 871 | if($row["s uccess"]) { $success = "Succes s"; } else { $succes s = "Failu re"; } | |
| 872 | $view_str .= "<tr><t d>" . html entities(d ate("m/d/y h:i:s A", $row["time "])) . "</ td><td>" . htmlentit ies($row[" sender"]) . "</td><t d>" . html entities(i mplode(", ",$this->j son->decod e($row["re cipient"]) )) . "</td ><td>" . $ row["size" ] . "</td> <td>" . $s uccess . " </td></tr> "; | |
| 873 | } | |
| 874 | $view_st r .= "</ta ble>"; | |
| 875 | } | |
| 876 | } | |
| 877 | else if($actio n == "edit ") { | |
| 878 | $this- >verify_pe rmission(" logs_edit" ); | |
| 879 | $data[ "active_ta b"] = "edi t"; | |
| 880 | if(is_ null($valu e)) { $pag e_start = 0; $page = 1; } | |
| 881 | else { $page = $ value; $pa ge_start = (($page-1 )*ADMINPAN EL_LOG_DIS PLAY_PER_P AGE); } | |
| 882 | $edits = $this-> db->query( "SELECT * FROM (SELE CT ROW_NUM BER() OVER (ORDER BY edit_date time DESC) AS RowNum , * FROM e dit_log) A S rows WHE RE RowNum > " . ($pa ge_start) . " AND Ro wNum <= " . ($page_s tart + ADM INPANEL_LO G_DISPLAY_ PER_PAGE) . " ORDER BY RowNum" ); | |
| 883 | $log_c ount_query = $this-> db->query( "SELECT CO UNT(edit_i d) AS edit _count FRO M edit_log "); | |
| 884 | if($ed its && $lo g_count_qu ery) { | |
| 885 | $row = $ log_count_ query->row _array(); | |
| 886 | $log_cou nt = $row[ "edit_coun t"]; | |
| 887 | $view_st r = "<span style=\"f loat: righ t;\"><a hr ef=\"javas cript:expo rtCSV('edi t');\">Exp ort</a></s pan>"; | |
| 888 | $view_st r .= "<h2> System Log s → User Edit Logs</h2>" ; | |
| 889 | $view_st r .= $this ->generate _paginatio n($page,$l og_count,A DMINPANEL_ LOG_DISPLA Y_PER_PAGE ,'/adminpa nel/logs/e dit/'); | |
| 890 | $view_st r .= "<tab le class=\ "log\">"; | |
| 891 | $view_st r .= '<cap tion class ="hidden_c ontext">Lo g of Edit Records</c aption>'; | |
| 892 | $view_st r .= "<tr> <th>Log Da te"; | |
| 893 | if(isset ($timezone _abbrev)) { $view_st r .= ' (' . $timezon e_abbrev . ')'; } | |
| 894 | $view_st r .= "</th ><th>Targe t</th><th> Actor</th> <th>Action </th></tr> "; | |
| 895 | for($i = 0; $i < $ edits->num _rows(); $ i++) { | |
| 896 | $row = $ed its->row_a rray($i); | |
| 897 | $target_id _query = $ this->db-> query("SEL ECT user_n ame FROM u sers WHERE user_id=" . $this-> db->escape ($row["tar get_user_i d"])); | |
| 898 | $actor_id_ query = $t his->db->q uery("SELE CT user_na me FROM us ers WHERE user_id=" . $this->d b->escape( $row["acto r_user_id" ])); | |
| 899 | if($target _id_query && $actor_ id_query) { | |
| 900 | $t arget_id_r ow = $targ et_id_quer y->row_arr ay(); | |
| 901 | $a ctor_id_ro w = $actor _id_query- >row_array (); | |
| 902 | $t arget_name = isset($ target_id_ row ["user _name"]) ? $target_i d_row ["us er_name"] : "Unknown User"; | |
| 903 | $a ctor_name = isset($a ctor_id_ro w ["user_n ame"]) ? $ actor_id_r ow ["user_ name"] : " Unknown Us er"; | |
| 904 | $v iew_str .= "<tr><td> " . htmlen tities(dat e("m/d/y h :i:s A",$r ow["edit_d atetime"]) ) . "</td> <td>" . ht mlentities ($target_n ame) . "</ td><td>" . htmlentit ies($actor _name) . " </td><td>" . htmlent ities($row ["edit_act ion"]) . " </td></tr> "; | |
| 905 | } | |
| 906 | } | |
| 907 | $view_st r .= "</ta ble>"; | |
| 908 | } | |
| 909 | } | |
| 910 | else if($actio n == "feed back") { | |
| 911 | $this- >verify_pe rmission(" logs_feedb ack"); | |
| 912 | $data[ "active_ta b"] = "fee dback"; | |
| 913 | if(is_ null($valu e)) { $pag e_start = 0; $page = 1; } | |
| 914 | else { $page = $ value; $pa ge_start = (($page-1 )*ADMINPAN EL_LOG_DIS PLAY_PER_P AGE); } | |
| 915 | $feedb ack = $thi s->db->que ry("SELECT * FROM (S ELECT ROW_ NUMBER() O VER (ORDER BY feedba ck_id DESC ) AS RowNu m, * FROM feedback) AS rows WH ERE RowNum > " . ($p age_start) . " AND R owNum <= " . ($page_ start + AD MINPANEL_L OG_DISPLAY _PER_PAGE) . " ORDER BY RowNum "); | |
| 916 | $log_c ount_query = $this-> db->query( "SELECT CO UNT(feedba ck_id) AS feedback_c ount FROM feedback") ; | |
| 917 | if($fe edback && $log_count _query) { | |
| 918 | $row = $ log_count_ query->row _array(); | |
| 919 | $log_cou nt = $row[ "feedback_ count"]; | |
| 920 | $view_st r = "<span style=\"f loat: righ t;\"><a hr ef=\"javas cript:expo rtCSV('fee dback');\" >Export</a ></span>"; | |
| 921 | $view_st r .= "<h2> System Log s → User Feedb ack Logs</ h2>"; | |
| 922 | $view_st r .= $this ->generate _paginatio n($page,$l og_count,A DMINPANEL_ LOG_DISPLA Y_PER_PAGE ,'/adminpa nel/logs/f eedback/') ; | |
| 923 | $view_st r .= "<tab le class=\ "log\">"; | |
| 924 | $view_st r .= '<cap tion class ="hidden_c ontext">Lo g of Feedb ack Record s</caption >'; | |
| 925 | $view_st r .= "<tr> <th>Log Da te"; | |
| 926 | if(isset ($timezone _abbrev)) { $view_st r .= ' (' . $timezon e_abbrev . ')'; } | |
| 927 | $view_st r .= "</th ><th>Usern ame</th><t h>Feedback Type</th> <th>Feedba ck Comment s</th></tr >"; | |
| 928 | for($i = 0; $i < $ feedback-> num_rows() ; $i++) { | |
| 929 | $row = $fe edback->ro w_array($i ); | |
| 930 | $actor_id_ query = $t his->db->q uery("SELE CT user_na me FROM us ers WHERE user_id=" . $this->d b->escape( $row["user _id"])); | |
| 931 | if($actor_ id_query) { | |
| 932 | $a ctor_id_ro w = $actor _id_query- >row_array (); | |
| 933 | $a ctor_name = $actor_i d_row ["us er_name"]; | |
| 934 | $v iew_str .= "<tr><td> " . htmlen tities(dat e("m/d/y h :i:s A",$r ow["feedba ck_datetim e"])) . "< /td><td>" . htmlenti ties($acto r_name) . "</td><td> " . htmlen tities($ro w["feedbac k_type"]) . "</td><t d>" . html entities($ row["feedb ack_commen ts"]) . "< /td></tr>" ; | |
| 935 | } | |
| 936 | } | |
| 937 | $view_st r .= "</ta ble>"; | |
| 938 | } | |
| 939 | } | |
| 940 | else { show_40 4(); } | |
| 941 | $dat a["log_vie w"] = $vie w_str; | |
| 942 | retu rn $data; | |
| 943 | } | |
| 944 | ||
| 945 | /* This func tion takes inputs an d uses the m to creat e a table which can then be tr ansformed by the jQu ery visual ization | |
| 946 | * library. | |
| 947 | * / | |
| 948 | pr otected fu nction mar kup_for_jq uery_chart ($chartTyp e, $captio n, $data, $id, $widt h="325px", $height=" 100px", $c olors="['r ed']", $vi sualize=TR UE) { | |
| 949 | $cha rt_table = "<table c lass=\"cha rt\" id=\" " . $id . "\" style= \"width: " . $width ."; height : " . $hei ght . ";\" >\n"; | |
| 950 | $cha rt_table . = "<captio n>" . $cap tion . "</ caption>\n "; | |
| 951 | $cha rt_table . = "<tbody> \n"; | |
| 952 | if($ chartType != "table" ) { $chart _table .= "<thead>\n "; } | |
| 953 | $i = 0; | |
| 954 | fore ach($data as $row) { | |
| 955 | if($i == 0 && $c hartType ! = "table") { $chart_ table .= " <tr>\n"; } | |
| 956 | $j = 0 ; | |
| 957 | foreac h($row as $col) { | |
| 958 | if($j == 0 && $cha rtType != "table") { $chart_ta ble .= "<t h scope=\" col\">" . $col . "< /th>\n"; } | |
| 959 | $j++; | |
| 960 | } | |
| 961 | if($i+ 1 == count ($data) && $chartTyp e != "tabl e") { $cha rt_table . = "</tr>\n "; } | |
| 962 | $i++; | |
| 963 | } | |
| 964 | if($ chartType != "table" ) { $chart _table .= "</thead>\ n"; } | |
| 965 | $i = 0; | |
| 966 | fore ach($data as $row) { | |
| 967 | if($i == 0 || $c hartType = = "pie" || $chartTyp e == "tabl e") { $cha rt_table . = "<tr>\n" ; } | |
| 968 | $j = 0 ; | |
| 969 | foreac h($row as $col) { | |
| 970 | if($j != 0) { $cha rt_table . = "<td>" . $col . " </td>\n"; } | |
| 971 | else if( ($chartTyp e == "pie" || $chart Type == "t able") && $j == 0) { $chart_ta ble .= "<t h scope=\" row\">" . $col . "< /th>\n";} | |
| 972 | $j++; | |
| 973 | } | |
| 974 | if($i+ 1 == count ($data) || $chartTyp e == "pie" || $chart Type == "t able") { $ chart_tabl e .= "</tr >\n"; } | |
| 975 | $i++; | |
| 976 | } | |
| 977 | $cha rt_table . = "</tbody >\n"; | |
| 978 | $cha rt_table . = "</table >\n"; | |
| 979 | if($ visualize == TRUE) { | |
| 980 | $chart _table .= "<script> | |
| 981 | $(docu ment).read y( | |
| 982 | function () { $('#" . $id . " ').css('di splay','no ne'); | |
| 983 | $('#" . $id . "'). visualize( {type: '" .$chartTyp e . "', wi dth: '" . $width . " ', height: '" .$heig ht. "', co lors: ". $ colors ."} ); } | |
| 984 | ); | |
| 985 | </scri pt>\n"; | |
| 986 | } | |
| 987 | retu rn $chart_ table; | |
| 988 | } | |
| 989 | ||
| 990 | pr otected fu nction gen erate_pagi nation($pa ge,$items, $items_per _page,$lin k) { | |
| 991 | $vie w_str = '< h3 class=" hidden_con text">Pagi nation</h3 >'; | |
| 992 | if($ items > $i tems_per_p age) { | |
| 993 | $view_ str .= "<d iv id=\"pa gination\" >\n"; | |
| 994 | if($it ems%$items _per_page > 0) { $pa ge_count = (int)($it ems/$items _per_page) +1; } | |
| 995 | else { $page_cou nt = (int) ($items/$i tems_per_p age); } | |
| 996 | //styl e paginati on | |
| 997 | $befor e_span = 5 ; | |
| 998 | $after _span = 5; | |
| 999 | if($pa ge - 5 <= 0) { $afte r_span += abs($page - $before_ span); } | |
| 1000 | else i f($page + 5 > $page_ count) { $ before_spa n += abs($ page_count - ($page + $after_s pan)); } | |
| 1001 | for($i = ($page - $before_ span); $i <= ($page+ $after_spa n); $i++) { | |
| 1002 | if($i > 0 && $i <= $page_cou nt) { | |
| 1003 | if($i == ( $page - $b efore_span ) && ($pag e - $befor e_span > 1 )) { $view _str .= '< a style="m argin-righ t: 3px;" h ref="' . $ link . ($p age - 1). '"><img sr c="/images /lt.png" a lt="Previo us Page">< /a>'; } | |
| 1004 | if(($i) != $page) { $view_str .= '<a hre f="' . $li nk . ($i) . '">' . ( $i) . '</a > '; } | |
| 1005 | else { $v iew_str .= "<span st yle=\"padd ing: 2px; font-weigh t: bold;\" >" . ($i) . '</span> '; } | |
| 1006 | if($i == ( $page+$aft er_span) & & ($page+$ after_span < $page_c ount)) { $ view_str . = '<a href ="' . $lin k . ($page + 1). '"> <img src=" /images/gt .png" alt= "Next Page "></a>'; } | |
| 1007 | } | |
| 1008 | } | |
| 1009 | $view_ str .= "</ div>\n"; | |
| 1010 | } | |
| 1011 | retu rn $view_s tr; | |
| 1012 | } | |
| 1013 | ||
| 1014 | pr otected fu nction san itize_expo rt($input) { | |
| 1015 | retu rn str_rep lace("\"", "\"\"",str _replace(a rray("\r", "\n"),"",$ input)); | |
| 1016 | } | |
| 1017 | ||
| 1018 | pu blic funct ion valid_ formatted_ address($s tr) | |
| 1019 | { | |
| 1020 | $val id_format = (!preg_m atch("/^([ a-z0-9\'\+ _\-]+)(\.[ a-z0-9\'\+ _\-]+)*@([ a-z0-9\-]+ \.)+[a-z]{ 2,6}$/ix", $str)) ? FALSE : TR UE; | |
| 1021 | retu rn $valid_ format; | |
| 1022 | } | |
| 1023 | ||
| 1024 | pr otected fu nction _ca lcMessageP ercentage( $data, $wh ich) { | |
| 1025 | $suc cessCount = empty($d ata['succe ss']['val' ]) ? 0 : $ data['succ ess']['val ']; | |
| 1026 | $fai lCount = e mpty($data ['fail'][' val']) ? 0 : $data[' fail']['va l']; | |
| 1027 | $tot alCount = $successCo unt + $fai lCount; | |
| 1028 | ||
| 1029 | if ( $totalCoun t === 0) { | |
| 1030 | return 'N/A'; | |
| 1031 | } | |
| 1032 | ||
| 1033 | retu rn round($ data[$whic h]['val']/ $totalCoun t, 2) * 10 0 . '%'; | |
| 1034 | } | |
| 1035 | ||
| 1036 | ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// //// | |
| 1037 | // USER HE LPER FUNCT IONS | |
| 1038 | // These f unctions a re not web -accessibl e and at s ome point we should evaluate w hether or not they w ould more appropriat ely belong in models /libraries . | |
| 1039 | ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// //// | |
| 1040 | ||
| 1041 | pr otected fu nction can _edit_user ($username ){ | |
| 1042 | if($ this->has_ permission ("manage_u sers_all") ){ | |
| 1043 | return true; | |
| 1044 | }els e if($this ->has_perm ission("ma nage_users _facilitie s")){ | |
| 1045 | $resou rce = '/di rect/accou nt/in_faci lity/mailb ox/'.$this ->session- >userdata( 'username' ); | |
| 1046 | $resou rce .= '/f ormat/json '; | |
| 1047 | $respo nse = @$th is->api_mo del->webse rvice_call ($resource ,'GET'); | |
| 1048 | if($re sponse->ht tp_status === 200){ | |
| 1049 | $users = $response ->response ->accounts ; | |
| 1050 | if( in_a rray($user name, $use rs)){ | |
| 1051 | return tru e; | |
| 1052 | } | |
| 1053 | } | |
| 1054 | } | |
| 1055 | show _404(); | |
| 1056 | } | |
| 1057 | ||
| 1058 | /* This sear ches the a ddress boo k and retu rns a list of users for use wi th the sea rch in edi t distribu tion list view */ | |
| 1059 | pr otected fu nction get _user_sear ch($input = null){ | |
| 1060 | $i nput = url decode($in put); | |
| 1061 | $res ult_arr = array(); | |
| 1062 | $ent ries = ($t his->ldap- >search($i nput)); | |
| 1063 | $i = 0; | |
| 1064 | fore ach($entri es as $key => $val) { | |
| 1065 | if($th is->valid_ formatted_ address($v al['mail'] )) { | |
| 1066 | $contact _arr = arr ay('name'= >(isset($v al['displa yname'])?$ val['displ ayname']:" Undefined" ),'id'=>$v al['mail'] ); | |
| 1067 | array_pu sh($result _arr,$cont act_arr); | |
| 1068 | $i++; | |
| 1069 | } | |
| 1070 | } | |
| 1071 | ||
| 1072 | //so rt combine d result a rray (natu ral order, case inse nsitive) | |
| 1073 | usor t($result_ arr, funct ion( $el1, $el2) { r eturn strn atcasecmp( $el1['nam e'], $el2[ 'name']); }); | |
| 1074 | ||
| 1075 | //ad d whatever the user is current ly typing so that it is allowe d as well | |
| 1076 | if($ this->vali d_formatte d_address( $input)) { | |
| 1077 | $conta ct_arr = a rray('name ' => $inpu t, 'id' => $input); | |
| 1078 | array_ push($resu lt_arr,$co ntact_arr) ; | |
| 1079 | } | |
| 1080 | arra y_walk_rec ursive($re sult_arr, function ( &$value) { | |
| 1081 | $value = htmlent ities($val ue); | |
| 1082 | }); | |
| 1083 | retu rn $result _arr; | |
| 1084 | } | |
| 1085 | ||
| 1086 | ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ///// | |
| 1087 | // FORM VA LIDATION C ALLBACKS | |
| 1088 | // These a re current ly public - iddeally , these sh ould be pr otected or just adde d to the f orm valida tion libra ry so that they can be used th roughout t he applica tion | |
| 1089 | ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////////// ////// | |
| 1090 | ||
| 1091 | pu blic funct ion allowe d_mailbox_ characters ($name) { | |
| 1092 | $val id = (preg _match('/[ ^A-Za-z0-9 \'._-]/', $name) === 1) ? FALS E : TRUE; | |
| 1093 | if($ valid) { r eturn TRUE ; } | |
| 1094 | $thi s->form_va lidation-> set_messag e('allowed _mailbox_c haracters' , 'The %s field may only conta in alpha-n umeric cha racters (A -Z, a-z, 0 -9), under scores, pe riods, apo strophes, and dashes .'); | |
| 1095 | retu rn FALSE; | |
| 1096 | } | |
| 1097 | ||
| 1098 | pu blic funct ion check_ password_s trength($p assword) { | |
| 1099 | $val id = TRUE; | |
| 1100 | $msg = 'Passwo rd strengt h requirem ents not m et.<br />' ; | |
| 1101 | if(s trlen($pas sword) < 1 5) { | |
| 1102 | $msg . = 'Must be at least 15 charact ers long.< br />'; | |
| 1103 | $valid = FALSE; | |
| 1104 | } | |
| 1105 | if(! preg_match ("/[a-z]+/ ", $passwo rd)) { | |
| 1106 | $msg . = 'Must co ntain at l east one l owercase c haracter.< br />'; | |
| 1107 | $valid = FALSE; | |
| 1108 | } | |
| 1109 | if(! preg_match ("/[A-Z]+/ ", $passwo rd)) { | |
| 1110 | $msg . = 'Must co ntain at l east one u ppercase c haracter.< br />'; | |
| 1111 | $valid = FALSE; | |
| 1112 | } | |
| 1113 | if(! preg_match ("/[0-9]+/ ", $passwo rd)) { | |
| 1114 | $msg . = 'Must co ntain at l east one n umeric cha racter.<br />'; | |
| 1115 | $valid = FALSE; | |
| 1116 | } | |
| 1117 | if(! preg_match ("/[!@#$%& *()_+|~=`{ }[:;'<>?,. \-\^\]\\\\ ]+/", $pas sword)) { //four bac kslashes t o escape t he backsla sh once fo r PHP and once for t he regex | |
| 1118 | $msg . = 'Must co ntain at l east one s pecial cha racter.<br />'; | |
| 1119 | $valid = FALSE; | |
| 1120 | } | |
| 1121 | if(! $valid) { $this->for m_validati on->set_me ssage('che ck_passwor d_strength ', $msg); } | |
| 1122 | retu rn $valid; | |
| 1123 | } | |
| 1124 | ||
| 1125 | /* Form vali dation cal lback */ | |
| 1126 | pu blic funct ion list_i s_unique($ name) { | |
| 1127 | //if we're edi ting, we c ould be us ing the pu blic list model or t he deleted list mode l. otherw ise, it wi ll | |
| 1128 | if(! isset($thi s->list_mo del)) | |
| 1129 | $this- >load->mod el('public _distribut ion_list_m odel', 'li st_model') ; | |
| 1130 | ||
| 1131 | $thi s->form_va lidation-> set_messag e('list_is _unique', 'The %s fi eld must n ot match a ny existin g lists or removed l ists.'); | |
| 1132 | ||
| 1133 | $nam e_is_avail able = $th is->list_m odel->name _is_availa ble($name) ; | |
| 1134 | if($ name_is_av ailable) r eturn true ; | |
| 1135 | ||
| 1136 | //if we're edi ting (edit _distribut ion_list o r edit_rem oved_distr ibution_li st), check to see if the name is being u sed by the list we'r e editing | |
| 1137 | if(s tring_begi ns_with('e dit', $thi s->router- >method) & & string_e nds_with(' distributi on_list', $this->rou ter->metho d)){ | |
| 1138 | $list = $this->l ist_model- >find_one( compact('n ame')); | |
| 1139 | return $list['id '] == $thi s->input-> post('list _id',TRUE) ; | |
| 1140 | } | |
| 1141 | ||
| 1142 | retu rn $name_i s_availabl e; | |
| 1143 | } | |
| 1144 | ||
| 1145 | pu blic funct ion va_ema il($email) { | |
| 1146 | $val id = (preg _match("/^ ([a-z0-9\' \+_\-]+)(\ .[a-z0-9\' \+_\-]+)*@ +((.*(\.va \.gov))|va \.gov)$/ix ", $email) ) ? TRUE : FALSE; | |
| 1147 | ||
| 1148 | if($ valid) { r eturn TRUE ; } | |
| 1149 | $this->for m_validati on->set_me ssage('va_ email', 'T he %s fiel d must con tain a val id DNS . URL email add ress.'); | |
| 1150 | retu rn FALSE; | |
| 1151 | } | |
| 1152 | ||
| 1153 | pu blic funct ion valid_ trusted_ad dress($str ) { | |
| 1154 | //ha ve to urle ncode / ba se64 encod e the addr ess to sen d to the w eb service | |
| 1155 | $str = rawurle ncode(base 64_encode( $str)); | |
| 1156 | $res ource = '/ direct/val idate/addr ess/'.$str .'/format/ json'; | |
| 1157 | $url = WEBSERV ICE_URL . $resource; | |
| 1158 | ||
| 1159 | $hea ders = arr ay( | |
| 1160 | 'Autho rization: DPII ' . W EBSERVICE_ PUBLIC_KEY . ':'. ba se64_encod e(hash_hma c('sha256' ,"GET\n" . date('U') . "\n" . $ resource, WEBSERVICE _PRIVATE_K EY)), | |
| 1161 | 'Date: ' . date( 'U'), | |
| 1162 | ); | |
| 1163 | $ch = curl_ini t(); | |
| 1164 | curl _setopt($c h,CURLOPT_ URL, $url) ; | |
| 1165 | curl _setopt($c h, CURLOPT _RETURNTRA NSFER, tru e); | |
| 1166 | curl _setopt($c h, CURLOPT _SSL_VERIF YPEER, fal se); | |
| 1167 | curl _setopt($c h, CURLOPT _HTTPHEADE R,$headers ); | |
| 1168 | $ser ver_output = curl_ex ec($ch); | |
| 1169 | if($ server_out put === fa lse) | |
| 1170 | trigge r_error( c url_error( $ch), E_US ER_WARNING ); | |
| 1171 | $htt p_status = curl_geti nfo($ch, C URLINFO_HT TP_CODE); | |
| 1172 | $res ponse = $t his->json- >decode($s erver_outp ut); | |
| 1173 | if(i sset($resp onse->vali d)) { | |
| 1174 | $valid = $respon se->valid; | |
| 1175 | if(!$v alid) { $t his->form_ validation ->set_mess age('valid _trusted_a ddress', ' The %s fie ld must be a trusted Direct Ad dress'); } | |
| 1176 | return $valid; | |
| 1177 | } | |
| 1178 | else { $this-> form_valid ation->set _message(' valid_trus ted_addres s', 'The % s field mu st be a tr usted Dire ct Address '); return FALSE; } | |
| 1179 | } | |
| 1180 | ||
| 1181 | ||
| 1182 | } | |
| 1183 | /* End of file admin panel.php */ | |
| 1184 | /* Locatio n: ./appli cation/con trollers/a dminpanel. php */ |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.