Example #1
0
function update_system_thumbs()
{
    global $CONFIG;
    $results = mysql_query("SELECT * FROM " . $CONFIG['TABLE_PREFIX'] . "config;");
    while ($row = mysql_fetch_array($results)) {
        $CONFIG[$row['name']] = $row['value'];
    }
    // while
    mysql_free_result($results);
    // Code to rename system thumbs in images folder (except nopic.jpg and private.jpg)
    $old_thumb_pfx = 'thumb_';
    if ($old_thumb_pfx != $CONFIG['thumb_pfx']) {
        $folders = array('images/', $THEME_DIR . 'images/');
        foreach ($folders as $folder) {
            $thumbs = cpg_get_system_thumb_list($folder);
            foreach ($thumbs as $thumb) {
                @rename($folder . $thumb['filename'], $folder . str_replace($old_thumb_pfx, $CONFIG['thumb_pfx'], $thumb['filename']));
            }
        }
    }
    // If old images for nopic.jpg and private.jpg exist, delete the new ones
    if (file_exists('images/nopic.jpg')) {
        @unlink('images/thumb_nopic.jpg');
    }
    if (file_exists('images/private.jpg')) {
        @unlink('images/thumb_private.jpg');
    }
    // Rename old images to new format
    @rename('images/nopic.jpg', 'images/' . $CONFIG['thumb_pfx'] . 'nopic.jpg');
    @rename('images/private.jpg', 'images/' . $CONFIG['thumb_pfx'] . 'private.jpg');
}
 if ($superCage->post->keyExists('update_config') && $regexValidation == '1' && $evaluate_value != $CONFIG[$adminDataKey] && $CONFIG[$adminDataKey] !== stripslashes($evaluate_value)) {
     // A space cannot be stored in the config table since the value field is VARCHAR, so %20 is used instead.
     if ($adminDataKey == 'keyword_separator' && $evaluate_value == ' ') {
         $evaluate_value = '%20';
     }
     //  finally, all criteria have been met - let's write the updated data to the database
     cpg_config_set($adminDataKey, $evaluate_value);
     // perform special tasks -- start
     // Code to rename system thumbs in images folder
     $old_thumb_pfx =& $CONFIG['thumb_pfx'];
     $matches = $superCage->post->getMatched('thumb_pfx', '/^[0-9A-Za-z_-]+$/');
     $thumb_pfx = $matches[0];
     if ($old_thumb_pfx != $thumb_pfx) {
         $folders = array('images/', $THEME_DIR . 'images/');
         foreach ($folders as $folder) {
             $thumbs = cpg_get_system_thumb_list($folder);
             foreach ($thumbs as $thumb) {
                 @rename($folder . $thumb['filename'], $folder . str_replace($old_thumb_pfx, $thumb_pfx, $thumb['filename']));
             }
         }
     }
     // perform special tasks -- end
     // update configuration variables
     $admin_data_array[$adminDataKey] = stripslashes($evaluate_value);
     $CONFIG[$adminDataKey] = stripslashes($evaluate_value);
     if (isset($adminDataValue['force_config']) && $adminDataValue['force_config']) {
         $admin_data_array[$adminDataKey . '_config'] = stripslashes($evaluate_value);
         $CONFIG[$adminDataKey . '_config'] = stripslashes($evaluate_value);
     }
     $userMessage .= '<li style="list-style-image:url(images/icons/ok.png)">' . sprintf($lang_admin_php['config_setting_ok'], $lang_admin_php[$adminDataKey]) . '</li>' . $LINEBREAK;
 }
