Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
* add commit leak files
* add config to keywords
* theme thumbnail size fix
  • Loading branch information
kazy111 committed Mar 18, 2012
1 parent 6f76668 commit 3bf0603
Show file tree
Hide file tree
Showing 16 changed files with 154 additions and 42 deletions.
18 changes: 18 additions & 0 deletions admin/delete_legend.php
@@ -0,0 +1,18 @@
<?php
include '../header.php';
// TOOD confirm

if(!array_key_exists('id', $_GET)) exit();
$id = $_GET['id'];

$result = $manager->get_legend($id);
if($result){
$manager->delete_legend($id);
}

// redirect
header("HTTP/1.1 301 Moved Permanently");
header("Location: ".$site_url.'/admin/list_legend.php');
exit();

?>
57 changes: 57 additions & 0 deletions admin/edit_legend.php
@@ -0,0 +1,57 @@
<?php
// TODO sanitize, validation

include '../header.php';

// edit form & register
// if no id, create new entry

function get_form($id){
global $manager;

$body = '';

if($id){
// get info from DB
$result = $manager->get_legend($id);
if($result){
$body = sanitize_html($result['body']);
}
}

// display form

return <<< EOD
<form method="POST">
<input type="hidden" name="mode" value="1" />
<input type="hidden" name="id" value="$id" />
<span class="form_title">body:</span>
<textarea name="body" cols="40" rows="10">$body</textarea><br />
<input type="submit" value="submit" />
</form>
EOD;

}

function register(){
global $_POST, $manager;

$manager->set_legend($_POST);
}

$contents = '';
if ( array_key_exists('mode', $_POST) ) {
// TODO validation

register();
$contents .= '<span class="message">updated information</span>';
}

$contents .= get_form(get_key($_GET, 'id'));
$data = array();
$data['contents'] = $contents;
$page->set_relative_dir_to_top('..');
$page->set('raw', $data);

include '../footer.php';
?>
3 changes: 2 additions & 1 deletion check_irc.php
Expand Up @@ -86,8 +86,9 @@ function check_irc()
}else
$arr = array(0, '');
}
$arr[1] = mb_convert_encoding($arr[1], 'utf-8', 'utf-8');

log_print('room='.$arr[0].', topic=\''.$arr[1]);
log_print('room='.$arr[0].', topic=\''.$arr[1].'\'');
$manager->update_chat($hash[$k], $manager->sanitize($arr[0]), $manager->sanitize($arr[1]));
}

Expand Down
5 changes: 5 additions & 0 deletions classes/page.php
Expand Up @@ -95,6 +95,7 @@ function get($extra = '')
$data->assign('footer_description', $GLOBALS['footer_description']);
$data->assign('curr_time', time());
$data->assign('site_title', ($this->title?$this->title.' - ':'').$site_title);
$data->assign('keywords', $GLOBALS['keywords']);
$data->assign('additional_header', implode("\n", $this->header));
$ret = '';

