Exemple #1
0
$CONFIG['TABLE_CATEGORIES'] = $CONFIG['TABLE_PREFIX'] . "categories";
$CONFIG['TABLE_CONFIG'] = $CONFIG['TABLE_PREFIX'] . "config";
$CONFIG['TABLE_USERGROUPS'] = $CONFIG['TABLE_PREFIX'] . "usergroups";
$CONFIG['TABLE_VOTES'] = $CONFIG['TABLE_PREFIX'] . "votes";
$CONFIG['TABLE_USERS'] = $CONFIG['TABLE_PREFIX'] . "users";
$CONFIG['TABLE_BANNED'] = $CONFIG['TABLE_PREFIX'] . "banned";
$CONFIG['TABLE_EXIF'] = $CONFIG['TABLE_PREFIX'] . "exif";
$CONFIG['TABLE_FILETYPES'] = $CONFIG['TABLE_PREFIX'] . "filetypes";
$CONFIG['TABLE_ECARDS'] = $CONFIG['TABLE_PREFIX'] . "ecards";
$CONFIG['TABLE_TEMPDATA'] = $CONFIG['TABLE_PREFIX'] . "temp_data";
$CONFIG['TABLE_FAVPICS'] = $CONFIG['TABLE_PREFIX'] . "favpics";
$CONFIG['TABLE_BRIDGE'] = $CONFIG['TABLE_PREFIX'] . "bridge";
$CONFIG['TABLE_VOTE_STATS'] = $CONFIG['TABLE_PREFIX'] . "vote_stats";
$CONFIG['TABLE_HIT_STATS'] = $CONFIG['TABLE_PREFIX'] . "hit_stats";
// Connect to database
($CONFIG['LINK_ID'] = cpg_db_connect()) || die("<b>Coppermine critical error</b>:<br />Unable to connect to database !<br /><br />MySQL said: <b>" . mysql_error() . "</b>");
// Retrieve DB stored configuration
$results = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_CONFIG']}");
while ($row = mysql_fetch_array($results)) {
    $CONFIG[$row['name']] = $row['value'];
}
// while
mysql_free_result($results);
define('USER_GAL_CAT', 1);
define('FIRST_USER_CAT', 10000);
// We load the chosen language file
require "../lang/english.php";
require 'cpgAPIerrors.php';
// Check for GD GIF Create support
if ($CONFIG['thumb_method'] == 'im' || function_exists('imagecreatefromgif')) {
    $CONFIG['GIF_support'] = 1;
Exemple #2
0
function write_to_db($step)
{
    global $BRIDGE, $CONFIG, $default_bridge_data, $lang_bridgemgr_php, $previous_step, $next_step;
    $error = 0;
    // do the check for plausibility of posted data
    foreach ($_POST as $key => $value) {
        // loop through the posted data -- start
        // filter the post data that doesn't get written
        if (array_key_exists($key, $BRIDGE)) {
            // post data exists as db key -- start
            // do the lookups
            $options = explode(',', $default_bridge_data[$BRIDGE['short_name']][$key . '_used']);
            foreach ($options as $key2) {
                $options[$key2] = trim($options[$key2], ',');
                // get rid of the delimiters
            }
            if ($options[0] != '') {
                // only continue with this loop if there really is an option to check --- start
                if ($options[0] == 'lookfor') {
                    // check for the existance of a local file/folder --- start
                    if (file_exists($value . $options[1]) == false) {
                        $return[$key] = sprintf($lang_bridgemgr_php['error_folder_not_exist'], '<tt>' . $value . $options[1] . '</tt>', '<i>' . $lang_bridgemgr_php[$key] . '</i>');
                    }
                }
                // check for the existance of a file/folder --- end
                if ($options[0] == 'cookie') {
                    // check for the existance of a cookie --- start
                    foreach ($_COOKIE as $key2 => $value2) {
                        // loop through the cookie global var --- start
                        //print '<br>cookie:'.$key2.', content:'.$value2."<br />\n";
                        if (@strstr($key2, $value) == false && $options[1] == 'not_empty') {
                            $return[$key] = sprintf($lang_bridgemgr_php['error_cookie_not_readible'], '&quot;<tt>' . $value . '</tt>*&quot;', '<i>' . $lang_bridgemgr_php[$key] . '</i>');
                        }
                    }
                    // loop through the cookie global var --- end
                    if (isset($temp_err)) {
                        $return[$key] = $temp_err;
                    }
                }
                // check for the existance of a cookie --- end
                if ($options[1] == 'not_empty') {
                    // check for empty mandatory fields --- start
                    if ($value == '') {
                        $return[$key] = sprintf($lang_bridgemgr_php['error_mandatory_field_empty'], '<i>' . $lang_bridgemgr_php[$key] . '</i>');
                    }
                }
                // check for empty mandatory fields --- end
                if ($options[0] == 'no_trailing_slash' || $options[1] == 'no_trailing_slash' || $options[2] == 'no_trailing_slash') {
                    // check for unneeded trailing slashes --- start
                    if ($value != rtrim($value, '/')) {
                        $return[$key] = sprintf($lang_bridgemgr_php['error_no_trailing_slash'], '<i>' . $lang_bridgemgr_php[$key] . '</i>');
                    }
                }
                // check for unneeded traling slashes --- end
                if ($options[0] == 'trailing_slash' || $options[1] == 'trailing_slash' || $options[2] == 'trailing_slash') {
                    // check for needed trailing slashes --- start
                    if ($value == rtrim($value, '/')) {
                        $return[$key] = sprintf($lang_bridgemgr_php['error_trailing_slash'], '<i>' . $lang_bridgemgr_php[$key] . '</i>');
                    }
                }
                // check for needed traling slashes --- end
                //print "<hr />\n";
                //print $options[0].':'.$options[1].','.$options[2];
                //print "<hr />\n";
            }
            // only continue with this loop if there really is an option to check --- end
        }
        // post data exists as db key -- end
    }
    // loop through the posted data -- end
    // loop through the expected data
    //void
    // do some checking according to the step we're currently in
    switch ($step) {
        case "choose_bbs":
            if ($_POST['short_name'] == '') {
                $return['short_name'] = $lang_bridgemgr_php['error_specify_bbs'];
                $error++;
            }
            if ($_POST['short_name'] == 'custom_selector') {
                $_POST['short_name'] = $_POST['custom_filename'];
                if ($_POST['short_name'] == '') {
                    $return['short_name'] = $lang_bridgemgr_php['error_no_blank_name'];
                }
                if (ereg('[^A-Za-z0-9_-]', $_POST['short_name'])) {
                    $return['short_name'] = $lang_bridgemgr_php['error_no_special_chars'];
                }
            }
            // check if the bridge file actually exists
            if (file_exists('bridge/' . $_POST['short_name'] . '.inc.php') == false) {
                $return['bridge_file_not_exist'] = sprintf($lang_bridgemgr_php['error_bridge_file_not_exist'], '<i>bridge/' . $_POST['short_name'] . '.inc.php</i>');
            }
            break;
        case "settings_path":
            //if ($_POST['short_name'] == '') {
            //    $return['short_name'] = $lang_bridgemgr_php['error_specify_bbs'];
            //}
            break;
        case "db_group":
            //if ($_POST['use_standard_groups'] == '') {
            //    $_POST['use_standard_groups'] = 0 ;
            //}
            break;
        case "db_connect":
            if ($default_bridge_data[$BRIDGE['short_name']]['db_hostname_used'] != '') {
                // check the db connection --- start
                @mysql_close();
                //temporarily disconnect from the coppermine database
                ob_start();
                $link = mysql_connect($_POST['db_hostname'], $_POST['db_username'], $_POST['db_password']);
                $mysql_error_output = ob_get_contents();
                ob_end_clean();
                if (!$link) {
                    $return[$step] = $lang_bridgemgr_php['error_db_connect'] . '<tt>' . $mysql_error_output . '</tt>';
                } elseif ($default_bridge_data[$BRIDGE['short_name']]['db_database_name_used'] != '') {
                    // check the database
                    ob_start();
                    $db_selected = mysql_select_db($_POST['db_database_name'], $link);
                    print mysql_error();
                    $mysql_error_output = ob_get_contents();
                    ob_end_clean();
                    if (!$db_selected) {
                        $return['db_database_name'] = sprintf($lang_bridgemgr_php['error_db_name'], '<i>' . $_POST['db_database_name'] . '</i>', '<i>' . $lang_bridgemgr_php['db_database_name'] . '</i>') . ' <tt>' . $mysql_error_output . '</tt>';
                    }
                }
                @mysql_close($link);
                cpg_db_connect();
                // connect back to coppermine db
            }
            // check the db connection --- end
            break;
        case "db_tables":
            if ($default_bridge_data[$BRIDGE['short_name']]['table_prefix_used'] != '') {
                $prefix_and_table = sprintf($lang_bridgemgr_php['error_prefix_and_table'], '<i>' . $lang_bridgemgr_php['table_prefix'] . '</i>');
            }
            @mysql_close();
            //temporarily disconnect from the coppermine database
            $link = @mysql_connect($BRIDGE['db_hostname'], $BRIDGE['db_username'], $BRIDGE['db_password']);
            $db_selected = @mysql_select_db($BRIDGE['db_database_name'], $link);
            $loop_table_names = array('user_table', 'session_table', 'group_table', 'group_table', 'group_relation_table', 'group_mapping_table');
            foreach ($loop_table_names as $key) {
                // loop through the possible tables --- start
                if ($default_bridge_data[$BRIDGE['short_name']][$key . '_used'] != '') {
                    // check if table exists --- start
                    $temp_tablename = $_POST['table_prefix'] . $_POST[$key];
                    $result = mysql_query('SELECT * FROM ' . $temp_tablename);
                    if (!$result) {
                        $return['db_' . $key] = sprintf($lang_bridgemgr_php['error_db_table'], '<i>' . $temp_tablename . '</i>', $prefix_and_table . '<i>' . $lang_bridgemgr_php[$key] . '</i>') . ' <tt>' . $mysql_error_output . '</tt>';
                    }
                    @mysql_free_result($result);
                }
                // check if table exists --- end
            }
            // loop through the possible tables --- end
            @mysql_close($link);
            cpg_db_connect();
            // connect back to coppermine db
            break;
    }
    // end switch
    // write the post data to the database
    //print_r($_POST);
    foreach ($_POST as $key => $value) {
        // filter the post data that doesn't get written
        if (array_key_exists($key, $BRIDGE)) {
            if ($CONFIG['debug_mode'] != 0) {
                // print what actually get's written when in debug_mode
                print '<span class="explanation">Writing to database: ';
                print $key . '|' . $value;
                print '<br /></span>';
            }
            if ($return[$key] != '') {
                //print '|Error in this key';
            } else {
                cpg_db_query("UPDATE {$CONFIG['TABLE_BRIDGE']} SET value = '{$value}' WHERE name = '{$key}'");
            }
            //print '<br />';
        }
    }
    $value = $_POST['bridge_enable'];
    if ($value != '0' && $value != '1') {
        $value = $CONFIG['bridge_enable'];
    }
    cpg_db_query("UPDATE {$CONFIG['TABLE_CONFIG']} SET value = '{$value}' WHERE name = 'bridge_enable'");
    if ($_POST['clear_unused_db_fields'] == 1) {
        // clear all database entries that aren't actually used with the current bridge file
        // not implemented yet (not sure if necessary after all)
    }
    // ouput error messages, if any
    if (is_array($return)) {
        starttable('100%', $lang_bridgemgr_php['error_title']);
        print '<tr><td class="tableb" align="left"><ul>';
        foreach ($return as $key) {
            print '<li>' . $key . '</li>';
        }
        print '</ul></td></tr>';
        print '<tr>' . $new_line;
        print '    <td class="tablef" align="center">' . $new_line;
        print '        <a href="javascript:history.back()" class="admin_menu" title="' . $lang_bridgemgr_php['back'] . '" />&laquo;' . $lang_bridgemgr_php['back'] . '</a>' . $new_line;
        print '    </td>' . $new_line;
        print '</tr>' . $new_line;
        endtable();
        $error = 1;
    }
    print '<br />';
    if ($error != '') {
        return 'error';
    }
}
$CONFIG['TABLE_VOTES'] = $CONFIG['TABLE_PREFIX'] . 'votes';
$CONFIG['TABLE_USERS'] = $CONFIG['TABLE_PREFIX'] . 'users';
$CONFIG['TABLE_BANNED'] = $CONFIG['TABLE_PREFIX'] . 'banned';
$CONFIG['TABLE_EXIF'] = $CONFIG['TABLE_PREFIX'] . 'exif';
$CONFIG['TABLE_FILETYPES'] = $CONFIG['TABLE_PREFIX'] . 'filetypes';
$CONFIG['TABLE_ECARDS'] = $CONFIG['TABLE_PREFIX'] . 'ecards';
$CONFIG['TABLE_FAVPICS'] = $CONFIG['TABLE_PREFIX'] . 'favpics';
$CONFIG['TABLE_BRIDGE'] = $CONFIG['TABLE_PREFIX'] . 'bridge';
$CONFIG['TABLE_VOTE_STATS'] = $CONFIG['TABLE_PREFIX'] . 'vote_stats';
$CONFIG['TABLE_HIT_STATS'] = $CONFIG['TABLE_PREFIX'] . 'hit_stats';
$CONFIG['TABLE_TEMP_MESSAGES'] = $CONFIG['TABLE_PREFIX'] . 'temp_messages';
$CONFIG['TABLE_CATMAP'] = $CONFIG['TABLE_PREFIX'] . 'categorymap';
$CONFIG['TABLE_LANGUAGE'] = $CONFIG['TABLE_PREFIX'] . 'languages';
$CONFIG['TABLE_DICT'] = $CONFIG['TABLE_PREFIX'] . 'dict';
// Connect to database
$CONFIG['LINK_ID'] = cpg_db_connect();
if (!$CONFIG['LINK_ID']) {
    log_write("Unable to connect to database: " . mysql_error(), CPG_DATABASE_LOG);
    die('<strong>Coppermine critical error</strong>:<br />Unable to connect to database !<br /><br />MySQL said: <strong>' . mysql_error() . '</strong>');
}
// Retrieve DB stored configuration
$result = cpg_db_query("SELECT name, value FROM {$CONFIG['TABLE_CONFIG']}");
while ($row = mysql_fetch_assoc($result)) {
    $CONFIG[$row['name']] = $row['value'];
}
// while
mysql_free_result($result);
// Check if Coppermine is allowed to store cookies (cookie consent is required and user has agreed to store cookies)
define('CPG_COOKIES_ALLOWED', $CONFIG['cookies_need_consent'] && !$superCage->cookie->keyExists($CONFIG['cookie_name'] . '_cookies_allowed') ? false : true);
// A space cannot be stored in the config table since the value field is VARCHAR, so %20 is used instead.
if ($CONFIG['keyword_separator'] == '%20') {
Exemple #4
0
 function verifyKey($key)
 {
     global $CONFIG;
     cpg_db_connect();
     $query = "SELECT COUNT(*) from {$CONFIG['TABLE_CONFIG']} where name='" . $USERID . "_flash' and value='" . $key . "'";
     //echo "<br> " . $query ;
     $result = cpg_db_fetch_rowset(cpg_db_query($query));
     //echo "result " . $result[0][0];
     if ($result[0][0] != 0) {
         return true;
     } else {
         return false;
     }
 }