aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/TakeATour/tours/2_7_0/config_preparse.inc.php
blob: 87aa6227b4ada421042d015a19a7e89f617dd7ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
  $template->assign('TAT_index', make_index_url(array('section' => 'categories')));
  $template->assign('TAT_search', get_root_url().'search.php');

  //picture id
  if (isset($_GET['page']) and preg_match('/^photo-(\d+)(?:-(.*))?$/', $_GET['page'], $matches))
  {
    $_GET['image_id'] = $matches[1];
  }
  check_input_parameter('image_id', $_GET, false, PATTERN_ID);
  if (isset($_GET['image_id']) and pwg_get_session_var('TAT_image_id')==null)
  {
    $template->assign('TAT_image_id', $_GET['image_id']);
    pwg_set_session_var('TAT_image_id', $_GET['image_id']);
  }
  elseif (is_numeric(pwg_get_session_var('TAT_image_id')))
  {
    $template->assign('TAT_image_id', pwg_get_session_var('TAT_image_id'));
  }
  else
  {
    $query = '
    SELECT id
      FROM '.IMAGES_TABLE.'
      ORDER BY RAND()
      LIMIT 1  
    ;';
    $row = pwg_db_fetch_assoc(pwg_query($query));
    $template->assign('TAT_image_id', $row['id']);
  }
?>