Expand All @@ -106,13 +107,15 @@ function get($extra = '')
$this->data['site_url'] = $GLOBALS['site_url'];
$this->data['file_path'] = $GLOBALS['file_path'];
$this->data['site_title'] = $GLOBALS['site_title'];
$this->data['keywords'] = $GLOBALS['keywords'];
$this->data['relative_dir_to_top'] = $this->rel_dir;
$this->data['header_description'] = $GLOBALS['header_description'];
$this->data['footer_description'] = $GLOBALS['footer_description'];
}else{
$this->data->assign('site_url', $GLOBALS['site_url']);
$this->data->assign('file_path', $GLOBALS['file_path']);
$this->data->assign('site_title', $GLOBALS['site_title']);
$this->data->assign('keywords', $GLOBALS['keywords']);
$this->data->assign('relative_dir_to_top', $this->rel_dir);
$this->data->assign('header_description', $GLOBALS['header_description']);
$this->data->assign('footer_description', $GLOBALS['footer_description']);
Expand All @@ -134,13 +137,15 @@ function get_once($page, $data)
$data['site_url'] = $GLOBALS['site_url'];
$data['file_path'] = $GLOBALS['file_path'];
$data['site_title'] = $GLOBALS['site_title'];
$data['keywords'] = $GLOBALS['keywords'];
$data['relative_dir_to_top'] = $this->rel_dir;
$data['header_description'] = $GLOBALS['header_description'];
$data['footer_description'] = $GLOBALS['footer_description'];
}else{
$data->assign('site_url', $GLOBALS['site_url']);
$data->assign('file_path', $GLOBALS['file_path']);
$data->assign('site_title', $GLOBALS['site_title']);
$data->assign('keywords', $GLOBALS['keywords']);
$data->assign('relative_dir_to_top', $this->rel_dir);
$data->assign('header_description', $GLOBALS['header_description']);
$data->assign('footer_description', $GLOBALS['footer_description']);
Expand Down
7 changes: 7 additions & 0 deletions config.php
Expand Up @@ -24,6 +24,8 @@
$file_path = '/usr/home/kazy/public_html/checker/';
// メールフォームの送り先メールアドレス
$admin_mail = 'kazy@kazy111.info';
// サイトキーワード (検索エンジン用)
$keywords = 'ゲーム配信';

// トップページヘッダに表示する説明
$header_description = '<a href="http://www.gokusotsu.com/top/?cat=3">獄卒ch</a>関係な人の配信をチェック/視聴するページ / 獄卒チェッカー通知Twitter→<a href="http://twitter.com/g_checker">&psi;</a>';
Expand All @@ -46,6 +48,11 @@
$ontop[] = 60;
$ontop[] = 61;

// 限定キーワード (|区切)
// これがトピック、タイトルに含まれていると、indexで上位配置、配信通知する対象にする)
$limit_keywords = 'アイマス|アイドルマスター|ライブフォーユー|L4U|L4U|ステージフォーユー|S4U|S4U|グラビアフォーユー|G4U|G4U|プロデュース|写真撮影';


// wikiリンク用URL (このURL + wikiの値.html にリンクされます)
$wiki_url = '';

Expand Down
6 changes: 5 additions & 1 deletion edit_tag.php
Expand Up @@ -11,17 +11,20 @@ function get_info($id){

$data = array();
$tag = '';
$name = '';

if($id){
// get info from DB
$result = $manager->get_tag($id);
$result = $manager->get_streamer($id);
if($result){
$tag = $result['tag'];
$name = $result['name'];
}
}

$data['id'] = $id;
$data['tag'] = $tag;
$data['name'] = $name;

return $data;
}
Expand Down Expand Up @@ -64,6 +67,7 @@ function validate($data){
}

$data['message'] = $message;
$data['name'] =

print($page->get_once('edit_tag', $data));

Expand Down
73 changes: 45 additions & 28 deletions index_content.php
Expand Up @@ -47,6 +47,9 @@ function get_streamer_data($arrs, $extra)
$chats_raw = array();
$titles_raw = array();

// if live, show live service topic only
$live_topics = array();

// channel name array (key is type no.)
$ch_chat;
$ch_name = array();
Expand Down Expand Up @@ -92,6 +95,7 @@ function get_streamer_data($arrs, $extra)
break;
}
$ch_chat = substr($v['room'],1);
$live_topics[] = trim($v['topic']) != '' ? trim($v['topic']) : trim($v['title']);
}else {
if(!isset($live_thumb)) $live_thumb = $v['thumbnail'];
if(!isset($ch_chat)) $ch_chat = substr($v['room'],1);
Expand Down Expand Up @@ -137,7 +141,12 @@ function get_streamer_data($arrs, $extra)
$topics[] = $c[2];
}
$data['chat'] = implode(' ', $chats);
$data['topic'] = htmlspecialchars(implode(' ', $topics));

