function content() { $db = new sql(); $db->connect(); if (time() < 1098388800) { $res = $db->query("select projects.id, name, company, category, sum(IF(grade is null,0, grade))/count(IF(grade is null,0, grade)) as gsum, count(grade) as gcount FROM projects left join votes on projects.id=votes.id group by projects.id, name, company, category order by gsum desc"); } else { $res = $db->query("select projects.id, name, company, category, sum(IF(grade is null,0, grade))/count(IF(grade is null,0, grade)) as gsum, count(grade) as gcount FROM projects left join votes on projects.id=votes.id where grade>0 group by projects.id, name, company, category order by gsum desc"); } $cats = array(1 => "A", "C", "Y"); $tr = ""; while ($data = $db->fetch_array($res)) { $res1 = $db->query("select * from categories where category_id={$data['category']}"); $data1 = $db->fetch_array($res1); $url = "/projects/" . $cats[$data1["category_id"]] . "/"; eval('$tr.="' . page::template("modules/resultTR") . '";'); } if (!$tr) { $tr = "<p style=\"font-size: 0.85em;\">В настоящее время в данной номинации заявок не подано.</p><p style=\"font-size: 0.85em;\"><a href=\"/request/\">Заявки</a> принимаются до 15 октября 2004 года</p>"; } $resultTr .= $tr; if ($resultTr) { eval('$projectsMain.="' . page::template("modules/resultMain") . '";'); } $resultTr = ""; if (time() < 1098388800) { $text = "<p>Здесь размещены текущие результаты голосования, обновляющиеся в режиме реального времени.</p><p>Для того, чтобы проголосовать за проект надо перейти на его страницу.</p><p>Вы можете поставить свою оценку каждому из 22 представленных проектов, но можете сделать это только 1 раз за весь период голосования.</p><p>Голосование открыто до 0:00 22 октября 2004 года.</p>"; } else { $text = "<h3>Голование закрыто в 0:00 22 октября 2004 года.</h3><p><i>При анализе хода голосования за проекты в интернете, Оргкомитет конкурса М2. Новый Дом 2004. обнаружил многочисленные случаи злоупотребления при выставлении оценки 0 баллов. В целях повышения релевантности итогов голосования, Оргкомитет принял решение не учитывать оценки 0 баллов, выставленные за весь период голосования в интернете.</i></p>"; } $this->elements["content"] = $text . $projectsMain; }
function defaultAction() { $db = new sql(); $db->connect(); $chid = $this->chid; include "lib/pagination.class.php"; include "lib/orderby.class.php"; $adminConfig = admin::adminConfig(); for ($i = 1; $i < 4; $i++) { $voteTR = ""; $orderBy = new orderBy("?chid=" . $this->chid . "&", array("id" => "№", "time" => "Дата", "name" => "Заголовок", "company" => "Компания", "gsum" => "Средний бал", "gcount" => "Проголосовало"), array("gsum" => "desc"), $this->field[$i], $this->order[$i], array("field[{$i}]", "order[{$i}]")); $pagination = new pagination($orderBy->urlForPage(), $this->page, $adminConfig["recPerPage"], '', "projects", "id"); $res = $db->query("select projects.id, name, company, category_name, date, sum(IF(grade is null,0, grade))/count(IF(grade is null,0, grade)) as gsum, count(grade) as gcount FROM (projects LEFT JOIN categories ON projects.category = categories.category_id) left join votes on projects.id=votes.id where category={$i} group by projects.id, name, company, category_name, date " . $orderBy->orderByQuery() . " " . $pagination->limit()); $page = $this->page ? "&page=" . $this->page : ""; while ($data = $db->fetch_array($res)) { $data["date"] = date("d.m.Y", $data["date"]); eval('$voteTR.="' . admin::template("voteTR") . '";'); } $pageBar = $pagination->bar(); $th = $orderBy->bar(); eval('$content.="' . admin::template("voteMain") . '";'); $content .= "<br>"; } $this->elements["content"] = $content; }
function defaultAction() { global $HTTP_SERVER_VARS; include "./lib/config.inc.php"; $db = new sql(); $db->connect(); $result = $db->query('SELECT VERSION() AS version'); if ($result != FALSE && $db->num_rows($result) > 0) { $row = $db->fetch_array($result); $match = $row['version']; } else { $result = $db->query('SHOW VARIABLES LIKE \'version\''); if ($result != FALSE && $db->num_rows($result) > 0) { $row = $db->fetch_array($result); $match = $row[1]; } } $this->MYSQL_VER = $match; $this->PHP_OS = PHP_OS; $this->PHP_VERSION = PHP_VERSION; $this->CMS = $admin_config["name"] . " " . $admin_config["version"]; $this->AUTHOR = $admin_config["author"]; $this->HOME_PAGE = $admin_config["home_page"]; $content = admin::template("info", $this); $this->elements["content"] = $content; }
function rightBar() { $db = new sql(); $db->connect(); $res = $db->query(" select * from news order by time desc limit 0, 3"); while ($data = $db->fetch_array($res)) { $this->elements["rightBar"] .= '<table><tr><th>' . $data["title"] . ':</th></tr><tr><td>' . $data["text"] . '</td></tr></table>'; } $this->elements["rightBar"] = '<td valign="top" style="padding-left: 1em;">' . $this->elements["rightBar"] . '<p align="right"><a href="/news/">¬се новости →</a></p><br><i>¬ принципе, вы можете зайти и ознакомитьс¤ с <a href="/timeline/" target="_self">хронологией моих работ</a> (благо, их пока не так уж много).</i><p align="right"><a href="/card/" target="_self"> арта сайта →</a></p></td>'; }
function appendEdit() { $this->fields["time"] = mktime(0, 0, 0, $this->date["month"], $this->date["day"], $this->date["year"]); foreach ($this->fields as $key => $value) { $query .= "{$key}='{$value}', "; } $query = substr($query, 0, strlen($s) - 2); $db = new sql(); $db->connect(); $db->query("update news set {$query} where id=" . $this->fields["id"]); header("Location: ?chid=" . $this->chid . "&m=3"); }
function got_child($id) { $db = new sql(); $db->connect(); $res = $db->query(_QUERY . " where pid={$id}"); if ($db->num_rows($res) > 0) { return true; exit; } else { return false; exit; } }
function pagination($curUrl, $curPage, $recPerPage, $totalCount, $tableName = "", $fieldName = "", $where = "") { $this->url = $curUrl; $this->page = $curPage ? $curPage : 1; $this->recPerPage = $recPerPage; if ($totalCount) { $this->totalRecCount = $totlaCount; } else { $db = new sql(); $db->connect(); $db->query("select count({$fieldName}) as rec_count from {$tableName} {$where}"); $data = $db->fetch_array($db->result); $this->totalRecCount = $data["rec_count"]; } }
function admin() { include_once "./lib/config.inc.php"; session_start(); if ($_GET["action"] == "logout") { session_destroy(); header("Location: ./"); } if (!$_SESSION["user_id"]) { if ($_POST["user"] && $_POST["pass"]) { $db = new sql(); $db->connect(); $res = $db->query("select id, pass from users where login='******'"); $data = $db->fetch_array($res); if ($data["pass"] == md5($_POST["pass"])) { $_SESSION["user_id"] = $data["id"]; header("Location: ./"); } else { $this->message = "<h3 style=\"color: red;\">Ќеправильный логин или пароль!!!</h3>"; $login = $page->template("login", $this); echo $login; exit; } } else { $login = $this->template("login", $this); echo $login; exit; } } else { $db = new sql(); $db->connect(); $res = $db->query("select id, name, admin from users where id=" . $_SESSION["user_id"]); $data = $db->fetch_array($res); $this->user = $data["name"]; $this->user_id = $data["id"]; $this->user_admin = $data["admin"]; } $this->nav = $nav; $this->admin_config = $admin_config; $this->id = $_GET["chid"] ? $_GET["chid"] : 1; $this->action = $_GET["action"]; }
function _sel($id = 0, $url = "", $menu = 0) { $db = new sql(); $db->connect(); if ($menu == 1) { $where = " and menu=1"; } else { $where = " and menu!=1"; } $res = $db->query("select id, title, url from chapters where (pid={$id} and url<>'searchresult' and url<>'sitemap' and type<>4 and id<>1){$where} order by sortorder"); if ($db->num_rows($res) > 0) { $sel = "<ul>"; while ($data = $db->fetch_array($res)) { $str .= $data["title"]; $url1 = $url . "/" . $data["url"]; $sel .= "<li type=\"disc\"><a href=\"{$url1}/\">" . $data["title"] . "</a>\n"; $sel .= $this->_sel($data["id"], $url1); $sel .= "</li>\n"; } $sel .= "</ul>"; return $sel; } }
<?php class sql { var $mysql; function connect($host, $name, $pass, $bd) { $this->mysql = 'mysql_connect(localhost,valeriy42,ogenum21)'; $this->mysql = 'mysql_select_db(valeriy42_skazochnik)'; $this->mysql = 'mysql_query (set character_set_client="utf8")'; $this->mysql = 'mysql_query (set character_set_results="utf8")'; $this->mysql = 'mysql_query (set collation_connection="utf8_general_ci")'; } } $r = new sql(); $r->connect(localhost, valeriy42, ogenum21, valeriy42_skazochnik); var_dump($r);
function showAuthorSelectJS() { $db = new sql(); $db->connect(); $res = $db->query("select id, firstname, secondname, lastname from authors order by lastname, firstname, secondname"); while ($data = $db->fetch_array($res)) { $i++; $chid = $this->chid; $data["fio"] = $data["lastname"] . ($data["firstname"] ? " " . $data["firstname"] : "") . ($data["secondname"] ? " " . $data["secondname"] : ""); eval('$authorsJSline.="' . admin::template("authorsJSline") . '";'); } eval('$content="' . admin::template("authorsJS") . '";'); echo $content; }
$field = $form->addRawField('<h4>' . lang::get('user') . '</h4>'); $field = $form->addTextField('firstname', ''); $field->addValidator('notEmpty', lang::get('validator_not_empty')); $field->fieldName(lang::get('firstname')); $field = $form->addTextField('name', ''); $field->addValidator('notEmpty', lang::get('validator_not_empty')); $field->fieldName(lang::get('name')); $field = $form->addTextField('email', ''); $field->fieldName(lang::get('email')); $field->addValidator('notEmpty', lang::get('validator_not_empty')); $field->addValidator('email', lang::get('user_wrong_email')); $field = $form->addTextField('password', ''); $field->addValidator('notEmpty', lang::get('validator_not_empty')); $field->fieldName(lang::get('password')); if ($form->isSubmit()) { $sql = sql::connect($form->get('db_host'), $form->get('db_user'), $form->get('db_password'), $form->get('db_database')); if (is_null($sql)) { $DB = ['host' => $form->get('db_host'), 'user' => $form->get('db_user'), 'password' => $form->get('db_password'), 'database' => $form->get('db_database'), 'prefix' => $form->get('db_prefix')]; dyn::add('DB', $DB, true); dyn::add('setup', false, true); dyn::save(); install::newInstall(); install::insertDemoContent(); $template = new template(dyn::get('template')); if ($template->install() !== true) { $form->setSuccessMessage(null); $error = true; } $form->addParam('page', 'finish'); } else { echo message::danger($sql);
function appendEdit() { if ($this->fields["pass"]) { $this->fields["pass"] = md5($this->fields["pass"]); } else { unset($this->fields["pass"]); } foreach ($this->fields as $key => $value) { $query .= "{$key}='{$value}', "; } $query = substr($query, 0, strlen($s) - 2); $db = new sql(); $db->connect(); $db->query("update users set {$query} where id=" . $this->fields["id"]); header("Location: ?chid=" . $this->chid . "&m=3"); }
function getConfig() { $db = new sql(); $db->connect(); $res = $db->query("select * from config"); while ($data = $db->fetch_array($res)) { $this->config[$data["name"]] = $data["text"]; } return $this->config; }
function conf() { $db = new sql(); $db->connect(); $db->query("select * from subs_config"); $d = $db->fetch_array($db->result); $d["text"] = addslashes(str_replace("\r", "", $d["text"])); $d["html"] = addslashes(str_replace("\r", "", $d["html"])); return $d; }
function query($query) { $connect = sql::connect(); $rs = mysql_query($query, $connect); return $rs; }
<?php $sql = new sql(); $sql->connect(C_SQL_SERVER . (C_SQL_PORT == '' ? '' : ':' . C_SQL_PORT), C_SQL_USER, C_SQL_PASS); if (!$sql->query("USE `" . C_SQL_DB . "`")) { $sql->query("CREATE DATABASE `" . C_SQL_DB . "` CHARACTER SET 'utf8'") or die($sql->err()); $sql->query("USE `" . C_SQL_DB . "`") or die($sql->err()); } $sql->query("SET character_set_client='utf8'"); $sql->query("SET character_set_connection='utf8'"); $sql->query("SET character_set_results='utf8'");
include _BASE_LIBRARIES_ . 'admin.library.php'; include _BASE_LIBRARIES_ . 'tree.library.php'; include _BASE_LIBRARIES_ . 'language.library.php'; include _BASE_LIBRARIES_ . 'format.library.php'; include _BASE_LIBRARIES_ . 'filter.library.php'; include _BASE_LIBRARIES_ . 'url.library.php'; include _BASE_LIBRARIES_ . 'files.library.php'; include _BASE_LIBRARIES_ . 'JSON.library.php'; // Start the current session $cp = session_get_cookie_params(); session_set_cookie_params($cp['lifetime'], $cp['path'], _BASE_DOMAIN_); session_start(); // Read the basic configuration variables $config = new config(); // Connect to the SQL server if (!sql::connect(_MYSQL_HOST_, _MYSQL_USER_, _MYSQL_PASS_, _MYSQL_DB_)) { // We need the following objects initialized // Does not matter that then don't actually do anything $lang = new language(_DEFAULT_LANGUAGE_, _DEFAULT_SITE_, true); $theme =& new theme(); $theme->showError(_OFFLINE_MESSAGE_, 1); } // Read additional configuration variables from the database $config->read(); if (strlen($path) > 1) { if (substr($path, 0, 1) == '/') { $path = substr($path, 1, strlen($path) - 1); } if (substr($path, -1, 1) == '/') { $path = substr($path, 0, strlen($path) - 1); }
function _POST($POST) { if ($POST["action"] == "add" || $POST["action"] == "edit") { $POST["fields"]["time"] = $this->_get_time($POST["fields"]["time"]); $POST["fields"]["time_end"] = $this->_get_time($POST["fields"]["time_end"]); foreach ($POST["fields"] as $key => $value) { $value = str_replace("\r", "<br>", $value); $value = str_replace("\n", "", $value); $query .= "{$key}='{$value}', "; } $query = substr($query, 0, strlen($s) - 2); $db = new sql(); $db->connect(); } if ($POST["action"] == "add") { $db->query("insert into events set {$query}"); header("Location: " . $_SESSION["HTTP_REFERER"]); } else { $db->query("update events set {$query} where id=" . $POST["fields"]["id"]); header("Location: /events/?action=edit&id=" . $POST["fields"]["id"]); } }
autoload::addDir(dir::classes('utils')); new dyn(); if (dyn::get('setup') == true) { header('Location: install/'); exit; } if (isset($DYN['backend'])) { dyn::add('backend', $DYN['backend']); } else { dyn::add('backend', true); } unset($DYN); include dir::functions('html_stuff.php'); include dir::functions('url_stuff.php'); lang::setDefault(); lang::setLang(dyn::get('lang')); $DB = dyn::get('DB'); sql::connect($DB['host'], $DB['user'], $DB['password'], $DB['database']); ob_start(); date_default_timezone_set(dyn::get('timezone', 'Europe/Berlin')); new userLogin(); dyn::add('user', new user(userLogin::getUser())); cache::setCache(dyn::get('cache')); addonConfig::loadAllConfig(); addonConfig::includeAllLangFiles(); addonConfig::includeAllLibs(); if (dyn::get('backend')) { include dir::backend('backend.php'); } else { include dir::backend('frontend.php'); }
function add_Users() { $db = new sql(); $db->connect(); $db->query("delete from subs_subscribed where lid={$this->id}"); $res = $db->query("select id from subs_users"); while ($data = $db->fetch_array($res)) { $db->query("insert into subs_subscribed set lid={$this->id}, sid={$data['id']}"); } header("Location: ?chid={$this->chid}&action=show_Users&id={$this->id}"); }
function librarySelectI() { if (!$this->page) { $this->page = 1; } $db = new sql(); $db->connect(); include "lib/orderby.class.php"; $orderBy = new orderBy("?chid=" . $this->chid . "&", array("library" => "№", "time" => "Дата", "name" => "Заголовок", "short_text" => "Подзаголовок", "author" => "Автор"), array("library" => "desc"), $this->field, $this->order); $adminConfig = admin::adminConfig(); //echo "select library.id as library, name, short_text, time, authors.lastname as author FROM (library LEFT JOIN library_authors ON library.id = library_authors.library) LEFT JOIN authors ON library_authors.author = authors.id GROUP BY library.id".$orderBy->orderByQuery()." limit ".(($this->page-1)*$adminConfig["recPerPage"]).", ".$adminConfig["recPerPage"]; $res = $db->query("select library.id as library, name, short_text, time, authors.lastname as author FROM (library LEFT JOIN library_authors ON library.id = library_authors.library) LEFT JOIN authors ON library_authors.author = authors.id GROUP BY library.id" . $orderBy->orderByQuery() . " limit " . ($this->page - 1) * $adminConfig["recPerPage"] . ", " . $adminConfig["recPerPage"]); while ($data = $db->fetch_array($res)) { $i++; $data["date"] = date("d.m.Y", $data["time"]); $data["name"] = admin::null2nbsp($data["name"]); $data["short_text"] = admin::null2nbsp($data["short_text"]); $res1 = $db->query("select id, firstname, secondname, lastname from library_authors left join authors on library_authors.author = authors.id where library_authors.library=" . $data["library"] . " order by lastname, firstname, secondname"); while ($data1 = $db->fetch_array($res1)) { $data["fio"] .= "<li>" . $data1["lastname"] . ($data1["firstname"] ? " " . $data1["firstname"] : "") . ($data1["secondname"] ? " " . $data1["secondname"] : "") . "</li>"; } $data["fio"] = admin::null2nbsp($data["fio"]); $checked = $data["library"] == $this->id || !$this->id && $i == 1 ? " checked" : ""; eval("\$librarySelectITR.=\"" . admin::template("librarySelectITR") . "\";"); } eval("\$content=\"" . admin::template("librarySelectI") . "\";"); $this->elements["content"] = $content; }
#!/usr/local/bin/php <?php $socket = fsockopen("m-2.m-2.ru", 80); fputs($socket, "GET /subscribe/news.asp HTTP/1.0\nHOST: m-2.m-2.ru\n\n"); while (fgets($socket, 31337) != "\r\n" && !feof($socket)) { unset($buffer); } include "/www/vhosts/award.m-2.ru/adm/lib/htmlcleaner.php"; include "/www/vhosts/award.m-2.ru/lib/db.conf.php"; include "/www/vhosts/award.m-2.ru/lib/mysql.class.php"; $db = new sql(); $db->connect(); $hc = new htmlcleaner(); $s = $hc->cleanup(stripslashes($s)); while (!feof($socket)) { $buffer .= fread($socket, 1024); } $lines = explode("\n", $buffer); foreach ($lines as $key => $value) { if (trim($value)) { $tmp = explode("|||", trim($value)); preg_match("'(\\d{1,2})\\.(\\d{1,2})\\.(\\d{1,4}) (\\d{1,2}):(\\d{1,2}):(\\d{1,2})'", $tmp[1], $time_arr); $tmp[1] = mktime($time_arr[4], $time_arr[5], $time_arr[6], $time_arr[2], $time_arr[1], $time_arr[3]); $tmp[3] = str_replace("\\n", "||||||||n", $tmp[3]); $tmp[3] = $hc->cleanup(stripslashes($tmp[3])); $tmp[3] = str_replace("||||||||n", "\\n", $tmp[3]); $res = $db->query("select id from news where matID={$tmp['0']}"); if (!$db->num_rows($res)) { $db->query("insert into news set time='{$tmp['1']}', title='{$tmp['2']}', text='{$tmp['3']}', matID='{$tmp['0']}'"); } $arr[] = $tmp;
function _got_child($id) { $db = new sql(); $db->connect(); $res = $db->query("select id, pid, title, LENGTH(text) as bl, url from chapters where pid={$id}"); return $db->num_rows($res) > 0; }
function appendEdit() { $this->fields["date"] = admin::toUnixTime($this->fields["date"]); $this->fields["name"] = str_replace('"', """, $this->fields["name"]); //$this->fields["min_begin"]=$this->_strToFloat($this->fields["min_begin"]); //$this->fields["max_begin"]=$this->_strToFloat($this->fields["max_begin"]); //$this->fields["min_current"]=$this->_strToFloat($this->fields["min_current"]); //$this->fields["max_current"]=$this->_strToFloat($this->fields["max_current"]); //$this->fields["square"]=$this->_strToFloat($this->fields["square"]); //$this->fields["end"]=admin::toUnixTime($this->fields["end"]); foreach ($this->fields as $key => $value) { $query .= "{$key}='{$value}', "; } $query = substr($query, 0, strlen($s) - 2); $db = new sql(); $db->connect(); $db->query("update projects set {$query} where id=" . $this->fields["id"]); header("Location: ?chid=" . $this->chid . "&m=3"); }