예제 #1
0
 /**
  * Class constructor
  *
  * @param Db_MySqlDatabase db
  *
  */
 public function __construct(MySqlDatabase $db, Logger $logger = null)
 {
     if ($logger === null) {
         $this->setLogger(new SessionLogger());
     } else {
         $this->setLogger($logger);
     }
     $this->db_link = $db->getLink();
 }
예제 #2
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
예제 #3
0
 /**
  * Extract all images in database
  * @access public
  * @return hash hash of extracted images
  * @static
  */
 public static function selectAll()
 {
     $config = Configuration::getMysqlConfiguration();
     $query = "select * from immagini";
     try {
         $database = new MySqlDatabase($config['dbHost'], $config['dbUser'], $config['dbPassword'], $config['dbName'], $config['dbPort']);
         $connection = $database->dbConnect();
         $result = $database->executeQuery($query, $connection);
         $i = 0;
         $images = array();
         while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
             $images[$i] = $row;
             $i++;
         }
         return $images;
     } catch (Error $e) {
         $e->printHtmlError();
         $e->reportOnGitHub(array("mysql error", "image"));
     }
 }
 public static function convertMySqlDB2MongoDB($mysqldb_name, $mongodb_name)
 {
     // connect to mysql database
     $tables = MySqlDatabase::getAllTableFrom($mysqldb_name);
     // connect to mongo
     $mongo_connection = new Mongo();
     // create database
     $mongo_database = $mongo_connection->{$mongodb_name};
     foreach ($tables as $index => $name) {
         // create collection in MongoDB
         $collection = $mongo_database->{$name};
         $table_data = MySqlDatabase::getAllDataFrom($name);
         foreach ($table_data as $row_id => $row) {
             // insert document
             $collection->save($row);
         }
     }
 }
 /**
  * get all data from database
  * @param $table table name
  * @param $condition condition for querying
  * @return Array
  */
 public static function getAllDataFrom($table, $condition = null)
 {
     MySqlDatabase::connect();
     $sql = "select * from {$table} ";
     if ($condition != null) {
         $sql .= $condition;
     }
     $result = mysql_query($sql) or die(mysql_error());
     $table_result = array();
     $r = 0;
     while ($row = mysql_fetch_assoc($result)) {
         $arr_row = array();
         $c = 0;
         while ($c < mysql_num_fields($result)) {
             $col = mysql_fetch_field($result, $c);
             $arr_row[$col->name] = $row[$col->name];
             $c++;
         }
         $table_result[$r] = $arr_row;
         $r++;
     }
     return $table_result;
 }
