Warning: usort() [function.usort]: Invalid comparison functi

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : Warning: usort() [function.usort]: Invalid comparison functi

Re: Warning: usort() [function.usort]: Invalid comparison functi

par stopher » 04 nov. 2009, 08:51

En fait ,

j'ai bien l'impression que ta fonction de trie

SortOnKeys ()

n'est pas accessible depuis l'endroit ou tu l'appelle ( usort )
usort($leftColDisplay, "SortOnKeys");
usort($rightColDisplay, "SortOnKeys"); 

Note : pour nous lecteur , utilises les balises \[php\] \[/php\] pour simplifier la lecture du code ...

Ch.

Re: Warning: usort() [function.usort]: Invalid comparison functi

par max-affaires » 03 nov. 2009, 23:02

bonsoir,

toujours pas résolu ce problème si quelqu'un a une piste merci

Re: Warning: usort() [function.usort]: Invalid comparison functi

par max-affaires » 31 oct. 2009, 23:05

c'est plutot sa que je voulais edité désolé

<?php
/*
$Id: sitemap_seo.php,v 1.0 2008/12/29
written by Jack_mcs at www.osocmmerce-solution.com

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright (c) 2008 osocmmerce-solution.com
Portions Copyright 2009 oscommerce-solution.com

Released under the GNU General Public License
*/

function GetBoxLinks($box)
{
$boxLinks = array();

if ($box != TEXT_MAKE_BOX_SELECTION)
{
$end = (substr(DIR_FS_CATALOG, 0, -1) !== '/') ? '/' : '';
$path = DIR_FS_CATALOG . $end . DIR_WS_BOXES . '/'. $box;
$lines = array();

if (GetFilesArray($path, $lines))
{
for ($i = 0, $idx = 0; $i < count($lines); ++$i)
{
if (eregi("<a(.*)</a", $lines[$i], $out))
{
if (eregi("tep_href_link((.*))", $out[1], $locn))
{
$boxLinks[$idx]['box'] = $box;

$link = trim(substr($locn[1], strpos($locn[1], "(") + 1, strpos($locn[1], ")") - 1));
$linkParts = explode(",", $link); //only use the first part of the link - removes SSL, etc.
$link = $linkParts[0];

if ($link === strtoupper($link))
$boxLinks[$idx]['link'] = $link;
else //link contains something like index.php, 'cPath=23'
{
$parts = explode("'", $link); //so break it up and try to put it back together so it can be used
$newLink = '';
for ($p = 0; $p < count($parts); ++$p)
{
if (empty($parts[$p]) || strpos($parts[$p], ",") !== FALSE)
continue;
$newLink = (empty($newLink)) ? $parts[$p] : $newLink . '?'. $parts[$p];
}
$boxLinks[$idx]['link'] = $newLink;
}

$text = substr($locn[1], strpos($locn[1], ">") + 1);

if (strpos($text, ".") !== FALSE)
$boxLinks[$idx]['text'] = trim(substr($text, strpos($text, ".") + 1, strrpos($text, ".")), " .'");
else
$boxLinks[$idx]['text'] = trim($text, " - '");

$idx++;
}
}
}
}
}

return $boxLinks;
}

function GetFileName($define) //retrieve the defined filename
{
$end = (substr(DIR_FS_CATALOG, 0, -1) !== '/') ? '/' : '';
$file = DIR_FS_CATALOG . $end . DIR_WS_INCLUDES . 'filenames.php';
$fp = @file($file);

for ($idx = 0; $idx < count($fp); ++$idx)
{
if (strpos($fp[$idx], $define) !== FALSE)
{
$parts = explode("'", $fp[$idx]);
return $parts[3];
}
}
return NULL;
}

function GetFilesArray($path, &$lines) //use curl if possible to read in site information
{
global $messageStack;

$lines = array();

if (! function_exists('curl_init'))
{
$path = $admin_dir . '/' . $path;
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $path);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_USERPWD, $username.':'.$password);
$file_contents = curl_exec($ch);
curl_close($ch);
$lines = explode("\n", $file_contents);
return true;
}
else
{
if ($fd = @fopen ($path, "r"))
{
while (!feof ($fd))
{
$buffer = fgets($fd, 4096);
$lines[] = $buffer;
}
fclose ($fd);
}
else
return false;
}

return true;
}

