simply display global result // Mode full ==> display global result and user notations $ap_id = explode('concours/' , $_SERVER['REQUEST_URI']); $id_concours = $ap_id[1]; $user['ipguest'] = null; if (is_a_guest()) { if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $IP = $_SERVER['HTTP_X_FORWARDED_FOR']; elseif(isset($_SERVER['HTTP_CLIENT_IP'])) $IP = $_SERVER['HTTP_CLIENT_IP']; else $IP = $_SERVER['REMOTE_ADDR']; // store ip $user['ipguest'] = $IP; } $concours = new Concours($id_concours); $template->assign( 'CONCOURS', array( 'ID' => $concours->concours_infos['id'], 'NAME' => $concours->concours_infos['name'], 'DESCR' => $concours->concours_infos['descr'], 'BEGIN_DATE' => $concours->concours_infos['begin_date'], 'END_DATE' => $concours->concours_infos['end_date'], 'METHOD' => l10n("concours_method".$concours->concours_infos['method']) )); $category = $concours->concours_infos['category']; if (!(isset($concours->concours_infos['method']))) $concours->concours_infos['method'] = 1; $query = 'SELECT DISTINCT(img.id), img.name, img.file, img.path, img.tn_ext,img.author, ic.category_id, cat.name AS catname, conc.note, conc.moyenne, conc.nbvotant' .' FROM ' . IMAGES_TABLE.' AS img' .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id' .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id' .' INNER JOIN '.CONCOURS_RESULT_TABLE.' AS conc ON conc.img_id = img.id' .' WHERE ic.category_id = '.$concours->concours_infos['category'] .' AND conc.id_concours = '.$concours->concours_infos['id'] ; if ($concours->concours_infos['method'] == 1) // total $query .= ' ORDER BY note DESC'; elseif ($concours->concours_infos['method'] == 2) // moyenne $query .= ' ORDER BY moyenne DESC'; $query .=';'; // .' ORDER by note DESC;'; $result = pwg_query($query); $rang = 1; $previousNote = $previousMoy = 0; while ($row = mysql_fetch_assoc($result)) { // link on picture.php page set_make_full_url(); if ( isset($row['category_id']) & isset($row['catname']) ) { $url = duplicate_picture_url( array( 'image_id' => $row['id'], 'image_file' => $row['file'], 'category' => array( 'id' => $row['category_id'], 'name' => $row['catname'], 'permalink' => '' ) ), array('start') ); } else { $url = duplicate_picture_url( array( 'image_id' => $row['id'], 'image_file' => $row['file'] ), array('start') ); } unset_make_full_url(); // Check the exaequos if ($concours->my_config['check_exaequo']) { if ( ($concours->concours_infos['method'] == 1 // total AND ($row['note'] == $previousNote)) OR ($concours->concours_infos['method'] == 2 // moyenne AND ($row['moyenne'] == $previousMoy))) { // echo "Rang=".$rang."\n"; $rang --; } } $template->append( 'concours_note', array( 'img_id' => $row['id'], 'name' => $row['name'], 'file' => $row['file'], 'author' => $row['author'], 'rang' => $rang, 'thumb' => get_thumbnail_url($row), 'url' => $url, 'note' => ($row['note'] == 0 ? 'N/A' :$row['note']), 'moyenne' => ($row['moyenne'] == 0 ? 'N/A' :$row['moyenne']), 'nbvotant' => $row['nbvotant'], 'usernote' => $concours->get_img_globalnote_user($row['id'], null, null, $user['ipguest']) )); $rang ++; // echo "Rang=".$rang."\n"; $previousNote = $row['note']; $previousMoy = $row['moyenne']; } // Envoi de la page $template->assign(array( 'TITLE' => "Concours : ".$concours->concours_infos['name'])); $template->assign('IMG_URL', CONCOURS_IMG_PATH); $template->set_filenames(array('concours_result' => CONCOURS_ROOT.'/template/result.tpl')); $template->concat('PLUGIN_INDEX_CONTENT_BEGIN', $template->parse('concours_result', true)); $template->assign('PLUGIN_INDEX_ACTIONS' , '