не работещ скрипт на пхп 5

go6o78

Registered
минах на пхп5 и един компонент спря да ми работи пълноценно
компонента е за рецепти сайта на Joomla
когато е само една категория всичко е ок, но когато има подкатегории
неработи
мисля, че това е проблемния код
с пхп4 работи екстра, но вече не ми върши работа
Код:
 #######################################################
### Function ShowDropDownCategoryList
#######################################################		
	function ShowDropDownCategoryList ($cat, $cname = "cat", $extra = null, $flag = 0) {
	global $database, $ric_category, $gid, $Itemid, $category_list;
	$arr_cat = explode(",", $ric_category);
	$category = "<select name=\"$cname\" class=\"inputbox\" $extra>";

				if ($flag == 1) {
					$add_category = true;
				}

				if (@$add_category) {
					$category .= "<OPTION VALUE=0></OPTION>";
				} else {
					$category .= "<OPTION VALUE='0'></OPTION>";
				}
					$query = "select * from #__ricettario_catg \n where access<='" . $gid . "'" . "\nORDER BY name asc";

				$database->setQuery($query);
				$result = $database->query();
				$num_rows = mysql_num_rows($result);
				$i = 0;

					while ($i < $num_rows) {
						$category_id = mysql_result($result, $i, "cid");
						$category_name = mysql_result($result, $i, 'name' . @$mosConfig_lang);

				if (in_array($category_id, $arr_cat)) { @$category_list .= "<OPTION  VALUE='$category_id' ";

				if ($category_id == $cat) {
					$category_list .= " SELECTED";
		}

					$category_list .= ">" . ShowCategoryPath($category_id) . "</OPTION>\n";
	}

					$i++;
	}
					$categories = explode("\n", $category_list);
					asort($categories);
					$category .= implode("\n", $categories);

					$category .= "</select>";
					return $category;
	}

	
#######################################################
### Function ShowDropDownCategoryList
#######################################################			
	function dmoz ($catid, $Itemid) {
	global $database, $travelConfig, $task, $gid, $Itemid, $RICETTE;

			$database->setQuery("SELECT d.* "
			. " \n FROM #__ricettario_catg AS d "
			. " \n WHERE d.parent=$catid and d.published=1 \n "
			. " \n ORDER BY d.ordering DESC ");
			$rows = $database->loadObjectList();
			$num_rows = ceil(count($rows) / 3);
			$index = 0;
			$output = '<table cellspacing="0" cellpadding="4" border="0" width="100%">';
			$output .= '<tr>';
			$output .= '<td align="left">';
			$output .= "<strong>$RICETTE->RICETTE_0112</strong>";
			$output .= '</td>';
			$output .= '</tr>';
			$output .= '';
				for ($row_count = 0; $row_count < $num_rows; $row_count++) {
			$output .= '<tr >';
				for ($col_count = 0; $col_count < 3; $col_count++) {
			$output .= '<td width="' . floor(100 / 3) . '%" valign="top">';
			$cur_name = $rows[$index];

				if (trim($cur_name) == "") {
					$output .= '&nbsp';
				} else {
					$output .= '<img src="images/M_images/arrow.png"><a href="' . sefRelToAbs("index.php?option=com_ricettario&func=viewcategory&Itemid=$Itemid&catid=$cur_name->cid") . '">' . $cur_name->name . ' (' . GetNumberOfLinks($cur_name->cid) . ')</a>';

				if ($cur_name->access > 1) {
					$output .= " <small>[ $RICETTE->RICETTE_0044 ]</small>";
				} else if ($cur_name->access > 0) {
					$output .= " <small>[ $RICETTE->RICETTE_0045 ]</small>";
			}
	}
		$index++;
					$output .= '<br>' . $cur_name->description . '</td>';
			}
					$output .= '</tr>';
	}
					$output .= '</table>';
					return $output;
	}

	
#######################################################
### Function ShowCategoryPathLink
#######################################################		
	function ShowCategoryPathLink ($cat) {
    global $database, $mosConfig_lang, $gid, $Itemid, $RICETTE;

			$cat = intval($cat);
			$parent_id = 1000;

					while ($parent_id) {
					$query = "select * from #__ricettario_catg where cid=$cat and published=1 \n AND access<='" . $gid . "'";

						$database->setQuery($query);
						$result = $database->query();
						$parent_id = @mysql_result($result, 0, 'parent');
						$cid = @mysql_result($result, 0, 'cid');
						$name="<a href='" . sefRelToAbs("index.php?option=com_ricettario&Itemid=$Itemid&func=viewcategory&catid=$cat" )."'>" . @mysql_result( $result,0,'name' ) . "</a>";
                    // write path
						if (empty($path)) {
							$path = $name;
						} else {
							$path = $name . ' » ' . $path;
					}

                    // next looping
						$cat = $parent_id;
			}

						$home = "<a href='" . sefRelToAbs("index.php?option=com_ricettario&Itemid=$Itemid") . "'></a>";
						$pathName = $home . ' » ' . $path . " ";
					return $pathName;
		}
		
