Esempio n. 1
0
 function show()
 {
     $configuration = new Config();
     $database = new SafeMySQL(array('user' => $configuration->db->username, 'pass' => $configuration->db->password, 'db' => $configuration->db->database, 'charset' => $configuration->db->charset));
     $data = $database->getAll('SELECT * FROM students');
     $response = new Response();
     $response->setContent(json_encode($data));
     $response->send();
 }
Esempio n. 2
0
 public function userPage($userId)
 {
     if ($this->accessControl($userId)) {
         $db = new SafeMySQL();
         $users = $db->getAll('SELECT id,login,name,avatar FROM ?n WHERE id = ?i LIMIT ?i', $this->table, $userId, 1);
         $user = array();
         if (!empty($users[0]['id'])) {
             foreach ($users[0] as $key => $value) {
                 $user[$key] = $value;
             }
         }
         $userName = empty($user['name']) ? $user['login'] : $user['name'];
         $user['page_title'] = "Здравствуйте, " . $userName;
         $user['title'] = $userName;
         $user['avatar'] = empty($user['avatar']) ? $this->no_avatar : $user['avatar'];
         $this->view('user', $user);
     } else {
         $content['title'] = "УПС!";
         $content['message'] = "У вас нет доступа к этой странице. Пожалуйста <a href='/user'>авторизируйтесь</a> чтобы войти!";
         $this->view('check', $content);
     }
 }
Esempio n. 3
0
<?php

require_once "pass.php";
require_once "lib/safemysql.class.php";
$tableName = "tickets";
echo "Log in MySQL<br>\n";
$db = new SafeMySQL(['host' => $loginData['mysql_host'], 'user' => $loginData['mysql_username'], 'pass' => $loginData['mysql_password'], 'db' => $loginData['mysql_db']]);
echo "<br>List fields in table:<br>\n";
$sql = "SHOW COLUMNS FROM {$tableName}";
$fields = $db->getCol($sql);
//Print table to HTML
?>
<table border="1">
	<thead>
		<tr>
<?
foreach($fields as $fieldname) {
	echo "<td>$fieldname</td>\n";
}
echo "</tr></thead><tbody>";

$data=$db->getAll("SELECT * FROM $tableName ORDER BY dtime DESC LIMIT 100");
foreach($data as $row=>$cols) {
	echo"<tr>";
	foreach($cols as $col) {
		echo "   <td>$col</td>\n";
	}
	echo "</tr>\n";
}
echo "</tbody></table>";
?>
Esempio n. 4
0
<?php

