Example #1
0
/**
\sa http://creativyst.com/Doc/Articles/CSV/CSV01.htm
\sa http://en.wikipedia.org/wiki/Comma-separated_values
*/
function quote_csv($str, $csv_record_separator = "\n", $csv_field_separator = ',', $csv_incloser = '"')
{
    if (string_contains($str, $csv_incloser)) {
        return $csv_incloser . str_replace($csv_incloser, $csv_incloser . $csv_incloser, $str) . $csv_incloser;
    }
    if (string_contains($str, $csv_record_separator) || string_contains($str, $csv_field_separator) || string_begins_with_space($str) || string_ends_with_space($str)) {
        return $csv_incloser . $str . $csv_incloser;
    }
    return $str;
}
Example #2
0
{
    $scan = glob('modules/*');
    foreach ($scan as $path) {
        if (preg_match('/\\.php$/', $path)) {
            require_once $path;
        }
    }
}
function register_callback($callback)
{
    array_push($GLOBALS['callbacks'], $callback);
}
require_modules();
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$success = socket_connect($socket, HOST, PORT);
irc_send($socket, 'NICK ' . NICKNAME);
irc_send($socket, 'USER ' . NICKNAME . ' 0 * :' . NICKNAME);
do {
    $input = socket_read($socket, 2048, PHP_NORMAL_READ);
    if ($input === false) {
        break;
    }
    echo 'input: ', $input;
    if (!$joined && string_contains($input, 'MODE')) {
        irc_send($socket, 'JOIN ' . CHANNEL);
    } else {
        foreach ($callbacks as $callback) {
            $callback($socket, $input);
        }
    }
} while (true);
Example #3
0
/**
 * Alias of string_contains 
 *
 * @param string $input
 * @param string $substring
 *
 * @return bool
 *
 * @author Lucantis Swann <*****@*****.**>
 */
function string_include($input, $substring)
{
    return string_contains($input, $substring);
}
Example #4
0
<?php

function react_to_ping($socket, $input)
{
    $parts = explode(' ', $input);
    irc_send($socket, 'PONG ' . $parts[1]);
}
register_callback(function ($socket, $input) {
    if (string_contains($input, 'PING')) {
        react_to_ping($socket, $input);
    }
});
Example #5
0
function string_doesnt_contains($field, $value)
{
    return "not " . string_contains($field, $value);
}