#######################################################
### Function GetNumberOfLinks
#######################################################			
	function GetNumberOfLinks ($cat) {
	global $database, $gid, $Itemid;
				$queue[] = intval($cat);
					while (list($key, $cat) = each($queue)) {
				$query = "select cid from #__ricettario_catg where parent=$cat and published=1";

					$database->setQuery($query);
					$result = $database->query();
					$total = mysql_num_rows($result);
				$j = 0;

					while ($j < $total) {
				$val = mysql_fetch_row($result);
				$queue[] = $val[0];
				$j++;
		}
	}

		reset($queue);
				$query = "SELECT count(id) as count FROM #__ricettario  where ( 0!=0";
					while (list($key, $cat) = each($queue)) {
				$query .= " or catid = $cat";
	}
				$query = $query . " ) and published=1 AND approved = 1";

			$database->setQuery($query);
			$result = $database->query();
			$val = mysql_fetch_row($result);
			return $val[0];
	}

#######################################################
### Function GetNumberOfLinks
#######################################################		
	function ShowCategoryPath ($cat) {
	global $database, $mosConfig_lang, $gid, $Itemid;
	$cat = intval($cat);
	$parent_id = 1000;

			while ($parent_id) {
				$query = "select * from #__ricettario_catg where cid=$cat \n AND access<='" . $gid . "'";

					$database->setQuery($query);
					$result = $database->query();
					$parent_id = @mysql_result($result, 0, 'parent');
					$name = @mysql_result($result, 0, 'name');

            // write path
				if (empty($path)) {
					$path = $name;
				} else {
					$path = $name . ' » ' . $path;
			}
            // next looping
				$cat = $parent_id;
		}
				return $path . ' ';
	}
 
освен горния скрипт за функциите намерих и този, които може също да има отношение по въпроса ( и двата са от един и същ файл и затова не го пействам целия)

не съм много запознат с пхп но фукцията спира тук
Код:
  <?php
            if ($catid <> "") {
            echo ShowCategoryPathLink($catid);
            } else if ($id) {
            $database->setQuery("SELECT a.*, cc.name AS category "
            . " \nFROM #__ricettario AS a, #__ricettario_catg AS cc "
            . " \nWHERE a.catid=cc.cid AND a.id=$id "
            . " \n AND cc.access<='$gid'");
      
            $rows = $database->loadObjectList();
            $row = &$rows[0];
            echo ShowCategoryPathLink($row->catid);
      }
                  echo "</td>";
                  echo "<td align='right' class='directorypath' valign='middle'>";
                  echo "<INPUT TYPE='hidden' NAME='option' value='com_ricettario'><INPUT TYPE='hidden' NAME='Itemid' value='$Itemid'>";
                  echo "<INPUT TYPE='hidden' NAME='func' value='special'><INPUT TYPE='hidden' NAME='sorting' value='find'>";
                  echo "<input type='text' name='sstring' class='inputbox' onBlur=\"if(this.value=='') this.value='';\" onFocus=\"if(this.value=='".$RICETTE->RICETTE_0040."') this.value='';\" value='".$RICETTE->RICETTE_0040."'>";
                  echo "</td>";
                  echo "</tr></table></form></td></tr><tr><td align='right'>";
      if ($ric_showpanel) {
      if (!$my->username) {
                  echo "";
                  } else {
                  echo "<a href='" . sefRelToAbs("index.php?option=com_ricettario&func=userpannel&Itemid=$Itemid") . "'><strong>".$RICETTE->RICETTE_0114."</strong></a> ";
      }
                  echo "<img src='components/com_ricettario/images/bon.gif' border='0' alt='' align='absmiddle' hspace='6'> <a href='" . sefRelToAbs("index.php?option=com_ricettario&func=special&sorting=lastadd&Itemid=$Itemid") . "'>".$RICETTE->RICETTE_0032."</a>";
                  echo "<img src='components/com_ricettario/images/bon.gif' border='0' alt='' align='absmiddle' hspace='6'><a href='" . sefRelToAbs("index.php?option=com_ricettario&func=special&sorting=hits&Itemid=$Itemid") . "'>".$RICETTE->RICETTE_0034."</a>";
                  echo "<img src='components/com_ricettario/images/bon.gif' border='0' alt='' align='absmiddle' hspace='6'> <a href='" . sefRelToAbs("index.php?option=com_ricettario&func=special&sorting=rating&Itemid=$Itemid") . "'>".$RICETTE->RICETTE_0033."</a>";
                  echo "</td></tr><tr><td>";
      
      return;
            }
      }

#######################################################
### Funzione Footer
#######################################################            
      
      function GalleryFooter (){
            global $RICETTE;
            echo "</td></tr>";
      ?>

ето и линк към сайта
Код:
http://novini.bgstuff.net/index.php?option=com_ricettario&func=viewcategory&Itemid=58&catid=1
 

Back
Горе