Example #1
0
function SQL($query)
{
    $connect = BD();
    mysqli_query($connect, "SET NAMES UTF8");
    $response = mysqli_query($connect, $query);
    $data = array();
    if ($response) {
        while ($result = @mysqli_fetch_assoc($response)) {
            $data[] = $result;
        }
    }
    mysqli_close($connect);
    return $data;
}
Example #2
0
 function __construct($s1, $s2 = '', $s3 = '')
 {
     if (is_array($s1) && count($s1) > 0) {
         $s3 = isset($s1[2]) ? $s1[2] : $s3;
         $s2 = isset($s1[1]) ? $s1[1] : $s2;
         $s1 = isset($s1[0]) ? $s1[0] : '';
     }
     if (is_string($s1) && !empty($s1)) {
         $this->bd = BD();
         $this->s = $s1;
         $this->q = $s2;
         $this->l = $s3;
     } else {
         throw new Exception("`[LIGA] Parámetros incorrectos LIGA({$s1}, {$s2}, {$s3})´");
     }
 }
 public function ShowSkinList($list = 1, $per_page = 20, $gender = 2, $order_by = 'id', $sort = 1, $mode = 'base', $ratio = 1)
 {
     global $user;
     $list = (int) $list;
     if ($list <= 0) {
         $list = 1;
     }
     $ratio = (int) $ratio;
     if (($ratio < 1 or $ratio > 64) and $ratio != 1337 and $ratio != 31337) {
         return '';
     }
     $order_by = $order_by == 'id' ? 'id' : 'likes';
     $sort = $sort == 2 ? 'DESC' : '';
     // echo '['.$list.' |'.$per_page.' |'.$gender.' |'.$order_by.' |'.$sort.' |'.$mode.' |'.$ratio.']';
     $mode_txt = 'Классические образы (64х32)';
     $gender_txt = 'Женские';
     if ($gender < 2) {
         $gender_txt = ($gender ? 'Женские' : 'Мужские') . ' и без тега';
         $base_sql = "WHERE (`gender` = '2' OR `gender` = '" . ($gender ? 1 : 0) . "')";
     } elseif ($gender == 2) {
         $gender_txt = 'Без тега';
         $base_sql = "WHERE `gender` = '2'";
     } elseif ($gender == 3) {
         $gender_txt = 'Мужские';
         $base_sql = "WHERE `gender` = '0'";
     } else {
         $base_sql = "WHERE `gender` = '1'";
     }
     if ($mode == 'HD') {
         $mode_txt = 'Высокое разрешение';
     } elseif ($mode == 'likes') {
         $gender_txt = 'Любые';
         $mode_txt = 'Понравившиеся';
     }
     if ($mode != 'likes') {
         if ($mode == 'HD' and $ratio == 1337) {
             $base_sql .= " AND `ratio` != '1'";
         } else {
             $base_sql .= " AND `ratio` = '" . $ratio . "'";
         }
         $skins_count = mysql_result(BD("SELECT COUNT(*) FROM `" . $this->db . "` " . $base_sql), 0);
     } else {
         if (empty($user)) {
             $skins_count = 0;
         } else {
             $skins_count = mysql_result(BD("SELECT COUNT(*) FROM `" . $this->db_likes . "` WHERE `user_id`= '" . $user->id() . "' AND `item_type` = '" . $this->type . "' AND `var`='1'"), 0);
         }
     }
     $html_skin_list = '';
     if ($list > ceil($skins_count / $per_page)) {
         $list = 1;
     }
     if (!$skins_count) {
         $html_skin_list = $this->ShowPage('skin_empty.html');
     } else {
         if ($mode != 'likes') {
             $result = BD("SELECT `id` FROM `" . $this->db . "` " . $base_sql . " ORDER BY `{$order_by}` {$sort} LIMIT " . $per_page * ($list - 1) . ",{$per_page}");
         } else {
             $sql = "SELECT `item_id` AS 'id' ";
             $sql .= "FROM `" . $this->db . "` LEFT JOIN `" . $this->db_likes . "` ON " . $this->db . ".id = " . $this->db_likes . ".item_id ";
             $sql .= "WHERE " . $this->db_likes . ".user_id = '" . $user->id() . "' AND " . $this->db_likes . ".item_type = '" . $this->type . "' AND " . $this->db_likes . ".var = '1' ORDER BY " . $this->db_likes . ".id DESC LIMIT " . $per_page * ($list - 1) . ",{$per_page}";
             $result = BD($sql);
         }
         if (!mysql_num_rows($result)) {
             $html_skin_list = $this->ShowPage('skin_empty.html');
         }
         while ($line = mysql_fetch_array($result, MYSQL_NUM)) {
             $skin = new SPItem($line[0], $this->st_subdir);
             $html_skin_list .= $skin->Show();
         }
     }
     $html_skin_list .= $this->arrowsGenerator($this->base_url . $this->url_params . '&', $list, $skins_count, $per_page);
     ob_start();
     include $this->GetView('main.html');
     return ob_get_clean();
 }