function GetNameFromDefine($define, $languageName) //return the defined name
{
$end = (substr(DIR_FS_CATALOG, 0, -1) !== '/') ? '/' : '';
$path = DIR_FS_CATALOG . $end .DIR_WS_LANGUAGES . $languageName . '.php';
$lines = array();

if (GetFilesArray($path, $lines))
{
$cnt = count($lines);
for ($i = 0; $i < $cnt; ++$i)
{
if (strpos($lines[$i], $define) !== FALSE)
{
$parts = explode(",", $lines[$i]);
$parts[1] = str_replace("\'", "xyz", $parts[1]); //save any required apostrophes before stipping
$name = explode("'", $parts[1]); //strip the apostrophes
$name[1] = str_replace("xyz", "'", $name[1]); //add back the required ones
return trim($name[1]);
}
}
}

return $define;
}

function in_multi_array($needle, $haystack)
{
$in_multi_array = false;
if(in_array($needle, $haystack))
{
$in_multi_array = true;
}
else
{
foreach ($haystack as $key => $val)
{
if(is_array($val))
{
if (in_multi_array($needle, $val))
{
$in_multi_array = true;
break;
}
}
}
}
return $in_multi_array;
}

function IsViewable($file)
{
if (($fp = @file($file)))
{
for ($idx = 0; $idx < count($fp); ++$idx)
{
if (strpos($fp[$idx], "<head>") !== FALSE)
return true;
}
}
return false;
}

function SortOnKeys($a, $b) {
return strnatcasecmp($a["sortkey"], $b["sortkey"]);
}
?>

Re: Warning: usort() [function.usort]: Invalid comparison functi

par max-affaires » 31 oct. 2009, 00:40

voici le fichier complet

Code : Tout sélectionner

