00001 <?php
00002
00009 class c_server {
00010 var $host;
00011 var $port;
00012 var $nick;
00013
00014 var $isupport;
00015 var $user_mode_prefix;
00016 var $chan_modes_class_a;
00017 var $chan_modes_class_b;
00018 var $chan_modes_class_c;
00019 var $chan_modes_class_d;
00020
00030 function init($host,$port,$nick) {
00031 $this->host=$host;
00032 $this->port=$port;
00033 $this->nick=$nick;
00034 }
00035 }
00036
00043 class c_input {
00044 var $channel;
00045 var $params;
00046
00054 function init($channel) {
00055 $this->channel=$channel;
00056 $this->params=array();
00057 }
00058
00067 function set_next_parameter($value) {
00068 array_push($this->params,$value);
00069 }
00070
00078 function get_channel() {
00079 return $this->channel;
00080 }
00081
00091 function get_param($index)
00092 {
00093 if($index>=count($this->params))
00094 return NULL;
00095 return $this->params[$index];
00096 }
00097 }
00098
00105 class c_user {
00106 var $nick;
00107 var $ident;
00108 var $host;
00109 var $full_name;
00110 var $name;
00111 var $online;
00112 var $host_unknown;
00113 var $host_bot;
00114 var $irc_op;
00115 var $mode;
00116 var $host_masks;
00117 var $fullname_masks;
00118 var $meta;
00119 var $groups;
00120
00141 function init($nick, $ident, $host, $full_name, $name, $online,
00142 $host_unknown, $host_bot, $irc_op, $mode, $host_masks,
00143 $fullname_masks, $meta, $groups)
00144 {
00145 $this->nick=$nick;
00146 $this->ident=$ident;
00147 $this->host=$host;
00148 $this->full_name=$full_name;
00149 $this->name=$name;
00150 $this->online=$online;
00151 $this->host_unknown=$host_unknown;
00152 $this->host_bot=$host_bot;
00153 $this->irc_op=$irc_op;
00154 $this->mode=$mode;
00155 $this->host_masks=$host_masks;
00156 $this->fullname_mask=$fullname_masks;
00157 $this->meta=$meta;
00158 $this->groups=$groups;
00159 }
00160 }
00161
00168 class c_channel {
00169 var $name;
00170 var $users;
00171 var $bans;
00172 var $exceptions;
00173 var $invites;
00174 var $reops;
00175
00176 var $key;
00177 var $limit;
00178 var $mode;
00179 var $topic;
00180
00192 function init($name,$bans,$exceptions,$invites,$reops)
00193 {
00194 $this->name=$name;
00195 $this->users=array();
00196 $this->bans=$bans;
00197 $this->exceptions=$exceptions;
00198 $this->invites=$invites;
00199 $this->reops=$reops;
00200 }
00201
00210 function add_user($user)
00211 {
00212 foreach($this->users as $e)
00213 if($e->nick==$user->nick)
00214 return;
00215 array_push($this->users,$user);
00216 }
00217
00229 function find_users_name($name,$want_online,$want_offline,$ignore_case)
00230 {
00231 if(!$want_online && !$want_offline) {
00232 echo "Warning: ".__CLASS__."::".__FUNCTION__."() three-state logic issue: Do we want online, offline, or both? You want none!\n";
00233 return array();
00234 }
00235 $res=array();
00236 foreach($this->users as $e) {
00237 if((($want_online && $e->online) || ($want_offline && !$e->online)) && ((!$ignore_case && $e->name==$name) || ($ignore_case && strtolower($e->name)==strtolower($name))))
00238 array_push($res,$e);
00239 }
00240 return $res;
00241 }
00242
00253 function find_user_nick($nick,$ignore_case)
00254 {
00255 foreach($this->users as $e) {
00256 if((!$ignore_case && $e->nick==$nick) || ($ignore_case && strtolower($e->nick)==strtolower($nick)))
00257 return $e;
00258 }
00259 return NULL;
00260 }
00261
00269 function find_irc_op()
00270 {
00271 $res=array();
00272 foreach($this->users as $e) {
00273 if($e->irc_op)
00274 array_push($res,$e);
00275 }
00276 return $res;
00277 }
00278
00286 function find_unknown()
00287 {
00288 $res=array();
00289 foreach($this->users as $e) {
00290 if($e->host_unknown)
00291 array_push($res,$e);
00292 }
00293 return $res;
00294 }
00295
00304 function find_host_bot()
00305 {
00306 $res=array();
00307 foreach($this->users as $e) {
00308 if($e->host_bot)
00309 array_push($res,$e);
00310 }
00311 return $res;
00312 }
00313
00323 function find_mode($mode,$plus)
00324 {
00325 if(strlen($mode)!=1) {
00326 echo "Error: c_channel::find_mode() argument \$mode should be string one-character long. It is: \"".$mode."\"\n";
00327 return array();
00328 }
00329 $res=array();
00330 foreach($this->users as $e) {
00331 if(($plus && strpos($e->mode,$mode)!==FALSE) || (!$plus && strpos($e->mode,$mode)===FALSE))
00332 array_push($res,$e);
00333 }
00334 return $res;
00335 }
00336 }
00337
00344 class c_filesys_access {
00345 var $all_users;
00346 var $user_name;
00347 var $owner;
00348 var $read;
00349 var $delete;
00350 var $notify_owner;
00351 var $notify_user;
00352 var $secure;
00353 var $all_on_channel;
00354 var $also_unknown;
00355 var $notify_owner_message;
00356 var $notify_user_message;
00357
00376 function init($all_users, $user_name, $owner, $read, $delete,
00377 $notify_owner, $notify_user, $secure, $all_on_channel,
00378 $also_unknown, $notify_owner_message, $notify_user_message)
00379 {
00380 $this->all_users=$all_users;
00381 $this->user_name=$user_name;
00382 $this->owner=$owner;
00383 $this->read=$read;
00384 $this->delete=$delete;
00385 $this->notify_owner=$notify_owner;
00386 $this->notify_user=$notify_user;
00387 $this->secure=$secure;
00388 $this->all_on_channel=$all_on_channel;
00389 $this->also_unknown=$also_unknown;
00390 $this->notify_owner_message=$notify_owner_message;
00391 $this->notify_user_message=$notify_user_message;
00392 }
00393 }
00394
00401 class c_filesys_event {
00402 var $event_has_read;
00403 var $event_owner_notified;
00404 var $event_user_name;
00405 var $user_notified;
00406 var $event_timestamp;
00407
00419 function init($event_has_read, $event_owner_notified, $event_user_name,
00420 $user_notified, $event_timestamp)
00421 {
00422 $this->event_has_read=$event_has_read;
00423 $this->event_owner_notified=$event_owner_notified;
00424 $this->event_user_name=$event_user_name;
00425 $this->user_notified=$user_notified;
00426 $this->event_timestamp=$event_timestamp;
00427 }
00428 }
00429
00437 class c_filesys_object {
00438 var $type;
00439 var $internal_name;
00440 var $public_name;
00441 var $time;
00442 var $published;
00443 var $complete;
00444 var $expiration;
00445
00446 var $access;
00447 var $events;
00448
00462 function init($type, $internal_name, $public_name, $time, $published,
00463 $complete, $expiration)
00464 {
00465 $this->type=$type;
00466 $this->internal_name=$internal_name;
00467 $this->public_name=$public_name;
00468 $this->time=$time;
00469 $this->published=$published;
00470 $this->complete=$complete;
00471 $this->expiration=$expiration;
00472 $this->access=array();
00473 $this->events=array();
00474 }
00475
00483 function add_access($access) {
00484 array_push($this->access,$access);
00485 }
00486
00494 function add_event($event) {
00495 array_push($this->events,$event);
00496 }
00497 }
00498
00505 class c_output {
00506 var $lines;
00507
00508 var $commited;
00509
00516 function init() {
00517 $this->lines="";
00518 $this->commited=FALSE;
00519 }
00520
00530 function put($priority_class,$raw)
00531 {
00532 $x="PUT ".$priority_class." ".$raw;
00533 $this->lines.=$x."\n";
00534 }
00535
00544 function log($string)
00545 {
00546 $x="LOG ".$string;
00547 $this->lines.=$x."\n";
00548 }
00549
00559 function execute($procedure,$arguments)
00560 {
00561 $x="EXECUTE ".$procedure."(";
00562 $first=TRUE;
00563 foreach($arguments as $e) {
00564 if(!$first)
00565 $x.=",";
00566 $first=FALSE;
00567 $x.="\"";
00568 $x.=addslashes($e);
00569 $x.="\"";
00570 }
00571 $x.=")";
00572
00573 $this->lines.=$x."\n";
00574 }
00575
00585 function filesys($object)
00586 {
00587 $r="FILESYS InternalName ".$object->internal_name;
00588 $this->lines.=$r."\n";
00589
00590 $r="FILESYS SET type ".$object->type;
00591 $this->lines.=$r."\n";
00592
00593 $r="FILESYS SET PublicName ".$object->public_name;
00594 $this->lines.=$r."\n";
00595
00596 $r="FILESYS SET Time ".$object->time;
00597 $this->lines.=$r."\n";
00598
00599 $r="FILESYS SET Published ".($object->published?"1":"0");
00600 $this->lines.=$r."\n";
00601
00602 $r="FILESYS SET Complete ".($object->complete?"1":"0");
00603 $this->lines.=$r."\n";
00604
00605 $r="FILESYS SET Expiration ".$object->expiration;
00606 $this->lines.=$r."\n";
00607
00608 foreach($object->access as $e) {
00609
00610 $r="FILESYS ACCESS_BEGIN";
00611 $this->lines.=$r."\n";
00612
00613 $r="FILESYS SET AllUsers ".($e->all_users?"1":"0");
00614 $this->lines.=$r."\n";
00615
00616 $r="FILESYS SET UserName ".$e->user_name;
00617 $this->lines.=$r."\n";
00618
00619 $r="FILESYS SET Owner ".($e->owner?"1":"0");
00620 $this->lines.=$r."\n";
00621
00622 $r="FILESYS SET Read ".($e->read?"1":"0");
00623 $this->lines.=$r."\n";
00624
00625 $r="FILESYS SET Delete ".($e->delete?"1":"0");
00626 $this->lines.=$r."\n";
00627
00628 $r="FILESYS SET NotifyOwner ".($e->notify_owner?"1":"0");
00629 $this->lines.=$r."\n";
00630
00631 $r="FILESYS SET NotifyUser ".($e->notify_user?"1":"0");
00632 $this->lines.=$r."\n";
00633
00634 $r="FILESYS SET Secure ".($e->secure?"1":"0");
00635 $this->lines.=$r."\n";
00636
00637 $r="FILESYS SET AllOnChannel ".$e->all_on_channel;
00638 $this->lines.=$r."\n";
00639
00640 $r="FILESYS SET AlsoUnknown ".($e->also_unknown?"1":"0");
00641 $this->lines.=$r."\n";
00642
00643
00644 $r="FILESYS SET NotifyOwnerMessage ".$e->notify_owner_message;
00645 $this->lines.=$r."\n";
00646
00647
00648 $r="FILESYS SET NotifyUserMessage ".$e->notify_user_message;
00649 $this->lines.=$r."\n";
00650
00651
00652 $r="FILESYS ACCESS_END";
00653 $this->lines.=$r."\n";
00654 }
00655
00656
00657
00658
00659 $r="FILESYS COMMIT";
00660 $this->lines.=$r."\n";
00661 }
00662
00669 function cancel($string)
00670 {
00671 $this->lines="";
00672 }
00673
00680 function commit()
00681 {
00682 if($this->commited) {
00683 echo "Warning: ".__CLASS__."::".__FUNCTION__."() You have already done commit - this can confuse bot!\n";
00684 }
00685 $this->commited=TRUE;
00686 echo "\n#####\n".$this->lines."#####\n";
00687 $this->lines="";
00688 }
00689 }
00690
00691 ?>