Example #1
0
 /**
  * @param Context $context
  * @param bool $useQuestion
  * @param int $characters
  */
 public function __construct($context, $useQuestion = true, $characters = 5)
 {
     $mywords = LanguageFactory::GetLanguageCollection(__CLASS__);
     if ($characters < 5) {
         $characters = 5;
     }
     $basePath = dirname(__FILE__);
     $font = array();
     $font[] = $basePath . '/arial_black.ttf';
     $font[] = $basePath . '/elephant.ttf';
     $font[] = $basePath . '/distress.ttf';
     $font[] = $basePath . '/dsmoster.ttf';
     $font2 = $basePath . '/arial.ttf';
     $pos_ini = 20;
     $font_len = 32 + rand(-3, 3);
     $letters = array(array('A', 'E', 'I', 'O', 'U'), array('B', 'C', 'D', 'F', 'G', 'H', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'V', 'X', 'Z'));
     $colors = array(array(20, 35, 40), array(235 + rand(-20, 20), 0, 0), array(0, 235 + rand(-20, 20), 0), array(0, 0, 235 + rand(-20, 20)));
     $colors_nam = array($mywords->Value('BLACK'), $mywords->Value('RED'), $mywords->Value('GREEN'), $mywords->Value('BLUE'));
     $colors_len = count($colors);
     $maxwidth = $characters * $font_len + $pos_ini * 2;
     $this->image = imagecreatetruecolor($maxwidth, 80);
     $backColor = imagecolorallocate($this->image, 230 + rand(-20, 20), 230 + rand(-20, 20), 230 + rand(-20, 20));
     imagefilledrectangle($this->image, 0, 0, $maxwidth, 80, $backColor);
     $avail = array(array(), array());
     $generatedText = "";
     for ($i = 0; $i < $characters; $i++) {
         $letter_type = rand(0, 1);
         $letter = $letters[$letter_type][rand(0, count($letters[$letter_type]) - 1)];
         $generatedText .= $letter;
         if (empty($avail[0][$letter_type])) {
             $avail[0][$letter_type] = $letter;
         } else {
             $avail[0][$letter_type] .= $letter;
         }
         $color = rand(0, $colors_len - 1);
         if (empty($avail[1][$color])) {
             $avail[1][$color] = $letter;
         } else {
             $avail[1][$color] .= $letter;
         }
         list($r, $g, $b) = $colors[$color];
         imagettftext($this->image, 30, rand(-35, 35), $pos_ini + $font_len * $i, 45, imagecolorallocate($this->image, $r, $g, $b), $font[rand(0, count($font) - 1)], $letter);
     }
     if ($useQuestion) {
         $ask = rand(0, 1);
         $options = array_keys($avail[$ask]);
         $type = $options[rand(0, count($options) - 1)];
         $this->text = $avail[$ask][$type];
         $question = $ask ? $colors_nam[$type] : ($type ? $mywords->Value("CONSONANT") : $mywords->Value("VOWEL"));
         $this->question = $mywords->Value("CHALLENGEQUESTION", $question);
     } else {
         $this->text = $generatedText;
         $this->question = $mywords->Value("SIMPLEQUESTION");
     }
     // Question
     $startx = 5 + rand(-4, 6);
     $starty = 72 + rand(-4, 4);
     imagettftext($this->image, 10.5, 0, $startx, $starty, imagecolorallocate($this->image, 0, 0, 0), $font2, $this->question);
     $color = imagecolorallocate($this->image, $r * rand(0, 1), $g * rand(0, 1), $b * rand(0, 1));
     imagettftext($this->image, 10.5, -0.5 * (1 - rand(0, 1)), $startx + 1, $starty + 1, $color, $font2, $this->question);
     for ($i = 0; $i < 10; $i++) {
         $x1 = rand(0, $maxwidth);
         $y1 = rand(0, 70);
         $x2 = rand(0, $maxwidth);
         $y2 = rand(0, 70);
         $color = imagecolorallocate($this->image, 255 * rand(0, 1), 255 * rand(0, 1), 255 * rand(0, 1));
         imageline($this->image, $x1, $y1, $x2, $y2, $color);
     }
     $x1 = rand(0, 30);
     $y1 = rand(65, 75);
     $x2 = rand($maxwidth - 50, $maxwidth);
     $y2 = rand(65, 75);
     $color = imagecolorallocate($this->image, 255 * rand(0, 1), 255 * rand(0, 1), 255 * rand(0, 1));
     imageline($this->image, $x1, $y1, $x2, $y2, $color);
 }
