コード例 #1
0
ファイル: reset.php プロジェクト: sinfocol/gwf3
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;
}
コード例 #2
0
ファイル: smile.php プロジェクト: sinfocol/gwf3
 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')));
 }