Example #1
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')));
 }