This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | require_once('common/dao/include/DataAccessObject.class.php'); |
||
4 | require_once('JabbexFactory.class.php'); |
||
5 | |||
6 | class IMDao extends DataAccessObject { |
||
7 | |||
8 | var $openfire_db_name; |
||
9 | var $codendi_db_name; |
||
10 | |||
11 | const MUC_ROOM_TYPE_ID = 23; |
||
12 | const OPENFIRE_ADMIN_AFFILIATION = 20; |
||
13 | const OPENFIRE_SUPER_ADMIN_AFFILIATION = 10; |
||
14 | |||
15 | /** |
||
16 | * Constructs the IMDao |
||
17 | * @param $da instance of the DataAccess class |
||
18 | */ |
||
19 | function __construct($da) { |
||
20 | parent::__construct($da); |
||
21 | $this->openfire_db_name = $da->db_name; |
||
22 | $this->codendi_db_name = $GLOBALS['sys_dbname']; |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * Returns an instance of jabdex |
||
27 | * @return Jabbex object class for im processing |
||
28 | */ |
||
29 | function _get_im_object() { |
||
30 | return JabbexFactory::getJabbexInstance(); |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * search groups no synchronized with muc room |
||
35 | * @DataAccesResult |
||
36 | */ |
||
37 | function search_group_without_muc() { |
||
38 | |||
39 | $sql_muc="SELECT cg.group_id,LOWER(cg.unix_group_name) AS unix_group_name, cg.group_name,cg.short_description |
||
40 | FROM ". $this->codendi_db_name .".groups AS cg |
||
41 | LEFT JOIN ".$this->openfire_db_name.".ofMucRoom AS muc |
||
42 | ON (muc.name = LOWER(cg.unix_group_name)) |
||
43 | WHERE muc.name IS NULL |
||
44 | AND cg.status = 'A' |
||
45 | ORDER BY group_name ASC"; |
||
46 | |||
47 | return $this->retrieve($sql_muc); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * used for unique ID sequence generation |
||
52 | */ |
||
53 | function get_last_room_id() { |
||
54 | $sql = sprintf("SELECT id FROM ".$this->openfire_db_name.".ofID WHERE idType=%s", |
||
55 | $this->da->quoteSmart(self::MUC_ROOM_TYPE_ID)); |
||
56 | $id_dar = $this->retrieve($sql); |
||
57 | $row = $id_dar->getRow(); |
||
58 | return $row['id']; |
||
59 | } |
||
60 | |||
61 | |||
62 | /** |
||
63 | * get room_id by group_unix_name |
||
64 | */ |
||
65 | function get_room_id_by_unix_name($unix_name) { |
||
66 | $sql=sprintf("SELECT roomID FROM ".$this->openfire_db_name.".ofMucRoom WHERE name=%s", |
||
67 | $this->da->quoteSmart($unix_name)); |
||
68 | $id_dar=$this->retrieve($sql); |
||
69 | $row=$id_dar->getRow(); |
||
70 | return $row['roomID']; |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * update last roomID |
||
75 | */ |
||
76 | |||
77 | function update_last_room_id() { |
||
78 | $last_id=$this->get_last_room_id ()+1; |
||
79 | $sql=sprintf("UPDATE ".$this->openfire_db_name.".ofID SET id= %s WHERE idType=%s", |
||
80 | $this->da->quoteSmart($last_id), |
||
81 | $this->da->quoteSmart(self::MUC_ROOM_TYPE_ID)); |
||
82 | $updated = $this->update($sql); |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * search groups no synchronized with muc room |
||
87 | * @@return DataAccesResult query result |
||
88 | */ |
||
89 | function search_group_without_shared_group() { |
||
90 | |||
91 | $sql='SELECT cg.group_id |
||
92 | FROM '. $this->codendi_db_name .'.groups AS cg |
||
93 | LEFT JOIN '.$this->openfire_db_name.'.ofGroupProp AS og |
||
94 | ON (og.groupName = LOWER(cg.unix_group_name) |
||
95 | AND og.name = \'sharedRoster.showInRoster\') |
||
96 | WHERE og.groupName IS NULL |
||
97 | AND cg.status = \'A\' |
||
98 | ORDER BY group_name ASC'; |
||
99 | |||
100 | return $this->retrieve($sql); |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * synchronize_grp_for_im_display_name |
||
105 | * @return true/false |
||
0 ignored issues
–
show
|
|||
106 | */ |
||
107 | function synchronize_grp_for_im_display_name() { |
||
108 | $sql_displayName='INSERT INTO '.$this->openfire_db_name.'.ofGroupProp (groupName, name, propValue)' . |
||
109 | 'SELECT LOWER(cg.unix_group_name), \'sharedRoster.displayName\', cg.group_name |
||
110 | FROM '. $this->codendi_db_name .'.groups AS cg LEFT JOIN '.$this->openfire_db_name.'.ofGroupProp AS og |
||
111 | ON (og.groupName = cg.unix_group_name |
||
112 | AND og.name = \'sharedRoster.displayName\') |
||
113 | WHERE og.groupName IS NULL |
||
114 | AND cg.status = \'A\''; |
||
115 | return $this->update($sql_displayName); |
||
116 | } |
||
117 | |||
118 | /** |
||
119 | * synchronize_grp_for_im_show_in_roster |
||
120 | * @return true/false |
||
0 ignored issues
–
show
The doc-type
true/false could not be parsed: Unknown type name "true/false" at position 0. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. ![]() |
|||
121 | */ |
||
122 | function synchronize_grp_for_im_show_in_roster() { |
||
123 | $sqlshowInRoster='INSERT INTO '.$this->openfire_db_name.'.ofGroupProp (groupName, name, propValue)' . |
||
124 | 'SELECT LOWER(cg.unix_group_name), \'sharedRoster.showInRoster\', \'onlyGroup\' |
||
125 | FROM '. $this->codendi_db_name .'.groups AS cg LEFT JOIN '.$this->openfire_db_name.'.ofGroupProp AS og |
||
126 | ON (og.groupName = cg.unix_group_name |
||
127 | AND og.name = \'sharedRoster.showInRoster\') |
||
128 | WHERE og.groupName IS NULL |
||
129 | AND cg.status = \'A\' |
||
130 | ORDER BY group_name ASC'; |
||
131 | return $this->update($sqlshowInRoster); |
||
132 | } |
||
133 | |||
134 | /** |
||
135 | * to set muc members |
||
136 | */ |
||
137 | function add_muc_room_user($roomID,$jid/*,$nickname='',$firstName='',$lastName='',$url='',$faqentry=''*/) { |
||
138 | $forma="INSERT INTO ".$this->openfire_db_name.".ofMucMember(roomID,jid) |
||
139 | VALUES(%s, %s)"; //we can add also , %s, %s,%s, %s, %s--->nickname,firstName,lastName,url,faqentry |
||
140 | $sql = sprintf($forma, |
||
141 | $this->da->quoteSmart($roomID), |
||
142 | $this->da->quoteSmart($jid)/*, |
||
143 | $this->da->quoteSmart($nickname), |
||
144 | $this->da->quoteSmart($firstName), |
||
145 | $this->da->quoteSmart($lastName), |
||
146 | $this->da->quoteSmart($url), |
||
147 | $this->da->quoteSmart($faqentry)*/); |
||
148 | $this->update($sql); |
||
149 | //echo $sql.'<br>'; |
||
150 | } |
||
151 | |||
152 | /** |
||
153 | * muc room affiliation |
||
154 | */ |
||
155 | function muc_room_affiliation($roomID,$jid,$affiliation) { |
||
156 | $forma="INSERT INTO ".$this->openfire_db_name.".ofMucAffiliation(roomID,jid,affiliation) |
||
157 | VALUES (%s, %s, %s);"; |
||
158 | $sql = sprintf($forma, |
||
159 | $this->da->quoteSmart($roomID), |
||
160 | $this->da->quoteSmart($jid), |
||
161 | $this->da->quoteSmart($affiliation)); |
||
162 | $this->update($sql); |
||
163 | //echo $sql.'<br>'; |
||
164 | } |
||
165 | |||
166 | /** |
||
167 | * synchronize_grp_for_im_display_name |
||
168 | * @@return true/false |
||
0 ignored issues
–
show
The doc-type
true/false could not be parsed: Unknown type name "true/false" at position 0. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. ![]() |
|||
169 | */ |
||
170 | function synchronize_grp_for_im_muc_room() { |
||
171 | $pm = ProjectManager::instance(); |
||
172 | $dar=&$this->search_group_without_muc(); |
||
173 | $result=$dar->getResult();//$this->retrieve($sql)->query; |
||
174 | if(isset($result)&&$result){ |
||
175 | //var_dump($result); |
||
176 | ///about jabber server |
||
177 | $im_object=$this->_get_im_object(); |
||
178 | $jabberConf=$im_object->get_server_conf(); |
||
179 | $server_dns=$jabberConf['server_dns']; |
||
180 | $admin_server=$jabberConf['username']; |
||
181 | $admin_affiliation = self::OPENFIRE_ADMIN_AFFILIATION; |
||
182 | $super_admin_affiliation = self::OPENFIRE_SUPER_ADMIN_AFFILIATION; |
||
183 | |||
184 | $creation_date=''.round(1000*microtime(true)); |
||
185 | $creation_date=$this->da->quoteSmart($creation_date, 'force_string'); |
||
186 | //echo $creation_date; |
||
187 | $modification_date=''.round(1000*microtime(true)); |
||
188 | $modification_date=$this->da->quoteSmart($modification_date, 'force_string'); |
||
189 | $short_name=''; |
||
190 | $public_name=''; |
||
191 | $owner=''; |
||
192 | $description=''; |
||
193 | $locked_date = '000000000000000'; |
||
194 | $locked_date = $this->da->quoteSmart($locked_date, 'force_string'); |
||
195 | $empty_date=''.round(1000*microtime(true)); |
||
196 | $empty_date=$this->da->quoteSmart($empty_date, 'force_string'); |
||
197 | $change_subject=1; |
||
198 | $change_subject=$this->da->quoteSmart($change_subject); |
||
199 | $max_user=0; |
||
200 | $max_user=$this->da->quoteSmart($max_user); |
||
201 | $public_room=1; |
||
202 | $public_room=$this->da->quoteSmart($public_room); |
||
203 | $moderated=1; |
||
204 | $moderated=$this->da->quoteSmart($moderated); |
||
205 | $members_only=1; |
||
206 | $members_only=$this->da->quoteSmart($members_only); |
||
207 | $can_invite=1; |
||
208 | $can_invite=$this->da->quoteSmart($can_invite); |
||
209 | $can_discover_JID=1; |
||
210 | $can_discover_JID=$this->da->quoteSmart($can_discover_JID); |
||
211 | $log_enabled=1; |
||
212 | $log_enabled=$this->da->quoteSmart($log_enabled); |
||
213 | $subject=""; |
||
214 | $subject=$this->da->quoteSmart($subject); |
||
215 | $role_to_broadcast=7; |
||
216 | $role_to_broadcast=$this->da->quoteSmart($role_to_broadcast); |
||
217 | $use_reserved_NICK=0; |
||
218 | $use_reserved_NICK=$this->da->quoteSmart($use_reserved_NICK); |
||
219 | $can_changed_nick=1; |
||
220 | $can_changed_nick=$this->da->quoteSmart($can_changed_nick); |
||
221 | $can_register=1; |
||
222 | $can_register=$this->da->quoteSmart($can_register); |
||
223 | |||
224 | // //for last muc Id |
||
225 | // $resultID=$this->retrieve("SELECT roomID FROM ".$this->openfire_db_name.".mucRoom ORDER BY roomID ASC")->query; |
||
226 | // $lastID=0; |
||
227 | // |
||
228 | // while ($donnees = db_fetch_array($resultID) ){ |
||
229 | // $lastID=$donnees["roomID"]; |
||
230 | // //echo $lastID.'<br>'; |
||
231 | // } |
||
232 | // db_free_result($resultID); |
||
233 | // //var_dump($dar); |
||
234 | $lastID=1; |
||
235 | $tamp=false; |
||
236 | //synchronize each project |
||
237 | while ($row=$dar->getRow()){ |
||
238 | //$lastID++; |
||
239 | //echo $lastID.'<br>'; |
||
240 | $lastID=$this->get_last_room_id(); |
||
241 | $id=$this->da->quoteSmart($lastID); |
||
242 | $short_name=strtolower($row['unix_group_name']); |
||
243 | $short_name=$this->da->quoteSmart($short_name); |
||
244 | $public_name=$row['group_name']; |
||
245 | $public_name=$this->da->quoteSmart($public_name); |
||
246 | $description=$row['short_description']; |
||
247 | $description=$this->da->quoteSmart($description); |
||
248 | |||
249 | //echo "<font color=\"red\"><b>Owner : </b></font> : ".$row['user_name']." |<font color=\"red\"><b>Nom public : </b></font>".$row['group_name']." |"."<font color=\"red\"><b>Unix name : </b></font>".$row['unix_group_name']." desc :".$row['short_description']."<br>"; |
||
250 | $forma="INSERT INTO ".$this->openfire_db_name.".ofMucRoom |
||
251 | (roomID, creationDate, modificationDate, name, naturalName, description, lockedDate, emptyDate, canChangeSubject, maxUsers, publicRoom, moderated, membersOnly, canInvite, canDiscoverJID, logEnabled, subject, rolesToBroadcast, useReservedNick, canChangeNick, canRegister) |
||
252 | VALUES (%s, %s, %s, %s,%s, %s, %s, %s,%s, %s, %s, %s,%s, %s, %s, %s, %s, %s, %s,%s, %s)"; |
||
253 | $sql = sprintf($forma,$id,$creation_date,$modification_date,$short_name,$public_name,$description,$locked_date,$empty_date,$change_subject,$max_user,$public_room,$moderated,$members_only,$can_invite,$can_discover_JID,$log_enabled,$subject,$role_to_broadcast,$use_reserved_NICK,$can_changed_nick,$can_register); |
||
254 | //echo $sql.'<br>'; |
||
255 | |||
256 | $tamp=$this->update($sql); |
||
257 | //$tamp=true;//to be delete |
||
258 | //about muc members |
||
259 | $group_id=$row['group_id']; |
||
260 | $grp = $pm->getProject($group_id); |
||
261 | $project_members_ids=$grp->getMembersId(); |
||
262 | foreach($project_members_ids as $user_id){ |
||
0 ignored issues
–
show
|
|||
263 | $user_object = UserManager::instance()->getUserById($user_id); |
||
264 | $user_name =trim($user_object->getName()); |
||
265 | $jid_value=trim($user_name.'@'.$server_dns); |
||
266 | //$this->add_muc_room_user($id,$jid_value); |
||
267 | if($user_object->isMember($group_id,'A')){ |
||
268 | $this->muc_room_affiliation ($id,$jid_value,$admin_affiliation); |
||
269 | }else{ |
||
270 | $this->add_muc_room_user($id,$jid_value); |
||
271 | } |
||
272 | } |
||
273 | |||
274 | //the owner of the muc |
||
275 | $this->muc_room_affiliation ($id,trim($admin_server.'@'.$server_dns),$super_admin_affiliation); |
||
276 | //We can also use the flowing instruction to synchronize cleanly each project with his muc |
||
277 | //$this->_get_im_object ()->create_muc_room($donnees['unix_group_name'],$donnees['group_name'],$donnees['short_description'],$donnees['user_name']); |
||
278 | $this->update_last_room_id(); |
||
279 | } |
||
280 | if($donnees = db_fetch_array($result)){ |
||
281 | $GLOBALS['Response']->addFeedback('error', 'ERROR'); |
||
282 | return false; |
||
283 | }else{ |
||
284 | $GLOBALS['Response']->addFeedback('info', 'synchronize sucessful !!!'); |
||
285 | return $tamp; |
||
286 | } |
||
287 | } |
||
288 | } |
||
289 | |||
290 | |||
291 | /** |
||
292 | * synchronize all project with IM concept . |
||
293 | */ |
||
294 | function synchronize_all_project() { |
||
295 | $this->synchronize_grp_for_im_muc_room(); |
||
296 | $this->synchronize_grp_for_im_show_in_roster(); |
||
297 | $this->synchronize_grp_for_im_display_name(); |
||
298 | } |
||
299 | |||
300 | |||
301 | |||
302 | |||
303 | |||
304 | /** |
||
305 | * add members and affiliate admins and owner room for the group identified by $group_id |
||
306 | * @param long $group_id. |
||
0 ignored issues
–
show
There is no parameter named
$group_id. . Did you maybe mean $group_id ?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit. Consider the following example. The parameter /**
* @param array $germany
* @param array $ireland
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was changed, but the annotation was not. ![]() |
|||
307 | */ |
||
308 | function muc_member_build($group_id) { |
||
309 | $pm = ProjectManager::instance(); |
||
310 | //IM infos |
||
311 | $im_object = $this->_get_im_object(); |
||
312 | $jabberConf = $im_object->get_server_conf(); |
||
313 | $server_dns = $jabberConf['server_dns']; |
||
314 | $admin_server = $jabberConf['username']; |
||
315 | |||
316 | //muc affiliation infos |
||
317 | $admin_affiliation = self::OPENFIRE_ADMIN_AFFILIATION; |
||
318 | $super_admin_affiliation = self::OPENFIRE_SUPER_ADMIN_AFFILIATION; |
||
319 | |||
320 | //about projet to be synchronize |
||
321 | $grp = $pm->getProject($group_id); |
||
322 | $roomID = $this->get_room_id_by_unix_name ($grp->getUnixName()); |
||
323 | $project_members_ids = $grp->getMembersId(); |
||
324 | |||
325 | foreach ($project_members_ids as $user_id) { |
||
0 ignored issues
–
show
|
|||
326 | $user_object = UserManager::instance()->getUserById($user_id); |
||
327 | $user_name = trim($user_object->getName()); |
||
328 | $jid_value = trim($user_name.'@'.$server_dns); |
||
329 | if( ! ($user_object->isMember($group_id,'A')) ) { |
||
330 | $this->add_muc_room_user($roomID,$jid_value); |
||
331 | } |
||
332 | } |
||
333 | } |
||
334 | |||
335 | /** |
||
336 | * synchronize_muc_only : |
||
337 | * |
||
338 | * @throw Exception |
||
339 | */ |
||
340 | function synchronize_muc_only($unix_group_name, $group_name, $group_description, $group_Owner_name, $group_id) { |
||
341 | $im_object = $this->_get_im_object(); |
||
342 | if (isset($im_object) && $im_object) { |
||
343 | $im_object->create_muc_room(strtolower($unix_group_name), $group_name, $group_description, $group_Owner_name); |
||
344 | $this->muc_member_build($group_id); |
||
345 | } else { |
||
346 | throw new Exception("IM Object not available"); |
||
347 | } |
||
348 | } |
||
349 | |||
350 | /** |
||
351 | * synchronize_grp_only |
||
352 | */ |
||
353 | function synchronize_grp_only($unix_group_name, $group_name) { |
||
354 | $im_object = $this->_get_im_object(); |
||
355 | if (isset($im_object) && $im_object) { |
||
356 | $im_object->create_shared_group(strtolower($unix_group_name), $group_name); |
||
357 | } else { |
||
358 | throw new Exception("IM Object not available"); |
||
359 | } |
||
360 | } |
||
361 | |||
362 | } |
||
363 | ?> |
||
364 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.