Ejemplo n.º 1
0
function LVSM_refresh()
{
    GDO::table('LIVIN_Smile')->truncate();
    if (false === ($dir = scandir('challenge/livinskull/smile/smiles'))) {
        echo GWF_HTML::err(ERR_FILE_NOT_FOUND, 'smileys');
        return false;
    }
    foreach ($dir as $file) {
        if (1 === preg_match('/(.*)\\.(?:gif|jpg|png|jpeg)$/', $file, $matches)) {
            $rule = '/:' . preg_quote($matches[1]) . ':/';
            $path = '/challenge/livinskull/smile/smiles/' . $file;
            $path = sprintf('<img src="%s" />', htmlspecialchars($path));
            LIVIN_Smile::onAddSmiley($rule, $path);
        }
    }
    return true;
}
Ejemplo n.º 2
0
        die(file_get_contents('LIVIN_Smile.php'));
    }
}
# -------------------------- #
chdir('../../../');
define('GWF_PAGE_TITLE', 'Smile');
require_once 'challenge/html_head.php';
require_once GWF_CORE_PATH . 'module/WeChall/solutionbox.php';
if (false === ($chall = WC_Challenge::getByTitle(GWF_PAGE_TITLE))) {
    $chall = WC_Challenge::dummyChallenge(GWF_PAGE_TITLE, 4, 'challenge/livinskull/smile/index.php', false);
}
$chall->showHeader();
# -------------------------- #
if (false !== ($answer = Common::getPostString('answer', false))) {
    require_once 'challenge/livinskull/smile/LIVIN_Smile.php';
    $solution = LIVIN_Smile::getSolution();
    if ($answer === $solution) {
        $chall->onChallengeSolved(GWF_Session::getUserID());
    } else {
        echo WC_HTML::error('err_wrong');
    }
}
# -------------------------- #
$url1 = 'index.php?show=smile';
$url2 = 'index.php?highlight=smile';
$url3 = 'index.php?show=livin_smile';
$url4 = 'index.php?highlight=livin_smile';
$url5 = 'smile.php';
echo GWF_Box::box($chall->lang('info', array($url1, $url2, $url3, $url4, $url5)), $chall->lang('title'));
# -------------------------- #
if (false !== ($file = Common::getGetString('highlight', false))) {
Ejemplo n.º 3
0
 public function onAdd(WC_Challenge $chall)
 {
     $module = Module_WeChall::instance();
     $form = $this->getForm($chall);
     if (false !== ($error = $form->validate($module))) {
         return $error;
     }
     $pattern = $form->getVar('pattern');
     $path = $form->getVar('filename');
     // 		if (!preg_match('/^[\x00-\x7f]+$/D', $pattern))
     // 		{
     // 			return GWF_HTML::error('Smile Pattern', array($chall->lang('err_ascii')));
     // 		}
     if (!preg_match('/^[\\x00-\\x7f]+$/D', $path)) {
         return GWF_HTML::error('Smile Path', array($chall->lang('err_ascii')));
     }
     # Show a sample output for the new smiley :)
     if (!LIVIN_Smile::testSmiley($chall, $pattern, $path)) {
         return GWF_HTML::error('Smile', array($chall->lang('err_test')));
     }
     # If it looks valid we even add it globally :)
     if (!LIVIN_Smile::looksHarmless($path)) {
         return GWF_HTML::error('Smile', array($chall->lang('err_xss')));
     }
     if (!LIVIN_Smile::imageExists($path)) {
         return GWF_HTML::error('Smile', array($chall->lang('err_path')));
     }
     # Like this :)
     LIVIN_Smile::onAddSmiley($pattern, $path);
     return GWF_HTML::message('Smile', array($chall->lang('msg_rule_added')));
 }