Foros del Web » Programando para Internet » PHP »

Problemas con PHP 5.3.10

Estas en el tema de Problemas con PHP 5.3.10 en el foro de PHP en Foros del Web. Bueno les cuento, estoy armando un sitio de fans de Britney Spears, y tendrá una seccion de avatares/iconos, con el script Icon Sort. www.britney-galaxy.com/icons Ven ...
  #1 (permalink)  
Antiguo 04/06/2012, 16:42
 
Fecha de Ingreso: octubre-2011
Mensajes: 4
Antigüedad: 12 años, 5 meses
Puntos: 0
Problemas con PHP 5.3.10

Bueno les cuento, estoy armando un sitio de fans de Britney Spears, y tendrá una seccion de avatares/iconos, con el script Icon Sort.

www.britney-galaxy.com/icons

Ven el error del eregi() ?

Alguna solucion? gracias, a continuacion les dejo el codigo:

Código:
              <?php
/*

ICON SORT
------------------------------------------------
A Quick and Easy PHP Icon Management Script by Julie (http://new-place.org/)

This script is free for non-commercial use and may be modified for personal use.  Please do not distribute modified copies of this script without my permission.  You may not sell this script or modified versions of it under any circumstances.

As provided, this script is valid XHTML 1.0 transitional.  The only requirement is PHP support (no database needed)!


UPDATES
------------------------------------------------
February 7, 2005 - Fixed the pagination to work with register_globals off.  Added file setup example to the instructions and tidied up the code in general.

September 2, 2005 - Two new features added!  It is now possible to display the icon count per category on the menu, and/or to paginate the individual category pages.  There are three new config variables.


SETUP INSTRUCTIONS
------------------------------------------------
Icon Sort can be installed in a new directory created specifically for this script, or you can put it in an existing directory that holds other files.  You can safely rename this file to whatever you'd like it to be called!

1.) Create a folder named "categories" in the same directory where this file will go.  If you don't want to call it "categories," edit the $catdir config variable (below the instructions) to the name you choose.

2.) Inside the "categories" folder, create a folder for each category of icons you want.  If there are spaces in the category name, replace them with underscores.  For example, instead of "Veronica Mars" use "Veronica_Mars."  (Replacing spaces with underscores is optional, but recommended, as it creates cleaner, more compatible links.  The underscores will not show up on the page.)  Upload your icons into their respective category folders.

   An example of the setup:
   yoursite.com/icons.php  <- this file
   yoursite.com/categories/  <- the categories folder
   yoursite.com/categories/Veronica_Mars  <- the individual category folders go inside that folder

3.) If desired, change the "sort" config variable (below the instructions) from 'first' to 'last' if you prefer new icons to be added to the bottom of the page.  By default, the newest icons added to a category are shown first on the category page. 

4.) Edit the "getcount," "perpage," and "divider" variables as desired.  None of them has to be changed for the script to work, but they allow you to customize the setup.

5.)  Edit or replace the header and footer at the top and bottom of this file to fit your site.  Edit or remove the paragraph above the menu (scroll down and find "<!-- Content Above Menu -->").  Upload this file.  That's it!


CUSTOMIZATION AND SUPPORT
------------------------------------------------
There are a few built in CSS styles to help you style your page.  The menu <ul> is id="iconmenu", the category page menu <p> is class="pagemenu", the <p> that holds the icons is class="icons", and the <p> that holds the credit to my site is class="credit".

If you are having a problem, send in a contact form at my site (http://new-place.org/) or post at the CodeGrrl forums (http://codegrrl.com/) and I will try to help.
 

CONFIG VARIABLES
------------------------------------------------*/
$catdir = 'categories';  // the icon categories folder (see step 1)
$sort = 'first';         // set 'first' to show newest icons first, 'last' to show newest icons last
$getcount = true;        // true shows the icon count per category in the menu, and false turns it off
$perpage = 6;          // the number of icons shown on each page (set to a really high number to turn off pagination)
$divider = '&nbsp;';     // the divider between the numbers and front/back arrows in the page navigation


// DO NOT EDIT THE PHP BELOW THIS LINE.  Scroll down to edit the text above the menu, and to add your footer.
// ----------------------------------------------

// get category folders and sort
if (!file_exists($catdir)) {
	echo 'Error!  The folder named <strong>' . $catdir . '</strong>, as specified in the config, does not exist in this directory.  The value of the variable $catdir must match the name of the created folder (case-sensitive), and that folder must be in this directory for the script to work.  Create the folder and put the individual icon category folders inside it.';
	exit();
}
$getfolders = opendir($catdir);
while (($file = readdir($getfolders)) !== false) {
	if (($file != '.' && $file != '..') && (is_dir($catdir.'/'.$file))) {
		$cats[] = $file;
	}
}
if (!$cats) {
   echo 'No category folders were found inside the folder named <strong>' . $catdir . '</strong>.  Create your individual category folders inside that folder and the menu will appear.';
	exit();
}
natcasesort($cats);

