Просмотр файла script/random2.php

Размер файла: 3.98Kb
<?php
/*-----------------------------------------------------------------------------------------
mcGalleryPRO
All code is © 2003 Marc Cagninacci.
No files may be redistributed in whole or significant part.
----------------- mcgalleryPRO IS NOT FREE SOFTWARE -------------------
You should have receive a file called license.txt in this package
--------------------------------------------------------------------------------------------*/

/*
ENGLISH
This file is to display a random photo on any page of your web site.
Set here the virtual path FROM selected page TO your mcgallerypro folder, without end slash
  i.e.  $path_to_folder = "./mcgallerypro";
  or $path_to_folder = "./myfolder"; if you have changed the folder name to "myfolder"
  or, if you have: http://yoursite.com/somewhere/index.php and http://yoursite.com/mcgallerypro, set
  $path_to_folder = "../mcgallerypro";

Upload this file random2.php in the same folder than the page to display random photo is.

Then, in the page you want to display the random picure in, at the exact place it should be, write:
 <?php include  "./random2.php"; ?> (without <?php and ?> if it's yet in PHP code).
ATTENTION: if this page is called "something.html", rename it "something.php".

FRANCAIS
Ce fichier sert а afficher une photo au hasard dans n'importe quelle page de votre site web.
Indiquer ici le chemin virtuel DEPUIS votre page VERS votre repertoire mcgallerypro, sans slash а la fin
exemple: $path_to_folder = "./mcgallerypro";
ou bien $path_to_folder = "./monrep"; si vous avez changй le nom du repertoire en "monrep"
ou encore, si vous avez: http://votresite.com/unrep/index.php et http://votresite.com/mcgallerypro, mettez
$path_to_folder = "../mcgallerypro";

Envoyez ce fichier random2.php dans le mкme repertoire que celui oщ se trouve la page oщ vous voulez afficher la photo.

Enfin, dans cette page, а l'endroit oщ vous voulez voir la photo, ecrivez:
<?php include  "./random2.php"; ?> (sans <?php et ?> si c'est dйjа dans du code PHP).
ATTENTION: si cette page s'appelle "mapage.html", renommez-la "mapage.php".

---------- MODIFICATION AREA --------*/

$path_to_folder = ".";

/*------- END OF MODIFICATION AREA --------*/


error_reporting(E_ALL & ~ E_NOTICE);
if (!empty($_SERVER)) { extract($_SERVER, EXTR_OVERWRITE); }
if (!empty($_GET)) { extract($_GET, EXTR_OVERWRITE); }
if (!empty($_POST)) { extract($_POST, EXTR_OVERWRITE); }
if (!empty($_COOKIE)) { extract($_COOKIE, EXTR_OVERWRITE); }
if (!empty($_SESSION)) { extract($_SESSION, EXTR_OVERWRITE); }

include ("$path_to_folder/admin/common.php");
include ("$path_to_folder/lang/$lang_def");

  if (!session_is_registered('private_login'))
 {
 $album_level = 'a.level = 1';
 }
 else
 {
	if ($level == 'admin' || $level == 'all') $album_level = 'a.level > 0';
	else  $album_level = 'a.level = 1 OR a.level IN ('. $level.')';
 }

 $connect = mysql_connect($host,$login,$pass);
  mysql_select_db($base, $connect);

 echo '<table border="0" cellpadding="1" cellspacing="0" class="td1" valign="top"><tr>';
 echo '<td class="td2" width="'.$thumb_width.'">';
 $query = "SELECT p.idalbum, p.file, p.album, p.author, p.title, p.id FROM mcgallery_albumphoto a, mcgallery_photo p WHERE $album_level AND p.idalbum = a.idalbum ORDER BY RAND()";
 $result = mysql_query($query);
 $rand = mysql_fetch_row($result);
 list($path1,$path2) = split('_', $rand[1],2);
 echo '<a href="'.$path_to_folder.'/show.php?id='.$rand[5].'" onMouseOver="window.status=\'\';return true">';
 echo '<img src="'.$path_to_folder.'/photos/'.$path1.'/small/'.$path2.'" border="0" alt="" width="'.$thumb_width.'" align="middle"></a></td>';
 echo '<td class="td2" valign="bottom">';
 echo '<font size="1">';
 if ($rand[4] != '') { echo '&nbsp;&nbsp;'.$l_Titre.': '.stripslashes($rand[4]).'<br>'; }
 if ($rand[3] != '') { echo '&nbsp;&nbsp;'.$l_Auteur.': '.stripslashes($rand[3]).'<br>'; }
 echo '&nbsp;&nbsp;'.$l_Album.': '.stripslashes($rand[2]);
 echo '</font>';
 echo '</td></tr></table>';
?>