Exemple #1
0
function main()
{
    stream_filter_register('test.md5', 'Md5Filter');
    stream_filter_register('test.ucase', 'UpperCaseFilter');
    doTest('stream_filter_append');
    doTest('stream_filter_prepend');
}
Exemple #2
0
    $display .= checkInstallDir();
    $urls = array(array('db-config.php', 'db-config.php'), array('logs/error.log', 'logs ' . $LANG_SECTEST['directory']), array('plugins/staticpages/functions.inc', 'plugins ' . $LANG_SECTEST['directory']), array('system/lib-security.php', 'system ' . $LANG_SECTEST['directory']));
    foreach ($urls as $tocheck) {
        $display .= doTest($url, $tocheck[0], $tocheck[1]);
    }
    // Note: We're not testing the 'sql' and 'language' directories.
    if ($_CONF['allow_mysqldump'] == 1 && $_DB_dbms == 'mysql') {
        if (makeTempfile($_CONF['backup_path'] . 'test.txt')) {
            $display .= doTest($url, 'backups/test.txt', 'backups ' . $LANG_SECTEST['directory']);
            @unlink($_CONF['backup_path'] . 'test.txt');
        } else {
            $display .= '<li>' . sprintf($LANG_SECTEST['failed_tmp'], 'backups') . '</li>';
        }
    }
    if (makeTempfile($_CONF['path_data'] . 'test.txt')) {
        $display .= doTest($url, 'data/test.txt', 'data directory');
        @unlink($_CONF['path_data'] . 'test.txt');
    } else {
        $display .= '<li>' . sprintf($LANG_SECTEST['failed_tmp'], 'data') . '</li>';
    }
    $display .= checkDefaultPassword();
    $display .= '</ol>';
} else {
    $resultInstallDirCheck = checkInstallDir();
    $resultPasswordCheck = checkDefaultPassword();
    if ($failed_tests == 0) {
        $display .= '<p>' . $LANG_SECTEST['okay'] . '</p>';
    } else {
        $display .= '<ol>';
        $display .= $resultInstallDirCheck . LB . $resultPasswordCheck;
        $display .= '</ol>';
Exemple #3
0
require_once FS_ROOT . "/../../www/lib/music.php";
require_once FS_ROOT . "/../../www/lib/category.php";
$music = new Music(true);
$db = new Db();
$limit = 10;
$testSpecificRel = 'Joy - Touch By Touch 2011-CDM-2010-RQS';
//make this string empty to check last $limit releases
if (empty($testSpecificRel)) {
    $res = $db->queryDirect(sprintf("SELECT searchname, ID from releases where musicinfoID IS NULL and categoryID in ( select ID from category where parentID = %d ) ORDER BY id DESC LIMIT %d", Category::CAT_PARENT_MUSIC, $limit));
    foreach ($res as $album) {
        $artist = $music->parseArtist($album);
        doTest($artist);
    }
} else {
    $artist = $music->parseArtist($testSpecificRel);
    doTest($artist);
}
function doTest($relInfo)
{
    echo $relInfo['releasename'] . '<br />';
    $result = updateMusicInfo($relInfo['artist'], $relInfo['album'], $relInfo['year']);
    if ($result !== false) {
        echo '<pre>';
        print_r($result);
        echo '</pre><br /><br />';
    }
}
function updateMusicInfo($artist, $album, $year)
{
    $db = new DB();
    $gen = new Genres();
Exemple #4
0
function executeProcess(array $argv)
{
    $CLASS_PATTERN = file_get_contents(file_path(__DIR__, 'class.txt'));
    $METHOD_PATTERN = file_get_contents(file_path(__DIR__, 'method.txt'));
    /*
     * Название тестового файла.
     * Для проверки мы сначала удалим класс для него, если он был, потом проверим, что за класс был сгенерирован.
     */
    $TEST_MESSAGES_FILE = 'ExampleSdkProcessMessages';
    //Убедимся, что тестовый .msgs существует и удалим тестовый .php файл
    $TEST_PHP_DI = DirItem::inst(__DIR__ . '/classes', $TEST_MESSAGES_FILE, PsConst::EXT_PHP)->remove();
    $TEST_MSGS_DI = DirItem::inst(__DIR__ . '/classes', $TEST_MESSAGES_FILE, PsConst::EXT_MSGS);
    check_condition($TEST_MSGS_DI->isFile(), "File {$TEST_MSGS_DI->getAbsPath()} must exists");
    dolog('Loading all files, ended with Messages.msgs');
    //TODO - после нужно получать эту информацию из какого-нибудь места
    $exceptDirs[] = DirManager::autogen()->relDirPath();
    $exceptDirs[] = DirManager::resources()->relDirPath();
    $exceptDirs[] = DirManager::stuff()->relDirPath();
    //$exceptDirs = array();
    $items = DirManager::inst()->getDirContentFull(null, function (DirItem $di) {
        dolog($di->getAbsPath());
        return $di->isFile() && ends_with($di->getName(), 'Messages.msgs');
    }, $exceptDirs);
    dolog('Message files for processing: {}', count($items));
    //Проверим, что был выбран тестовый файл
    check_condition(in_array($TEST_MSGS_DI, $items, true), "Test file [{$TEST_MESSAGES_FILE}] is not included");
    //Удалим его из массива...
    array_remove_value($items, $TEST_MSGS_DI, true);
    //И поместим наверх, чтобы он был обработан первым
    array_unshift($items, $TEST_MSGS_DI);
    /* @var $msgsDi DirItem */
    foreach ($items as $msgsDi) {
        dolog('PROCESSING [{}]', $msgsDi->getAbsPath());
        //Сбросим методы
        $METHODS = array();
        //Извлечём название класса
        $CLASS = $msgsDi->getNameNoExt();
        //DirItem файла с сообщениями php
        $classDi = DirItem::inst($msgsDi->getDirname(), $CLASS, PsConst::EXT_PHP);
        //Получаем сообщения из файла .msgs
        $messages = $msgsDi->getFileAsProps();
        foreach ($messages as $MSG_KEY => $MGG_VALUE) {
            dolog(' >> {}={}', $MSG_KEY, $MGG_VALUE);
            //Получим список всех параметров из макросов ({0}, {1}, {2} и т.д.)
            preg_match_all("/\\{(.+?)\\}/", $MGG_VALUE, $args);
            $args = array_values(array_unique($args[1]));
            sort($args, SORT_NUMERIC);
            $ARGS = array();
            for ($index = 0; $index < count($args); $index++) {
                $arg = $args[$index];
                $lineDescr = PsStrings::replaceWithBraced('[{}] in line [{}={}]', $msgsDi->getRelPath(), $MSG_KEY, $MGG_VALUE);
                check_condition(is_inumeric($arg), "Invalid argument [{$arg}] for {$lineDescr}");
                check_condition($index == $args[$index], "Missing index [{$index}] for {$lineDescr}");
                $ARGS[] = '$p' . $index;
            }
            $ARGS = join(', ', $ARGS);
            //Добавляем метод
            dolog(" A: {}::{} ({})", $CLASS, $MSG_KEY, $ARGS);
            $PARAMS['SUPPORT_CLASS'] = PsMsgs::getClass();
            $PARAMS['MESSAGE'] = $MGG_VALUE;
            $PARAMS['FUNCTION'] = $MSG_KEY;
            $PARAMS['ARGS'] = $ARGS;
            $METHODS[] = PsStrings::replaceMapBracedKeys($METHOD_PATTERN, $PARAMS);
        }
        dolog('Made methods: ({})', count($METHODS));
        if ($METHODS) {
            $PARAMS['FILE'] = $msgsDi->getAbsPath();
            $PARAMS['CLASS'] = $CLASS;
            $PARAMS['DATE'] = date(DF_PS);
            $PARAMS['METHODS'] = "\n" . join("\n\n", $METHODS) . "\n";
            $CLASS_PHP = PsStrings::replaceMapBracedKeys($CLASS_PATTERN, $PARAMS);
            $classDi->putToFile($CLASS_PHP);
        }
        /*
         * Если обрабатываем тестовый файл - проверим его
         */
        //TEST CLASS VALIDATION START >>>
        if ($msgsDi->equals($TEST_MSGS_DI)) {
            dolog('');
            dolog('Validating test class {}', $TEST_MESSAGES_FILE);
            //Проверим, что .php был сгенерирован
            check_condition($TEST_PHP_DI->isFile(), "File {$TEST_PHP_DI->getAbsPath()} was not created!");
            //Проверим, что для каждого сообщения был создан метод
            $methods = PsUtil::newReflectionClass($TEST_MESSAGES_FILE)->getMethods();
            $messages = $TEST_MSGS_DI->getFileAsProps();
            check_condition(count($methods) == count($messages), 'Methods count missmatch, check ' . $TEST_PHP_DI->getAbsPath());
            /* @var $method ReflectionMethod */
            foreach ($methods as $method) {
                check_condition(array_key_exists($method->getName(), $messages), "No method {$TEST_MESSAGES_FILE}::" . $method->getName());
            }
            //Проверим, что возвращают методы тестового сгенерированного класса
            function doTest($className, $methodName, array $params, $expected)
            {
                $method = "{$className}::{$methodName}";
                $actual = call_user_func_array($method, $params);
                dolog("{}({})='{}', Expected='{}'", $method, join(', ', $params), $actual, $expected);
                check_condition($actual == $expected, "{$actual} != {$expected}");
            }
            doTest($TEST_MESSAGES_FILE, 'message1', array(), 'Message 1');
            doTest($TEST_MESSAGES_FILE, 'message2', array('a', 'b', 'c'), 'Parametred a,c,b');
            dolog('Test class is valid!');
        }
        //TEST CLASS VALIDATION END <<<
    }
    //# DirItems validation end
}
Exemple #5
0
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
*/
define('_HOMEREXEC', "1");
/* MAIN CLASS modules */
include "class/index.php";
$task = getVar('task', 'search', $_REQUEST, 'string');
switch ($task) {
    case 'sipmessage':
        sipMessage();
        break;
    case 'test':
        doTest();
        break;
    case 'livesearch':
        liveSearch();
        break;
    case 'saveit':
        SaveCflow();
        break;
    case 'sipsend':
        phpSip();
        break;
    case 'sipVic':
        vicCrash();
        break;
    case 'pcapin':
        LoadPcap();
Exemple #6
0
        $failed_tests++;
    }
    $display .= checkInstallDir();
    $urls = array(array($privatePath . 'db-config.php', 'db-config.php'), array($privatePath . 'logs/error.log', 'logs directory'), array($privatePath . 'plugins/staticpages/staticpages.php', 'plugins directory'), array($privatePath . 'system/lib-security.php', 'system directory'));
    foreach ($urls as $tocheck) {
        $display .= doTest($url, $tocheck[0], $tocheck[1]);
    }
    // Note: We're not testing the 'sql' and 'language' directories.
    if (makeTempfile($_CONF['backup_path'] . 'test.txt')) {
        $display .= doTest($url, $privatePath . 'backups/test.txt', 'backups directory');
        @unlink($_CONF['backup_path'] . 'test.txt');
    } else {
        $display .= '<li>Failed to create a temporary file in your backups directory. Check your directory permissions!</li>';
    }
    if (makeTempfile($_CONF['path_data'] . 'test.txt')) {
        $display .= doTest($url, $privatePath . 'data/test.txt', 'data directory');
        @unlink($_CONF['path_data'] . 'test.txt');
    } else {
        $display .= '<li>Failed to create a temporary file in your data directory. Check your directory permissions!</li>';
    }
    $display .= checkDefaultPassword();
    $display .= '</ol>';
} else {
    $resultInstallDirCheck = checkInstallDir();
    $resultPasswordCheck = checkDefaultPassword();
    if ($failed_tests == 0) {
        $display .= '<p>Everything seems to be in order.</p>';
    } else {
        $display .= '<ol>';
        $display .= $resultInstallDirCheck . LB . $resultPasswordCheck;
        $display .= '</ol>';
Exemple #7
0
        echo 'Logging out.' . "\n";
        $result = doLogout($test, $curl);
        if ($result !== "OK") {
            if (is_string($result)) {
                echo 'Failed to log out. Result from SP: ' . $result . "\n";
            } else {
                echo 'Failed to log out.' . "\n";
            }
            $res = FALSE;
            break;
        }
        echo 'Logged out.' . "\n";
    } while (0);
    curl_close($curl);
    return $res;
}
$ret = 0;
/* Run the tests. */
foreach ($tests as $i => $test) {
    echo '############################################################' . "\n";
    echo 'Running test #' . ($i + 1) . '.' . "\n";
    $res = doTest($test);
    if ($res === FALSE) {
        $ret = 1;
        echo 'Test #' . ($i + 1) . ' failed.' . "\n";
    } else {
        echo 'Test #' . ($i + 1) . ' succeeded.' . "\n";
    }
}
echo '############################################################' . "\n";
exit($ret);
Exemple #8
0
{
    echo '<tr><th>', htmlentities($name), '</th>';
    echo '<td class="', $result ? 'succ' : 'error', '">';
    echo $result ? 'Passed' : 'Failed';
    echo '</td>';
    if (!$result) {
        echo '<td>', $failinfo, '</td>';
    }
    echo '</tr>';
}
echo '<tr><th colspan="2">Poidsy requirements</th></tr>';
doTest('PHP Version', version_compare(PHP_VERSION, '5.2.10', '>='), 'Poidsy requires PHP version 5.2.10 or greater to run');
doTest('Allow_url_fopen', ini_get('allow_url_fopen'), 'Poidsy requires allow_url_fopen to be configured to true');
echo '<tr><th colspan="2">Associate mode requirements</th></tr>';
doTest('hash_hmac function', function_exists('hash_hmac'), 'Poidsy requires the hash_hmac function to use associate mode. It should be available in PHP 5.2.0 or greater, unless you\'ve explicitly disabled it when compiling PHP');
doTest('Keycache writable', is_writable(dirname(__FILE__) . '/keycache.php'), 'Poidsy requires write access to the keycache.php file in its directory. Without it, Poidsy will be unable to use associate mode.');
echo '<tr><th colspan="2">Diffie-Hellman key exchange requirements</th></tr>';
$extensions = array(array('modules' => array('gmp', 'php_gmp'), 'extension' => 'gmp'), array('modules' => array('bcmath', 'php_bcmath'), 'extension' => 'bcmath'));
$best = '';
foreach ($extensions as $ext) {
    if ($ext['extension'] && extension_loaded($ext['extension'])) {
        $loaded = true;
    } elseif (function_exists('dl')) {
        foreach ($ext['modules'] as $module) {
            if (@dl($module . "." . PHP_SHLIB_SUFFIX)) {
                $loaded = true;
                break;
            }
        }
    }
    if ($loaded) {
Exemple #9
0
        ++$i;
        $scName = $sc->getNameNoExt();
        dolog('');
        dolog('STARTED SCENARIO: ' . $scName);
        $props = $sc->getFileAsProps();
        $newGlobals = array_merge($PS_GLOBALS, $props);
        dolog('Set scenario global props: ' . print_r($props, true));
        dolog('Full global props: ' . print_r($newGlobals, true));
        PsGlobals::inst()->updateProps($props);
        dolog($i . ' scenario of ' . count($scenarios));
        $RESULTS = doTest();
        dolog('Test finished, restoring globals.');
        PsGlobals::inst()->updateProps($PS_GLOBALS);
        $SC_RESULTS[$scName] = array('res' => $RESULTS, 'props' => $newGlobals);
    }
} else {
    $RESULTS = doTest();
    $SC_RESULTS = array('res' => $RESULTS);
}
$sm->stop();
dolog('RESULTS: ' . print_r($SC_RESULTS, true));
$params['time'] = str_replace('.', ',', round($sm->getTotalTime(), 2));
$params['total'] = $TOTAL;
$params['host'] = $HOST;
$params['rqcnt'] = $REQUESTS_CNT;
$params['result'] = $SC_RESULTS;
$params['usesc'] = $USE_SCENARIOS;
/*
 * Сохраняем в файл
 */
saveResult2Html('speedtest.tpl', $params, __DIR__, $HOST . '_' . $DATE);