<?php // RCI code start echo $cre_RCI->get('global', 'top'); echo $cre_RCI->get('sitemap', 'top'); // RCI code eof ?> <?php /****************** DISPLAY ARTICLES MANAGER LINKS *********************/ $showArticlesManager = ''; if (count($articlesManagerLinksArray) > 0) { if (tep_not_null($settings['heading_articles_manager'])) { $showArticlesManager .= '<tr><th class="sitemapHeading" align="' . SITEMAP_SEO_HEADING_ALIGNMENT . '">' . $settings['heading_articles_manager'] . '</td></tr>'; } $showArticlesManager .= '<tr><td width="50%" class="sitemap"><ul class="sitemap">'; $pageCount = count($articlesManagerLinksArray); for ($i = 0; $i < $pageCount; ++$i) $showArticlesManager .= '<li><a class="sitemap" href="' . tep_href_link(FILENAME_ARTICLE_INFO, 'articles_id=' . $articlesManagerLinksArray[$i]['link']) .'" title="' . $articlesManagerLinksArray[$i]['anchor_text'] . '">' . $articlesManagerLinksArray[$i]['text'] . '</a></li>'; $showArticlesManager .= '</ul></td></tr>'; } /****************** DISPLAY CATEGORIES *********************/ $showCategories = ''; if (tep_not_null($settings['heading_categories'])) { $showCategories .= '<tr><th class="sitemapHeading" align="' . SITEMAP_SEO_HEADING_ALIGNMENT . '">' . $settings['heading_categories'] . '</td></tr>'; } $showCategories .= '<tr><td class="sitemap">'; $class = (SITEMAP_SEO_DISPLAY_PRODUCTS_CATEGORIES == 'true') ? 'category_tree.php' : 'category_tree_no_products.php'; require DIR_WS_CLASSES . $class; $osC_CategoryTree = new osC_CategoryTree; $showCategories .= $osC_CategoryTree->buildTree(); $showCategories .= '</td></tr>'; /****************** DISPLAY INFOPAGES LINKS *********************/ $showInfoPages = ''; if (count($infoPagesArray) > 0) { if (tep_not_null($settings['heading_infopages'])) { $showInfoPages .= '<tr><th class="sitemapHeading" align="' . SITEMAP_SEO_HEADING_ALIGNMENT . '">' . $settings['heading_infopages'] . '</td></tr>'; } $showInfoPages .= '<tr><td width="50%" class="sitemap"><ul class="sitemap">'; $pageCount = count($infoPagesArray); for ($i = 0; $i < $pageCount; ++$i) $showInfoPages .= '<li><a class="sitemap" href="' . tep_href_link(FILENAME_INFORMATION, 'info_id='. $infoPagesArray[$i]['link']) .'" title="' . $infoPagesArray[$i]['anchor_text'] . '">' . $infoPagesArray[$i]['text'] . '</a></li>'; $showInfoPages .= '</ul></td></tr>'; } /****************** DISPLAY MANUFACTURERS *********************/ $showManufacturers = ''; if (count($manufacturersArray) > 0) { if (tep_not_null($settings['heading_manufacturers'])) { $showManufacturers .= '<tr><th class="sitemapHeading" align="' . SITEMAP_SEO_HEADING_ALIGNMENT . '">' . $settings['heading_manufacturers'] . '</td></tr>'; } $showManufacturers .= '<tr><td width="50%" class="sitemap"><ul class="sitemap">'; $pageCount = count($manufacturersArray); for ($i = 0; $i < $pageCount; ++$i) { $showManufacturers .= '<li><a class="sitemap" href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $manufacturersArray[$i]['link']) .'" title="' . $manufacturersArray[$i]['anchor_text'] . '">' . $manufacturersArray[$i]['text'] . '</a></li>'; $cnt = count($manufacturersArray[$i]['productArray']); if ($cnt > 0) { $showManufacturers .= '<ul>'; for ($p = 0; $p < $cnt; ++$p) { $pA = $manufacturersArray[$i]['productArray'][$p]; //makes it more readable $showManufacturers .= '<li><a class="sitemapProducts" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $pA['link']) .'" title="' . $pA['anchor_text'] . '">' . $pA['text'] . '</a></li>'; } $showManufacturers .= '</ul>'; } } $showManufacturers .= '</ul></td></tr>'; } /****************** DISPLAY PAGEMANAGER LINKS *********************/ $showPageManager = ''; if (count($pageManagerLinksArray) > 0) { if (tep_not_null($settings['heading_page_manager'])) { $showPageManager .= '<tr><th class="sitemapHeading" align="' . SITEMAP_SEO_HEADING_ALIGNMENT . '">' . $settings['heading_page_manager'] . '</td></tr>'; } $showPageManager .= '<tr><td width="50%" class="sitemap"><ul class="sitemap">'; $pageCount = count($pageManagerLinksArray); for ($i = 0; $i < $pageCount; ++$i) $showPageManager .= '<li><a class="sitemap" href="' . tep_href_link(FILENAME_PAGES, 'page=' . $pageManagerLinksArray[$i]['link']) .'" title="' . $pageManagerLinksArray[$i]['anchor_text'] . '">' . $pageManagerLinksArray[$i]['text'] . '</a></li>'; $showPageManager .= '</ul></td></tr>'; } /****************** DISPLAY STANDARD INFOBOXES LINKS *********************/ $showInfoBoxes = ''; if (count($boxDataArray) > 0) { if (tep_not_null($settings['heading_standard_boxes'])) { $showInfoBoxes .= '<tr><th class="sitemapHeading" align="' . SITEMAP_SEO_HEADING_ALIGNMENT . '">' . $settings['heading_standard_boxes'] . '</td></tr>'; } $showInfoBoxes .= '<tr><td width="50%" class="sitemap"><ul class="sitemap">'; $showInfoBoxes .= '<li>'.$boxDataArray[0]['heading'].'</li><ul>'; $pageCount = count($boxDataArray); for ($i = 0; $i < $pageCount; ++$i) $showInfoBoxes .= '<li><a class="sitemap" href="' . tep_href_link($boxDataArray[$i]['link']) .'" title="' . $boxDataArray[$i]['anchor_text'] . '">' . $boxDataArray[$i]['text'] . '</a></li>'; $showInfoBoxes .= '</ul></ul></td></tr>'; } /****************** DISPLAY STANDARD PAGES *********************/ $showPages = ''; if (count($pagesArray) > 0) { if (tep_not_null($settings['heading_standard_pages'])) { $showPages .= '<tr><th class="sitemapHeading" align="' . SITEMAP_SEO_HEADING_ALIGNMENT . '">' . $settings['heading_standard_pages'] . '</td></tr>'; } $showPages .= '<tr><td width="50%" class="sitemap"><ul class="sitemap">'; $pageCount = count($pagesArray); if ($pageCount > 0) for ($b = 0; $b < $pageCount; ++$b) $showPages .= '<li><a class="sitemap" title="'. $pagesArray[$b]['anchor_text'] .'" href="' . tep_href_link($pagesArray[$b]['link']) . '">' . $pagesArray[$b]['text'] . '</a></li>'; $showPages .= '</ul></td></tr>'; } /****************** BUILT THE DISPLAY *********************/ $leftColDisplay = array(); $rightColDisplay = array(); $sortOrderArray = array(array('placement' => SITEMAP_SEO_MODULE_PLACEMENT_ARTICLES_MANAGER, 'sortkey' => SITEMAP_SEO_SORTORDER_ARTICLES_MANAGER, 'module' => $showArticlesManager), array('placement' => SITEMAP_SEO_MODULE_PLACEMENT_CATEGORIES, 'sortkey' => SITEMAP_SEO_SORTORDER_CATEGORIES, 'module' => $showCategories), array('placement' => SITEMAP_SEO_MODULE_PLACEMENT_INFOPAGES, 'sortkey' => SITEMAP_SEO_SORTORDER_INFOPAGES, 'module' => $showInfoPages), array('placement' => SITEMAP_SEO_MODULE_PLACEMENT_MANUFACTURERS, 'sortkey' => SITEMAP_SEO_SORTORDER_MANUFACTURERS, 'module' => $showManufacturers), array('placement' => SITEMAP_SEO_MODULE_PLACEMENT_PAGE_MANAGER, 'sortkey' => SITEMAP_SEO_SORTORDER_PAGE_MANAGER, 'module' => $showPageManager), array('placement' => SITEMAP_SEO_MODULE_PLACEMENT_STANDARD_BOXES, 'sortkey' => SITEMAP_SEO_SORTORDER_STANDARD_BOXES, 'module' => $showInfoBoxes), array('placement' => SITEMAP_SEO_MODULE_PLACEMENT_STANDARD_PAGES, 'sortkey' => SITEMAP_SEO_SORTORDER_STANDARD_PAGES, 'module' => $showPages)); foreach($sortOrderArray as $key) { if (tep_not_null($key['module'])) { if ($key['placement'] == 'left') $leftColDisplay[] = $key; else $rightColDisplay[] = $key; } } usort($leftColDisplay, "SortOnKeys"); usort($rightColDisplay, "SortOnKeys"); $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_SITEMAP_SEO)); ?> <?php // RCI code start echo $cre_RCI->get('sitemap', 'bottom'); echo $cre_RCI->get('global', 'bottom'); // RCI code eof ?>

