Location: PHPKode > projects > CorePHPAlbum > cpa-2.0.2/index.php
<?php

/*   ========================================================
     =                                                      =
     = corePHPAlbum - web-based photo gallery               =
     =                                                      =
     = Official code                                        =
     = file release 2.0.2                                   =
     =                                                      =
     = http://sourceforge.net/projects/corephpalbum         =
     =                                                      =
     ======================================================== */

require_once('_res/sources/utilities.php');
require_once('_res/sources/functions.php');
require_once('_res/sources/encryption.php');
require_once('_switches.php');

require_once('_res/sources/debug.php');
debug_init();

// Initialization
//
$starttime = float_microtime();
$_config = array();
$_info = array();

init_codetable();
$basedir = ($_GET['id'] == ''? '' : id_decrypt($_GET['id']));
$subdirs = split_dir($basedir);

import_info($basedir);
import_config($basedir);

require_once('_res/index_modes/' . $_config['index_mode'] . '.php');
require_once('_res/languages/' . $_config['language'] . '.php');

// Build the thumbnail list
$thumbnail_list = thumbnail_list('_res/buttons/' . $_config['index_buttons'] . '/' . 'folder.png', '_res/buttons/' . $_config['index_buttons'] . '/' . 'photo.png');

format_index(index_made($thumbnail_list, index_pos(count($thumbnail_list)), $_GET['mark']), index_navigator($thumbnail_list, $_GET['mark']), index_action($thumbnail_list, $pos));
exit();

//
// Main program ends, functions below.
//

function format_index($what, $navigator, $action='')
{
  global $_switch, $_config, $core, $_info, $starttime;

	// Save Protection
	$js = (strtolower($_switch['save_protect']) === 'on' ? $core['save_protect'] . "\r\n" : '' );

  // Import the theme template file
  $data = file_get_contents('_res/templates/' . $_config['template'] . '.html');


  $data = preg_replace("/{{meta}}/i", $js . index_meta(), $data);
  $data = preg_replace("/{{javascriptcode}}/i", $action, $data);
  $data = preg_replace("/{{pagetitle}}/i", strip_tags($_info['title']), $data);
  $data = preg_replace("/{{title}}/i", index_title(), $data);
  $data = preg_replace("/{{theme}}/i", $_config['template'], $data);
  $data = preg_replace("/{{css}}/i", $_config['index_css'], $data);
  $data = preg_replace("/{{image_set}}/i", $_config['index_buttons'], $data);
  $data = preg_replace("/{{route}}/i", routemap(), $data);
  $data = preg_replace("/{{navigator}}/i", $navigator, $data);
  $data = preg_replace("/{{header}}/i", index_header(), $data);
  $data = preg_replace("/{{content}}/i", $what, $data);
  $data = preg_replace("/{{remarks}}/i", "", $data);
  $data = preg_replace("/{{footer}}/i", index_footer(), $data);
  $data = preg_replace("/{{copyright}}/i", $_config['copyright'], $data);

  // index version is defined here.
  $powered_by = 'Powered by <a class="albumfooter" href="http://sourceforge.net/projects/corephpalbum" target="_blank">corePHPAlbum v' . $core['version'] . ' </a><br />';
  $powered_by .= str_replace ('%s', round(float_microtime() -$starttime, 4), "(page generated in %s seconds)<br /><br />");
  $data = preg_replace("/{{powered_by}}/i", $powered_by, $data);
  $data = preg_replace("/{{debug}}/i", debug_write(), $data);

  //System vlaues that could be used in ".inc" and ".note" files.
	require_once('_res/sources/systemvalues.php');
	foreach ($_sv as $i => $value) {
		$data = preg_replace("/{{".$i."}}/i", $value, $data);
	}

  echo $data;
}

function index_pos($max, $shift=0)
{
	global $_config;
  
  // Read the position
  $res = ($_GET['pos'] == "" ? 0 : $_GET['pos']);
  settype($res, "integer");
  
  // Normalize the position
  $res = normalise_index_pos($max, $res);
  
  // Then shift
  if ($shift !== 0) {
  	$res = $res +$shift;
	  $res = normalise_index_pos($max, $res);
  }

	return $res;
}

function normalise_index_pos($max, $curr)
{
	global $_config;

  // Normalize the position
  $res = $curr;
  if ($res >= $max) {
  	$res = $max -$_config['num_total'];
  }
  if ($res < 0) {
  	$res = 0;
  }
  
  return $res;
}

?>
Return current item: CorePHPAlbum