Skip to content

Commit

Permalink
whatever i changed
Browse files Browse the repository at this point in the history
  • Loading branch information
crutchy committed Oct 13, 2015
1 parent b76510a commit d4d2a04
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 28 deletions.
2 changes: 2 additions & 0 deletions exec.txt
Expand Up @@ -45,6 +45,8 @@ include test.php
~deb|10|0|1|0|*||||{ apt-cache show '%%trailing%%' | grep "Description-en" | sed 's/^.*: //' ; } 2>&1

~addr|10|0|1|0|*||||{ host '%%trailing%%' | head -1 ; } 2>&1
help ~addr|syntax: ~addr <host/ip>
help ~addr|DNS lookup utility

# http://kedar.nitty-witty.com/blog/how-to-get-stock-quote-on-linux-using-google-curl-grep-awk
# todo: test with single quotes around %%trailing%% to prevent shell code injection
Expand Down
2 changes: 2 additions & 0 deletions irc.php
Expand Up @@ -67,6 +67,7 @@
define("EXEC_INCLUDE","include");
define("EXEC_INIT","init");
define("EXEC_STARTUP","startup");
define("EXEC_HELP","help");
define("FILE_DIRECTIVE_DELIM",":");
define("FILE_DIRECTIVE_EXEC","exec");
define("FILE_DIRECTIVE_INIT","init");
Expand Down Expand Up @@ -242,6 +243,7 @@

$init=array();
$startup=array();
$help=array();

$socket=initialize_socket();
if (file_exists(EXEC_SOCK_FILE)==True)
Expand Down
82 changes: 60 additions & 22 deletions irc_lib.php
Expand Up @@ -164,12 +164,65 @@ function init()
buckets_load($items);
initialize_buckets();
#handle_data(CMD_INIT."\n",False,False,True);
process_exec_helps();
process_exec_inits();
process_scripts($items,ALIAS_INIT);
}

#####################################################################################################

function process_exec_helps()
{
global $help;
global $exec_list;
term_echo("help:");
$help_lines=array();
$file_lines=array();
for ($i=0;$i<count($help);$i++)
{
if (file_exists($help[$i])==True)
{
if (is_dir($help[$i])==True)
{
load_directory($help[$i],$file_lines,FILE_DIRECTIVE_HELP);
}
else
{
load_include($help[$i],$file_lines,FILE_DIRECTIVE_HELP);
}
}
else
{
$help_lines[]=$help[$i];
}
}
foreach ($file_lines as $filename => $file_help_lines)
{
for ($i=0;$i<count($file_help_lines);$i++)
{
$help_lines[]=$file_help_lines[$i];
}
}
unset($file_lines);
for ($i=0;$i<count($help_lines);$i++)
{
$help_parts=explode("|",$help_lines[$i]);
if (count($help_parts)>=2)
{
$alias=trim($help_parts[0]);
if (isset($exec_list[$alias]["help"])==True)
{
array_shift($help_parts);
$help_line=implode("|",$help_parts);
$exec_list[$alias]["help"][]=$help_line;
term_echo("ALIAS HELP: $alias => $help_line");
}
}
}
}

#####################################################################################################

function process_exec_inits()
{
global $init;
Expand Down Expand Up @@ -1922,6 +1975,7 @@ function handle_data($data,$is_sock=False,$auth=False,$exec=False,$piped_command
else
{
write_out_buffer_command($items,"rehash");
process_exec_helps();
process_exec_inits();
process_exec_startups();
$users=get_users();
Expand Down Expand Up @@ -2067,7 +2121,9 @@ function exec_load()
global $exec_list;
global $init;
global $startup;
global $help;
global $buckets;
$help=array();
$startup=array();
$init=array();
$exec_errors=array();
Expand Down Expand Up @@ -2111,28 +2167,6 @@ function exec_load()
for ($j=0;$j<count($exec_lines);$j++)
{
$exec_record=load_exec_line($exec_lines[$j],$filename);
if ($exec_record!==False)
{
$help_lines=array();
load_include($filename,$help_lines,FILE_DIRECTIVE_HELP);
$alias_help=array();
if (isset($help_lines[$filename])==True)
{
for ($k=0;$k<count($help_lines[$filename]);$k++)
{
$help_parts=explode("|",$help_lines[$filename][$k]);
if (trim($help_parts[0])==$exec_record["alias"])
{
array_shift($help_parts);
$alias_help[]=implode("|",$help_parts);
}
}
}
if (count($alias_help)>0)
{
$exec_list[$exec_record["alias"]]["help"]=$alias_help;
}
}
}
}
unset($file_lines);
Expand All @@ -2143,6 +2177,9 @@ function exec_load()
case EXEC_INIT:
$init[]=$trailing;
break;
case EXEC_HELP:
$help[]=$trailing;
break;
default:
load_exec_line($data[$i],EXEC_FILE);
}
Expand Down Expand Up @@ -2288,6 +2325,7 @@ function load_exec_line($line,$filename,$saved=True)
$result["saved"]=$saved;
$result["line"]=$line;
$result["file"]=$filename;
$result["help"]=array();
$exec_list[$alias]=$result;
term_echo("SUCCESS: $line");
return $result;
Expand Down
2 changes: 1 addition & 1 deletion scripts/help.php
Expand Up @@ -29,7 +29,7 @@
$help_lines=$exec_list[$trailing]["help"];
for ($i=0;$i<count($help_lines);$i++)
{
privmsg($help_lines[$i]);
privmsg(chr(3)."06".$help_lines[$i]);
}
return;
}
Expand Down
6 changes: 1 addition & 5 deletions scripts/jisho.php
@@ -1,13 +1,9 @@
<?php

#####################################################################################################

# .jisho|20|0|0|1|||##anime-japanese,#irciv||php scripts/japanese.php %%trailing%% %%dest%% %%nick%% %%alias%%
# this script has been superseded by jisho2.php

#####################################################################################################

# http://jisho.org/api/v1/search/words?keyword=house

ini_set("display_errors","on");

require_once("lib.php");
Expand Down
2 changes: 2 additions & 0 deletions scripts/jisho2.php
Expand Up @@ -2,6 +2,8 @@

/*
exec:~jisho|20|0|0|1|||||php scripts/jisho2.php %%trailing%%
help:~jisho|syntax: ~jisho <word>
help:~jisho|looks up jisho.org
*/

require_once("lib.php");
Expand Down

0 comments on commit d4d2a04

Please sign in to comment.