public function SPItem($id = false, $style_sd = false) { global $bd_names, $site_ways; parent::View($style_sd); $this->base_dir = MCR_ROOT . 'instruments/sp2/skins/'; $this->base_url = 'instruments/sp2/skins/'; $this->base_name = 'sp_nc'; $this->db_likes = $bd_names['likes']; $this->db = $bd_names['sp_skins']; $this->db_bad_skins = $bd_names['sp_bad_skins']; $this->db_ratio = $bd_names['sp_skins_ratio']; $this->id = !$id ? (int) $id : false; $result = BD("SELECT `id`, `name`, `fname`, `fsize`, `dislikes`, `likes`, `ratio`, `gender`, `downloads` FROM `{$this->db}` WHERE `id`='" . TextBase::SQLSafe($id) . "'"); if (mysql_num_rows($result) != 1) { $this->id = false; return false; } $line = mysql_fetch_array($result, MYSQL_NUM); $this->id = (int) $line[0]; $this->name = $line[1]; $this->fname = $line[2]; $this->fsize = $line[3]; $this->dislikes = (int) $line[4]; $this->likes = (int) $line[5]; $this->ratio = (int) $line[6]; $this->gender = (int) $line[7]; $this->downloads = (int) $line[8]; }
public function notifyRule(Rule $rule) { if (is_string($rule->operation) && strcasecmp($rule->operation, ':range') === 0 && !$rule->isNegative && $this->control->type !== 'text') { list($this->control->min, $this->control->max) = $rule->arg; // for HTML 5 } parent::notifyRule($rule); }
public function notifyRule(Rule $rule) { if (is_string($rule->operation) && strcasecmp($rule->operation, ':length') === 0 && !$rule->isNegative) { $this->control->maxlength = is_array($rule->arg) ? $rule->arg[1] : $rule->arg; } elseif (is_string($rule->operation) && strcasecmp($rule->operation, ':maxLength') === 0 && !$rule->isNegative) { $this->control->maxlength = $rule->arg; } parent::notifyRule($rule); }
/** * Generates control's HTML element. * @return Html */ public function getControl() { $control = parent::getControl(); foreach ($this->getRules() as $rule) { if ($rule->isNegative || $rule->type !== Rule::VALIDATOR) { } elseif ($rule->operation === Form::RANGE && $control->type !== 'text') { list($control->min, $control->max) = $rule->arg; } elseif ($rule->operation === Form::PATTERN) { $control->pattern = $rule->arg; } } if ($control->type !== 'password') { $control->value = $this->getValue() === '' ? $this->translate($this->emptyValue) : $this->value; } return $control; }
/** * Email validation test. * @return void */ public function testEmailValidation() { $control = new TextInput(); $control->value = ''; $this->assertEquals(FALSE, TextBase::validateEmail($control), $control->value); $control->value = '@.'; $this->assertEquals(FALSE, TextBase::validateEmail($control), $control->value); $control->value = '*****@*****.**'; $this->assertEquals(TRUE, TextBase::validateEmail($control), $control->value); $control->value = "name@žluťoučký.cz"; // name@�lu�ou�k�.cz $this->assertEquals(TRUE, TextBase::validateEmail($control), $control->value); $control->value = "žname@žluťoučký.cz"; // �name@�lu�ou�k�.cz $this->assertEquals(FALSE, TextBase::validateEmail($control), $control->value); }
} else { include View::Get('server_add.html', $st_subdir . 'server/'); } break; case 'constants': $site_name = Filter::input('site_name'); if ($site_name) { $site_offline = Filter::input('site_offline', 'post', 'bool'); $smtp = Filter::input('smtp', 'post', 'bool'); $site_about = Filter::input('site_about'); $keywords = Filter::input('site_keyword'); if (TextBase::StringLen($keywords) > 200) { $info .= lng('INCORRECT_LEN') . ' (' . lng('ADMIN_KEY_WORDS') . ') ' . lng('TO') . ' 200 ' . lng('CHARACTERS'); break; } if (!TextBase::StringLen($site_name)) { $info .= lng('INCORRECT') . ' (' . lng('ADMIN_SITE_NAME') . ') '; break; } $sbuffer = Filter::input('sbuffer', 'post', 'bool'); $rewrite = Filter::input('rewrite', 'post', 'bool'); $log = Filter::input('log', 'post', 'bool'); $comm_revers = Filter::input('comm_revers', 'post', 'bool'); $theme_id = Filter::input('theme_name', 'post'); $theme_delete = Filter::input('theme_delete', 'post'); $theme_old = $config['s_theme']; $email_name = Filter::input('email_name', 'post'); $email_mail = Filter::input('email_mail', 'post'); $email_test = Filter::input('email_test', 'post'); if (ThemeManager::GetThemeInfo($theme_id) === false) { $theme_id = false;
public function Create($message, $user_id, $item_id, $item_type) { if ($this->id) { return 0; } $this->parent_id = (int) $item_id; $this->parent_type = (int) $item_type; if (!$this->initParent()) { return 1703; } $this->user_id = $user_id; $message = Message::Comment($message); if (TextBase::StringLen($message) < 2) { return 1701; } // lock read \ write cause comments may asked to be shown \ delete while creation $sql = "INSERT INTO `{$this->db}` ( `message`, `time` , `item_id`, `item_type`, `user_id`) " . "VALUES (:message, NOW(), '" . $this->parent_obj->id() . "', '" . $this->parent_obj->type() . "', '" . $this->user_id . "')"; $result = getDB()->ask($sql, array('message' => $message)); if ($result) { $this->id = getDB()->lastInsertId(); $this->parent_obj->OnComment(); return 1; } return 0; }
/** * Generates control's HTML element. * @return Html */ public function getControl() { $control = parent::getControl(); $control->setText($this->value === '' ? $this->translate($this->emptyValue) : $this->tmpValue); return $control; }
/** * Rangle validator: is a control's value number in specified range? * @param TextBase * @param array min and max value pair * @return bool */ public static function validateRange(TextBase $control, $range) { return ($range[0] === NULL || $control->getValue() >= $range[0]) && ($range[1] === NULL || $control->getValue() <= $range[1]); }
public function Edit($name, &$permissions) { if (!$this->id) { return false; } if (!$name or !TextBase::StringLen($name)) { return false; } $line = getDB()->fetchRow("SELECT COUNT(*) FROM `{$this->db}` " . "WHERE `name`=:name and `id`!='{$this->id}'", array('name' => $name), 'num'); if ((int) $line[0]) { return false; } $sql = '`name`=?'; $sqlData = array($name); foreach (self::$permissions as $key => $value) { if ($value == 'bool') { $sqlData[] = (isset($permissions[$key]) and $permissions[$key]) ? 1 : 0; } elseif (isset($permissions[$key])) { $sqlData[] = (int) $permissions[$key]; } else { continue; } $sql .= ",`{$key}`=?"; } $result = getDB()->ask("UPDATE `{$this->db}` SET {$sql} WHERE `id`='{$this->id}'", $sqlData); if ($result and $result->rowCount()) { return true; } return false; }
public function ShowNewsEditor() { global $bd_names; $editorTitle = 'Добавить новость'; $editorButton = 'Добавить'; $editInfo = array('vote' => !Filter::input('hide_vote', 'post', 'bool'), 'discus' => !Filter::input('hide_discus', 'post', 'bool')); $editCategory = Filter::input('cid', 'post', 'int', true); $editMode = Filter::input('editMode', 'post', 'int'); $editTitle = Filter::input('title', 'post', 'string', true); $editMessage = Filter::input('message', 'post', 'html', true); $editMessage_Full = Filter::input('message_full', 'post', 'html', true); $error = ''; if ($editCategory !== false and $editTitle !== false and $editMessage !== false) { ob_start(); $state = 'error'; if (!$editCategory or !$editMessage or !$editTitle) { $text_str = 'Заполните необходимые поля.'; } else { if ($editMode > 0) { $news_item = new News_Item($editMode, $this->st_subdir); if ($news_item->Edit($editCategory, $editTitle, $editMessage, $editMessage_Full, $editInfo['vote'], $editInfo['discus'])) { $state = 'success'; $text_str = 'Новость обновлена'; } else { $text_str = 'Недостаточно прав'; } $editMode = 0; } else { $news_item = new News_Item(); $news_item->Create($editCategory, $editTitle, $editMessage, $editMessage_Full, $editInfo['vote'], $editInfo['discus']); $state = 'success'; $text_str = 'Новость добавлена'; } } include $this->GetView('news_admin_mess.html'); $error = ob_get_clean(); } elseif (Filter::input('delete', 'get', 'int')) { $news_item = new News_Item(Filter::input('delete', 'get', 'int')); $news_item->Delete(); header("Location: " . $this->work_link . "ok"); } elseif (Filter::input('edit', 'get', 'int')) { $editorTitle = 'Обновить новость'; $editorButton = 'Изменить'; $news_item = new News_Item(Filter::input('edit', 'get', 'int')); if (!$news_item->Exist()) { return ''; } $editInfo = $news_item->getInfo(); $editMode = $editInfo['id']; $editCategory = $editInfo['category_id']; $editTitle = TextBase::HTMLDestruct($editInfo['title']); $editMessage = TextBase::HTMLDestruct($editInfo['text']); $editMessage_Full = TextBase::HTMLDestruct($editInfo['text_full']); } ob_start(); $cat_list = CategoryManager::GetList($editCategory); include $this->GetView('news_add.html'); return ob_get_clean(); }
public function SetText($var, $field = 'name') { if (!$this->Exist()) { return false; } else { if ($field !== 'name' and $field !== 'info') { return false; } } if (!$var or !TextBase::StringLen($var)) { return false; } getDB()->ask("UPDATE `" . $this->db . "` SET `{$field}`=:var WHERE `id`='" . $this->id . "'", array('var' => $var)); if ($field == 'name') { $this->name = $var; } else { $this->info = $var; } }
public function notifyRule(Rule $rule) { if (!is_string($rule->operation)) { // nothing to do } elseif ($rule->type === Rule::VALIDATOR && strcasecmp($rule->operation, ':length') === 0) { $this->control->maxlength = is_array($rule->arg) ? $rule->arg[1] : $rule->arg; } elseif ($rule->type === Rule::VALIDATOR && strcasecmp($rule->operation, ':maxLength') === 0) { $this->control->maxlength = $rule->arg; } parent::notifyRule($rule); }
/** * Rangle validator: is a control's value number in specified range? * @param TextBase * @param array min and max value pair * @return bool */ public static function validateRange(TextBase $control, $range) { return Validators::isInRange($control->getValue(), $range); }
/** * Rangle validator: is a control's value number in specified range? * @param TextBase * @param array min and max value pair * @return bool */ public static function validateRange(TextBase $control, $range) { return $control->getValue() >= $range[0] && $control->getValue() <= $range[1]; }
/* Sync or drop config */ if (Filter::input('save', 'post', 'bool')) { sqlConfigSet('rcon-serv', $game_server); sqlConfigSet('rcon-pass', $rcon_pass); sqlConfigSet('rcon-port', $rcon_port); } else { sqlConfigSet('rcon-serv', 0); } try { $rcon = new MinecraftRcon(); $rcon->Connect($game_server, $rcon_port, $rcon_pass); if ($userlist) { $page = GetUserListHTML($rcon->Command('list')); exit("<script>'.{$token}.'parent.GetById('users_online').innerHTML = '" . $page[0] . "'; " . $page[1] . "</script>"); } $command = str_replace(array("\r\n", "\n", "\r"), '', $command); $command = preg_replace('| +|', ' ', $command); $str = trim(TextBase::HTMLDestruct($rcon->Command($command))); $str = str_replace(array("\r\n", "\n", "\r"), '', $str); if (!strncmp($command, 'say', 3) and strlen($str) > 2) { $str = substr($str, 2); } if (!strncmp(substr($str, 2), 'Usage', 5)) { $str = substr($str, 2); } $str = str_replace(array(chr(167)), '', $str); echo '<script>' . $token . 'parent.showResult("' . $str . '");</script>'; } catch (MinecraftRconException $e) { echo '<script>' . $token . 'parent.showResult("' . $e->getMessage() . '");</script>'; } $rcon->Disconnect();
public static function Comment($text) { $text = trim($text); $text = TextBase::HTMLDestruct($text); $text = preg_replace('/(\\R{2})\\R++/Usi', '$1', $text); $text = nl2br($text); $text = TextBase::CutWordWrap($text); $text = TextBase::CutString($text); return $text; }