HomeHelpTrac

Changeset 15339


Ignore:
Timestamp:
07/13/11 05:48:55 (11 months ago)
Author:
Anton Lesnikov
Message:

Get rid of $dir and $GLOBALSdir? global variables.

Location:
trunk
Files:
1 added
1 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/inc/admin.inc.php

    r15211 r15339  
    4747 
    4848function profile_delete($ID) { 
    49     global $dir; 
    50  
    5149    $oDb = BxDolDb::getInstance(); 
    5250 
  • trunk/inc/classes/BxDolConfig.php

    r15338 r15339  
    6161        $this->aUrlDynamic = array( 
    6262            'tmp' => BX_DOL_URL_ROOT . 'tmp/', 
    63             'media_images' => BX_DOL_URL_ROOT . 'media/images/', 
    64             'media_images_promo' => BX_DOL_URL_ROOT . 'media/images/promo/' 
     63            'simg' => BX_DOL_URL_ROOT . 'simg/', 
     64            'rpr_images_main' => '', //--- For Site's main images like logo, etc 
     65            'rpr_images_promo' => '', //--- For Promo images 
     66            'rpr_images_watermark' => '' //--- For Watermarks 
    6567        ); 
    6668 
    6769        $this->aPathDynamic = array( 
    6870            'tmp' => BX_DIRECTORY_PATH_ROOT . 'tmp/', 
    69             'media_images' => BX_DIRECTORY_PATH_ROOT . 'media/images/', 
    70             'media_images_promo' => BX_DIRECTORY_PATH_ROOT . 'media/images/promo/' 
     71            'simg' => BX_DIRECTORY_PATH_ROOT . 'simg/', 
     72            'rpr_images_main' => '', //--- For Site's main images like logo, etc 
     73            'rpr_images_promo' => '', //--- For Promo images 
     74            'rpr_images_watermark' => '' //--- For Watermarks 
    7175        ); 
    7276 
  • trunk/inc/classes/BxDolCronCmd.php

    r15338 r15339  
    130130    } 
    131131 
    132     function del_old_all_files() 
    133     { 
    134         global $dir; 
    135  
     132    function del_old_all_files() { 
    136133        $num_tmp = 0; 
    137134        $num_del = 0; 
     
    139136        $file_life = 86400;  // one day 
    140137        $dirToClean = array(); 
    141         $dirToClean[] = $dir['tmp']; 
    142         $dirToClean[] = $dir['cache']; 
     138        $dirToClean[] = BxDolConfig::getInstance()->get('path_dynamic', 'tmp'); 
     139        $dirToClean[] = BX_DIRECTORY_PATH_CACHE; 
    143140 
    144141        foreach( $dirToClean as $value ) 
  • trunk/inc/classes/BxDolJoinProcessor.php

    r15211 r15339  
    184184 
    185185    function registerMember() { 
     186        $sTmpPath = BxDolConfig::getInstance()->get('path_dynamic', 'tmp'); 
    186187 
    187188        bx_import('BxDolProfilesController'); 
     
    197198        if(!$iId1) { 
    198199            if(isset($aProfile1['ProfilePhoto']) && !empty($aProfile1['ProfilePhoto'])) 
    199                 @unlink($GLOBALS['dir']['tmp'] . $aProfile1['ProfilePhoto']); 
     200                @unlink($sTmpPath . $aProfile1['ProfilePhoto']); 
    200201 
    201202            return array(false, 'Fail'); 
     
    209210            check_logged(); 
    210211 
    211             BxDolService::call('avatar', 'set_image_for_cropping', array ($iId1, $GLOBALS['dir']['tmp'] . $aProfile1['ProfilePhoto'])); 
     212            BxDolService::call('avatar', 'set_image_for_cropping', array ($iId1, $sTmpPath . $aProfile1['ProfilePhoto'])); 
    212213 
    213214            if (BxDolRequest::serviceExists('photos', 'perform_photo_upload', 'Uploader')) { 
     
    219220                    'album' => str_replace('{nickname}', getNickName($iId1), getParam('bx_photos_profile_album_name')), 
    220221                ); 
    221                 BxDolService::call('photos', 'perform_photo_upload', array($GLOBALS['dir']['tmp'] . $aProfile1['ProfilePhoto'], $aFileInfo, false), 'Uploader'); 
     222                BxDolService::call('photos', 'perform_photo_upload', array($sTmpPath . $aProfile1['ProfilePhoto'], $aFileInfo, false), 'Uploader'); 
    222223            } 
    223224        } 
  • trunk/inc/classes/BxDolProfileFields.php

    r15338 r15339  
    167167                                    if (isset($_FILES['ProfilePhoto'])) { 
    168168                                        if ($_FILES['ProfilePhoto']['error'] == UPLOAD_ERR_OK) { 
    169                                             $sTmpName  = tempnam($GLOBALS['dir']['tmp'], 'pphot'); 
     169                                            $sTmpName  = tempnam(BxDolConfig::getInstance()->get('path_dynamic', 'tmp'), 'pphot'); 
    170170                                            if (move_uploaded_file($_FILES['ProfilePhoto']['tmp_name'], $sTmpName)) 
    171171                                                $mValue = basename($sTmpName); 
     
    470470                    return true; 
    471471 
    472                 $sFileName = $GLOBALS['dir']['tmp'] . $mValue; 
     472                $sFileName = BxDolConfig::getInstance()->get('path_dynamic', 'tmp') . $mValue; 
    473473 
    474474                if ($mValue && !file_exists($sFileName)) // hack attempt 
  • trunk/inc/design.inc.php

    r15338 r15339  
    184184    return BxTemplFunctions::getInstance()->msgBox($sText, $iTimer); 
    185185} 
     186 
    186187function LoadingBox($sName) { 
    187188    bx_import('BxTemplFunctions'); 
    188189    return BxTemplFunctions::getInstance()->loadingBox($sName); 
    189190} 
     191 
    190192function PopupBox($sName, $sTitle, $sContent, $aActions = array(), $isHiddenByDefault = false) { 
    191193    bx_import('BxTemplFunctions'); 
    192194    return BxTemplFunctions::getInstance()->popupBox($sName, $sTitle, $sContent, $aActions, $isHiddenByDefault); 
    193195} 
     196 
    194197function getMainLogo() { 
    195     $oSysConfig = BxDolConfig::getInstance(); 
     198    $sRprMain = BxDolConfig::getInstance()->get('path_dynamic', 'rpr_images_main'); 
    196199 
    197200    $sFileName = getParam('sys_main_logo'); 
    198     if(!file_exists($oSysConfig->get('path_dynamic', 'media_images') . $sFileName)) 
     201    if(!file_exists($sRprMain . $sFileName)) 
    199202        return ''; 
    200203 
    201     return '<a href="' . BX_DOL_URL_ROOT . '"><img src="' . $oSysConfig->get('url_dynamic', 'media_images') . $sFileName . '" class="mainLogo" alt="logo" /></a>'; 
     204    return '<a href="' . BX_DOL_URL_ROOT . '"><img src="' . $sRprMain . $sFileName . '" class="mainLogo" alt="logo" /></a>'; 
    202205} 
    203206 
    204207function getPromoImagesArray() { 
    205     global $dir; 
     208    $sPromoPath = BxDolConfig::getInstance()->get('path_dynamic', 'rpr_images_promo'); 
    206209 
    207210    $aAllowedExt = array('jpg' => 1, 'png' => 1, 'gif' => 1, 'jpeg' => 1); 
    208211    $aFiles = array(); 
    209     $rDir = opendir( $dir['imagesPromo'] ); 
     212    $rDir = opendir($sPromoPath); 
    210213    if( $rDir ) { 
    211         while( $sFile = readdir( $rDir ) ) { 
    212             if( $sFile == '.' or $sFile == '..' or !is_file( $dir['imagesPromo'] . $sFile ) ) 
     214        while(($sFile = readdir($rDir)) !== false) { 
     215            if($sFile == '.' or $sFile == '..' or !is_file($sPromoPath . $sFile)) 
    213216                continue; 
    214217            $aPathInfo = pathinfo($sFile); 
  • trunk/inc/images.inc.php

    r15338 r15339  
    5353{ 
    5454    $use_gd = false; 
    55     global $CONVERT; 
    5655    global $gdInstalled; 
    57     global $dir; 
     56 
     57    $sTmpPath = BxDolConfig::getInstance()->get('path_dynamic', 'tmp'); 
    5858 
    5959    // constant values 
     
    135135    { 
    136136        // create image with background 
    137         $workFilename = "{$dir['tmp']}bg{$hash}.png"; 
    138         $cmd  = "$CONVERT " . BX_DIRECTORY_PATH_ROOT . "simg/images/bg{$backgroundIndex}.png -crop {$sizeX}x{$sizeY}+{$backgroundOffsetX}+{$backgroundOffsetY} $workFilename"; 
     137        $workFilename = "{$sTmpPath}bg{$hash}.png"; 
     138        $cmd  = BX_SYSTEM_CONVERT . " " . BX_DIRECTORY_PATH_ROOT . "simg/images/bg{$backgroundIndex}.png -crop {$sizeX}x{$sizeY}+{$backgroundOffsetX}+{$backgroundOffsetY} $workFilename"; 
    139139        @exec( $cmd ); 
    140140        if ( !file_exists( $workFilename ) ) 
     
    142142 
    143143        // write text on image 
    144         $workFilename = "{$dir['tmp']}{$hash}.png"; 
     144        $workFilename = "{$sTmpPath}{$hash}.png"; 
    145145        $color = '#' . sprintf( '%02x', $fontColorR ) . sprintf( '%02x', $fontColorG ) . sprintf( '%02x', $fontColorB ); 
    146146        $textX += $backgroundOffsetX; 
    147147        $textY += $backgroundOffsetY; 
    148         $cmd  = "$CONVERT {$dir['tmp']}bg{$hash}.png -font $fontFile -fill \"{$color}\" -pointsize $fontSize -gravity NorthWest -draw \"translate {$textX},{$textY} rotate {$angle} text 0,0 '{$text}'\" $workFilename"; 
     148        $cmd  = BX_SYSTEM_CONVERT . " {$sTmpPath}bg{$hash}.png -font $fontFile -fill \"{$color}\" -pointsize $fontSize -gravity NorthWest -draw \"translate {$textX},{$textY} rotate {$angle} text 0,0 '{$text}'\" $workFilename"; 
    149149        @exec( $cmd ); 
    150150        if ( !file_exists( $workFilename ) ) 
     
    163163 
    164164        // unlink temporary files 
    165         unlink( "{$dir['tmp']}bg{$hash}.png" ); 
    166         unlink( "{$dir['tmp']}{$hash}.png" ); 
     165        unlink( "{$sTmpPath}bg{$hash}.png" ); 
     166        unlink( "{$sTmpPath}{$hash}.png" ); 
    167167 
    168168        return IMAGE_ERROR_SUCCESS; 
     
    263263 
    264264function ResizeAllPromos() { 
    265     global $dir; 
     265    $sRprPromoPath = BxDolConfig::getInstance()->get('path_dynamic', 'rpr_images_promo'); 
    266266 
    267267    //cleaning old 
    268     $sDestFold = BxDolConfig::getInstance()->get('path_dynamic', 'media_images_promo'); 
     268    $sDestFold = $sRprPromoPath; 
    269269    $rDir = opendir($sDestFold); 
    270270    if($rDir) { 
     
    279279    //inserting new 
    280280    $iImgCnt = 1; 
    281     $sDestFold = $dir['imagesPromo'] . 'original/'; 
     281    $sDestFold = $sRprPromoPath; 
    282282    $rDir = opendir($sDestFold); 
    283283    if($rDir) { 
     
    285285            if($sFile == '.' || $sFile == '..' || !is_file($sDestFold . $sFile)) 
    286286                continue; 
    287             ResizeAnyPromo($sDestFold . $sFile, $dir['imagesPromo'] . $sFile); 
     287            ResizeAnyPromo($sDestFold . $sFile, $sRprPromoPath . $sFile); 
    288288            $iImgCnt++; 
    289289        } 
  • trunk/inc/utils.inc.php

    r15338 r15339  
    586586 
    587587function echoDbgLog($mWhat, $sDesc = '', $sFileName = 'debug.log') { 
    588     global $dir; 
    589  
    590588    $sCont = 
    591589        '--- ' . date('r') . ' (' . BX_DOL_START_TIME . ") ---\n" . 
     
    593591        print_r($mWhat, true) . "\n\n\n"; 
    594592 
    595     $rFile = fopen($dir['tmp'] . $sFileName, 'a'); 
     593    $rFile = fopen(BxDolConfig::getInstance()->get('path_dynamic', 'tmp') . $sFileName, 'a'); 
    596594    fwrite($rFile, $sCont); 
    597595    fclose($rFile); 
  • trunk/simg/simg.php

    r15211 r15339  
    2929$oSession->setValue('strSec', $hashtext); 
    3030 
    31 if ( produceSecurityImage( $textstr, $hashtext ) != IMAGE_ERROR_SUCCESS ) 
    32 { 
     31if ( produceSecurityImage( $textstr, $hashtext ) != IMAGE_ERROR_SUCCESS ) { 
    3332    // output header 
    3433    //header( "Content-Type: image/gif" ); 
     
    4140 
    4241    // output error image 
    43     @readfile( $dir['profileImage'] . 'simg_error.gif' ); 
     42    @readfile(BxDolConfig::getInstance()->get('path_dynamic', 'simg') . 'simg_error.gif'); 
    4443} 
    4544 
    4645ob_end_flush(); 
    47 ?> 
  • trunk/studio/classes/BxDolStudioSettings.php

    r15228 r15339  
    369369 
    370370    function _saveCatWatermark(&$aData){ 
    371         global $dir; 
    372371        $bResult = false; 
     372        $sRprPath = BxDolConfig::getInstance()->get('path_dynamic', 'rpr_images_watermark'); 
    373373 
    374374        if(!empty($aData['transparent1'])) { 
     
    386386        if ($_FILES['Water_Mark'] && $_FILES['Water_Mark']['error'] == UPLOAD_ERR_OK) { 
    387387 
    388             if (BxDolImageResize->getInstance()->isAllowedImage($_FILES['Water_Mark']['tmp_name'])) { 
    389                 $sPath = $dir['profileImage'] . $_FILES['Water_Mark']['name']; 
     388            if (BxDolImageResize::getInstance()->isAllowedImage($_FILES['Water_Mark']['tmp_name'])) { 
     389                $sPath = $sRprPath . $_FILES['Water_Mark']['name']; 
    390390                if (move_uploaded_file($_FILES['Water_Mark']['tmp_name'], $sPath)) { 
    391391                    $sOldImage = getParam('Water_Mark'); 
    392                     if (!empty($sOldImage) && ($dir['profileImage'] . $sOldImage) != $sPath) 
    393                         @unlink($dir['profileImage'] . $sOldImage); 
     392                    if (!empty($sOldImage) && ($sRprPath . $sOldImage) != $sPath) 
     393                        @unlink($sRprPath . $sOldImage); 
    394394 
    395395                    @chmod($sPath, 0666); 
Note: See TracChangeset for help on using the changeset viewer.