Example #4
0
<?php

if (!defined('MCR')) {
    exit;
}
BD("CREATE TABLE IF NOT EXISTS `{$bd_names['sp_skins']}` (\n  `id` bigint(20) NOT NULL AUTO_INCREMENT,\n  `user_id` bigint(20) DEFAULT 0,\n  `name` char(255) DEFAULT NULL,\n  `fname` char(255) DEFAULT NULL,\n  `dislikes` int(10) DEFAULT 0,\n  `likes` int(10) DEFAULT 0,\n  `downloads` int(10) DEFAULT 0,\n  `ratio` smallint(3) NOT NULL DEFAULT 1,\n  `gender` tinyint(1) NOT NULL DEFAULT 2,\n  `fsize` char(32) DEFAULT 0,\n  `hash` char(32) DEFAULT NULL,\n  PRIMARY KEY (`id`),\n  KEY `user_id` (`user_id`),\n  KEY `gender` (`gender`),\n  KEY `skin_spec` (`gender`, `ratio`)\n) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
BD("CREATE TABLE IF NOT EXISTS `{$bd_names['sp_bad_skins']}` (\n  `id` bigint(20) NOT NULL AUTO_INCREMENT,\n  `hash` char(32) DEFAULT NULL,\n  PRIMARY KEY (`id`)\n) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
BD("CREATE TABLE IF NOT EXISTS `{$bd_names['sp_skins_ratio']}` (\n  `ratio` int(10) DEFAULT 0,\n  `num` int(10) DEFAULT 1,\n  PRIMARY KEY (`ratio`)\n) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;");
BD("ALTER TABLE `{$bd_names['groups']}` DROP `skinposer`;");
// drop depricated field
BD("ALTER TABLE `{$bd_names['groups']}`\tADD `sp_upload` tinyint(1) NOT NULL DEFAULT 0;");
BD("ALTER TABLE `{$bd_names['groups']}`\tADD `sp_change` tinyint(1) NOT NULL DEFAULT 0;");
BD("UPDATE `{$bd_names['groups']}` SET `sp_upload`='1',`sp_change`='1' WHERE `id`='3'");
BD("UPDATE `{$bd_names['groups']}` SET `sp_upload`='0',`sp_change`='1' WHERE `id`='1'");
Example #5
0
<?php

// Cargamos LIGA3
require_once 'LIGA3/LIGA.php';
// Personalizo una conexión a la base de datos (servidor, usuario, contraseña, schema)
BD('localhost', 'root', '', 'base');
// Configuramos la entidad a usar
$tabla = 'usuarios';
$liga = LIGA($tabla);
// Controlador de acciones
$resp = '';
if (isset($_GET['accion'])) {
    if ($_GET['accion'] == 'insertar') {
        $resp = $liga->insertar($_POST);
    } elseif ($_GET['accion'] == 'modificar') {
        $datos = array($_POST['cual'] => $_POST);
        $resp = $liga->modificar($datos);
    }
}
if (isset($_GET['borrar'])) {
    $resp = $liga->eliminar($_GET['borrar']);
}
// Si es una petición asíncrona sólo muestro la respuesta
if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
    echo $resp;
    exit(0);
}
// Imprimo las etiquetas HTML iniciales
HTML::cabeceras(array('title' => 'Pruebas LIGA 3', 'description' => 'Página de pruebas para LIGA 3', 'css' => 'util/LIGA.css', 'style' => 'label { width:100px; }'));
// Guardo el bufer para colocarlo en el layout
ob_start();
function PostFactory()
{
    return BD()->getFactory();
}