<?php

/* PHP输出图片 */
@ require ('inc/set/set.php');
@ require ('inc/set/set_sql.php');

$obj_text = $eval = '';
if (!empty($_GET['title'])) {

  if (file_exists('__temp__/temp/'.urlencode($_GET['title']))) {
    header('Location: __temp__/temp/'.urlencode(urlencode($_GET['title'])).'');
    exit;
  }
  if (db_conn()) {
    $result = @mysql_query('SELECT text,type FROM '.$sql['pref'].''.$sql['data']['承载上传数据的表名'].' WHERE title="'.$_GET['title'].'" LIMIT 1', $db);
    $row = @mysql_fetch_assoc($result);
    @mysql_free_result($result);
    if ($row) {
      $obj_text = $row['text'];
      $format = strtolower(ltrim(strrchr($_GET['title'], '.'), '.'));
      header('Content-type: '.$row['type'].'');
      if (strstr('jpg|jpeg|gif|png', $format)) {
        /*die('<script>alert("'.$row['type'].'");</script>');*/
        header('Cache-Control: max-age=31536000');
      } elseif (strstr('gif|swf|'.$web['_17_type'], $format)) {
        header('Cache-Control: max-age=2592000');
      //case strstr($web['_18_type'], $format):
      } else {
        header('Content-Disposition: attachment; filename='.urlencode($_GET['title']).'');
      }
      unset($row);
      if ($web['temp'] == 1) {
        $eval = '@file_put_contents(\'__temp__/temp/'.urlencode($_GET['title']).'\', $obj_text);';
      }
    }
    @mysql_close();
  }
}
if ($obj_text != '') {
  echo $obj_text;
  eval($eval);
} else {
  //header('HTTP/1.1 404 Not Found'); 
  //header("status: 404 Not Found"); 
  //if ($_SERVER['HTTP_REFERER'] && $web['sitehttp'] && !strstr($_SERVER['HTTP_REFERER'], $web['sitehttp'])) {
    //die('error!');
  //} else {
    //header('location: inc/images/userface_default.gif');
  //}
    header('location: inc/images/userface_default.gif');
}
exit;

?>