예제 #6
0
 define('FLGR_BASE', implode('/', $tmp));
 // Включаем конфигурационный файл
 require_once FLGR_BASE . '/config.php';
 $dbglog = '';
 require_once FLGR_COMMON . '/common.php';
 // Все общие функции
 // unk.jpg
 if ('/photos/thumbnails' == unslashify($_SERVER['REQUEST_URI'])) {
     header('Content-type: image/jpeg');
     readfile(FLGR_PHOTOS_THUMBNAILS . '/unk.jpg');
     exit;
 }
 // Включаем профайлер
 $Profiler = new PhpQuickProfiler(PhpQuickProfiler::getMicroTime());
 // DataBase
 $Db = new MySqlDatabase(DB_HOST, DB_USER, DB_PASSWORD);
 $Db->connect(true);
 $Db->changeDatabase(DB_NAME);
 $Db->query('SET NAMES cp1251');
 // Использование деструктора объекта в качестве
 // единой точки выхода
 if (bIsDbgIp()) {
     class PqpOuter
     {
         public function __destruct()
         {
             global $Profiler;
             global $Db;
             // FORCE_QUIT - это аjax ответ :)
             if (!defined('FORCE_QIUT')) {
                 if (defined('DBG_PROFILER')) {
예제 #7
0
<?php

/**
 * Города и страны
 */
//define('FLGR_BASE', dirname(__FILE__));
$tmp = explode(DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT']);
// Важно использовать DIRECTORY_SEPARATOR вместо '/' при разборе
define('FLGR_BASE', implode('/', $tmp));
// Включаем конфигурационный файл
require_once FLGR_BASE . '/config.php';
require_once FLGR_COMMON . '/common.php';
// Все общие функции
// DataBase
$Db = new MySqlDatabase(DB_HOST, DB_USER, DB_PASSWORD);
$Db->connect(true);
$Db->changeDatabase(DB_NAME);
$Db->query('SET NAMES cp1251');
// Components // ***TODO***: Кэшировать в файле алиасы таблиц, чтобы не дергать каждый раз базу
$Components = new Components();
foreach ($Components->getAllTablesAndAliases() as $v) {
    $v['alias'] = 'DB_TBL_' . strtoupper($v['alias']);
    if (!defined($v['alias'])) {
        define($v['alias'], $v['name']);
        //dbg($v['alias']);
    }
}
// BREADCRUMBS
//$BreadCrumbs->addBreadCrumbs($sKey, $sTitle);
$file = file_get_contents(__FILE__);
$pos = strpos($file, '?' . '>') + 2;
예제 #8
0
파일: rss.php 프로젝트: sonicmaster/RPG
<?php

//version 2.3
define('INSIDE', true);
include 'includes/functions/classes/MySqlDatabase.php';
$db_rss = new MySqlDatabase();
header('Content-type: text/xml; charset="utf-8"');
$rss_titulo = $db_rss->game_config["game_name"];
$rss_url = dirname("http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) . "/";
$rss_descripcion = "Noticias de {$db_rss->game_config["game_name"]}";
$rss_email = $db_rss->game_config["user_mail"] . "@" . $db_rss->game_config["smtp_mail"];
// Escribimos el archivo RSS
echo '<?xml version="1.0" encoding="iso-8859-1"?>';
echo "<rss version=\"0.92\">\n      <channel>\n          <docs>{$rss_url}rss.php</docs>\n          <title>{$rss_titulo}</title>\n          <link>{$rss_url}</link>\n          <description>{$rss_descripcion}</description>\n          <language>es</language>\n          <managingEditor>{$rss_email}</managingEditor>\n          <webMaster>{$rss_email}</webMaster>\n          <copyright>Copyright 2009 - 2010 Xnova-Svn</copyright>\n          <generator>Xnova Svn RSS</generator>\n";
$rss_query = $db_rss->query("SELECT * FROM `{{table}}` ORDER BY `news_id` DESC LIMIT 0 , 10", 'news');
while ($rss = mysql_fetch_array($rss_query)) {
    echo "<item>\n";
    echo "<title><![CDATA[" . $rss["news_titulo"] . "]]></title>\n";
    echo "<link><![CDATA[" . $rss_url . "game.php?page=news&idnew=" . $rss["news_id"] . "]]></link>\n";
    echo "<description><![CDATA[" . $rss["news_news"] . "]]></description>\n";
    echo "<pubDate>" . date("d-m-y H:i:s", $rss["news_date"]) . "</pubDate>\n";
    echo "</item>\n";
}
echo "</channel>";
echo "</rss>";
예제 #9
0
파일: common.php 프로젝트: sonicmaster/RPG
    if (filesize($svn_root . 'config.php') == 0) {
        exit(header("location:" . $svn_root . "install/"));
    }
}
if (!file_exists($svn_root . 'config.php') && INSTALL != true) {
    exit(header("location:" . $svn_root . "install/"));
}
$phpEx = "php";
include_once $svn_root . 'includes/constants.' . $phpEx;
include_once $svn_root . 'includes/functions.' . $phpEx;
include_once $svn_root . "includes/functions/classes/class.TemplatePower.inc." . $phpEx;
include $svn_root . 'includes/functions/classes/Console.' . $phpEx;
include $svn_root . 'includes/functions/classes/PhpQuickProfiler.' . $phpEx;
include $svn_root . 'includes/functions/classes/MySqlDatabase.' . $phpEx;
include $svn_root . 'includes/functions/classes/class.plugins.' . $phpEx;
$db = new MySqlDatabase();
include $svn_root . "includes/displays." . $phpEx;
$displays = new displays();
include $svn_root . 'includes/functions/classes/class.user.' . $phpEx;
$users = new users();
if (INSTALL != true) {
    $plugin = new plugins();
    include $svn_root . 'includes/vars.' . $phpEx;
    include $svn_root . 'includes/functions/CreateOneMoonRecord.' . $phpEx;
    include $svn_root . 'includes/functions/CreateOnePlanetRecord.' . $phpEx;
    define('DEFAULT_LANG', $db->game_config['lang'] == '' ? "es" : $db->game_config['lang']);
    includeLang('GAME');
    if ($InLogin != true) {
        $users->CheckUser();
        if ($db->game_config['game_disable'] == 1 && $users->user['authlevel'] == 0) {
            $displays->message(stripslashes($db->game_config['close_reason']));