コード例 #1
0
function olc_db_query($query, $link = 'db_link', $allow_cache = true)
{
    global ${$link}, ${$link_1};
    $s = 'MULTI_DB_SERVER';
    if (!defined($s)) {
        define($s, false);
    }
    if (MULTI_DB_SERVER) {
        $db_link = olc_db_get_db_link($query);
    } else {
        $db_link = ${$link};
    }
    if (USE_ADODB === true) {
        if (ADODB_USE_LOGGING) {
            $db_link->LogSQL(true);
            // turn on logging
        }
        if (ADOBD_USE_CACHING && $allow_cache) {
            $recordset = $db_link->CacheExecute(ADOBD_CACHING_SECONDS, $query);
        } else {
            $recordset = $db_link->Execute($query);
        }
        if (ADODB_USE_LOGGING) {
            $db_link->LogSQL(false);
            // turn on logging
        }
        if ($recordset !== false) {
            $recordset->canSeek = true;
            $recordset->hasLimit = true;
        } else {
            $recordset_error_nr = $db_link->ErrorNo();
            $recordset_error_text = $db_link->ErrorMsg();
        }
    } else {
        if (DB_USE_LOGGING) {
            error_log('QUERY ' . $query . NEW_LINE, 3, STORE_PAGE_PARSE_TIME_LOG);
        }
        $recordset = mysql_query($query, $db_link);
        $recordset_error_text = mysql_error();
        $recordset_error_nr = mysql_errno();
        if (DB_USE_LOGGING) {
            error_log('RESULT ' . $recordset . BLANK . $recordset_error_text . NEW_LINE, 3, STORE_PAGE_PARSE_TIME_LOG);
        }
    }
    if ($recordset_error_nr) {
        // include needed functions
        include_once DIR_FS_INC . 'olc_db_error.inc.php';
        $recordset_error_text = olc_db_error($query, $recordset_error_nr, $recordset_error_text);
    }
    return $recordset;
}
コード例 #2
0
function olc_db_fetch_array(&$recordset)
{
    if (USE_ADODB === true) {
        if ($recordset->EOF) {
            $recordset->Close();
        } else {
            $result = $recordset->FetchRow();
            if ($result === false) {
                global ${$link};
                $errno = ${$link}->ErrorNo();
                $errtext = ${$link}->ErrorMsg();
            }
        }
    } else {
        $result = mysql_fetch_array($recordset, MYSQL_ASSOC);
        $errno = mysql_errno();
        $errtext = mysql_error();
    }
    if ($errno) {
        olc_db_error($query, $errno, $errtext);
    } else {
        return $result;
    }
}
コード例 #3
0
         }
     }
     if ($collect_sql_statement) {
         $sql_command .= $line;
         if (strrpos($line, SEMI_COLON) !== false) {
             //Terminator ";" found, execute SQL-command
             $collect_sql_statement = false;
             $not_collect_sql_statement = true;
             if ($insert_function) {
                 if ($change_charset) {
                     $sql_command = iconv($charset, $convcharset . '//TRANSLIT', $sql_command);
                     //$sql_command=iconv($charset, $convcharset . '//IGNORE', $what);
                 }
             }
             $result = olc_db_query($sql_command);
             $result_error = olc_db_error();
             if ($result_error) {
                 if ($have_log) {
                     $log = "\n\n";
                 }
                 $sql_command = $quote . $sql_command . $quote;
                 $log .= $sep . $result_error . "\n\n\"" . $sql_command . NEW_LINE;
                 fputs($fl, $log);
                 $log = EMPTY_STRING;
                 $have_log = true;
             }
             $sql_command = EMPTY_STRING;
         }
     }
 }
 fclose($fl);
