Skip to content

Commit

Permalink
whatever i changed
Browse files Browse the repository at this point in the history
  • Loading branch information
crutchy committed Feb 28, 2015
1 parent 23d0517 commit e49451a
Show file tree
Hide file tree
Showing 12 changed files with 279 additions and 63 deletions.
65 changes: 58 additions & 7 deletions scripts/comment_feed.php
Expand Up @@ -3,8 +3,8 @@
#####################################################################################################

/*
exec:~comments|1700|0|0|1|crutchy||||php scripts/comment_feed.php
exec:~comments-internal|1700|3600|0|1||INTERNAL|||php scripts/comment_feed.php
exec:~comments|1700|0|0|1|||||php scripts/comment_feed.php %%trailing%% %%dest%% %%nick%% %%alias%%
exec:~comments-internal|1700|3600|0|1||INTERNAL|||php scripts/comment_feed.php %%trailing%% %%dest%% %%nick%% %%alias%%
startup:~join #comments
*/

Expand All @@ -31,11 +31,62 @@
require_once("feeds_lib.php");
#require_once("copyright_lib.php");

$subscribers=get_array_bucket("<<comment_feed_subscribers>>"); # TODO

define("COMMENTS_FEED_FILE","../data/comments_feed.txt");
define("COMMENTS_CID_FILE","../data/comments_cid.txt");
define("COMMENTS_TOP_FILE","../data/comments_top.txt");
define("COMMENTS_DESTS_FILE","../data/comments_dests.txt");

$trailing=trim($argv[1]);
$dest=strtolower(trim($argv[2]));
$nick=strtolower(trim($argv[3]));
$alias=strtolower(trim($argv[4]));

$dests=load_settings(COMMENTS_DESTS_FILE);

if ($alias=="~comments")
{
$parts=explode(" ",$trailing);
$action=strtolower($parts[0]);
array_shift($parts);
$channel="";
if (isset($parts[0])==True)
{
$channel=strtolower($parts[0]);
array_shift($parts);
}
$trailing=trim(implode(" ",$parts));
switch ($action)
{
case "feed":
if (users_get_account($nick)=="crutchy")
{
break;
}
return;
case "dest-add":

$dests=save_settings($dests,COMMENTS_DESTS_FILE);
return;
case "dest-delete":

$dests=save_settings($dests,COMMENTS_DESTS_FILE);
return;
case "dest-rename":

$dests=save_settings($dests,COMMENTS_DESTS_FILE);
return;
case "filter-add":

$dests=save_settings($dests,COMMENTS_DESTS_FILE);
return;
case "filter-delete":

$dests=save_settings($dests,COMMENTS_DESTS_FILE);
return;
default:
return;
}
}

$host="soylentnews.org";
$feed_uri="/index.xml";
Expand Down Expand Up @@ -264,16 +315,16 @@

function output($msg,$term=False)
{
global $subscribers;
#global $subscribers;
if ($term==True)
{
term_echo($msg);
}
pm("#comments",$msg);
for ($i=0;$i<count($subscribers);$i++)
/*for ($i=0;$i<count($subscribers);$i++)
{
pm($subscribers[$i],$msg);
}
}*/
}

#####################################################################################################
Expand Down
26 changes: 12 additions & 14 deletions scripts/tama.php → scripts/filth.php
Expand Up @@ -2,28 +2,26 @@

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

/*
exec:~filth|30|300|0|1|||#||php scripts/filth.php %%trailing%% %%dest%% %%nick%%
*/

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

require_once("lib.php");

$trailing=trim($argv[1]);
$dest=trim($argv[2]);
$nick=trim($argv[3]);
$dest=$argv[2];
$nick=$argv[3];

if ($trailing=="")
{
return;
# poke ciri with something random
}

$rules=exec_file_read("tama_rules");

$parts=explode(" ",$trailing);



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

function get_directive($element)
else
{

# google search using $trailing
wget($host,$uri,$port=80,$agent=ICEWEASEL_UA,$extra_headers="",$timeout=20,$breakcode="",$chunksize=1024)
}

#####################################################################################################
Expand Down
1 change: 1 addition & 0 deletions scripts/github_feed.php
Expand Up @@ -77,6 +77,7 @@
"Subsentient/substrings",
"SoylentNews/slashcode",
"SoylentNews/slashcode_vm",
"SoylentNews/SoylentCode",
"cosurgi/trunk",
"dimkr/LoginKit",
"paulej72/slashcode",
Expand Down
81 changes: 81 additions & 0 deletions scripts/lib_mysql.inc
@@ -0,0 +1,81 @@
<?php

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

$pdo=new PDO("mysql:host=localhost","www",trim(file_get_contents("../pwd/mysql_www")));
if ($pdo===False)
{
die("ERROR CONNECTING TO DATABASE");
}

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

function fetch_query($sql)
{
global $pdo;
$statement=$pdo->query($sql);
if ($statement===False)
{
die("SQL QUERY ERROR\n\n$sql");
}
return $statement->fetchAll(PDO::FETCH_ASSOC);
}

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

function execute_prepare($sql,$params)
{
global $pdo;
$statement=$pdo->prepare($sql);
if ($statement===False)
{
die("SQL PREPARE ERROR\n\n$sql");
}
foreach ($params as $key => $value)
{
if (ctype_digit(strval($value))==True)
{
$statement->bindParam(":$key",$params[$key],PDO::PARAM_INT);
}
else
{
$statement->bindParam(":$key",$params[$key],PDO::PARAM_STR);
}
}
if ($statement->execute()===False)
{
die("SQL EXECUTE ERROR\n\n$sql");
}
}

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

