myGully.com

myGully.com (https://mygully.com/index.php)
-   Entwicklung & Programmierung (https://mygully.com/forumdisplay.php?f=72)
-   -   Probelm mit php script (https://mygully.com/showthread.php?t=2744990)

cyberdemon3 05.11.12 22:22

Probelm mit php script
 
hallo ich will mit ssh ein s***** aufführen das auch schonmal ging.
jetzt gehts aufeinmal nicht mehr und es kommt folgende fehlermeldung:



PHP-Code:

PHP Warning:  require_once(): SAFE MODE Restriction in effect.  The s***** whose uid is 0 is not allowed to access /var/www/vhosts/xxx.de/httpdocs/shell/abstract.php owned by uid 1072 in /var/www/vhosts/xxx.de/httpdocs/shell/import_categories.php on line 3
PHP Warning
:  require_once(/var/www/vhosts/xxx.de/httpdocs/shell/abstract.php): failed to open streamInappropriate ioctl for device in /var/www/vhosts/xxx.de/httpdocs/shell/import_categories.php on line 3
PHP Fatal error
:  require_once(): Failed opening required 'abstract.php' (include_path='.:'in /var/www/vhosts/xxx.de/httpdocs/shell/import_categories.php on line 3 

hier ist das s*****

PHP-Code:

<?php

require_once 'abstract.php';

/**
 * S***** for automatic category tree creation.
 *
 * @category    Mage
 * @package     Mage_Shell
 * @author      Johann Reinke
 */
class Mage_Shell_ImportCategories extends Mage_Shell_Abstract
{
    
/**
     * This method catches invalid store codes because of Magento throwing an exception with empty message!
     *
     * @return Mage_Core_Model_Store
     */
    
protected function _getStore($storeCode)
    {
        try {
            return 
Mage::app()->getStore($storeCode);
        } catch (
Mage_Core_Model_Store_Exception $e) {
            
Mage::throwException(sprintf("Could not find store with code '%s'"$storeCode));
        }
    }

    
/**
     * Prepares default data of new category with specified name.
     *
     * @param string $name
     * @return array
     */
    
protected function _prepareCategoryData($name)
    {
        return array(
            
'name'              => trim($name),
            
'is_active'         => 1,
            
'include_in_menu'   => 1,
            
'is_anchor'         => 0,
            
'url_key'           => '',
            
'des*****ion'       => '',
            
'display_mode'      => PAGE,
            
'page_layout'        => one_column,
        );
    }

    
/**
     * Creates new category.
     *
     * @param int    $parentId
     * @param string $name
     * @param int    $storeId
     * @return Mage_Catalog_Model_Category
     */
    
protected function _createCategory($parentId$name$storeId)
    {
        
$category Mage::getModel('catalog/category');
        
/* @var $category Mage_Catalog_Model_Category */

        
$data $this->_prepareCategoryData($name);
        
$parent Mage::getModel('catalog/category')->load($parentId);

        
$category->setData($data)
            ->
setAttributeSetId($category->getDefaultAttributeSetId())
            ->
setStoreId($storeId)
            ->
setPath(implode('/'$parent->getPathIds()))
            ->
setParentId($parentId)
            ->
save();

        return 
$category;
    }

    
/**
     * Process some stuff before running categories import.
     */
    
protected function _beforeProcess()
    {
        
// Needed for correct creation of categories url rewrites.
        
$processes Mage::getSingleton('index/indexer')->getProcessesCollection();
        
$processes->walk('setMode', array(Mage_Index_Model_Process::MODE_MANUAL));
        
$processes->walk('save');
    }

    
/**
     * Process some stuff after running categories import.
     */
    
protected function _afterProcess()
    {
        
$processes Mage::getSingleton('index/indexer')->getProcessesCollection();
        
$processes->walk('setMode', array(Mage_Index_Model_Process::MODE_REAL_TIME));
        
$processes->walk('save');

        echo 
PHP_EOL 'Reindexing all...' PHP_EOL;
        
$processes->walk('reindexAll');
    }

    
/**
     * Displays critical message and exit.
     */
    
protected function _fault($msg)
    {
        exit(
PHP_EOL $msg PHP_EOL);
    }

    
/**
     * Main s***** method that imports all categories from specified CSV file.
     */
    
public function run()
    {
        
$start microtime(true);

        if (!
$file $this->getArg('f')) {
            echo 
$this->usageHelp();
        } else {
            
$delimiter $this->getArg('d') ? $this->getArg('d') : ',';
            
$enclosure $this->getArg('e') ? $this->getArg('e') : '"';

            
$file Mage::getBaseDir() . '/' $file;
            if (!
file_exists($file)) {
                
$this->_fault("File $file doest not exists.");
            } elseif (!
is_readable($file)) {
                
$this->_fault("File $file is not readable.");
            }

            
$collection Mage::getModel('catalog/category')->getCollection()
                ->
addFieldToFilter('level'2);
            if (
$collection->count() > 0) {
                if (!
$this->getArg('force')) {
                    
$this->_fault('Categories already created. Use --force option to delete old categories automatically.');
                } else {
                    
$collection->walk('delete');
                    echo 
'Deleted old categories' PHP_EOL;
                }
            }

            
$fh fopen($file'r');
            if (!
$fh) {
                
$this->_fault("An error occured opening file $file.");
            }

            try {
                
$line 0;
                
$otherStoreCodes = array();
                
$rootId Mage::app()->getDefaultStoreView()->getRootCategoryId();
                
$parentIds = array(=> $rootId);

                
$this->_beforeProcess();

                while (
$data fgetcsv($fhnull$delimiter$enclosure)) {
                    
$line++;

                    if (
$line === && ($this->getArg('t') || empty($data[0]))) {
                        
$otherStoreCodes array_filter($data); // will keep store column number and store code
                        
continue;
                    }

                    foreach (
$data as $i => $value) {
                        if (!empty(
$otherStoreCodes) && $i >= min(array_keys($otherStoreCodes))) {
                            break;
                        }
                        
$label trim($value);
                        if (empty(
$label)) {
                            continue;
                        }
                        
$parentId $parentIds[$i];
                        
$category $this->_createCategory($parentId$label0);
                        
$parentIds[$i 1] = $category->getId();
                        echo 
str_repeat('--'$i 1) . ' ' $label;
                        foreach (
$otherStoreCodes as $j => $storeCode) {
                            
$label trim($data[$j]);
                            if (!empty(
$label)) {
                                
$category->setStoreId($this->_getStore($storeCode)->getId())
                                    ->
setUrlKey('')
                                    ->
setName($label)
                                    ->
save();
                                
printf(' [%s: %s]'$storeCode$label);
                            }
                        }
                        echo 
PHP_EOL;
                    }
                }

                
$this->_afterProcess();
            } catch (
Exception $e) {
                
Mage::logException($e);
                
$this->_fault($e->getMessage());
            }
        }

        
$end microtime(true);
        
$time $end $start;
        echo 
PHP_EOL;
        echo 
'S***** Start: ' date('H:i:s'$start) . PHP_EOL;
        echo 
'S***** End: ' date('H:i:s'$end) . PHP_EOL;
        echo 
'Duration: ' number_format($time3) . ' sec' PHP_EOL;
    }

    
/**
     * List of available s***** options.
     *
     * @return string
     */
    
public function usageHelp()
    {
        return <<< USAGE
Usage:  php -f import_categories.php -- [options]

  -f            File to import
  -d            Delimiter (default is ,)
  -e            Enclosure (default is ")
  -t            Enable store translations in first line
  --force       Delete old categories and create new ones
  -h            Short alias for help
  help          This help

USAGE;
    }
}

if (
php_sapi_name() != 'cli') {
    exit(
'Run it from cli.');
}

$shell = new Mage_Shell_ImportCategories();
$shell->run();

den safemod hab ich schon mit on / off getestet. an was kann das liegen?

mfg

scandic 20.01.13 16:16

Also die Fehlermeldung ist eindeutig und als der Fehler auftrat, war der SafeMode noch aktiv.
Wie hast Du das S***** denn genau aufgerufen?


Alle Zeitangaben in WEZ +1. Es ist jetzt 02:18 Uhr.

Powered by vBulletin® (Deutsch)
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.