コード例 #4
0
function olc_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE, $link = 'db_link')
{
    global ${$link}, $db;
    if (USE_ADODB === true) {
        define('DB_USE_LOGGING', STORE_DB_TRANSACTIONS == TRUE_STRING_S || IS_LOCAL_HOST);
        define('ADODB_ASSOC_CASE', 2);
        // use native-case for ADODB_FETCH_ASSOC
        include_once ADMIN_PATH_PREFIX . 'adodb/adodb.inc.php';
        /*
        define('ADODB_FETCH_DEFAULT',0);
        define('ADODB_FETCH_NUM',1);
        define('ADODB_FETCH_ASSOC',2);
        define('ADODB_FETCH_BOTH',3);
        */
        $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
        $ADODB_LANG = 'de';
        //Set language
        $error_nr = -1;
        ${$link} = NewADOConnection(ADOBD_DB_TYPE);
        if (${$link}) {
            if (USE_PCONNECT == TRUE_STRING_S) {
                ${$link}->PConnect($server, $username, $password, $database);
            } else {
                ${$link}->Connect($server, $username, $password, $database);
            }
            if (${$link}->IsConnected()) {
                if (ADOBD_USE_CACHING) {
                    define('ADOBD_CACHING_SECONDS', 3600);
                    $ADOBD_CACHING_SECONDS = ADOBD_CACHING_SECONDS;
                    $ADODB_CACHE_DIR = ADMIN_PATH_PREFIX . 'cache/adodb_cache';
                }
                if (ADOBD_USE_STATS) {
                    ${$link}->fnExecute = 'CountExecs';
                    ${$link}->fnCacheExecute = ${$link}->fnExecute . 'Cached';
                    global $EXECS, $CACHED;
                    $EXECS = 0;
                    $CACHED = 0;
                }
                $db = ${$link};
            } else {
                $error_text = "Kann keine Verbindung zur Datenbank '" . $database . "' auf Server '" . $server . "' herstellen!";
            }
        } else {
            $error_text = "Fehler bei 'NewADOConnection' mit ADOBD_DB_TYPE='" . ADOBD_DB_TYPE . APOS;
        }
    } else {
        define('DB_USE_LOGGING', STORE_DB_TRANSACTIONS == TRUE_STRING_S);
        if (USE_PCONNECT == TRUE_STRING_S) {
            ${$link} = mysql_pconnect($server, $username, $password);
        } else {
            ${$link} = mysql_connect($server, $username, $password);
        }
        if (${$link}) {
            mysql_select_db($database);
            $mysql_version = trim(mysql_get_server_info());
            if (substr($mysql_version, 0, 1) > '4') {
                //Disable "STRICT" mode for MySQL 5!
                olc_db_query("SET SESSION sql_mode=''");
            }
        } else {
            $error_text = mysql_error();
            $error_nr = mysql_errno();
        }
    }
    if ($error_text) {
        olc_db_error(EMPTY_STRING, $error_nr, 'olc_db_connect -- ' . $error_text);
    } else {
        return ${$link};
    }
}
function UpdateTables()
{
    global $version_nr, $version_datum;
    SendHTMLHeader;
    $alter_table = 'ALTER TABLE ';
    $alter_table_orders = $alter_table . TABLE_ORDERS . ' ADD ';
    $sql[1] = $alter_table . TABLE_PRODUCTS . ' ADD products_ean VARCHAR(128) AFTER products_id';
    $sql[2] = $alter_table_orders . 'payment_class VARCHAR(32) NOT NULL';
    $sql[3] = $alter_table_orders . 'shipping_method VARCHAR(32) NOT NULL';
    $sql[4] = $alter_table_orders . 'shipping_class VARCHAR(32) NOT NULL';
    $sql[5] = $alter_table_orders . 'billing_country_iso_code_2 CHAR(2) NOT NULL AFTER billing_country';
    $sql[6] = $alter_table_orders . 'delivery_country_iso_code_2 CHAR(2) NOT NULL AFTER delivery_country';
    $sql[7] = $alter_table_orders . 'billing_firstname VARCHAR(32) NOT NULL AFTER billing_name';
    $sql[8] = $alter_table_orders . 'billing_lastname VARCHAR(32) NOT NULL AFTER billing_firstname';
    $sql[9] = $alter_table_orders . 'delivery_firstname VARCHAR(32) NOT NULL AFTER delivery_name';
    $sql[10] = $alter_table_orders . 'delivery_lastname VARCHAR(32) NOT NULL AFTER delivery_firstname';
    $sql[11] = $alter_table . TABLE_ORDERS . ' CHANGE payment_method payment_method VARCHAR(255) NOT NULL';
    $sql[12] = $alter_table . TABLE_ORDERS . ' CHANGE shipping_method shipping_method VARCHAR(255) NOT NULL';
    $sql[13] = 'CREATE TABLE ' . TABLE_PREFIX_INDIVIDUAL . 'cao_log ( id int(11) NOT NULL auto_increment, date datetime NOT NULL default "0000-00-00 00:00:00",' . 'user varchar(64) NOT NULL default "", pw varchar(64) NOT NULL default "", method varchar(64) NOT NULL default "",' . 'action varchar(64) NOT NULL default "", post_data mediumtext, get_data mediumtext, PRIMARY KEY  (id))';
    $link = 'db_link';
    global ${$link}, $logger;
    $header_title = 'CAO-Faktura - OL-Commerce Shopanbindung';
    $header_subtitle = 'Version ' . $version_nr . ' Stand : ' . $version_datum;
    $main_content = '';
    for ($i = 1; $i <= 13; $i++) {
        $main_content .= '<b>SQL:</b> ' . $sql[$i] . '<br>';
        if (olc_db_query($sql[$i], ${$link})) {
            $main_content .= '<b>Ergebnis : OK</b>';
        } else {
            $error = olc_db_error();
            $pos = strpos($error, 'Duplicate column name');
            if ($pos === False) {
                $pos = strpos($error, 'already exists');
                if ($pos === False) {
                    $main_content .= '<b>Ergebnis : </b><font color="red"><b>' . $error . '</b></font>';
                } else {
                    $main_content .= '<b>Ergebnis : OK, Tabelle existierte bereits !</b>';
                }
            } else {
                $main_content .= '<b>Ergebnis : OK, Spalte existierte bereits !</b>';
            }
        }
        $main_content .= '<br><br>';
    }
    if (INTEGRATE_INTO_OLC) {
        chdir('admin');
        $header_icon_image = HEADING_MODULES_ICON;
        $show_column_right = true;
        require PROGRAM_FRAME;
        olc_exit();
    } else {
        $main_content = '<html><head></head><body>
<h3>' . $header_title . '</h3>
<h4>' . $header_subtitle . '</h4>
' . $main_content . '
</body>
</html>
';
    }
}