Re: Warning: usort() [function.usort]: Invalid comparison functi

par stopher » 31 oct. 2009, 00:26

Salut ,

je pense que le pb , vient de tes fonctions de comparaison .. edites les nous..

Ch .

Warning: usort() [function.usort]: Invalid comparison functi

par max-affaires » 30 oct. 2009, 23:32

bonsoir,

j'utilise ce code pour mon site

Code : Tout sélectionner

/****************** BUILT THE DISPLAY *********************/ $leftColDisplay = array(); $rightColDisplay = array(); $sortOrderArray = array(array('placement' => SITEMAP_SEO_MODULE_PLACEMENT_ARTICLES_MANAGER, 'sortkey' => SITEMAP_SEO_SORTORDER_ARTICLES_MANAGER, 'module' => $showArticlesManager), array('placement' => SITEMAP_SEO_MODULE_PLACEMENT_CATEGORIES, 'sortkey' => SITEMAP_SEO_SORTORDER_CATEGORIES, 'module' => $showCategories), array('placement' => SITEMAP_SEO_MODULE_PLACEMENT_INFOPAGES, 'sortkey' => SITEMAP_SEO_SORTORDER_INFOPAGES, 'module' => $showInfoPages), array('placement' => SITEMAP_SEO_MODULE_PLACEMENT_MANUFACTURERS, 'sortkey' => SITEMAP_SEO_SORTORDER_MANUFACTURERS, 'module' => $showManufacturers), array('placement' => SITEMAP_SEO_MODULE_PLACEMENT_PAGE_MANAGER, 'sortkey' => SITEMAP_SEO_SORTORDER_PAGE_MANAGER, 'module' => $showPageManager), array('placement' => SITEMAP_SEO_MODULE_PLACEMENT_STANDARD_BOXES, 'sortkey' => SITEMAP_SEO_SORTORDER_STANDARD_BOXES, 'module' => $showInfoBoxes), array('placement' => SITEMAP_SEO_MODULE_PLACEMENT_STANDARD_PAGES, 'sortkey' => SITEMAP_SEO_SORTORDER_STANDARD_PAGES, 'module' => $showPages)); foreach($sortOrderArray as $key) { if (tep_not_null($key['module'])) { if ($key['placement'] == 'left') $leftColDisplay[] = $key; else $rightColDisplay[] = $key; } } usort($leftColDisplay, "SortOnKeys"); usort($rightColDisplay, "SortOnKeys"); $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_SITEMAP_SEO));



et j'obtiens ce message d'erreur

Warning: usort() [function.usort]: Invalid comparison function in /home/maxaffai/www/templates/content/sitemap.tpl.php on line 148

Warning: usort() [function.usort]: Invalid comparison function in /home/maxaffai/www/templates/content/sitemap.tpl.php on line 149

apres plusieur heure de recherche je bloque.

est ce que quelqu'un pourrai m'aider et m'expliquer par la meme occassion l'erreur afin que je puisse comprendre merci