Example #2
0
 /**
  * @return LanguageCollection
  * @desc WordCollection Imodule interface
  */
 public function WordCollection()
 {
     if ($this->_words == null) {
         $this->_words = LanguageFactory::GetLanguageCollection(get_called_class());
     }
     return $this->_words;
 }
Example #3
0
 /**
  *@desc Constructor
  *@param Context $context XMLNuke context object
  *@param array fields Fields will be processed
  *@param string header Simple $header
  *@param string module Module will be process this request-> Usually is the same $module instantiate the XmlnukeCrudDB
  *@param array $buttons Custom $buttons in View/Select mode
  *@return
  */
 public function __construct($context, $fields, $header, $module, $buttons)
 {
     $this->_context = $context;
     $this->_fields = $fields->getCrudFieldCollection();
     $this->_buttons = $buttons;
     $this->_header = $header;
     $this->_module = $module;
     $this->_new = true;
     $this->_view = true;
     $this->_delete = true;
     $this->_edit = true;
     $this->_currentAction = $this->_context->get("acao");
     foreach ($this->_fields as $i => $field) {
         if ($field->key) {
             $this->_keyIndex[] = $i;
         }
     }
     $this->_parameter = array();
     //$this->_filter = $this->_context->get("filter"); //encoded
     //$this->_sort = $this->_context->get("sort"); // encoded
     $this->_valueId = $this->_context->get("valueid");
     $this->_curPage = $this->_context->get("curpage");
     $this->_qtdRows = $this->_context->get("offset");
     $this->_decimalSeparator = $this->_context->Language()->getDecimalPoint();
     $this->_dateFormat = $this->_context->Language()->getDateFormat();
     $this->_lang = LanguageFactory::GetLanguageCollection(__CLASS__);
 }
Example #4
0
 /**
  * Initialize a poll context
  * Use the method processData to process data.
  *
  * @param Context $context
  * @param string $urlProcess
  * @param string $poll
  * @param string $lang
  * @return XmlnukePoll
  */
 public function __construct($urlProcess, $poll, $lang = "")
 {
     $this->_context = Context::getInstance();
     $this->_url = $urlProcess;
     $this->_poll = $poll;
     if ($lang != "") {
         $this->_lang = $lang;
     } else {
         $this->_lang = $this->_context->Language()->getName();
     }
     $this->_processed = false;
     $this->getPollConfig();
     $this->_myWords = LanguageFactory::GetLanguageCollection(get_class());
 }
Example #5
0
 /**
  * Enter description here...
  *
  * @param XmlnukeDocument $xmlDoc
  */
 protected function CreateMenuAdmin()
 {
     // Load Language file for Module Object
     $lang = LanguageFactory::GetLanguageCollection("AdminModules");
     // Create a Menu Item for GROUPS and MODULES.
     // This menu have CP_ before GROUP NAME
     $itGroup = $this->GetAdminGroups();
     while ($itGroup->hasNext()) {
         $srGroup = $itGroup->moveNext();
         $this->defaultXmlnukeDocument->addMenuGroup($lang->Value("GROUP_" . strtoupper($srGroup->getField("name"))), "CP_" . $srGroup->getField("name"));
         $arrModules = $this->GetAdminModules($srGroup->getField("name"));
         foreach ($arrModules as $key => $value) {
             $url = $value[1];
             $name = $key;
             $icon = $value[0];
             if ($url != "") {
                 $this->defaultXmlnukeDocument->addMenuItem($url, $lang->Value("MODULE_TITLE_" . strtoupper($name)), $lang->Value("MODULE_ABSTRACT_" . strtoupper($name)), "CP_" . $srGroup->getField("name"), $icon);
             }
         }
     }
     return $lang;
 }