if(count($live_topics) > 0){
$data['topic'] = htmlspecialchars($live_topics[0]);
}else{
$data['topic'] = htmlspecialchars(implode(' ', $topics));
}
$data['topic'] = preg_replace('/(https?|ftp)(:\/\/[[:alnum:]\+\$\;\?\.%,!#~*\/:@&=_-]+)/i', '<a class="urllink" href="\\0" target="_blank">&psi;</a>' , $data['topic']);
// when topic is empty, alter text to program title
if(trim($data['topic']) == ''){
Expand Down Expand Up @@ -172,15 +181,38 @@ function display_list($sort, $extra)
{
global $ontop, $page;
// streamers compare function for sort
function cmp_viewer( $a, $b ){

function cmp_common( $a, $b ){
global $ontop;

if( in_array($a['sid'], $ontop) && !in_array($b['sid'], $ontop) ){
return FALSE;
}else if( !in_array($a['sid'], $ontop) && in_array($b['sid'], $ontop) ){
return TRUE;
}else if( in_array($a['sid'], $ontop) && in_array($b['sid'], $ontop) ){
return $a['sid'] > $b['sid'];
return $a['name'] > $b['name'];
}
if($GLOBALS['limit_keywords'] != '' && $a['live'] && $b['live'] ){
// when set limit keywords, give priority to keyword including
$atitle = $a['topic'];
$btitle = $b['topic'];
$_keywords = '/'.$GLOBALS['limit_keywords'].'/';

if( preg_match($_keywords, $atitle) > 0 && preg_match($_keywords, $btitle) == 0 ) {
return FALSE;
}
if( preg_match($_keywords, $atitle) == 0 && preg_match($_keywords, $btitle) > 0 ) {
return TRUE;
}
}

return null;
}

function cmp_viewer( $a, $b ){

$ret = cmp_common($a, $b);
if($ret !== null) return $ret;

if( $a['live'] ){
if( $b['live'] ){
Expand All @@ -198,14 +230,9 @@ function cmp_viewer( $a, $b ){
}
// name
function cmp_name( $a, $b ){
global $ontop;
if( in_array($a['sid'], $ontop) && !in_array($b['sid'], $ontop) ){
return FALSE;
}else if( !in_array($a['sid'], $ontop) && in_array($b['sid'], $ontop) ){
return TRUE;
}else if( in_array($a['sid'], $ontop) && in_array($b['sid'], $ontop) ){
return $a['sid'] > $b['sid'];
}

$ret = cmp_common($a, $b);
if($ret !== null) return $ret;

global $ontop;
if( in_array($a['sid'], $ontop) && !in_array($a['sid'], $ontop) ){
Expand All @@ -231,14 +258,9 @@ function cmp_name( $a, $b ){
}
// time
function cmp_time( $a, $b ){
global $ontop;
if( in_array($a['sid'], $ontop) && !in_array($b['sid'], $ontop) ){
return FALSE;
}else if( !in_array($a['sid'], $ontop) && in_array($b['sid'], $ontop) ){
return TRUE;
}else if( in_array($a['sid'], $ontop) && in_array($b['sid'], $ontop) ){
return $a['sid'] > $b['sid'];
}

$ret = cmp_common($a, $b);
if($ret !== null) return $ret;

global $ontop;
if( in_array($a['sid'], $ontop) && !in_array($a['sid'], $ontop) ){
Expand All @@ -265,14 +287,9 @@ function cmp_time( $a, $b ){
// random
srand(time());
function cmp_random( $a, $b ){
global $ontop;
if( in_array($a['sid'], $ontop) && !in_array($b['sid'], $ontop) ){
return FALSE;
}else if( !in_array($a['sid'], $ontop) && in_array($b['sid'], $ontop) ){
return TRUE;
}else if( in_array($a['sid'], $ontop) && in_array($b['sid'], $ontop) ){
return $a['sid'] > $b['sid'];
}

$ret = cmp_common($a, $b);
if($ret !== null) return $ret;

if( $a['live'] ){
if( $b['live'] ){
Expand Down Expand Up @@ -345,7 +362,7 @@ function cmp_random( $a, $b ){

// get random legend
$result = $manager->get_random_legend();
$legend = sanitize_html($result['body']);
$legend = $result['body'];

// output page contents
$data = new Dwoo_Data();
Expand Down
4 changes: 2 additions & 2 deletions themes/Twitter/index_streamer.tpl
Expand Up @@ -2,13 +2,13 @@
<span class="tweet-img">
<a href="view.php?id={$sid}" target="_blank">
{if $live_raw && $thumbnail != ''}
<img class="thumb" src="{$thumbnail}" width="80" height="60" />
<img class="thumb" src="{$thumbnail}" width="80" />
{else}
{if $twitter != ''}
<img class="thumb" src="http://gadgtwit.appspot.com/twicon/{$twitter}/bigger" width="73" height="73" />
<span class="thumb_offline">offline</span>
{else}
<img class="thumb" src="./themes/Twitter/offline.png" width="80" height="60" />
<img class="thumb" src="./themes/Twitter/offline.png" width="80" />
{/if}
{/if}
</a>
Expand Down
4 changes: 2 additions & 2 deletions themes/Twitter/index_streamer_offline.tpl
Expand Up @@ -2,13 +2,13 @@
<span class="tweet-img">
<a href="view.php?id={$sid}" target="_blank">
{if $live_raw && $thumbnail != ''}
<img class="thumb" src="{$thumbnail}" width="80" height="60" />
<img class="thumb" src="{$thumbnail}" width="80" />
{else}
{if $twitter != ''}
<img class="thumb" src="http://gadgtwit.appspot.com/twicon/{$twitter}/bigger" width="73" height="73" />
<span class="thumb_offline">offline</span>
{else}
<img class="thumb" src="./themes/Twitter/offline.png" width="80" height="60" />
<img class="thumb" src="./themes/Twitter/offline.png" width="80" />
{/if}
{/if}
</a>
Expand Down
4 changes: 2 additions & 2 deletions themes/Twitter/mobile_index_streamer.tpl
Expand Up @@ -2,13 +2,13 @@
<span class="tweet-img">
<a href="view.php?id={$sid}" target="_blank">
{if $live_raw && $thumbnail != ''}
<img class="thumb" src="{$thumbnail}" width="80" height="60" />
<img class="thumb" src="{$thumbnail}" width="80" />
{else}
{if $twitter != ''}
<img class="thumb" src="http://gadgtwit.appspot.com/twicon/{$twitter}/bigger" width="73" height="73" />
<span class="thumb_offline">offline</span>
{else}
<img class="thumb" src="./themes/Twitter/offline.png" width="80" height="60" />
<img class="thumb" src="./themes/Twitter/offline.png" width="80" />
{/if}
{/if}
</a>
Expand Down
4 changes: 2 additions & 2 deletions themes/Twitter/mobile_index_streamer_offline.tpl
Expand Up @@ -2,13 +2,13 @@
<span class="tweet-img">
<a href="view.php?id={$sid}" target="_blank">
{if $live_raw && $thumbnail != ''}
<img class="thumb" src="{$thumbnail}" width="80" height="60" />
<img class="thumb" src="{$thumbnail}" width="80" />
{else}
{if $twitter != ''}
<img class="thumb" src="http://gadgtwit.appspot.com/twicon/{$twitter}/bigger" width="73" height="73" />
<span class="thumb_offline">offline</span>
{else}
<img class="thumb" src="./themes/Twitter/offline.png" width="80" height="60" />
<img class="thumb" src="./themes/Twitter/offline.png" width="80" />
{/if}
{/if}
</a>
Expand Down
3 changes: 3 additions & 0 deletions themes/black/theme.css
Expand Up @@ -58,6 +58,9 @@ table.list-table th{
.offline .time_diff{
display: none;
}
.old{
display: none;
}

/*popup*/
.popup img.thumb {
Expand Down
2 changes: 1 addition & 1 deletion themes/default/edit_tag.tpl
Expand Up @@ -8,7 +8,7 @@

<body>

<h2>タグ編集</h2>
<h2>タグ編集 - {$name}</h2>


<div class="message"><strong>{$message}</strong></div>
Expand Down

0 comments on commit 3bf0603

Please sign in to comment.