Example #3
0
function update_system_thumbs()
{
    global $CONFIG, $lang_update_php, $lang_common, $ok_icon, $already_done_icon, $error_icon;
    $results = mysql_query("SELECT * FROM {$CONFIG['TABLE_PREFIX']}config;");
    while ($row = mysql_fetch_array($results)) {
        $CONFIG[$row['name']] = $row['value'];
    }
    // while
    mysql_free_result($results);
    // Code to rename system thumbs in images folder
    $default_thumb_pfx = 'thumb_';
    if ($default_thumb_pfx != $CONFIG['thumb_pfx']) {
        $THEME_DIR = 'themes/' . $CONFIG['theme'] . '/';
        $folders = array('images/thumbs/', $THEME_DIR . 'images/');
        $loopCounter = 0;
        foreach ($folders as $folder) {
            $thumbs = cpg_get_system_thumb_list($folder);
            foreach ($thumbs as $thumb) {
                $cellStyle = $loopCounter / 2 == floor($loopCounter / 2) ? 'tableb' : 'tableb tableb_alternate';
                $rename_file_from = $folder . $thumb['filename'];
                $rename_file_to = $folder . str_replace($default_thumb_pfx, $CONFIG['thumb_pfx'], $thumb['filename']);
                $rename_output = sprintf($lang_update_php['rename_file'], '&laquo;<tt>' . $rename_file_from . '</tt>&raquo;', '&laquo;<tt>' . $rename_file_to . '</tt>&raquo;');
                echo <<<EOT
            <tr>
                <td class="{$cellStyle}">
                    {$rename_output}
                </td>

EOT;
                if (file_exists($rename_file_to)) {
                    $result_output = $already_done_icon . $lang_update_php['already_done'];
                    echo <<<EOT
                <td class="{$cellStyle}">
                    {$result_output}
                </td>
            </tr>

EOT;
                    $loopCounter++;
                    if ($rename_file_from == $rename_file_to) {
                        continue;
                    }
                    $cellStyle = $loopCounter / 2 == floor($loopCounter / 2) ? 'tableb' : 'tableb tableb_alternate';
                    $delete_file = $rename_file_from;
                    $delete_output = sprintf($lang_update_php['delete_file'], '&laquo;<tt>' . $delete_file . '</tt>&raquo;');
                    echo <<<EOT
            <tr>
                <td class="{$cellStyle}">
                    {$delete_output}
                </td>

EOT;
                    if (!file_exists($delete_file)) {
                        $result_output = $already_done_icon . $lang_update_php['already_done'];
                    } else {
                        list($delete_result, $debug_output) = cpg_folder_file_delete($delete_file);
                        if ($delete_result == TRUE) {
                            $result_output = $ok_icon . $lang_common['ok'];
                        } else {
                            $result_output = $error_icon . $lang_update_php['could_not_delete'];
                        }
                    }
                    echo <<<EOT
                <td class="{$cellStyle}">
                    {$result_output}
                </td>
            </tr>

EOT;
                    $loopCounter++;
                    continue;
                } else {
                    $rename_result = @rename($rename_file_from, $rename_file_to);
                    if ($rename_result == TRUE) {
                        $result_output = $ok_icon . $lang_common['ok'];
                    } else {
                        $result_output = $error_icon . $lang_update_php['could_not_rename'];
                    }
                }
                echo <<<EOT
                <td class="{$cellStyle}">
                    {$result_output}
                </td>
            </tr>

EOT;
                $loopCounter++;
            }
            // foreach $thumbs
        }
        // foreach $folders
    }
    // if different thumb_pfx
    /*
    // Unnecessary for 1.5 since these thumbs are included with the system thumbs above
    // If old images for nopic.jpg and private.jpg exist, delete the new ones
    if (file_exists('images/nopic.jpg')) {
        cpg_folder_file_delete('images/thumb_nopic.jpg');
        @rename('images/nopic.jpg', 'images/' . $CONFIG['thumb_pfx'] . 'nopic.jpg');
    }
    if (file_exists('images/private.jpg')) {
        cpg_folder_file_delete('images/thumb_private.jpg');
        @rename('images/private.jpg', 'images/' . $CONFIG['thumb_pfx'] . 'private.jpg');
    }
    */
}