function fetch_prepare($sql,$params)
{
global $pdo;
$statement=$pdo->prepare($sql);
if ($statement===False)
{
die("SQL PREPARE ERROR\n\n$sql");
}
foreach ($params as $key => $value)
{
if (ctype_digit(strval($value))==True)
{
$statement->bindParam(":$key",$value,PDO::PARAM_INT);
}
else
{
$statement->bindParam(":$key",$value,PDO::PARAM_STR);
}
}
if ($statement->execute()===False)
{
die("SQL EXECUTE ERROR\n\n$sql");
}
return $statement->fetchAll(PDO::FETCH_ASSOC);
}

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

?>
8 changes: 5 additions & 3 deletions scripts/link.php
Expand Up @@ -3,8 +3,9 @@
#####################################################################################################

/*
exec:~link|10|0|0|1|*||||php scripts/link.php %%trailing%% %%dest%% %%nick%%
exec:~!|10|0|0|1|*||||php scripts/link.php %%trailing%% %%dest%% %%nick%%
exec:~link|10|0|0|1|*||||php scripts/link.php %%trailing%% %%dest%% %%nick%% %%alias%%
exec:~links|10|0|0|1|*||||php scripts/link.php %%trailing%% %%dest%% %%nick%% %%alias%%
exec:~!|10|0|0|1|*||||php scripts/link.php %%trailing%% %%dest%% %%nick%% %%alias%%
*/

#####################################################################################################
Expand All @@ -14,10 +15,11 @@
$trailing=trim($argv[1]);
$dest=$argv[2];
$nick=$argv[3];
$alias=$argv[4];

if ($trailing=="")
{
privmsg("syntax to search: ~! %search%, set: ~! %id% %content%, delete: ~! %id% -");
privmsg("syntax to search: $alias %search%, set: $alias %id% %content%, delete: $alias %id% -");
privmsg("can't use pipe (|) char, %id% can't contain spaces, but %content% can, %search% is a regexp pattern");
privmsg("will return a list of one or more %id% => %content% if %search% matches either %id% or %content%");
return;
Expand Down
24 changes: 24 additions & 0 deletions scripts/mysql/schema_log.sql
@@ -0,0 +1,24 @@
DROP DATABASE IF EXISTS exec_log;
CREATE DATABASE IF NOT EXISTS exec_log DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

CREATE TABLE `exec_log`.`irc.sylnt.us` (
`id` integer unsigned NOT NULL AUTO_INCREMENT,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`data` varchar(1000) NOT NULL,
`prefix` varchar(255) NOT NULL,
`params` varchar(255) NOT NULL,
`trailing` varchar(500) NOT NULL,
`user` varchar(255) NOT NULL,
`nick` varchar(100) NOT NULL,
`hostname` varchar(255) NOT NULL,
`destination` varchar(100) NOT NULL,
`cmd` varchar(20) NOT NULL,
PRIMARY KEY (`id`),
INDEX `timestamp` (`timestamp` ASC),
INDEX `params` (`params` ASC),
INDEX `trailing` (`trailing` ASC),
INDEX `nick` (`nick` ASC),
INDEX `cmd` (`cmd` ASC),
INDEX `hostname` (`hostname` ASC),
INDEX `destination` (`destination` ASC)
) ENGINE=InnoDB AUTO_INCREMENT=1;
36 changes: 36 additions & 0 deletions scripts/mysql/setup.php
@@ -0,0 +1,36 @@
<?php

define("DB_HOST","localhost");
define("DB_USER","root");
define("DB_PASSWORD",trim(file_get_contents("../../../pwd/mysql_root_cs")));

$pdo=new PDO("mysql:host=".DB_HOST,DB_USER,DB_PASSWORD);
if ($pdo===False)
{
die("ERROR CONNECTING TO MYSQL SERVER\n");
}
else
{
echo "CONNECTED\n";
}
$sql=file_get_contents("schema_log.sql");
$result=$pdo->exec($sql);
if ($result===False)
{
die("ERROR CREATING DATABASE\n");
}
else
{
echo "DATABASE CREATED\n";
}
$result=$pdo->exec("GRANT SELECT, INSERT, UPDATE, DELETE ON news_my_to.* TO www@'%';");
if ($result===False)
{
die("ERROR GRANTING PRIVILEGES\n");
}
else
{
die("PRIVILEGES GRANTED\n");
}

?>
12 changes: 12 additions & 0 deletions scripts/sn_api.php
Expand Up @@ -42,9 +42,21 @@
"0"=>False,
"1e12"=>"Anonymous Coward",
"-1"=>False,
"-"=>False,
"@"=>False,
"1"=>"Anonymous Coward",
"2"=>"NCommander",
"2 2 2"=>"NCommander",
"2-2"=>"NCommander",
"&#50;"=>False,
"2"=>False,
"#2"=>False,
""=>False,
"\"2\""=>False,
"˜2"=>False,
""=>"NCommander",
"*"=>False,
"2); DROP users"=>"NCommander",
"18"=>"The Mighty Buzzard",
"34"=>"chromas",
"x34"=>False,
Expand Down
1 change: 1 addition & 0 deletions scripts/users_lib.php
Expand Up @@ -51,6 +51,7 @@ function users_get_account($nick)
{
if (isset($users[$nick]["account"])==True)
{
# TODO: expiry
return $users[$nick]["account"];
}
}
Expand Down

0 comments on commit e49451a

Please sign in to comment.