News:

Please note these forums are mostly a testing ground for my SMF work and I don't really use them otherwise.

Main Menu

Paste-1209013610:v:use_geshi-1:v:type-php

Started by SleePy, Apr 24, 2008, 05:06 AM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

SleePy

// Get a single mod loaded and looking nice
function scRetrieveHack($modID)
{
   global $scSet, $scTxt, $scout;

   // If this occurs it is messed up.
   $modID = (int) $modID;
   $mod = $scSet['hacks']['list'][$modID];
   $file_path = $scSet['hacks']['path'] . '/' . $mod['filename'];

   $scout['customization'] = array(
      'id' => $mod['id'],
      'name' => $mod['name'],
      'file_path' => $file_path,
      'can_access' => $mod['access'] == 0 || ($mod['access'] == 1 && $scSet['l']['is_logged']) || ($mod['access'] == 2 && $scSet['l']['is_admin']),
      'access_level' => $mod['access'],
      'is_legacy' => isset($mod['legacy']) ? $mod['legacy'] : FALSE,
      'version_support' => isset($mod['version_support']) ? $mod['version_support'] : FALSE,
      'modsite' => array(
            'id' => isset($mod['smfmod_id']) ? $mod['smfmod_id'] : 0,
            'href' => 'http://custom.simplemachines.org/mods/index.php?mod=' . $mod['smfmod_id'],
      ),
   );

   // Do we have a readme?
   if (file_exists($file_path . '/Readme.txt'))
      $scout['customization']['readme'] = str_replace(array("\r", "\n"), '
', implode('', file($file_path . '/Readme.txt')));
   else
      $scout['customization']['readme'] = $scTxt['hacks']['lostdes'] . '
' . $mod['qdescription'];

   // How about some files?
   $scout['customization']['files'] = array();
   if (is_dir($file_path . '/releases'))
   {
      $handle = opendir($file_path . '/releases');
      while ($file = readdir($handle))
      {
         // Ignore the return folder and index files
          if (substr($file, 0, 1) == '.' || substr($file, 0, 5) == 'index')
                continue;

         // We are files...
         if (is_file($file_path . '/releases/' . $file))
            $scout['customization']['files'][] = array(
               'name' => $file,
               'href' => $scSet['urli'], '?action=hacks;file;id=', $scout['customization']['id'], ';name=', $file,
               );
      }
      closedir ($handle);
   }

   // How about some images into the pot?
   $scout['customization']['images'] = array();
   if (is_dir($file_path . '/releases/images'))
   {
      $files = array();

      $handle= opendir($file_path . '/releases/images');
      while ($file = readdir($handle))
      {
         // Ignore the return folder and index files
             if (substr($file, 0, 1) == '.' || substr($file, 0, 5) == 'index')
                 continue;
      
         // We are files...
         if (is_file($file_path . '/releases/images/' . $file))
            $scout['customization']['images'][] = array(
                  'name' => $file,
                  'href' => $scSet['urli'] . '?action=hacks;image;id=' . $mod['id'] . ';name=' . $file
                  );
      }

      // Done with the files? Close it to save php..
      closedir ($handle);
   }

   // Its Gone!
   scTheme('Hacks', 'Hack');
}
No siggy! :D