add( "", "", "", "", "", DBKIND_TEXTSQL );
}
function config_models( &$controller )
{
$controller->AddModel( dirname(__FILE__) . "/models/admin.php" );
$controller->AddModel( dirname(__FILE__) . "/models/image.php" );
}
function config_controller( &$controller )
{
$controller->SetTemplateFile( "template.html" );
$controller->set('is_modern_browser', is_modern_browser());
}
function InitTime( $time )
{
$year = substr( $time, 0, 4 );
$month = substr( $time, 4, 2 );
$day = substr( $time, 6, 2 );
$hour = substr( $time, 8, 2 );
$minute = substr( $time, 10, 2 );
$second = substr( $time, 12, 2 );
return "$year-$month-$day $hour:$minute:$second";
}
if( !function_exists( "is_secure" ) )
{
function is_secure( &$controller )
{
return true;
}
}
function check_secure( &$controller )
{
if( isset($_SESSION['usr']) && $_SESSION['usr'] == USER_NAME )
{
}
else
{
$controller->redirect( "../" );
}
}
function _getHost($init_url = '') {
static $script;
if( $init_url=='' )
{
//get
if (isset($script)) return $script;
//set automatically
foreach (array('SCRIPT_NAME', 'SERVER_ADMIN', 'SERVER_NAME',
'SERVER_PORT', 'SERVER_SOFTWARE') as $key) {
define($key, isset($_SERVER[$key]) ? $_SERVER[$key] : '');
unset(${$key}, $_SERVER[$key]);
}
$str = (SERVER_PORT == 443 ? 'https://' : 'http://'); // scheme
$str .= SERVER_NAME; // host
$str .= (SERVER_PORT == 80 ? '' : ':' . SERVER_PORT); // port
$str .= $_SERVER['REQUEST_URI'];
//親の親
$script = dirname(dirname($str.'dummy'));
}
else
{
$script = dirname($init_url.'dummy');
}
return $script;
}
/**
* セキュアなセッションスタートの方法。
* ただし、QHMと連動しつつ、QHMコミュにも対応するために、ややこしい処理をしている
* ので注意が必要
*/
function secure_session_start()
{
$vals = parse_url( _getHost().'/index.php' );
if(TRUE){
$domain = $vals['host'];
if($domain != 'localhost' && $domain != '127.0.0.1'){
if(isset($vals['port']))
{
$domain .= ':'.$vals['port'];
}
$dir = str_replace('\\', '', dirname( $vals['path'] ));
$ckpath = ($dir=='/') ? '/' : $dir.'/';
if( function_exists('ini_set') ){
ini_set('session.use_trans_sid',0);
ini_set('session.name', QHM_SESSION_NAME.strlen($ckpath));
ini_set('session.use_only_cookies', 1);
ini_set('session.cookie_path', $ckpath);
ini_set('session.cookie_domain', $domain);
ini_set('session.cookie_lifetime', 0);
}
}
}
if (SESSION_SAVE_PATH != '') {
session_save_path('../'.SESSION_SAVE_PATH);
}
session_start();
}
function h($str){
return htmlspecialchars($str);
}
function el($name, $mtime, $size, $thumb=true, $id='', $desc=''){
$cmd = '';
$class = '';
if(preg_match('/.*(jpeg|png|gif|jpg)$/i',$name))
$class = 'class="screenshot"';
else
$class = 'class="tooltip"';
$value = "{$name}";
$image = "";
$icon = "";
//image
if( preg_match('/.*(jpeg|png|gif|jpg)$/i', $name) )
{
$icon = '';
$info = getimagesize(SWFU_DATA_DIR.$name);
if(!$thumb)
$value .= '
('.$info[0].'x'.$info[1].')';
$image = '
';
$cmd = '&ref2('.BASE.SWFU_DATA_DIR.$name.',nolink,画像の説明);';
}
//video
else if( preg_match('/.*(swf|mov|ram|wmv|avi|flv)$/i',$name) )
{
$icon = '';
$cmd = '#playvideo('.BASE.SWFU_DATA_DIR.$name.',幅,高さ);';
}
//PDF
else if( preg_match('/.*(pdf)$/i', $name) )
{
$icon = '';
$cmd = '&dlbutton('.BASE.SWFU_DATA_DIR.$name.');';
}
//compressed file
else if( preg_match('/.*(zip|lzh|tgz|gz|rar|tar|bz2)$/i', $name) )
{
$icon = '';
$cmd = '&dlbutton('.BASE.SWFU_DATA_DIR.$name.');';
}
//execute file
else if( preg_match('/.*(exe|dmg)$/i', $name) )
{
$icon = '';
$cmd = '&dlbutton('.BASE.SWFU_DATA_DIR.$name.');';
}
//office file
else if( preg_match('/.*(doc|docx|xls|xlsx|ppt|pptx)$/i', $name) )
{
$icon = '';
$cmd = '&dlbutton('.BASE.SWFU_DATA_DIR.$name.');';
}
//text file
else if( preg_match('/.*(txt|text|html)$/i', $name) )
{
$icon = '';
$cmd = '&dlbutton('.BASE.SWFU_DATA_DIR.$name.');';
}
//script file
else if( preg_match('/.*(java|php|cgi|c|cpp|sh|js)$/i', $name) )
{
$icon = '';
$cmd = '&dlbutton('.BASE.SWFU_DATA_DIR.$name.');';
}
else
{
$cmd = '&dlbutton('.BASE.SWFU_DATA_DIR.$name.');';
}
$value = $icon.' '.$value;
if(! $thumb)
$value .= '
'.date('Y年m月d日 H:i:s',$mtime).'
';
if($thumb){
$value .= '
'.$image;
}
else{
$value .= ' ';
$value .= '
';
}
return $value;
}
function set_menu(&$c)
{
//recent_file & pae
$res = $c->image->find('','created desc'); //var_dump($res);
$rs = $c->admin->findone('$name=="recent_file"');
$rct_fnum = $rs['value'];
$rs = $c->admin->findone('$name=="recent_page"');
$rct_pnum = $rs['value'];
$recent_file = array();
$recent_page = array();
$end = count($res);
$rcf_cnt = 0; $rcp_cnt = 0;
for($i=0; $i<$end; $i++){
//recent file count
if($rcf_cnt < $rct_fnum){
$recent_file[$i] = $res[$i];
$rcf_cnt ++;
}
//recent page count
if($rcp_cnt < $rct_pnum){
$pname = $res[$i]['page_name'];
if( $pname!='' && !isset($recent_page[$pname]))
{
$recent_page[$pname] = $pname;
$rcp_cnt ++;
}
}
}
$c->set('recent_page',$recent_page);
$c->set('recent_file',$recent_file);
}
function echo_menu($recent_file, $recent_page)
{
if(isset($_SESSION['swfu']['page_name']))
{
$top = 'list.php?page='.rawurlencode($_SESSION['swfu']['page_name']);
$uplink_query = '?page='.rawurlencode($_SESSION['swfu']['page_name']);
$uplink_msg = $_SESSION['swfu']['page_name'];
$uplink_msg_after = 'へ';
}
else{
$top = 'index.php';
$uplink_query = '';
$uplink_msg = '';
$uplink_msg_after = '';
}
$uploader = is_modern_browser()? 'up2.php': 'up.php';
echo <<
アップロード
EOD;
foreach($recent_file as $k=>$v){
$class = '';
if(preg_match('/.*(jpeg|png|gif|jpg)$/i',$v['name']))
$class = 'class="screenshot"';
else
$class = 'class="tooltip"';
echo "{$v['name']}
EOD;
foreach($recent_page as $k=>$v){
$p = rawurlencode($k);
echo "{$v}
";
}
echo <<最近のページ
";
}
echo <<一覧
検索
EOD;
}
function pr($v){echo '';var_dump($v);echo '
';}
function format_bytes($size, $round = 1) {
$units = array(' B', ' KB', ' MB', ' GB', ' TB');
for ($i = 0; $size >= 1024 && $i < 4; $i++) $size /= 1024;
return round($size, $round) . $units[$i];
}
//function echo_insert_script($image)
/**
* Print Tool Buttons
*
* @params
* $image
': ' ');
$buttons .= ''.$btnimg['lbx'].''. ($br? ' ': ' ');
$buttons .= ''.$btnimg['gbx'].'
';
}
/* ビデオファイル */
else if( preg_match('/.*(swf|mov|ram|wmv|avi|flv)$/i',$name) ){
$past = "#playvideo({$path},幅,高さ);";
$buttons .= ''.$btnimg['video'].''. ($br? '
': ' ');
}
/* mp3ファイル */
else if( preg_match('/.*mp3$/i',$name) ){
$past = '#playlist(タイトル){{\n'.$path.','.$image['description'].'\n}}\n';
$buttons .= ''.$btnimg['music'].''. ($br? '
': ' ');
}
$past = "&dlbutton({$path});";
$buttons .= ''.$btnimg['dlbtn'].' ';
$past = "&dllink({$path}){ダウンロード};";
$buttons .= ''.$btnimg['dllnk'].'';
if ($print) {
echo $buttons;
}
return $buttons;
}
/**
* jquery file Upload を利用できるかどうか
*
* Google Chrome - 7.0, 8.0, 9.0, 10.0
* Apple Safari - 5.0 *1
* Mozilla Firefox - 3.6, 4.0
* Opera - 10.6 *2, 11.0 *2
* Microsoft Internet Explorer 6.0 *2, 7.0 *2, 8.0 *2, 9.0 *2
*
* *1 Drag & Drop is not supported on the Windows version of Safari.
* *2 MSIE and Opera have no support for Drag & Drop, multiple file selection or upload progress indication.
*
* see also http://aquantum-demo.appspot.com/file-upload
*/
function is_modern_browser() {
$is_modern = true;
$ua = $_SERVER['HTTP_USER_AGENT'];
//chrome and firefox
if (preg_match('/\s(Chrome|Firefox)\/(\d+)/', $ua, $mts)) {
$browser = $mts[1];
$version = $mts[2];
}
//Safari
else if(preg_match('/\sVersion\/([\d.]+)\sSafari/', $ua, $mts)) {
$browser = 'Safari';
$version = $mts[1];
}
else {
$is_modern = false;
}
if ($is_modern) {
switch ($browser) {
case 'Chrome':// Chrome v7-
if ($version < 7) {
$is_modern = false;
}
break;
case 'Firefox':// Fiefox v3.6-
if ($version < 3.6) {
$is_modern = false;
}
break;
case 'Safari':// Safari 5- (Mac)
if ($version < 5) {
$is_modern = false;
} else if (strpos($ua, 'Macintosh') === FALSE) {
$is_modern = false;
}
break;
default:
$is_modern = false;
}
}
return $is_modern;
}
//--------------------------------
//main
if ( isset($script) && $script != '') {
_getHost($script); // Init matically
}
?>