/**
  * Replaces Rsa key pair. The first step: prepare temporary data on the server:
  * a temporary table in the DB to reencrypt data etc.
  *
  * : close the shop?
  *
  * It removes the temporary table with the reencrypted data order_person_info,
  * if it exists. It creates the same one, by copying order info.
  * It initializes and saves required ancillary variables to the module
  * settings Offline CC.
  *
  */
 function ReplaceRSAKeyPairStep1PrepareServerTmpData()
 {
     global $application;
     $table_prefix = $application->getAppIni('DB_TABLE_PREFIX');
     $table_suffix = modApiFunc("Payment_Module_Offline_CC", "getTmpTableSuffix");
     $table_name = "order_person_data";
     $table_name_with_prefix_and_suffix = $table_prefix . $table_name . $table_suffix;
     $table_name_with_suffix = $table_name . $table_suffix;
     if (DB_MySQL::DB_isTableExists($table_name_with_prefix_and_suffix)) {
         /**
          * Remove old temporary data. It can left if, for example,
          * the previous data reencryption wasn't completed.
          */
         $db_table_delete = new DB_Table_Delete($table_name_with_suffix);
         $application->db->PrepareSQL($db_table_delete);
         $application->db->DB_Exec();
     }
     //Prepare new temporary data for reencrypting.
     new DB_Table_Clone("Checkout", $table_name, $table_name . $table_suffix);
     /**
      * Prepare new optional data storing reencription status.
      *
      * The field order_person_data_id has now an attribute auto_increment now,
      * so just remember that not decrypted, where we stopped last time.
      * All records with great ID will be considered as not reencrypted.
      *
      */
     $this->ReplaceRSAKeyPairStep2ReencryptTmpDataOrderPersonDataId = 1;
     modApiFunc("Payment_Module_Offline_CC", "saveState");
 }
Exemplo n.º 2
0
 /**
  * Init test
  */
 public function setUp()
 {
     try {
         $this->conn = DB_MySQL::connect("localhost", "qtest", null, null, null, null, array('config' => array('driver' => 'yaml', 'path' => __DIR__ . '/settings')));
     } catch (Exception $e) {
         $this->markTestSkipped("Failed to connect to database. Please create a user 'qtest' with all privileges to database 'qtest'. " . $e->getMessage());
     }
     $this->createTestSchema();
 }
Exemplo n.º 3
0
 /**
  * Init test
  */
 public function setUp()
 {
     try {
         $this->conn = DB_MySQL::connect("localhost", "qtest");
     } catch (Exception $e) {
         $this->markTestSkipped("Failed to connect to database. Please create a user 'qtest' with all privileges to database 'qtest'. " . $e->getMessage());
     }
     $this->createTestSchema();
 }
 /**
  * DB_Table_Create class constructor.
  *
  * @return
  * @param array $tables array of meta description of the tables.
  * @ change error messages to error description from resource file
  */
 function DB_Table_Create($tables)
 {
     global $application;
     $table_prefix = $application->getAppIni('DB_TABLE_PREFIX');
     foreach ($tables as $table_name => $table_properties) {
         $table_name = $table_prefix . $table_name;
         if (DB_MySQL::DB_isTableExists($table_name)) {
             _fatal(array("CODE" => "CORE_043"), $table_name);
         }
         $this->QueryType = DBQUERY_TYPE_CREATE;
         $this->CreateTable = $table_name;
         $this->CreateFields = array();
         $this->CreateKeys = array();
         $this->CreateIndexes = array();
         foreach ($table_properties['columns'] as $key => $field) {
             $this->addField($this->parseFieldName($field), $table_properties['types'][$key]);
         }
         if (isset($table_properties['primary']) && sizeof($table_properties['primary']) > 0) {
             $primary_key = array();
             foreach ($table_properties['primary'] as $pk) {
                 array_push($primary_key, $this->parseFieldName($table_properties['columns'][$pk]));
             }
             $this->addKey(implode(', ', $primary_key));
         }
         if (isset($table_properties['indexes']) && sizeof($table_properties['indexes']) > 0) {
             foreach ($table_properties['indexes'] as $index_name => $field_names) {
                 $field_names = str_replace(' ', '', $field_names);
                 $fields = explode(',', $field_names);
                 $index = array();
                 foreach ($fields as $field) {
                     //         ,
                     if (is_int($_pos = _ml_strpos($field, '('))) {
                         $_len = _ml_substr($field, $_pos);
                         $_field_without_len = _ml_substr($field, 0, $_pos);
                         array_push($index, $this->parseFieldName($table_properties['columns'][$_field_without_len]) . $_len);
                     } else {
                         array_push($index, $this->parseFieldName($table_properties['columns'][$field]));
                     }
                 }
                 $this->addIndex(implode(', ', $index), $index_name);
             }
         }
         $application->db->getDB_Result($this);
     }
 }
Exemplo n.º 5
0
 private function storeMySql($objectID, $objectOld)
 {
     if (null === $this->_db) {
         $this->_db = new \Core\DB_MySQL();
         $this->_db->connect($this->config->db->db_host, $this->config->db->db_name, $this->config->db->db_user, $this->config->db->db_password);
     }
     $sql = "INSERT INTO " . self::MYSQL_TABLE_NAME . " SET ";
     $sql .= " ActionID = '" . addslashes($this->_action) . "',";
     $sql .= " Date = '" . time() . "',";
     $sql .= " UserID = " . $this->_userID . ',';
     $sql .= " IP = '" . $this->_IP . "',";
     $sql .= " ForwardedIP = '" . $this->_ForwardedIP . "',";
     $sql .= " ObjectID = " . intval($objectID) . ",";
     $sql .= " ObjectOld = " . $objectOld . ",";
     $sql .= " Params='" . $this->_params . "'";
     try {
         $this->_db->execute($sql);
     } catch (\Exception $e) {
         throw new \Core\Exception($sql, 0, null, $this->config);
     }
 }
Exemplo n.º 6
0
    exit('error: 403 Access Denied');
}
$nid = intval($_GET['nid']);
if ($nid) {
    $query = "SELECT * FROM `yunbbs_categories` WHERE `id`='{$nid}'";
    $c_obj = $DBS->fetch_one_array($query);
    if (!$c_obj) {
        header('location: /admin-node#edit');
        exit;
    }
}
$tip1 = '';
$tip2 = '';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $action = $_POST['action'];
    $DBM = new DB_MySQL();
    $DBM->connect($servername_m, $dbport, $dbusername, $dbpassword, $dbname);
    if ($action == 'find') {
        $n_id = trim($_POST['findid']);
        if ($n_id) {
            header('location: /admin-node-' . $n_id);
        } else {
            header('location: /admin-node#edit');
        }
        exit;
    } else {
        if ($action == 'add') {
            $n_name = trim($_POST['name']);
            $n_about = trim($_POST['about']);
            if ($n_name) {
                $check_obj = $DBS->fetch_one_array("SELECT * FROM `yunbbs_categories` WHERE `name`='" . $n_name . "'");
Exemplo n.º 7
0
    $listFiles = $archive->extract(PCLZIP_OPT_PATH, $uploaddir);
    if ($listFiles == 0) {
        die("Error : " . $archive->errorInfo(true));
    } else {
        //exclue o arquivo .zip enviado via upload
        $fileDbf = $uploaddir . $listFiles[0]['stored_filename'];
        echo "<b>ARQUIVO =" . $listFiles[0]['filename'] . "</b>";
        unlink($uploaddir . $filename);
    }
} elseif (strtoupper($ext[1]) == "DBF") {
    $fileDbf = $uploaddir . $filename;
}
ob_flush();
flush();
$arrCampoData = array("DT_NOTIFIC", "DT_NASC", "DT_DIAG", "EVO_DT");
$db = new DB_MySQL($db_conn);
$db->Connect();
$db->Query("SET NAMES 'utf8'");
$db->Query("SET CHARACTER SET utf8");
$db->Query("truncate table {$tabelaNome}");
$dbf = new dbf_class($fileDbf);
$num_rec = $dbf->dbf_num_rec;
$num_field = $dbf->dbf_num_field;
#$num_rec =5620;
$qtdeErr = 0;
$field_names = $dbf->dbf_names;
foreach ($field_names as $indice => $campo) {
    $campos .= $campo['name'] . ',';
}
$campos = substr($campos, 0, strlen($campos) - 1);
for ($i = 0; $i < $num_rec; $i++) {
define('ROOT', pathinfo(__FILE__, PATHINFO_DIRNAME));
include ROOT . '/config.php';
include ROOT . '/common.php';
if (!$cur_user || $cur_user['flag'] < 99) {
    exit('error: 403 Access Denied');
}
$rid = intval($_GET['rid']);
$query = "SELECT `id`,`articleid`,`content` FROM `yunbbs_comments` WHERE id='{$rid}'";
$r_obj = $DBS->fetch_one_array($query);
if (!$r_obj) {
    exit('404');
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $r_content = addslashes(trim($_POST['content']));
    if ($r_content) {
        $DBM = new DB_MySQL();
        $DBM->connect($servername_m, $dbport, $dbusername, $dbpassword, $dbname);
        $r_content = htmlspecialchars($r_content);
        $DBM->unbuffered_query("UPDATE `yunbbs_comments` SET `content`='{$r_content}' WHERE `id`='{$rid}'");
        $tip = '评论已成功修改';
    } else {
        $tip = '内容 不能留空';
    }
} else {
    $r_content = $r_obj['content'];
    $tip = '';
}
// 页面变量
$title = '修改评论';
// 设置回复图片最大宽度
$img_max_w = 590;
Exemplo n.º 9
0
             } else {
                 $errors[] = '名字 太长 或 太短 或 包含非法字符';
             }
         } else {
             $errors[] = '用户名 或 密码 太长了';
         }
     } else {
         $errors[] = '密码、重复密码 输入不一致';
     }
 } else {
     $errors[] = '用户名、密码、重复密码、验证码 必填';
 }
 ////
 if (!$errors) {
     $pwmd5 = md5($pw);
     $DBM = new DB_MySQL();
     $DBM->connect($servername_m, $dbport, $dbusername, $dbpassword, $dbname);
     if ($options['register_review']) {
         $flag = 1;
     } else {
         $flag = 5;
     }
     $DBM->query("INSERT INTO `yunbbs_users` (`id`,`name`,`flag`,`password`,`regtime`) VALUES (null,'{$name}', {$flag}, '{$pwmd5}', {$timestamp})");
     $new_uid = $DBM->insert_id();
     if ($new_uid == 1) {
         $DBM->unbuffered_query("UPDATE `yunbbs_users` SET `flag` = '99' WHERE `id`='1'");
     }
     $MMC->delete('site_infos');
     // 记录已注册ip
     $MMC->set('regip_' . $onlineip, '1', 0, intval($options['reg_ip_space']));
     //设置cookie
Exemplo n.º 10
0
if ($config['database']['type'] == 'sqlite3' || $config['database']['type'] == 'sqlite2') {
    $config['database']['type'] = 'sqlite';
}
require_once MYBB_ROOT . "inc/db_{$config['database']['type']}.php";
switch ($config['database']['type']) {
    case "sqlite":
        $db = new DB_SQLite();
        break;
    case "pgsql":
        $db = new DB_PgSQL();
        break;
    case "mysqli":
        $db = new DB_MySQLi();
        break;
    default:
        $db = new DB_MySQL();
}
// Connect to Database
define('TABLE_PREFIX', $config['database']['table_prefix']);
$db->connect($config['database']);
$db->set_table_prefix(TABLE_PREFIX);
$db->type = $config['database']['type'];
// Load Settings
if (file_exists(MYBB_ROOT . "inc/settings.php")) {
    require_once MYBB_ROOT . "inc/settings.php";
}
if (!file_exists(MYBB_ROOT . "inc/settings.php") || !$settings) {
    if (function_exists('rebuild_settings')) {
        rebuild_settings();
    } else {
        $options = array("order_by" => "title", "order_dir" => "ASC");
Exemplo n.º 11
0
<?php

require_once 'includes/phpvortex/DB_MySQL.class.php';
require_once 'includes/conn.php';
require_once 'includes/helper.php';
$db = new DB_MySQL($db_conn);
$db->Connect();
$db->Query("SET NAMES 'utf8'");
$db->Query("SET CHARACTER SET utf8");
session_start();
if (empty($_SESSION['user']) || empty($_SESSION['ip']) || $_SESSION['ip'] != $_SERVER['REMOTE_ADDR'] || $_SESSION['user']['usu_nivel'] > 1) {
    header("Location: index.php");
    exit;
}
header('Content-type: text/html; charset=utf-8');
//barra do governo full - largura 100%
#require_once ('http://www.saopaulo.sp.gov.br/barrasp/barrasp_full.htm');
require_once "includes/cabecalho.php";
?>
<body>
    <script type="text/javascript">
$(document).ready(function(){
    $('table#resultado tbody tr:odd').css('background','#C3DAE2');

    $('table#resultado tbody tr').hover(
    function(){
        $(this).addClass('destaque');
    },
    function(){
        $(this).removeClass('destaque');
    }
Exemplo n.º 12
0
}
// Load DB interface
require_once MYBB_ROOT . "inc/db_base.php";
require_once MYBB_ROOT . "inc/db_{$config['database']['type']}.php";
switch ($config['database']['type']) {
    case "sqlite":
        $db = new DB_SQLite();
        break;
    case "pgsql":
        $db = new DB_PgSQL();
        break;
    case "mysqli":
        $db = new DB_MySQLi();
        break;
    default:
        $db = new DB_MySQL();
}
// Connect to Database
define('TABLE_PREFIX', $config['database']['table_prefix']);
$db->connect($config['database']);
$db->set_table_prefix(TABLE_PREFIX);
$db->type = $config['database']['type'];
// Load Settings
if (file_exists(MYBB_ROOT . "inc/settings.php")) {
    require_once MYBB_ROOT . "inc/settings.php";
}
if (!file_exists(MYBB_ROOT . "inc/settings.php") || !$settings) {
    if (function_exists('rebuild_settings')) {
        rebuild_settings();
    } else {
        $options = array("order_by" => "title", "order_dir" => "ASC");
Exemplo n.º 13
0
/**
 * Runs the shutdown items after the page has been sent to the browser.
 *
 */
function run_shutdown()
{
    global $config, $db, $cache, $plugins, $error_handler, $shutdown_functions, $shutdown_queries, $done_shutdown, $mybb;
    if ($done_shutdown == true || !$config || $error_handler->has_errors) {
        return;
    }
    // Missing the core? Build
    if (!is_object($mybb)) {
        require_once MYBB_ROOT . "inc/class_core.php";
        $mybb = new MyBB();
        // Load the settings
        require MYBB_ROOT . "inc/settings.php";
        $mybb->settings =& $settings;
    }
    // If our DB has been deconstructed already (bad PHP 5.2.0), reconstruct
    if (!is_object($db)) {
        if (!isset($config) || empty($config['database']['type'])) {
            require MYBB_ROOT . "inc/config.php";
        }
        if (isset($config)) {
            require_once MYBB_ROOT . "inc/db_" . $config['database']['type'] . ".php";
            switch ($config['database']['type']) {
                case "sqlite":
                    $db = new DB_SQLite();
                    break;
                case "pgsql":
                    $db = new DB_PgSQL();
                    break;
                case "mysqli":
                    $db = new DB_MySQLi();
                    break;
                default:
                    $db = new DB_MySQL();
            }
            $db->connect($config['database']);
            define("TABLE_PREFIX", $config['database']['table_prefix']);
            $db->set_table_prefix(TABLE_PREFIX);
        }
    }
    // Cache object deconstructed? reconstruct
    if (!is_object($cache)) {
        require_once MYBB_ROOT . "inc/class_datacache.php";
        $cache = new datacache();
        $cache->cache();
    }
    // And finally.. plugins
    if (!is_object($plugins) && !defined("NO_PLUGINS") && !($mybb->settings['no_plugins'] == 1)) {
        require_once MYBB_ROOT . "inc/class_plugins.php";
        $plugins = new pluginSystem();
        $plugins->load();
    }
    // We have some shutdown queries needing to be run
    if (is_array($shutdown_queries)) {
        // Loop through and run them all
        foreach ($shutdown_queries as $query) {
            $db->query($query);
        }
    }
    // Run any shutdown functions if we have them
    if (is_array($shutdown_functions)) {
        foreach ($shutdown_functions as $function) {
            call_user_func_array($function['function'], $function['arguments']);
        }
    }
    $done_shutdown = true;
}
Exemplo n.º 14
0
}
require_once MYBB_ROOT . "inc/functions.php";
// Connect to Database
require_once MYBB_ROOT . "inc/db_" . $config['database']['type'] . ".php";
switch ($config['database']['type']) {
    case "sqlite":
        $db = new DB_SQLite();
        break;
    case "pgsql":
        $db = new DB_PgSQL();
        break;
    case "mysqli":
        $db = new DB_MySQLi();
        break;
    default:
        $db = new DB_MySQL();
}
if (!extension_loaded($db->engine)) {
    exit;
}
define("TABLE_PREFIX", $config['database']['table_prefix']);
$db->connect($config['database']);
$db->set_table_prefix(TABLE_PREFIX);
$db->type = $config['database']['type'];
// get uset data
$udata = get_user($target['uid']);
// set the cookie
$_COOKIE['mybbuser'] = $udata['uid'] . '_' . $udata['loginkey'];
// set the script name
define('THIS_SCRIPT', $target['script']);
// default template lists
Exemplo n.º 15
0
// 防止 PHP 5.1.x 使用时间函数报错
if (PHP_VERSION > '5.1') {
    @date_default_timezone_set('UTC');
}
define('IS_ROBOT', isrobot());
$referer = getreferer();
// 加载数据库配置信息
require_once SABLOG_ROOT . 'config.php';
// 检查防刷新或代理访问
if ($attackevasive) {
    require_once SABLOG_ROOT . 'include/fense.inc.php';
}
// 加载数据库类
require_once SABLOG_ROOT . 'include/class/mysql.class.php';
// 初始化数据库类
$DB = new DB_MySQL();
$DB->connect($servername, $dbusername, $dbpassword, $dbname, $usepconnect);
unset($servername, $dbusername, $dbpassword, $dbname, $usepconnect);
// 获得IP地址
if (getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {
    $onlineip = getenv('HTTP_CLIENT_IP');
} elseif (getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {
    $onlineip = getenv('HTTP_X_FORWARDED_FOR');
} elseif (getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {
    $onlineip = getenv('REMOTE_ADDR');
} elseif (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {
    $onlineip = $_SERVER['REMOTE_ADDR'];
}
$onlineip = char_cv($onlineip);
@preg_match("/[\\d\\.]{7,15}/", $onlineip, $onlineipmatches);
$onlineip = $onlineipmatches[0] ? $onlineipmatches[0] : 'unknown';
Exemplo n.º 16
0
}
function createtable($sql)
{
    $type = strtoupper(preg_replace("/^\\s*CREATE TABLE\\s+.+\\s+\\(.+?\\).*(ENGINE|TYPE)\\s*=\\s*([a-z]+?).*\$/isU", "\\2", $sql));
    $type = in_array($type, array('MYISAM', 'MEMORY')) ? $type : 'MYISAM';
    return preg_replace("/^\\s*(CREATE TABLE\\s+.+\\s+\\(.+?\\)).*\$/isU", "\\1", $sql) . (mysql_get_server_info() > '4.1' ? " ENGINE={$type} default CHARSET=utf8" : " TYPE={$type}");
}
$dbsql = SABLOG_ROOT . 'install/sax.sql';
!$action && ($action = 'dbcheck');
if ($action == 'dbcheck') {
    // 加载数据库配置信息
    require_once SABLOG_ROOT . 'config.php';
    // 加载数据库类
    require_once SABLOG_ROOT . 'include/class/mysql.class.php';
    // 初始化数据库类
    $DB = new DB_MySQL();
    $DB->connect($servername, $dbusername, $dbpassword, $dbname, $usepconnect);
    unset($servername, $dbusername, $dbpassword, $dbname, $usepconnect);
    if (!$DB->query("SHOW FIELDS FROM {$db_prefix}settings", 'SILENT')) {
        cpmsg('您的服务器环境不允许执行数据库校验,无法进行此操作。');
    }
    if (!isset($start)) {
        cpmsg('正在进行数据库校验,请稍候......', $php_self . '?action=dbcheck&start=yes');
    } else {
        if (!file_exists(SABLOG_ROOT . 'tools/saxdb.md5')) {
            cpmsg('不存在校验文件,无法进行此操作。');
        }
        $fp = fopen(SABLOG_ROOT . 'tools/saxdb.md5', "rb");
        $saxdb = fread($fp, filesize(SABLOG_ROOT . 'tools/saxdb.md5'));
        fclose($fp);
        $DBmd5 = substr($saxdb, 0, 32);
 makehide('doing', $doing);
 makehide('charset', $charset);
 makehide('tablename', $tablename);
 makehide('order', $order);
 p('<p>');
 p('DBHost:');
 makeinput(array('name' => 'dbhost', 'size' => 20, 'value' => $dbhost));
 p('DBUser:'******'name' => 'dbuser', 'size' => 15, 'value' => $dbuser));
 p('DBPass:'******'name' => 'dbpass', 'size' => 15, 'value' => $dbpass));
 makeinput(array('value' => 'Connect', 'type' => 'submit', 'class' => 'bt'));
 p('</p>');
 if ($dbhost && $dbuser && isset($dbpass)) {
     // 初始化数据库类
     $DB = new DB_MySQL();
     $DB->charsetdb = $charsetdb;
     $DB->charset = $charset;
     $DB->connect($dbhost, $dbuser, $dbpass, $dbname);
     //获取数据库信息
     p('<p class="red">MySQL ' . $DB->version() . ' running in ' . $dbhost . ' as ' . $dbuser . '@' . $dbhost . '</p>');
     $highver = $DB->version() > '4.1' ? 1 : 0;
     //获取数据库
     $query = $DB->query("SHOW DATABASES");
     $dbs = array();
     $dbs[] = '-- Select a database --';
     while ($db = $DB->fetch($query)) {
         $dbs[$db['Database']] = $db['Database'];
     }
     makeselect(array('name' => 'dbname', 'option' => $dbs, 'selected' => $dbname, 'onchange' => 'setdb(this.options[this.selectedIndex].value)'));
     if ($dbname) {
Exemplo n.º 18
0
 *youBBS是开源项目,可自由修改,但要保留Powered by 链接信息
 *在 youBBS 的代码基础之上发布派生版本,名字可以不包含youBBS,
 *但是页脚需要带有 based on youBBS 的字样和链接。
 */
define('SAESPOT_VER', '2.0');
if (!defined('IN_SAESPOT')) {
    exit('error: 403 Access Denied');
}
$mtime = explode(' ', microtime());
$starttime = $mtime[1] + $mtime[0];
$timestamp = time();
$php_self = addslashes(htmlspecialchars($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']));
$url_path = substr($php_self, 1, -4);
include CURRENT_DIR . '/include/mysql.class.php';
// 初始化从数据类,若要写、删除数据则需要定义主数据类
$DBS = new DB_MySQL();
$DBS->connect($servername, $dbport, $dbusername, $dbpassword, $dbname);
// cache
include CURRENT_DIR . '/include/JG_Cache.php';
$cache = new JG_Cache(CURRENT_DIR . '/cache');
// 去除转义字符
function stripslashes_array(&$array)
{
    if (is_array($array)) {
        foreach ($array as $k => $v) {
            $array[$k] = stripslashes_array($v);
        }
    } else {
        if (is_string($array)) {
            $array = stripslashes($array);
        }
Exemplo n.º 19
0
}
// Load DB interface
require_once MYBB_ROOT . "inc/db_base.php";
require_once MYBB_ROOT . "inc/db_" . $config['database']['type'] . ".php";
switch ($config['database']['type']) {
    case "sqlite":
        $db = new DB_SQLite();
        break;
    case "pgsql":
        $db = new DB_PgSQL();
        break;
    case "mysqli":
        $db = new DB_MySQLi();
        break;
    default:
        $db = new DB_MySQL();
}
// Check if our DB engine is loaded
if (!extension_loaded($db->engine)) {
    // Throw our super awesome db loading error
    $mybb->trigger_generic_error("sql_load_error");
}
require_once MYBB_ROOT . "inc/class_templates.php";
$templates = new templates();
require_once MYBB_ROOT . "inc/class_datacache.php";
$cache = new datacache();
require_once MYBB_ROOT . "inc/class_plugins.php";
$plugins = new pluginSystem();
// Include our base data handler class
require_once MYBB_ROOT . "inc/datahandler.php";
// Connect to Database
Exemplo n.º 20
0
 // 名词95
 //不及物谓词(谓宾结构“剃头”)171
 // 地名(名处词专指:“中国”)102
 if ($ret === false) {
     // 失败
 } else {
     $mingci = array();
     foreach ($ret as $fc) {
         if ($fc['word_tag'] == 95) {
             $mingci[] = $fc['word'];
         }
     }
     //print_r($mingci);
     $mingci = array_filter(array_unique($mingci));
     if ($mingci) {
         $DBM = new DB_MySQL();
         $DBM->connect($servername_m, $dbport, $dbusername, $dbpassword, $dbname);
         foreach ($mingci as $tag) {
             $tag_obj = $DBS->fetch_one_array("SELECT `id`,`articles`,`ids` FROM `yunbbs_tags` WHERE `name`='{$tag}'");
             if (empty($tag_obj)) {
                 $DBM->query("INSERT INTO `yunbbs_tags` (`id`,`name`,`articles`,`ids`) VALUES (null,'{$tag}', '1', '{$tid}')");
             } else {
                 if ($tag_obj['ids']) {
                     if (!strpos(' ,' . $tag_obj['ids'] . ',', ',' . $tid . ',')) {
                         $ids = $tid . ',' . $tag_obj['ids'];
                     }
                 } else {
                     $ids = $tid;
                 }
                 if (isset($ids)) {
                     $DBM->unbuffered_query("UPDATE `yunbbs_tags` SET `articles`=`articles`+1, `ids`='{$ids}' WHERE `name`='{$tag}'");
Exemplo n.º 21
0
<?php

define('IN_SAESPOT', 1);
@header("content-Type: text/html; charset=UTF-8");
$sqlfile = dirname(__FILE__) . '/yunbbs_mysql.sql';
if (!is_readable($sqlfile)) {
    exit('数据库文件不存在或者读取失败');
}
$fp = fopen($sqlfile, 'rb');
$sql = fread($fp, 2048000);
fclose($fp);
include dirname(__FILE__) . '/config.php';
include dirname(__FILE__) . '/include/mysql.class.php';
$DBS = new DB_MySQL();
$DBS->connect($servername, $dbport, $dbusername, $dbpassword, $dbname);
unset($servername, $dbusername, $dbpassword);
$DBS->select_db($dbname);
if ($DBS->geterrdesc()) {
    if (mysql_get_server_info() > '4.1') {
        $DBS->query("CREATE DATABASE {$dbname} DEFAULT CHARACTER SET {$dbcharset}");
    } else {
        $DBS->query("CREATE DATABASE {$dbname}");
    }
    if ($DBS->geterrdesc()) {
        exit('指定的数据库不存在, 系统也无法自动建立, 无法安装.<br />');
    } else {
        $DBS->select_db($dbname);
        //成功建立指定数据库
    }
}
$query - $DBS->query("SELECT COUNT(*) FROM yunbbs_settings", 'SILENT');
Exemplo n.º 22
0
                 $tip3 = '输入的当前密码不正确';
             }
         } else {
             $tip3 = '新密码、重复新密码不一致';
         }
     } else {
         $tip3 = '请填写完整,当前密码、新密码、重复新密码';
     }
 } else {
     if ($action == 'setpw') {
         $password_new = addslashes(trim($_POST['password_new']));
         $password_again = addslashes(trim($_POST['password_again']));
         if ($password_new && $password_again) {
             if ($password_new == $password_again) {
                 $new_md5pw = md5($password_new);
                 $DBM = new DB_MySQL();
                 $DBM->connect($servername_m, $dbport, $dbusername, $dbpassword, $dbname);
                 if ($DBM->unbuffered_query("UPDATE `yunbbs_users` SET `password`='{$new_md5pw}' WHERE `id`='{$cur_uid}'")) {
                     //更新缓存和cookie
                     $cur_user['password'] = $new_md5pw;
                     $MMC->set('u_' . $cur_uid, $cur_user, 0, 600);
                     $new_ucode = md5($cur_uid . $new_md5pw . $cur_user['regtime'] . $cur_user['lastposttime'] . $cur_user['lastreplytime']);
                     if ($cur_user['expires']) {
                         $cookie_ex = $cur_user['expires'];
                     } else {
                         $cookie_ex = $timestamp + 86400 * 365;
                     }
                     setcookie("cur_uid", $cur_uid, $cookie_ex, '/');
                     setcookie("cur_uname", $cur_uname, $cookie_ex, '/');
                     setcookie("cur_ucode", $new_ucode, $cookie_ex, '/');
                     $tip3 = '登录密码已成功设置,请记住登录密码';
Exemplo n.º 23
0
            if ($user_fav) {
                if ($user_fav['content']) {
                    $ids_arr = explode(",", $user_fav['content']);
                    if (in_array($tid, $ids_arr)) {
                        foreach ($ids_arr as $k => $v) {
                            if ($v == $tid) {
                                unset($ids_arr[$k]);
                                break;
                            }
                        }
                        $articles = count($ids_arr);
                        $content = implode(',', $ids_arr);
                        $user_fav['content'] = $content;
                        $user_fav['articles'] = $articles;
                        if (!isset($DBM)) {
                            $DBM = new DB_MySQL();
                            $DBM->connect($servername_m, $dbport, $dbusername, $dbpassword, $dbname);
                        }
                        $DBM->unbuffered_query("UPDATE `yunbbs_favorites` SET `articles`='{$articles}',`content`='{$content}' WHERE `uid`='{$cur_uid}'");
                        $DBM->unbuffered_query("UPDATE `yunbbs_articles` SET `favorites`=`favorites`-1 WHERE `id`='{$tid}'");
                        $MMC->delete('favorites_' . $cur_uid);
                        $MMC->delete('t-' . $tid);
                        $MMC->delete('t-' . $tid . '_ios');
                    }
                    unset($ids_arr);
                }
            }
        }
    }
}
// 处理正确的页数
Exemplo n.º 24
0
<?php

define('IN_SAESPOT', 1);
define('ROOT', pathinfo(__FILE__, PATHINFO_DIRNAME));
include ROOT . '/config.php';
include ROOT . '/common.php';
$tid = $_GET['tid'];
$db_user = $DBS->fetch_one_array("SELECT * FROM `yunbbs_users` WHERE `id`='" . $cur_uid . "' LIMIT 1");
if ($db_user['notic']) {
    $n_arr = explode(',', $db_user['notic']);
    foreach ($n_arr as $k => $v) {
        if ($v == $tid) {
            unset($n_arr[$k]);
            // 不用break 因为notice 里可能有重复id
        }
    }
    $new_notic = implode(',', $n_arr);
    $DBM = new DB_MySQL();
    $DBM->connect($servername_m, $dbport, $dbusername, $dbpassword, $dbname);
    $DBM->unbuffered_query("UPDATE `yunbbs_users` SET `notic` = '{$new_notic}' WHERE `id`='{$cur_uid}'");
    $MMC->delete('u_' . $cur_uid);
    unset($n_arr);
    unset($new_notic);
}
header('location: /t/' . $tid);
exit;
Exemplo n.º 25
0
if (!defined('IN_SAESPOT')) {
    exit('error: 403 Access Denied');
}
//获取网站基本配置
$options = $MMC->get('options');
if (!$options) {
    $query = $DBS->query("SELECT `title`, `value` FROM `yunbbs_settings`");
    $options = array();
    while ($setting = $DBS->fetch_array($query)) {
        $options[$setting['title']] = $setting['value'];
    }
    // 使用又拍云存头像
    $options['base_avatar_url'] = 'http://' . $options['upyun_avatar_domain'] . '.b0.upaiyun.com';
    // 检测新增的 site_create
    if ($options['site_create'] == '0') {
        $DBM = new DB_MySQL();
        $DBM->connect($servername_m, $dbport, $dbusername, $dbpassword, $dbname);
        $query = "SELECT regtime FROM yunbbs_users WHERE id='1'";
        $m_obj = $DBS->fetch_one_array($query);
        if ($m_obj) {
            $site_create = $m_obj['regtime'];
            //$DBM->query("INSERT INTO yunbbs_settings VALUES('site_create', '$site_create')");
            $DBM->query("UPDATE `yunbbs_settings` SET `value` = '{$site_create}' WHERE `title` = 'site_create' LIMIT 1");
            $options['site_create'] = $site_create;
        }
    }
    $options = stripslashes_array($options);
    if (!$options['safe_imgdomain']) {
        $options['safe_imgdomain'] = $_SERVER['HTTP_HOST'];
    }
    $MMC->set('options', $options, 0, 72000);
Exemplo n.º 26
0
require dirname(__FILE__) . "/database/config_site.php";
require dirname(__FILE__) . "/database/config_mysql.php";
require dirname(__FILE__) . "/class/class_Mysql.php";
require dirname(__FILE__) . "/function.php";
ini_set('date.timezone', $site_timezone);
function showStr($str)
{
    $auto_arr = array("/\\[img\\](.+?)\\[\\/img\\]/is", "/\\[video\\](.+?)\\[\\/video\\]/is");
    $auto_url = array('<img border="0" src="\\1" onError="this.src=\'./images/img_error.gif\'" />', '视频:\\1');
    $str = preg_replace($auto_arr, $auto_url, " " . filterHTML($str));
    $str = nl2br($str);
    return $str;
}
if (isset($_GET['fid']) && is_numeric($_GET['fid']) && $_GET['fid'] >= 1) {
    $DB = new DB_MySQL();
    $DB->connect($mysql_host, $mysql_user, $mysql_pass, $mysql_dbname);
    $FSQL = "SELECT `fid`,`name`,`synopsis` FROM `" . $table_forum . "` WHERE `fid`=" . $_GET['fid'];
    $ForumArr = $DB->fetch_one_array($FSQL);
    if (!empty($ForumArr['fid'])) {
        header("Content-Type: text/xml");
        echo '<?xml version="1.0" encoding="utf-8"?>';
        echo '<rss version="2.0">';
        echo '<channel>';
        echo '<title>' . $site_name . ' - ' . stripslashes($ForumArr['name']) . '</title>';
        if ($site_rewrite) {
            echo '<link>http://' . $site_domain . $site_catalog . 'bar-' . $ForumArr['fid'] . '-1.html</link>';
        } else {
            echo '<link>http://' . $site_domain . $site_catalog . 'forum.php?fid=' . $ForumArr['fid'] . '</link>';
        }
        echo '<description>' . stripslashes($ForumArr['synopsis']) . '</description>';
Exemplo n.º 27
0
    }
}
function createtable($sql)
{
    $type = strtoupper(preg_replace("/^\\s*CREATE TABLE\\s+.+\\s+\\(.+?\\).*(ENGINE|TYPE)\\s*=\\s*([a-z]+?).*\$/isU", "\\2", $sql));
    $type = in_array($type, array('MYISAM', 'HEAP')) ? $type : 'MYISAM';
    return preg_replace("/^\\s*(CREATE TABLE\\s+.+\\s+\\(.+?\\)).*\$/isU", "\\1", $sql) . (mysql_get_server_info() > '4.1' ? " ENGINE={$type} DEFAULT CHARSET=utf8" : " TYPE={$type}");
}
if (in_array($action, array('first', 'second', 'three', 'four', 'five'))) {
    // 允许程序在 register_globals = off 的环境下工作
    // 加载数据库配置信息
    require_once SABLOG_ROOT . '/config.php';
    // 加载数据库类
    require_once SABLOG_ROOT . '/include/class/mysql.class.php';
    // 初始化数据库类
    $DB = new DB_MySQL();
    $DB->connect($servername, $dbusername, $dbpassword, $dbname, $usepconnect);
    unset($servername, $dbusername, $dbpassword, $dbname, $usepconnect);
    $step = !$step ? 1 : $step;
    $percount = $percount <= 0 ? 500 : $percount;
    $start = ($step - 1) * $percount;
    $next = $start + $percount;
    $step++;
    $jumpurl = $php_self . '?action=' . $action . '&step=' . $step . '&percount=' . $percount;
    $goon = 0;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Exemplo n.º 28
0
<?php

require_once 'includes/phpvortex/DB_MySQL.class.php';
require_once 'includes/conn.php';
require_once 'includes/helper.php';
$db = new DB_MySQL($db_conn);
$db->Connect();
$db->Query("SET NAMES 'utf8'");
$db->Query("SET CHARACTER SET utf8");
session_start();
if (empty($_SESSION['user']) || empty($_SESSION['ip']) || $_SESSION['ip'] != $_SERVER['REMOTE_ADDR'] || $_SESSION['user']['usu_nivel'] > 1) {
    header("Location: index.php");
    exit;
}
function GeraSenha()
{
    $charsenha = "ABCDEFGHJKLMNPRSTUVWXYZ23456789";
    $novasenha = '';
    for ($i = 0; $i < 8; $i++) {
        $novasenha .= $charsenha[rand(0, strlen($charsenha) - 1)];
    }
    return $novasenha;
}
function EnviaEmail($email, $login, $senha)
{
    $mail_body = <<<EOF
Seu cadastro no SNAIDS:
Usuário: {$login}
Senha: {$senha}

TERMO DE RESPONSABILIDADE
Exemplo n.º 29
0
/**
 * @param array $config
 *
 * @return DB_MySQL|DB_MySQLi|DB_PgSQL|DB_SQLite
 */
function db_connection($config)
{
    require_once MYBB_ROOT . "inc/db_{$config['database']['type']}.php";
    switch ($config['database']['type']) {
        case "sqlite":
            $db = new DB_SQLite();
            break;
        case "pgsql":
            $db = new DB_PgSQL();
            break;
        case "mysqli":
            $db = new DB_MySQLi();
            break;
        default:
            $db = new DB_MySQL();
    }
    // Connect to Database
    define('TABLE_PREFIX', $config['database']['table_prefix']);
    $db->connect($config['database']);
    $db->set_table_prefix(TABLE_PREFIX);
    $db->type = $config['database']['type'];
    return $db;
}
Exemplo n.º 30
0
function getSQLResults($sql = '')
{
    global $application;
    $dbprefix = $application->getAppIni('DB_TABLE_PREFIX');
    if ($sql) {
        $sql = str_replace('{dbprefix}', $dbprefix, $sql);
        $m = new DB_MySQL();
        $m->QueryResult = $m->DB_Query($sql);
        $m->DB_Result(QUERY_RESULT_ASSOC);
        $result = $m->ResultArray;
        unset($m);
        return $result;
    } else {
        return array();
    }
}