// build main menu
if ((!$_GET['cat']) || (!in_array($_GET['cat'], $cats))) {
	?>
              <br>
              Welcome to the Icon Archive of Britney-Galaxy.COM. Here you will find a huge collection of Britney icons for you to use on your favourite forums, message boards, messenger, live journal, etc. Please  remember credit us, and don't re-distribute these as your own. Do you want to&nbsp;<a href="mailto: [email protected]">donate</a>?&nbsp; </p>
          </div>
            <p class="Estilo2">
              <?php
	echo '<ul id="iconmenu">';
	foreach ($cats as $value) {
		$catname = str_replace('_', ' ', $value);
      echo '<li><a href="' . $_SERVER['PHP_SELF'] . '?cat=' . $value . '">' . $catname . '</a>';
      if ($getcount) {
         $icons = array();
			$getcount = opendir($catdir . '/' . $value);
			while (($icon = readdir($getcount)) !== false) {
				if (eregi(".jpg$|.jpeg$|.gif$|.png$|.bmp$", $icon)) {
					$icons[] = $value;
				}
			}
			$count = count($icons);
         if ($count == 1) {
				echo ' (' . $count . ' icon)';
			} else {
				echo ' (' . $count . ' icons)';
			}
      }
      echo '</li>';
	}
	echo '</ul>';
}

// get icons and sort
if (in_array($_GET['cat'], $cats)) {
	$icons = array();
	$geticons = opendir($catdir.'/'.$_GET['cat']);
	while (($icon = readdir($geticons)) !== false) {
		if (eregi(".jpg$|.jpeg$|.gif$|.png$|.bmp$", $icon))
			$icons[] = array("name" => $icon, "modified" => filemtime($catdir . '/' . $_GET['cat'] . '/' . $icon));
		}
	}
	$count = count($icons);
	if ($count > 0) {
		function modcmp($a, $b) {
			return strcmp($a['modified'], $b['modified']);
		}
		usort($icons, 'modcmp');
		if ($sort == 'first') {
			$icons = array_reverse($icons);
		}

      // show category name and total icon count
		$catname = str_replace('_', ' ', $_GET['cat']);
      echo '<p><strong>' . $catname . ': ' . $count;
		if ($count == 1) {
			echo ' icon';
		} else {
         echo ' icons';
		}
		echo '</strong></p>';

      // configure pagination
		if ((!$perpage) || ($perpage < 1) || (!is_numeric($perpage))) {
			$perpage = 20;
		}
		$pagecalc = ($count / $perpage);
		$pagecount = ceil($pagecalc);
      $page = $_GET['page'];
		if (($page > $pagecount) || ($page == '0')) {
			$start = 0;
		} elseif (!$page) {
			$start = 0;
			$page = 1;
		} elseif (!is_numeric($page)) {
			$start = 0;
			$page = 1;
		} else {
			$start = (($page * $perpage) - $perpage);
		}
		$pagearray = array_slice($icons, $start, $perpage);

		// if there is more than one page, show the page menu
		if ($pagecount > 1) {
			if (($page <= $pagecount) && ($page > 1)) {
				$backpagecalc = ($page - 1);
            $backpage = '<a href="?cat=' . $_GET['cat'] . '&amp;page=' . $backpagecalc . '">&laquo;</a> ' . $divider;
			}
			if ($page < $pagecount) {
				$nextpagecalc = ($page + 1);
				$nextpage = $divider . ' <a href="?cat=' . $_GET['cat'] . '&amp;page=' . $nextpagecalc . '">&raquo;</a>';
			}
			echo '<p class="pagemenu">Pages: &nbsp;' . $backpage . ' ';
			$i = 1;
			while ($i <= $pagecount) {
            $pagespanstart = ((($i * $perpage) - $perpage) + 1);
            $pagespanend = ($i * $perpage);
            if ($i == $pagecount) {
               if ( $i == $page) {
                  echo $i;
               } else {
                  echo '<a href="?cat=' . $_GET['cat'] . '&amp;page=' . $i . '">' . $i . '</a>';
               }
            } else {
               if ($i == $page) {
                  echo $i . ' ' . $divider . ' ';
               } else {
                  echo '<a href="?cat=' . $_GET['cat'] . '&amp;page=' . $i . '">' . $i . '</a> ' . $divider . ' ';
               }
            }
            $i++;
			}			
			echo ' ' . $nextpage . '</p>';
		}
		
		// show the icons
		echo '<center><p class="icons">';
			foreach ($pagearray as $value) {
				$iconsize = getimagesize($catdir . '/' . $_GET['cat'] . '/' . $value['name']);
				echo '<img src="' . $catdir . '/' . $_GET['cat'] . '/' . $value['name'] . '" ' . $iconsize[3] . ' alt="" /> ';
			}
	} else {
		echo '<p>There are no icons in this category.';
	}
	echo '</p><p>&laquo; <a href="' . $_SERVER['PHP_SELF'] . '">back</a></p>';
?>
  #2 (permalink)  
Antiguo 05/06/2012, 19:55
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Respuesta: Problemas con PHP 5.3.10

eregi ya esta deprecado, necesitas migrar a expresiones regulares usando la librería preg para que funcione con tu versión de PHP.

Saludos.

Etiquetas: icon, sort
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:55.