require '../php/main/SafeMySQL.php';
$string_object = new SafeMySQL();
if ($category === 'all' || !$category) {
    $query = $string_object->getAll("SELECT i.v_id, i.user_id, i.title, i.image, i.date, u.nickname FROM posts_videos_in i, users_information u WHERE i.user_id = u.user_id ORDER BY i.v_id DESC LIMIT 0,10");
} else {
    $query = $string_object->getAll("SELECT i.v_id, i.user_id, i.title, i.image, i.date, u.nickname FROM posts_videos_in i, users_information u WHERE i.category=?s AND i.user_id = u.user_id ORDER BY i.v_id DESC LIMIT 0,10", $category);
}
$arr = array();
$i = 0;
foreach ($query as $array) {
    $image = file_exists('../upload_image/videos/pre_500px/' . $array['image'] . '.jpg') ? $array['image'] : 'default';
    $link = $category ? $page . '=' . $category . '&video=' . $array['v_id'] : $page . '&video=' . $array['v_id'];
    $res = array('n0' => $array['v_id'], 'n1' => $image, 'n2' => $array['title'], 'n3' => $array['date'], 'n4' => $array['nickname']);
    if (!$i) {
        $res = array('head' => '<nav id="content_menu">
                    <a href="vo=all" class="new_local"><p>ВСЕ</p></a>
                    <a href="vo=review" class="new_local"><p>ОБЗОРЫ</p></a>
                    <a href="vo=letsplay" class="new_local"><p>ЛЕТСПЛЕИ</p></a>
                    <a href="vo=vlog" class="new_local"><p>БЛОГИ</p></a>
                    <div id="lookatme">
                                    <div class="lookatme"></div>
                                    <div class="lookatme"></div>
                                    <div class="lookatme"></div>
                    </div>
                </nav>
                <nav id="content_search"></nav><section id="content_block">', 'tmp' => '<a href="vo&video=%n[0]" class="new_modal">
                <article class="video" id="%n[0]" style="background:#000 no-repeat center url(upload_image/videos/pre_500px/%n[1].jpg)">
                    <div class="video_title">
                        <p>%n[2]</p>
Esempio n. 5
0
<?php

require '../php/main/db_connect.php';
require 'mm/parser.php';
$arr = array();
if ($last_id && $page && $user_id) {
    $string_object = new SafeMySQL();
    $writer = new Writer();
    $y = $string_object->getRow("SELECT d_id, other_id, pioneer_id,meter FROM users_dialogs WHERE d_id=?i AND pioneer_id=?i OR d_id=?i AND other_id=?i LIMIT 1", $category, $user_id, $category, $user_id);
    if ($y['d_id']) {
        $dg = $string_object->getAll("SELECT m.text, m.date, m.mes_id, i.avatar, i.category, i.nickname FROM users_messages m, users_information i WHERE m.d_id=?i AND m.mes_id < ?i AND i.user_id = m.user_id ORDER BY m.mes_id DESC LIMIT 10", $y['d_id'], $last_id);
        $avatar = $string_object->getOne('SELECT avatar FROM users_information WHERE user_id=?i', $user_id);
        $avatar = file_exists('../upload_image/avatars/pre_150px/' . $avatar . '.jpg') ? $avatar : 'default';
        $i = 0;
        foreach ($dg as $array) {
            $res = array('n0' => $y['d_id'], 'n1' => $array['mes_id'], 'n2' => $array['avatar'], 'n3' => $array['nickname'], 'n4' => $array['date'], 'n5' => $writer->main($array['text'], 1));
            $i++;
            array_push($arr, $res);
        }
        unset($array);
    }
}
print json_encode($arr);
Esempio n. 6
0
<?php

require '../php/main/SafeMySQL.php';
$o = new SafeMySQL();
$base = $o->getAll('SELECT id,title FROM base_games LIMIT 0,10');
$arr = array();
$i = 0;
foreach ($base as $array) {
    $res = array('n0' => $array['id'], 'n1' => $array['title']);
    if (!$i) {
        $res = array('head' => '<nav id="content_menu">
                                    <a href="be=games" class="new_local"><p>ИГРЫ</p></a>
                            </nav><nav id="content_search"></nav><section id="content_block">', 'tmp' => '<article id="%n[0]" class="game">
                        <div class="game_img"></div>
                        <h4>%n[1]</h4>
                    </article>', 'footer' => '</section>') + $res;
    }
    $i++;
    array_push($arr, $res);
}
unset($array);
print json_encode($arr);
Esempio n. 7
0
<?php

require '../php/main/SafeMySQL.php';
$string_object = new SafeMySQL();
if ($category === 'all' || !$category) {
    $query = $string_object->getAll("SELECT u.user_id, u.avatar, u.nickname, u.category, o.online FROM users_information u, users_online o WHERE o.user_id = u.user_id  ORDER BY user_id DESC LIMIT 0,10");
} else {
    $query = $string_object->getAll("SELECT u.user_id, u.avatar, u.nickname, u.category, o.online FROM users_information u, users_online o WHERE o.user_id = u.user_id AND u.category=?s ORDER BY user_id DESC LIMIT 0,10", $category);
}
$arr = array();
$i = 0;
foreach ($query as $array) {
    $image = file_exists('../upload_image/avatars/pre_50px/' . $array['avatar'] . '.jpg') ? $array['avatar'] : 'default';
    $res = array('n0' => $array['user_id'], 'n1' => $image, 'n2' => $array['nickname'], 'n3' => $array['online'], 'n4' => $array['category'], 'n5' => 'Null');
    if (!$i) {
        $res = array('head' => '<nav id="content_menu">
                                    <a href="pe=all" class="new_local"><p>ВСЕ</p></a>
                                    <a href="pe=user" class="new_local"><p>ПОЛЬЗОВАТЕЛИ</p></a>
                                    <a href="pe=motiondesign" class="new_local"><p>МОУШЕН-ДИЗАЙНЕРЫ</p></a>
                                    <a href="pe=review" class="new_local"><p>ОБОЗРЕВАТЕЛИ</p></a>
                                    <a href="pe=letsplay" class="new_local"><p>ЛЕТСПЛЕЕРЫ</p></a>
                                </nav>
                                <nav id="content_search">
                                    <button class="content_search">
                                        Город
                                    </button>
                                    <button class="content_search">
                                        Пол
                                    </button>
                                    <button class="content_search">
                                        Возраст
Esempio n. 8
0
<?php

require '../php/main/SafeMySQL.php';
if ($last_id) {
    $o = new SafeMySQL();
    $base = $o->getAll('SELECT id,title FROM base_games WHERE id>?i LIMIT 0,10', $last_id);
    $arr = array();
    $i = 0;
    foreach ($base as $array) {
        $res = array('n0' => $array['id'], 'n1' => $array['title']);
        $i++;
        array_push($arr, $res);
    }
    unset($array);
    print json_encode($arr);
}
Esempio n. 9
0
<?php

// TODO убрать/переделать
// выбираем список категорий в зависимости от раздела
// используется для аякс-запроса при добавлении записи
if (!empty($_POST['category_list'])) {
    include $_SERVER['DOCUMENT_ROOT'] . '/admin/inc/functions.php';
    include $_SERVER['DOCUMENT_ROOT'] . '/admin/inc/mysql.class.php';
    check_install();
    // проверяем, установлена ли cms
    $db = new SafeMySQL(array('user' => DB_LOGIN, 'pass' => DB_PASSWORD, 'db' => DB_NAME, 'charset' => 'utf8'));
    $rows = $db->getAll('SELECT * FROM ' . DB_PREFIX . '_catalog_subcategories WHERE pid=?i', $_POST['category_list']);
    foreach ($rows as $rows2) {
        echo '<option value="' . $rows2['id'] . '">' . $rows2['title'] . '</option>';
    }
    exit;
}
defined('CAFE') or die(header('Location: /'));
check_error();
include 'config.php';
// сохранение настроек
if ($_POST['update-settings']) {
    $w_string = '<?php
define ("DEFAULT_CITY",   "' . $_POST['default-city'] . '"); // город по умолчанию
define ("DEFAULT_COORD",  "' . $_POST['default-coord'] . '"); // начальные координаты
?>';
    $fop = fopen($_SERVER["DOCUMENT_ROOT"] . 'admin/modules/catalog/config.php', 'w');
    if ($fwr = fwrite($fop, $w_string)) {
        fclose($fop);
        $message = 'Настройки обновлены';
    } else {
Esempio n. 10
0
<?php

require '../php/main/db_connect.php';
$string_object = new SafeMySQL();
if ($user_id) {
    $arr = array();
    $res = array('head' => '<nav id="content_menu">
                            <a href="hm=subscribes" class="new_local"><p>ПОДПИСКИ</p></a>
                            <a href="hm=news" class="new_local"><p>НОВОСТИ</p></a>
                            </nav><div id="material_null">
                                    <p>МАТЕРИАЛОВ НЕТ</p>
                            </div>');
    array_push($arr, $res);
    print json_encode($arr);
} else {
    $query = $string_object->getAll("SELECT v_id, image, title FROM posts_videos_in ORDER BY v_id DESC LIMIT 0,9");
    $arr = array();
    $i = 0;
    foreach ($query as $array) {
        $image = file_exists('../upload_image/videos/pre_500px/' . $array['image'] . '.jpg') ? $array['image'] : 'default';
        $res = array('n0' => $array['v_id'], 'n1' => $image, 'n2' => $array['text'], 'n3' => $array['title']);
        if (!$i) {
            $res = array('head' => '<section id="main_news">', 'tmp' => '<a href="hm&video=%n[0]" class="new_local"><article class="main_news" style="background: no-repeat center url(upload_image/videos/pre_500px/%n[1].jpg)">
                    <div class="main_news_information">
                    <p>%n[2]</p>
                    </div>
                    <div class="main_title">
                    <p>%n[3]</p>
                    </div>
                    <div class="main_icon" style="background:#000 url(../../img/post_icon/video.png) no-repeat center;">
                    </div>
Esempio n. 11
0
<?php

require '../php/main/db_connect.php';
if ($last_id && $page && $user_id) {
    $string_object = new SafeMySQL();
    $o = $string_object->getAll("SELECT v_id, user_id, title, image, date FROM posts_videos_in WHERE user_id=?i AND v_id<?i ORDER BY v_id DESC LIMIT 0,10", $user_id, $last_id);
    $arr = array();
    $i = 0;
    foreach ($o as $array) {
        $image = file_exists('../upload_image/videos/pre_500px/' . $array['image'] . '.jpg') ? $array['image'] : 'default';
        $res = array('n0' => $array['v_id'], 'n1' => $image, 'n2' => $array['title'], 'n3' => $array['date']);
        array_push($arr, $res);
        $i++;
    }
    print json_encode($arr);
    unset($array);
}