📄 index.php
字号:
$handle = fopen($filename, 'w');
if (fwrite($handle, $comment_to_store) === FALSE) {
echo 'Cannot write comment to comment data file';
exit;
}
//echo 'file written';
fclose($handle);
}else{
echo 'The file comment data file is not writable';
}
}
$comments_data = implode ('', file ($filename));
$comments_arr = explode('}|+|{', $comments_data);
$current_image_id = str_replace('data/thumbdata_','',substr($curr_image['thumb'], 0, -4));
foreach ($comments_arr as $comments_data){
$comments_data = unserialize($comments_data);
if($current_image_id == $comments_data['id']){
?>
<div class="entry">
<div class="meta"><b><?php echo $comments_data['name'];?></b> <?php if($comments_data['website']){echo '(<a href="http://'.str_replace('http://','',$comments_data['website']).'" target="_blank">'.$comments_data['website'].'</a>)';}?> on <?php echo date('l, j F Y', $comments_data['time']);?></div>
<div class="comment"><?php echo $comments_data['comment'];?></div>
</div>
<?
}
}
?>
</div>
<div class="form">
<form method="POST" action="./?dir=<?php echo urlencode(get_param('dir')) . '&pic=' . urlencode(get_param('pic')); ?>#comments">
<input type="hidden" name="com_id" value="<?php echo str_replace('data/thumbdata_','',substr($curr_image['thumb'], 0, -4)); ?>">
name<br />
<input type="text" name="com_name" value="" /> (required)<br />
email<br />
<input type="text" name="com_email" value="" /> (will not be shown) (required)<br />
website<br />
<input type="text" name="com_website" value="" /><br />
comment<br />
<textarea name="com_comment"></textarea><br /><br />
<input type="submit" name="submit" value="Submit Comment" />
</form>
</div>
</div>
</div>
</div>
<?php
}elseif(get_param('dir')){
$image_list_arr = readDirectory(get_param('dir'));
//pre($image_list_arr);
$image_list_arr = multi_array_sort($image_list_arr, SORT_BY, SORT_ORDER);
if($image_list_arr){
$cols = 4;
$i = 1;
echo "<table align='center' width='50%' border ='0' cellpadding='0' cellspacing='0'><tr>";
foreach($image_list_arr as $image_key => $image){
//using table style
if(TILE_STYLE == 'table'){
if (is_int($i / $cols)) {
$table_tile_header = '<td align="center" valign="top">';
$table_tile_footer = '</td></tr><tr>';
}else{
$table_tile_header = '<td align="center" valign="top">';
$table_tile_footer = '</td>';
}
$i++;
echo $table_tile_header;
?>
<div class="thumb_wrapper tile_table">
<div class="container">
<?php
if($image['item_type'] == 'dir'){
?>
<div class="dir_icon"><a href="?dir=<?php echo urlencode($image['dir']); ?>/<?php echo urlencode($image['title']);?>"><img src="directory.jpg" border="0"/></a></div>
<?
}else{
?>
<div class="shadow"> </div>
<div class="thumb"><a href="?dir=<?php echo urlencode($image['dir']); ?>&pic=<?php echo urlencode($image['title']);?>"><img src="<?php echo $image['thumb']; ?>" border="0"/></a></div>
<?
}
?>
</div>
<div class="title"><?php echo $image['title']; ?></div>
</div>
<?
echo $table_tile_footer;
}elseif(TILE_STYLE == 'css'){
//using true-css style
?>
<div class="thumb_wrapper tile">
<div class="container">
<?php
if($image['item_type'] == 'dir'){
?>
<div class="dir_icon"><a href="?dir=<?php echo urlencode($image['dir']); ?>/<?php echo urlencode($image['title']);?>"><img src="directory.jpg" border="0"/></a></div>
<?
}else{
?>
<div class="shadow"> </div>
<div class="thumb"><a href="?dir=<?php echo urlencode($image['dir']); ?>&pic=<?php echo urlencode($image['title']);?>"><img src="<?php echo $image['thumb']; ?>" border="0"/></a></div>
<?
}
?>
</div>
<div class="title"><?php echo $image['title']; ?></div>
</div>
<?
}
}
echo "</tr></table>";
}else{
echo ' Sorry. No photos found in this directory.';
}
}else{
home_page();
}
}
function thumbs_generator(){
?>
<iframe id="thumbgen" name="thumbgen" style="width:0px; height:0px; border: 0px" src="thumb_generator.php?dir=<?php echo urlencode(get_param('dir')); ?>"></iframe>
<?
}
function html_LastAddition(){
?>
<div class="latest">
<p>Latest Photos Added (<a href="#" onclick="javascript:popup_latestupdate();" title="Notes About Latest Added Photos">?</a>)</p>
<?php
$image_list_arr = readLastAddition();
if($image_list_arr){
foreach($image_list_arr as $image_key => $image){
?>
<div class="thumb_wrapper tile">
<div class="container">
<div class="shadow"> </div>
<div class="thumb"><a href="?dir=<?php echo urlencode($image['dir']); ?>&pic=<?php echo urlencode($image['title']);?>"><img src="data/thumbdata_<?php echo base64_encode($image['dir'] . ']|[' . $image['filename'] . ']|[' . $image['last_modify']); ?>.jpg" border="0"/></a></div>
</div>
<div class="title"><?php echo $image['title']; ?></div>
</div>
<?
}
}else{
echo ' Sorry. No photos submitted yet.';
}
?>
</div>
<?php
}
function readLastAddition(){
$image_list_arr = array();
$opendir = 'data';
if ($handle = opendir($opendir)) {
while (false !== ($file = readdir($handle))) {
if ($file != '.' AND $file != '..' AND (substr($file,0,10) == 'thumbdata_')) {
$file_data_arr = explode(']|[', base64_decode(str_replace('thumbdata_','',$file)));
/* i also dont know what the hell is this for */
$file_data_arr[2] = str_replace('帢','',$file_data_arr[2]);
//pre($file_data_arr);
$image_list_arr[] = array('dir' => $file_data_arr[0], 'filename' => $file_data_arr[1], 'title' => str_replace('_',' ',substr($file_data_arr[1],0,-4)), 'last_modify' => $file_data_arr[2]);
}
}
closedir($handle);
//krsort($image_list_arr);
$image_list_arr = multi_array_sort($image_list_arr, 'last_modify', 'asc');
$i = 1;
$maximum_img_at_homepage = 4;
$image_at_homepage = array();
if($image_list_arr){
foreach($image_list_arr as $image_list_key => $image_list_value){
$image_at_homepage[$image_list_key] = $image_list_value;
if($i == $maximum_img_at_homepage){ break; }
$i++;
}
}
return $image_at_homepage;
}else{
return false;
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -