Jump to content

Handling Directory and Files


danielshamir

Recommended Posts

Hi

 

I am having a problem with my code.

I does not read files from some reason.

 

Can someone give me a idea?

 

Thanks

 

my code is here:

<?php

  $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));

  $directory_array = array();

  if ($dir = @dir($module_directory)) {

    while ($file = $dir->read()) {

      if (!is_dir($module_directory . $file)) {

        if (substr($file, strrpos($file, '.')) == $file_extension) {

          $directory_array[] = $file;

        }

      }

    }

    sort($directory_array);

    $dir->close();

  }

  $installed_modules = array();

  for ($i=0, $n=sizeof($directory_array); $i<$n; $i++) {

    $file = $directory_array[$i];

    include(DIR_FS_CATALOG_LANGUAGES . $language . '/modules/' . $module_type . '/' . $file);

    include($module_directory . $file);

 

    $class = substr($file, 0, strrpos($file, '.'));

    if (tep_class_exists($class)) {

      $module = new $class;

      if ($module->check() > 0) {

        if ($module->sort_order > 0) {

          $installed_modules[$module->sort_order] = $file;

        } else {

          $installed_modules[] = $file;

        }

      }

 

      if ((!isset($HTTP_GET_VARS['module']) || (isset($HTTP_GET_VARS['module']) && ($HTTP_GET_VARS['module'] == $class))) && !isset($mInfo)) {

        $module_info = array('code' => $module->code,

                            'title' => $module->title,

                            'description' => $module->description,

                            'status' => $module->check());

 

        $module_keys = $module->keys();

 

        $keys_extra = array();

        for ($j=0, $k=sizeof($module_keys); $j<$k; $j++) {

          $key_value_query = tep_db_query("select configuration_title, configuration_value, configuration_description, use_function, set_function from " . TABLE_CONFIGURATION . " where configuration_key = '" . $module_keys[$j] . "'");

          $key_value = tep_db_fetch_array($key_value_query);

 

          $keys_extra[$module_keys[$j]]['title'] = $key_value['configuration_title'];

          $keys_extra[$module_keys[$j]]['value'] = $key_value['configuration_value'];

          $keys_extra[$module_keys[$j]]['description'] = $key_value['configuration_description'];

          $keys_extra[$module_keys[$j]]['use_function'] = $key_value['use_function'];

          $keys_extra[$module_keys[$j]]['set_function'] = $key_value['set_function'];

        }

 

        $module_info['keys'] = $keys_extra;

 

        $mInfo = new objectInfo($module_info);

      }

 

      if (isset($mInfo) && is_object($mInfo) && ($class == $mInfo->code) ) {

        if ($module->check() > 0) {

          echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class . '&action=edit') . '\'">' . "\n";

        } else {

          echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)">' . "\n";

        }

      } else {

        echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class) . '\'">' . "\n";

      }

?>

Link to comment
Share on other sites

Hi

 

I am having a problem with my code.

I does not read files from some reason.

 

geting the message :

 

Warning: dir(includes/modules/payment/): failed to open dir: No such file or directory in /home/content/d/a/n/danielshamir/html/admin/modules.php on line 107

 

Can someone give me a idea?

 

Thanks

 

my code is here:

<?php

  $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));

  $directory_array = array();

  if ($dir = dir($module_directory)) {

    while ($file = $dir->read()) {

      if (!is_dir($module_directory . $file)) {

        if (substr($file, strrpos($file, '.')) == $file_extension) {

          $directory_array[] = $file;

        }

      }

    }

    sort($directory_array);

    $dir->close();

  }

  $installed_modules = array();

  for ($i=0, $n=sizeof($directory_array); $i<$n; $i++) {

    $file = $directory_array[$i];

    include(DIR_FS_CATALOG_LANGUAGES . $language . '/modules/' . $module_type . '/' . $file);

    include($module_directory . $file);

 

    $class = substr($file, 0, strrpos($file, '.'));

    if (tep_class_exists($class)) {

      $module = new $class;

      if ($module->check() > 0) {

        if ($module->sort_order > 0) {

          $installed_modules[$module->sort_order] = $file;

        } else {

          $installed_modules[] = $file;

        }

      }

 

      if ((!isset($HTTP_GET_VARS['module']) || (isset($HTTP_GET_VARS['module']) && ($HTTP_GET_VARS['module'] == $class))) && !isset($mInfo)) {

        $module_info = array('code' => $module->code,

                             'title' => $module->title,

                             'description' => $module->description,

                             'status' => $module->check());

 

        $module_keys = $module->keys();

 

        $keys_extra = array();

        for ($j=0, $k=sizeof($module_keys); $j<$k; $j++) {

          $key_value_query = tep_db_query("select configuration_title, configuration_value, configuration_description, use_function, set_function from " . TABLE_CONFIGURATION . " where configuration_key = '" . $module_keys[$j] . "'");

          $key_value = tep_db_fetch_array($key_value_query);

 

          $keys_extra[$module_keys[$j]]['title'] = $key_value['configuration_title'];

          $keys_extra[$module_keys[$j]]['value'] = $key_value['configuration_value'];

          $keys_extra[$module_keys[$j]]['description'] = $key_value['configuration_description'];

          $keys_extra[$module_keys[$j]]['use_function'] = $key_value['use_function'];

          $keys_extra[$module_keys[$j]]['set_function'] = $key_value['set_function'];

        }

 

        $module_info['keys'] = $keys_extra;

 

        $mInfo = new objectInfo($module_info);

      }

 

      if (isset($mInfo) && is_object($mInfo) && ($class == $mInfo->code) ) {

        if ($module->check() > 0) {

          echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class . '&action=edit') . '\'">' . "\n";

        } else {

          echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)">' . "\n";

        }

      } else {

        echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class) . '\'">' . "\n";

      }

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.