PHP Functions

By Ayon on Mar 25, 2010

Again.. Another self explained script....

Example:
[00:03] @FamilyGuy › !php explode
[00:03] @stillborn › (PHP 4, PHP 5) explode - Split a string by string: (http://www.php.net/manual/en/function.explode.php)
[00:03] @stillborn › Description: Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by the string delimiter .

on 1:TEXT:!php *:#:{
  if (%aflood. [ $+ [ $nick ] ]) { halt }
  set -u5 %aflood. [ $+ [ $nick ] ] 1
  if (!$2) { halt }
  .set %sock.php.chan #
  .set %sock.php.search $2
  .set %sock.php.page $+(/manual/en/function.,$regsubex($2,/([^a-zA-Z0-9]+)/g,-),.php)
  .set %sock.php.server www.php.net
  .set %sock.php.port 80
  sockopen php %sock.php.server %sock.php.port
}

on 1:SOCKOPEN:php:{
  set %sock.php.status 1
  sockwrite -n $sockname GET %sock.php.page HTTP/1.0
  sockwrite -n $sockname Host: $+(%sock.php.server,:,%sock.php.port)
  sockwrite -n $sockname Connection: Keep-Alive
  sockwrite -n $sockname $crlf
}

on 1:SOCKREAD:php:{
  sockread -fn &var
  set %sock.php.source $bvar(&var, 1, 300).text
  if (%sock.php.nextline) { inc %sock.php.nextline }
  if (*<span class="dc-title">* iswm %sock.php.source) {
    noop $regex(%sock.php.source,/<p class\=\"verinfo\">(.+)<\/p>/U)
    set %sock.php.version $regml(1)
    noop $regex(%sock.php.source,/<span class\=\"refname\">(.+)<\/span>/isU)
    set %sock.php.function $regml(1)
    noop $regex(%sock.php.source,/<span class\=\"dc\-title\">(.+)<\/span>/isU)
    set %sock.php.title $regml(1)
  }
  elseif (*<p class="para rdfs-comment">* iswm %sock.php.source) { set %sock.php.description $htmlentities(%sock.php.source) | inc %sock.php.nextline 1 }
  elseif (%sock.php.nextline > 1) { 
    if ($calc($len(%sock.php.description) + $len($htmlentities(%sock.php.source))) > 200) {
      inc %sock.php.count
      .set %sock.php.desc. [ $+ [ %sock.php.count ] ] $htmlentities(%sock.php.description)
      unset %sock.php.description
    }
    set %sock.php.description %sock.php.description $htmlentities(%sock.php.source)
  }
  if (*</div>* iswm %sock.php.source) && (%sock.php.nextline) {
    inc %sock.php.count
    .set %sock.php.desc. [ $+ [ %sock.php.count ] ] %sock.php.description
    .msg %sock.php.chan $+(,$replace(%sock.php.version,&gt;,>,&lt;,<),$chr(32),%sock.php.function - %sock.php.title,:) $+($chr(40),http://,%sock.php.server,%sock.php.page,$chr(41))
    if (%sock.php.count == 1) { .msg %sock.php.chan Description: $htmlentities($regsubex(%sock.php.desc.1 %sock.php.description,/(<[a-zA-Z\/][^>]*>)/g,)) }
    else {
      var %i 1
      ;.msg %sock.php.chan 
      while (%sock.php.count >= %i) { .msg %sock.php.chan $regsubex(%sock.php.desc. [ $+ [ %i ] ],/(<[a-zA-Z\/][^>]*>)/g,) | inc %i }
    }
    .unset %sock.php.*
    sockclose php
  }
}

on 1:SOCKCLOSE:php:{
  .msg %sock.php.chan $qt(%sock.php.search) is not an existing php function.
  .unset %sock.php.*
}

alias htmlentities return $regsubex($1-,/&#(\d*)\;/g,$chr(\1))

Comments

Sign in to comment.
Ayon   -  Mar 26, 2010

thanks for the nice comment and score :)

 Respond  
GuitarMasterx7   -  Mar 26, 2010

good job.
even has a flood control <3
keep up the good work
8/10 =o

 Respond  
Ayon   -  Mar 25, 2010

yeah i know.. i just copy/pasted the other, and modified it... but i've done some serious updates on it now... made it support multi lines, and also it converts htmlentities like $ etc to the correct sign :)

 Respond  
Jethro   -  Mar 25, 2010

The way of your socket construction is alike to one another. Nevertheless, keep up the good work.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.