Created
October 2, 2010 14:16
-
-
Save lizheming/607671 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define(P2_PATH,'http://pagecookery.net/'); //输入你的PageCookery地址,不要忘记最后的"/"哦! | |
include("config.php"); | |
mysql_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PSSWORD) or | |
die("Could not connect: " . mysql_error()); | |
mysql_select_db(DATABASE_DB_NAME); | |
mysql_query("SET NAMES UTF8"); | |
$sqlx="select * from entry where userid='1' order by time desc limit 1"; | |
$rsx=mysql_query($sqlx); | |
if (mysql_num_rows($rsx)!==0): | |
while ($datax=mysql_fetch_assoc($rsx)): | |
$contentx=$datax["content"]; | |
$timex=$datax["time"]; | |
$idx=$datax["id"]; | |
endwhile; | |
endif; | |
echo '<div class="content">' . $contentx . '</div><p class="data"><a href="'. P2_PATH . '?act=view&id=' . $idx . '" target="_blank">'; | |
$pasttime=time()-$timex; | |
if ($pasttime<60) | |
{ | |
echo 'about '.$pasttime.' seconds ago'; | |
}else if ($pasttime>60 && $pasttime<3600) | |
{ | |
echo 'about '.floor($pasttime/60).' minutes ago'; | |
}else if ($pasttime>3600 && $pasttime<86400) | |
{ | |
echo 'about '.floor($pasttime/3600).' hours ago'; | |
} | |
else{ | |
print_r(date('Y-n-j H:i:s', $timex)); | |
} | |
echo '</a></p>'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment