にへるつおるぐ | src | ブログ | コンタクト | 統計 | | Login |
|
|
ソースコード・スクリプト・パッチ置き場 |
GeneralItems that do not fit in other categories アイテム一覧
<
NP_GeSHi2.php.patch
NP_GeSHi2.php.patch
*** NP_GeSHi2.php 2007-11-10 14:25:48.000000000 +0900 --- NP_GeSHi2.php 2009-03-12 19:44:05.000000000 +0900 *************** *** 33,41 **** class NP_GeSHi2 extends NucleusPlugin { function getName() { return 'NP_GeSHi2'; } ! function getAuthor() { return 'Kai Greve'; } ! function getURL() { return 'http://kgblog.de/'; } ! function getVersion() { return '0.1'; } function getDescription() { return 'Integrates GeSHi - the Generic Syntax Highlighter - into Nucleus CMS. GeSHi can highlight code from several programming languages.'; } --- 33,41 ---- class NP_GeSHi2 extends NucleusPlugin { function getName() { return 'NP_GeSHi2'; } ! function getAuthor() { return 'Kai Greve + akebia'; } ! function getURL() { return 'http://nyan.co.uk/akebia/item/356'; } ! function getVersion() { return '0.1-2'; } function getDescription() { return 'Integrates GeSHi - the Generic Syntax Highlighter - into Nucleus CMS. GeSHi can highlight code from several programming languages.'; } *************** *** 66,80 **** // highlight the code with GeSHi $geshi =& new GeSHi($output, $code[2]); ! ! $geshi->set_header_type(GESHI_HEADER_NONE); ! $output=$geshi->parse_code(); ! if (stristr ($code[1], 'pre')) { $my_header=$this->getOption('pre_header'); $my_footer=$this->getOption('pre_footer'); } else { $my_header=$this->getOption('code_header'); $my_footer=$this->getOption('code_footer'); } --- 66,80 ---- // highlight the code with GeSHi $geshi =& new GeSHi($output, $code[2]); ! if (stristr ($code[1], 'pre')) { + $output=$geshi->parse_code(); $my_header=$this->getOption('pre_header'); $my_footer=$this->getOption('pre_footer'); } else { + $geshi->set_header_type(GESHI_HEADER_NONE); + $output=$geshi->parse_code(); $my_header=$this->getOption('code_header'); $my_footer=$this->getOption('code_footer'); } geshi.php.patch
geshi.php.patch
*** geshi.php 2012-08-19 16:25:52.000000000 +0900 --- geshi.php 2013-08-14 21:21:21.499601298 +0900 *************** *** 41,47 **** // /** The version of this GeSHi file */ ! define('GESHI_VERSION', '1.0.8.11'); // Define the root directory for the GeSHi code tree if (!defined('GESHI_ROOT')) { --- 41,47 ---- // /** The version of this GeSHi file */ ! define('GESHI_VERSION', '1.0.8.11-3'); // Define the root directory for the GeSHi code tree if (!defined('GESHI_ROOT')) { *************** *** 4025,4033 **** for ($i = 0; $i < $n; ++$i) { // Make lines have at least one space in them if they're empty // BenBE: Checking emptiness using trim instead of relying on blanks ! if ('' == trim($code[$i])) { ! $code[$i] = ' '; ! } // fancy lines if ($this->line_numbers == GESHI_FANCY_LINE_NUMBERS && $i % $this->line_nth_row == ($this->line_nth_row - 1)) { --- 4025,4033 ---- for ($i = 0; $i < $n; ++$i) { // Make lines have at least one space in them if they're empty // BenBE: Checking emptiness using trim instead of relying on blanks ! //if ('' == trim($code[$i])) { ! // $code[$i] = ' '; ! //} // fancy lines if ($this->line_numbers == GESHI_FANCY_LINE_NUMBERS && $i % $this->line_nth_row == ($this->line_nth_row - 1)) { MarkdownEx2.php
MarkdownEx2.php
<?php require 'markdown.php'; class MarkdownEx2_Parser extends MarkdownExtra_Parser { function detab($text) { return $text; } } function MarkdownEx2($text) { # # Initialize the parser and return the result of its transform method. # # Setup static parser variable. static $parser; if (!isset($parser)) { $parser_class = 'MarkdownEx2_Parser'; $parser = new $parser_class; } # Transform text using parser. return $parser->transform($text); } ?> NP_Markdown.php.patch
NP_Markdown.php.patch
*** NP_Markdown.php 2005-09-09 08:01:48.000000000 +0900 --- NP_Markdown.php 2009-03-12 15:44:23.000000000 +0900 *************** *** 32,42 **** function getName() { return 'Markdown'; } ! function getAuthor() { return 'Roberto "rbnet" Bolli'; } ! function getURL() { return 'http://www.rbnet.it.com/'; } ! function getVersion() { return '0.5'; } function getDescription() { return _MARKDOWN_DESCRIPTION; --- 32,42 ---- function getName() { return 'Markdown'; } ! function getAuthor() { return 'Roberto "rbnet" Bolli + akebia'; } ! function getURL() { return 'http://nyan.co.uk/akebia/item/359'; } ! function getVersion() { return '0.5-1'; } function getDescription() { return _MARKDOWN_DESCRIPTION; *************** *** 130,146 **** //else $CONF['MarkdownSyntax'] = 1; ! include_once( $this->getDirectory().'markdown.php' ); @include_once( $this->getDirectory().'smartypants.php' ); //warning silenzioso if ( function_exists('SmartyPants') ) { ! $data['item']->body = SmartyPants(Markdown($data['item']->body)); if ( trim($data['item']->more) ) ! $data['item']->more = SmartyPants(Markdown($data['item']->more)); } else { ! $data['item']->body = Markdown($data['item']->body); if ( trim($data['item']->more) ) ! $data['item']->more = Markdown($data['item']->more); } return; } --- 130,146 ---- //else $CONF['MarkdownSyntax'] = 1; ! include_once( $this->getDirectory().'MarkdownEx2.php' ); @include_once( $this->getDirectory().'smartypants.php' ); //warning silenzioso if ( function_exists('SmartyPants') ) { ! $data['item']->body = SmartyPants(MarkdownEx2($data['item']->body)); if ( trim($data['item']->more) ) ! $data['item']->more = SmartyPants(MarkdownEx2($data['item']->more)); } else { ! $data['item']->body = MarkdownEx2($data['item']->body); if ( trim($data['item']->more) ) ! $data['item']->more = MarkdownEx2($data['item']->more); } return; } *************** *** 188,191 **** } } ! ?> \ ファイル末尾に改行がありません --- 188,191 ---- } } ! ?> NP_Popularity.php
NP_Popularity.php
<?php class NP_Popularity extends NucleusPlugin{ function getName() {return 'Popularity';} function getAuthor() {return 'akebia'; } function getURL() {return 'http://nyan.co.uk/akebia/item/372';} function getVersion(){return '1.4';} function getDescription() {return "<%Popularity(order,num,catid,blogid)%>"; } function supportsFeature($f){switch($f){ case 'SqlTablePrefix': case 'SqlApi': return 1; default: return 0;}} function getMinNucleusVersion(){return '350';} function getTableList(){return sql_table('plugin_popularity');} function getEventList () {return array ('PostPluginOptionsUpdate', 'PreDeleteItem', 'PreDeleteBlog', 'PreUpdateItem');} function install(){ sql_query('CREATE TABLE IF NOT EXISTS '.sql_table('plugin_popularity').'('. 'id INT KEY,'. 'views INT NOT NULL,'. 'ip VARCHAR(255) NOT NULL,'. 'ctime BIGINT UNSIGNED NOT NULL,'. 'score INT NOT NULL,'. 'INDEX(views),'. 'INDEX(score)'. ')'); $this->createOption('IgnoreRepeat','同じIPからの反復を無視しますか?','yesno','yes'); $this->createOption('Cleanup','アンインストール時、データベースをクリアしますか?','yesno','no'); $this->createOption('SA','スコア計算時、アイテムの表示回数に乗ずる数(秒)','text','864000'); $this->createOption('SD','スコア計算に必要な最低期間(秒)','text','1200'); $this->createOption('SB','ハイスコア順のリストに出力するアイテムの最低表示回数','text','4'); $this->createOption('SC','ロースコア順のリストに出力するアイテムの最低表示回数','text','1'); $this->createOption('exclusion','除外するIP(複数の場合、","で区切る)','text',''); } function event_PostPluginOptionsUpdate($data){ if(!($this->getOption('SD') > 0)){$this->setOption('SD', 1);} } function unInstall(){ if($this->getOption('Cleanup') == 'yes') sql_query('DROP TABLE '.sql_table('plugin_popularity')); } function doTemplateVar(&$item, $order, $num = '', $cat = '', $blog = ''){ $itemid = $item->itemid; switch ($order){ case 'score': echo quickQuery('SELECT score as result FROM '. sql_table('plugin_popularity').' WHERE id='.$itemid); return; case 'views': echo quickQuery('SELECT views as result FROM '. sql_table('plugin_popularity').' WHERE id='.$itemid); return; case 'lisc': $this->li('score', $num, $cat, $blog); return; case 'livi': $this->li('views', $num, $cat, $blog); return; } $remote_ip = ServerVar('REMOTE_ADDR'); $time = time(); $exclusion_ip = split(",", $this->getOption('exclusion')); foreach($exclusion_ip as $value) {if(ltrim(rtrim($value)) == $remote_ip) return;} $query = "SELECT views,ip,ctime FROM ".sql_table('plugin_popularity'). " WHERE id=".$itemid; $res = sql_query($query); $row = sql_fetch_object($res); if(sql_num_rows($res) == 0){ $query = "INSERT INTO ".sql_table('plugin_popularity') . " VALUES ('$itemid','1','$remote_ip','$time','0')"; }else{ if($this->getOption('IgnoreRepeat') == 'yes') if($remote_ip == $row->ip) return; $time -= $row->ctime; if($time >= $this->getOption('SD')){ $views = $row->views; $score = intval($views * $this->getOption('SA') / $time); $views++; }else{ $score = -1; $views = $row->views + 1; } $query = "UPDATE ".sql_table('plugin_popularity') . " SET ip='$remote_ip',views='$views',score='$score' WHERE id=$itemid"; } sql_query($query); } function doSkinVar($skinType, $order, $num = '', $cat = '', $blog = ''){ switch ($order){ case 'lisc': $this->li('score', $num, $cat, $blog); return; case 'livi': $this->li('views', $num, $cat, $blog); return; } } function li($order, $num, $cat = '', $blog = ''){ $num = intval($num); $blog = $blog == '' ? $GLOBALS['blogid'] : intval($blog); $cat = $cat == '' ? $GLOBALS['catid'] : intval($cat); $blog = $blog ? " AND i.iblog = $blog" : ''; $cat = $cat ? " AND i.icat = $cat" : ''; if($order == 'score'){ $minv = $num >= 0 ? $this->getOption('SB') : $this->getOption('SC'); $minv = " AND v.views >= $minv AND v.score >= 0"; }else{ $minv = ''; } if($num >= 0){$od = 'DESC';}else{$od = 'ASC'; $num = -$num;} $q = "SELECT i.inumber id,v.views views,v.score score,i.ititle title". " FROM ".sql_table('plugin_popularity')." v, ".sql_table('item')." i". " WHERE v.id = i.inumber AND i.idraft = 0".$cat.$blog.$minv. " ORDER BY $order $od ". " LIMIT 0, ".$num; $res = sql_query($q); if($GLOBALS['catid']){$ext['catid'] = $GLOBALS['catid'];} echo "<ol>"; while($row = sql_fetch_array($res)){ echo '<li><a href="'.createItemLink($row['id'], $ext).'">'.($row['title']). '<small>('.$row['score'].'/'.$row['views'].')</small></a></li>'; } echo "</ol>"; } function event_PreDeleteItem(&$data) { sql_query( 'DELETE FROM '.sql_table('plugin_popularity'). ' WHERE id = '.$data['itemid'] ); } function event_PreUpdateItem(&$data) { $q = 'SELECT i.idraft result FROM '.sql_table('item').' i'. ' WHERE i.inumber='.$data['itemid']; if(quickQuery($q)) $this->event_PreDeleteItem($data); } function event_PreDeleteBlog(&$data) { sql_query( 'DELETE v FROM '. sql_table('plugin_popularity').' v, '.sql_table('item').' i'. ' WHERE v.id = i.inumber AND i.iblog = '.$data['blogid'] ); } } ?> NP_PluginList.php.patch
NP_PluginList.php.patch
*** NP_PluginList.php 2009-03-23 16:43:38.000000000 +0900 --- NP_PluginList.php 2004-02-16 18:58:04.000000000 +0900 *************** *** 15,33 **** // author of plugin function getAuthor() { ! return 'mas + akebia'; } // an URL to the plugin website // can also be of the form mailto:foo@bar.com function getURL() { ! return 'http://nyan.co.uk/akebia/item/382'; } // version of the plugin function getVersion() { ! return '1.1-1'; } // a description to be shown on the installed plugins listing --- 15,33 ---- // author of plugin function getAuthor() { ! return 'mas'; } // an URL to the plugin website // can also be of the form mailto:foo@bar.com function getURL() { ! return 'http://neconnect.net/'; } // version of the plugin function getVersion() { ! return '1.1'; } // a description to be shown on the installed plugins listing *************** *** 106,114 **** if($this->getOption(linkURL) == 'yes') // Link style ! $val = '<a href="'.$url[$key].'" title="author: '. ! htmlspecialchars($author[$key]).'">'. ! htmlspecialchars($val).'</a>'; echo $this->getOption(s_items) . $val .$ver. $this->getOption(e_items)."\n"; } --- 106,112 ---- if($this->getOption(linkURL) == 'yes') // Link style ! $val = '<a href="'.$url[$key].'" title="author: '.$author[$key].'">'. $val .'</a>'; echo $this->getOption(s_items) . $val .$ver. $this->getOption(e_items)."\n"; } *************** *** 117,120 **** } } ! ?> --- 115,118 ---- } } ! ?> \ ファイル末尾に改行がありません NP_Revision.php.patch
ご注意 このパッチは、何も考えずに適用すると厄介な事になることがあるので、関連記事をよく読んで納得できてから適用して下さい。 *** NP_Revision.php 2005-05-12 14:15:56.000000000 +0900 --- NP_Revision.php 2010-03-06 19:38:00.000000000 +0900 *************** *** 34,42 **** var $revertinprogress; function getName() { return 'Revision'; } ! function getAuthor() { return 'rakaz'; } ! function getURL() { return 'http://www.rakaz.nl/'; } ! function getVersion() { return '0.7'; } function getDescription() { return 'Store and access old revisions of stories.'; } function getTableList() { return array(sql_table("plugin_revision")); } --- 34,42 ---- var $revertinprogress; function getName() { return 'Revision'; } ! function getAuthor() { return 'rakaz + akebia'; } ! function getURL() { return 'http://nyan.co.uk/akebia/item/404'; } ! function getVersion() { return '0.7-4'; } function getDescription() { return 'Store and access old revisions of stories.'; } function getTableList() { return array(sql_table("plugin_revision")); } *************** *** 266,272 **** $rev = requestVar('rev'); if ($CONF['URLMode'] == 'pathinfo') { ! if (preg_match('/revision\/([0-9]+\.[0-9]+)/', serverVar('PATH_INFO'), $matches)) { $rev = $matches[1]; } } --- 266,274 ---- $rev = requestVar('rev'); if ($CONF['URLMode'] == 'pathinfo') { ! // if (preg_match('/revision\/([0-9]+\.[0-9]+)/', serverVar('PATH_INFO'), $matches)) { ! global $virtualpath; ! if (preg_match('/revision\/([0-9]+\.[0-9]+)/', $virtualpath, $matches)) { $rev = $matches[1]; } } *************** *** 338,344 **** } function event_PreAddItem(&$data) { ! $this->tmp = $data; } function event_PostAddItem(&$data) { --- 340,347 ---- } function event_PreAddItem(&$data) { ! //$this->tmp = $data; ! foreach ($data as $k => $v){$this->tmp[$k] = $v;} } function event_PostAddItem(&$data) { *************** *** 484,492 **** echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"; echo "<html><head><title>Revision overview for item ".$itemid."</title>"; echo "<link rel='stylesheet' type='text/css' href='".$CONF['AdminURL']."styles/bookmarklet.css' /><style type='text/css'>\n"; ! echo "th { text-align: left; }\n .diff-blockheader { background: #EEE; font-weight: bold; width: 50%;}\n"; ! echo ".diff-context { background: #EEE; }\n.diff-deletedline { background: #F99; }\n.diff-deletedline .diffchange { background: #933; color: #FFF; }\n"; ! echo ".diff-addedline { background: #9F9; }\n.diff-addedline .diffchange { background: #393; color: #FFF; }\n</style></head><body>"; echo "<h1>Revision overview for item ".$itemid."</h1>"; // Get every revision for this item... --- 487,495 ---- echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"; echo "<html><head><title>Revision overview for item ".$itemid."</title>"; echo "<link rel='stylesheet' type='text/css' href='".$CONF['AdminURL']."styles/bookmarklet.css' /><style type='text/css'>\n"; ! echo "th { text-align: left; }\n .diff-blockheader { background: #EEE; font-weight: bold; width: 50%; }\n"; ! echo ".diff-context { background: #EEE; white-space: normal; }\n.diff-deletedline { background: #F99; white-space: normal; }\n.diff-deletedline .diffchange { background: #933; color: #FFF; }\n"; ! echo ".diff-addedline { background: #9F9; white-space: normal; }\n.diff-addedline .diffchange { background: #393; color: #FFF; }\n</style></head><body>"; echo "<h1>Revision overview for item ".$itemid."</h1>"; // Get every revision for this item... *************** *** 591,597 **** } echo '<h3>Diff between revision '.$oldbase.'.'.$oldsub.' and '.$newbase.'.'.$newsub.':</h3>'; ! echo '<table>'; if ($olddata['ititle'] != $newdata['ititle']) { echo '<th colspan="4">Title</td>'; --- 594,600 ---- } echo '<h3>Diff between revision '.$oldbase.'.'.$oldsub.' and '.$newbase.'.'.$newsub.':</h3>'; ! echo '<table style="table-layout: auto;">'; if ($olddata['ititle'] != $newdata['ititle']) { echo '<th colspan="4">Title</td>'; *************** *** 909,912 **** } } ! ?> \ ファイル末尾に改行がありません --- 912,915 ---- } } ! ?> NP_RevisionFixDB.php
NP_RevisionFixDB.php
<?php class NP_RevisionFixDB extends NucleusPlugin{ function getName() {return 'Revision Fix DB';} function getAuthor() {return 'akebia';} function getURL() {return 'http://nyan.co.uk/akebia/item/404';} function getVersion() {return '1.1';} function getDescription(){return '初版の履歴データに対し、修正処理(アンクォート)を行います。';} function supportsFeature($f) {switch($f){case 'SqlTablePrefix': return 1; default: return 0;}} function getEventList() {return array ('PostPluginOptionsUpdate');} function install(){ $this->createOption('A','オプションの保存時に履歴データの修正処理を行いますか?(下の「メッセージ」のテキストエリア内の説明を読んでから決めて下さい。)','yesno','no'); $this->createOption('B','メッセージ','textarea','履歴データの修正処理は、よく分からない場合には、絶対に行わないこと。やり方を誤ると履歴データが壊れることがあります。このプラグイン自身には、この処理を行うべきか否かを自動的に判断する能力はありません。'); } function event_PostPluginOptionsUpdate($data){ if($this->getOption('A') != 'yes') return; $r = mysql_query( 'SELECT inumber, ititle, ibody, imore, rrevbase, rrevsub FROM ' . sql_table('plugin_revision') . " WHERE rcomment REGEXP '^Initial revision( |$)'" ); while($row = mysql_fetch_array($r)){mysql_query( 'UPDATE ' . sql_table('plugin_revision') . ' SET ititle="' . addslashes(stripslashes($row['ititle'])) . '",ibody="' . addslashes(stripslashes($row['ibody'])) . '",imore="' . addslashes(stripslashes($row['imore'])) . '"' . ' WHERE inumber=' . $row['inumber'] . ' AND rrevbase=' . $row['rrevbase'] . ' AND rrevsub=' . $row['rrevsub'] );} $this->setOption('A', 'no'); $this->setOption('B', '履歴データの修正処理は完了しました。この処理を繰り返し行うと履歴データが壊れることがあります。このまま「プラグイン管理」に戻り、このプラグインを削除して下さい。'); } } ?> NP_AutoTwitter.php.patch
NP_AutoTwitter.php.patch --- NP_AutoTwitter.php 2011-01-29 08:27:02.000000000 +0900 +++ NP_AutoTwitter.php 2013-08-18 21:54:14.000000000 +0900 @@ -17,20 +17,20 @@ // author of plugin function getAuthor(){ global $TWITTER; - return $TWITTER['AUTHOR']; + return $TWITTER['AUTHOR'].' + akebia'; } // an URL to the plugin website // can also be of the form mailto:foo@bar.com function getURL(){ global $TWITTER; - return $TWITTER['URL']; + return 'http://nyan.co.uk/akebia/item/695'; //$TWITTER['URL']; } // version of the plugin function getVersion(){ global $TWITTER; - return $TWITTER['VERSION']; + return $TWITTER['VERSION'].'-4'; } // a description to be shown on the installed plugins listing @@ -38,7 +38,7 @@ return 'Allows blog posts to be automatically announced via Twitter.'; } - function getEventList() { return array('PostAddItem','PreUpdateItem','PostUpdateItem','PostAddComment','QuickMenu'); } + function getEventList() { return array('PostAddItem','PreUpdateItem','PostUpdateItem','PostAddComment','QuickMenu','EditItemFormExtras'); } function init() { if (($this->getOption(UpdatePlugin)=="yes") || ($this->getOption(UpdatePlugin)=="")) { @@ -50,7 +50,7 @@ function event_PostAddComment(&$data) { global $manager,$blog; if($data['comment']['memberid'] > 0){ - if($this->getMemberOption($data['comment']['memberid'],'twitterComments')){ + if($this->getMemberOption($data['comment']['memberid'],'twitterComments') === 'yes'){ // The following line is causing failure, as blogid is not present in the array. if($data['comment']['blogid']){ $blogid=$data['comment']['blogid']; @@ -70,8 +70,9 @@ $b =& $manager->getBlog($CONF['DefaultBlog']); } $BlogURL = $b->getURL(); - $URLComponents=explode('?',createItemLink($data['comment']['itemid'])); - $LinkURL=$BlogURL.'?'.$URLComponents[1].'#c'; +// $URLComponents=explode('?',createItemLink($data['comment']['itemid'])); +// $LinkURL=$BlogURL.'?'.$URLComponents[1].'#c'; + $LinkURL=$this->shortenURL($this->itemURL($BlogURL, $data['comment']['itemid']).'#c'.$data['commentid'], $data['comment']['memberid']); $query = 'SELECT i.idraft as draft, i.inumber as itemid, i.iclosed as closed, ' . ' i.ititle as title, i.ibody as body, m.mname as author, ' @@ -100,7 +101,7 @@ $items = sql_query($query); $item = mysql_fetch_object($items); - if($this->getBlogOption($item->blogid,'twitterNewItems')){ + if($this->getBlogOption($item->blogid,'twitterNewItems') === 'yes'){ if($item->draft==0){ $this->sendItemTweet($item); } @@ -121,14 +122,15 @@ $query = 'SELECT i.idraft as draft, i.inumber as itemid,' . ' i.ititle as title,' . ' i.iauthor as authorid,' - . ' i.iblog as blogid ' - . ' FROM '.sql_table('item').' as i' - . ' WHERE i.inumber=' . $data['itemid']; + . ' c.cblog as blogid ' + . ' FROM '.sql_table('item').' as i,'.sql_table('category').' as c' + . ' WHERE i.icat=c.catid && i.inumber=' . $data['itemid']; $items = sql_query($query); $item = mysql_fetch_object($items); - if($this->getBlogOption($item->blogid,'twitterNewItems')){ - if(($this->itemIsDraft==1)&&($item->draft==0)){ + if($this->getBlogOption($item->blogid,'twitterNewItems') === 'yes'){ + if((($this->itemIsDraft==1)||requestvar('plug_autotwitter_tweet'))&& + ($item->draft==0)){ $this->sendItemTweet($item); } } @@ -158,6 +160,14 @@ $this->createMemberOption('twitterComments','Tweet Comments','yesno'); if (count($this->getAllMemberOptions('twitterCommentsTempl'))==0) $this->createMemberOption('twitterCommentsTempl','Tweet Template','text','Commented on %##BLOGNAME##% - %##URL##%'); + if (count($this->getAllMemberOptions('twitterBitly'))==0) + $this->createMemberOption('twitterBitly','Shorten URL with bit.ly','yesno'); + if (count($this->getAllMemberOptions('twitterBitlyDomain'))==0) + $this->createMemberOption('twitterBitlyDomain','bit.ly Domain','text','bit.ly'); + if (count($this->getAllMemberOptions('twitterBitlyUsername'))==0) + $this->createMemberOption('twitterBitlyUsername','bit.ly Username','text',''); + if (count($this->getAllMemberOptions('twitterBitlyAPIKey'))==0) + $this->createMemberOption('twitterBitlyAPIKey','bit.ly API Key','text',''); if (count($this->getAllBlogOptions('twitterNewItems'))==0) $this->createBlogOption('twitterNewItems','Tweet New Posts','yesno'); if (count($this->getAllBlogOptions('twitterNewItemsTempl'))==0) @@ -251,18 +261,57 @@ * @return unknown_type */ function sendItemTweet(&$item){ - global $manager,$blog; + global $manager,$blog,$CONF; // Post tweet for item, but only if the user has a username and password specified. $access_token = TwitterDriver::getAccessTokenForUser($item->authorid); if(TwitterDriver::isValidAccessToken($access_token)){ $b =& $manager->getBlog($item->blogid); $BlogURL = $b->getURL(); - $URLComponents=explode('?',createItemLink($item->itemid)); - $LinkURL=$BlogURL.'?'.$URLComponents[1]; - $twitterNewItemsTempl=$this->getBlogOption($item->authorid,'twitterNewItemsTempl'); +// $URLComponents=explode('?',createItemLink($item->itemid)); +// $LinkURL=$BlogURL.'?'.$URLComponents[1]; + $LinkURL=$this->shortenURL($this->itemURL($BlogURL, $item->itemid), $item->authorid); + $twitterNewItemsTempl=$this->getBlogOption($item->blogid,'twitterNewItemsTempl'); $tweet=$this->getReplacedText($twitterNewItemsTempl,$LinkURL,$item->title,$b->getName()); TwitterDriver::sendRawTweet($tweet,$access_token); } } + + function itemURL($blogurl, $itemid){ + global $CONF; + if ($CONF['URLMode'] == 'pathinfo') { + $LinkURL = $blogurl . $CONF['ItemKey'] . '/' . $itemid; + } else { + $LinkURL = $blogurl . '?itemid=' . $itemid; + } + return $LinkURL; + } + + function shortenURL($url, $authorid){ + if($this->getMemberOption($authorid,'twitterBitly') === 'yes'){ + $ch = curl_init(); + $w = array( + CURLOPT_URL => + 'http://api.'.$this->getMemberOption($authorid,'twitterBitlyDomain'). + '/v3/shorten?login='.$this->getMemberOption($authorid,'twitterBitlyUsername'). + '&apiKey='.$this->getMemberOption($authorid,'twitterBitlyAPIKey'). + '&format=txt&longUrl='.$url, + CURLOPT_RETURNTRANSFER => 1 + ); + curl_setopt_array($ch, $w); + $w = curl_exec($ch); + curl_close($ch); + if (substr($w, 0, 7) === 'http://') return $w; + } + return $url; + } + + function event_EditItemFormExtras(&$data) { + if($data['variables']['draft']) return; + global $TWITTER; + echo '<h3>',$TWITTER['TITLE'],'</h3>', + '<p><label>', + '<input name="plug_autotwitter_tweet" type="checkbox">Tweet', + '</label></p>'; + } } ?> \ ファイル末尾に改行がありません aw.SetSuspendState.c
aw.SetSuspendState.c /* aw.SetSuspendState.c 2013-7-21 by akebia * SetSuspendState * http://nyan.co.uk/akebia/item/848 */ #include <windows.h> #include <PowrProf.h> #include <string.h> int a(int argc, char *argv[], char *s) { int i; for(i = 1; i < argc; i++){ if(stricmp(argv[i], s) == 0) return TRUE; } return FALSE; } int main(int argc, char *argv[]) { return SetSuspendState( a(argc, argv, "Hibernate"), a(argc, argv, "ForceCritical"), a(argc, argv, "DisableWakeEvent") ) == 0 ? -1 : 0; } aw.suspend.js
aw.suspend.js // aw.suspend.js 2013-7-21 by akebia // SetSuspendState // http://nyan.co.uk/akebia/item/848 args = new Array(); objArgs = WScript.Arguments; for (i = 0; i < objArgs.length; i++){args[i] = objArgs(i);} new ActiveXObject("WScript.Shell").Run( 'cmd /C aw.SetSuspendState "' + args.join('" "') + '"', 0, false ); NP_GenerateURL.php
NP_GenerateURL.php <?php class NP_GenerateURL extends NucleusPlugin{ function getName() {return 'Generate URL';} function getAuthor() {return 'akebia';} function getURL() {return 'http://nyan.co.uk/akebia/item/858';} function getVersion() {return '1.2';} function getDescription(){return '';} function getEventList() {return array('GenerateURL');} function supportsFeature($f){switch($f){ case 'SqlTablePrefix': case 'SqlApi': return 1; default: return 0;}} function event_GenerateURL($data) { global $CONF, $manager, $virtualpath, $blogid; // url already generated if ($data['completed']) return; $params = $data['params']; $extra = $params['extra']; if (!is_array($extra)) $extra = array(); switch ($data['type']) { case 'item': $item_id = intval($params['itemid']); $blog_id = getBlogIDFromItemID($item_id); if ($blog_id == $blogid || !$blog_id) { $base_url = $CONF['ItemURL']; } else { $b =& $manager->getBlog($blog_id); $base_url = $b->getURL(); } if (substr($base_url, -1) != '/') $base_url .= '/'; $url = $base_url.$CONF['ItemKey'].'/'.$item_id; break; case 'member': $member_id = intval($params['memberid']); $url = $CONF['Self'].'/'.$CONF['MemberKey'].'/'.$member_id; break; case 'category': $cat_id = intval($params['catid']); $blog_id = getBlogIDFromCatID($cat_id); if ($blog_id == $blogid) { $base_url = $CONF['CategoryURL']; } elseif(!$blog_id) { $url = $CONF['CategoryURL'].'/'; break; } else { $b =& $manager->getBlog($blog_id); $base_url = $b->getURL(); } if (substr($base_url, -1) != '/') $base_url .= '/'; $url = $base_url.$CONF['CategoryKey'].'/'.$cat_id; break; case 'archivelist': if (!$params['blogid']) { $blog_id = $CONF['DefaultBlog']; } else { $blog_id = intval($params['blogid']); } if ($blog_id == $blogid || !$blog_id) { $base_url = $CONF['ArchiveListURL']; } else { $b =& $manager->getBlog($blog_id); $base_url = $b->getURL(); } if (substr($base_url, -1) != '/') $base_url .= '/'; $url = $base_url.$CONF['ArchivesKey'].'/'.$blog_id; break; case 'archive': $blog_id = intval($params['blogid']); if ($blog_id == $blogid || !$blog_id) { $base_url = $CONF['ArchiveURL']; } else { $b =& $manager->getBlog($blog_id); $base_url = $b->getURL(); } sscanf($params['archive'], '%d-%d-%d', $y, $m, $d); if ($d) { $archive = sprintf('%d-%d-%d', $y, $m, $d); } else { $archive = sprintf('%d-%d', $y, $m); } if (substr($base_url, -1) != '/') $base_url .= '/'; $url = $base_url.$CONF['ArchiveKey'].'/'.$archive; break; case 'blog': $blog_id = intval($params['blogid']); if ($blog_id == $blogid || !$blog_id) { $base_url = $CONF['BlogURL']; } else { $b =& $manager->getBlog($blog_id); $base_url = $b->getURL(); } if (substr($base_url, -1) != '/') $base_url .= '/'; $url = $base_url; break; } if ($extra['blogid'] == $blogid && !preg_match('/(^|\/)('.$CONF['BlogKey'].'|blogid)\//', $virtualpath)) { unset($extra['blogid']); } $data['url'] = addLinkParams($url, $extra); $data['completed'] = TRUE; return $data; } } ?> NP_RevisionFirst.php
NP_RevisionFirst.php <?php class NP_RevisionFirst extends NucleusPlugin{ function getName() {return 'Revision First';} function getAuthor() {return 'akebia';} function getURL() {return 'http://nyan.co.uk/akebia/item/235';} function getVersion() {return '1.2';} function getDescription(){return '<%RevisionFirst%>';} function supportsFeature($f) {switch($f){case 'SqlTablePrefix': return 1; default: return 0;}} function doSkinVar($skinType, $itemid = '') {echo $this->eval_First($itemid);} function doTemplateVar(&$item) {echo $this->eval_First($item->itemid);} function eval_First($itemid){ $last = $this->firstRevision($itemid); if($last){ list($base, $sub) = $last; return $base . '.' . $sub; }else{ return '1.0'; } } function firstRevision($inumber) { global $manager; $manager->_loadPlugin('NP_Revision'); $o = $manager->plugins['NP_Revision']; if($o->getOption('acOp1')){ $l = $o->lastRevision($inumber); if($l) $l = $l[0]; else $l = 1; $res = mysql_query( 'SELECT rrevbase, rrevsub FROM ' . sql_table('plugin_revision') . ' WHERE inumber = ' . $inumber . ' AND idraft = 0 AND rrevbase = ' . $l . ' ORDER BY rrevbase ASC, rrevsub ASC LIMIT 1' ); }else{ $res = mysql_query( 'SELECT rrevbase, rrevsub FROM ' . sql_table('plugin_revision') . ' WHERE inumber = ' . $inumber . ' AND idraft = 0' . ' ORDER BY rrevbase ASC, rrevsub ASC LIMIT 1' ); } if($row = mysql_fetch_array($res)) return array($row['rrevbase'], $row['rrevsub']); else return false; } } ?> NP_znItemCache.php.patch
NP_znItemCache.php.patch *** NP_znItemCache.php 2007-05-15 06:47:18.000000000 +0900 --- NP_znItemCache.php 2013-08-12 19:42:15.476434151 +0900 *************** *** 27,33 **** } if (!$this->checkPluginOption('debugMode')) $this->createOption("debugMode", 'debug mode', 'yesno', 'no'); if (!$this->checkPluginOption('verCheck')) $this->createOption('verCheck', ''._ZNITEMCACHE1.'', 'yesno', 'no'); //version check //vc ! return '0.024'; } function getName() { --- 27,33 ---- } if (!$this->checkPluginOption('debugMode')) $this->createOption("debugMode", 'debug mode', 'yesno', 'no'); if (!$this->checkPluginOption('verCheck')) $this->createOption('verCheck', ''._ZNITEMCACHE1.'', 'yesno', 'no'); //version check //vc ! return '0.024-2'; } function getName() { *************** *** 35,45 **** } function getAuthor() { ! return ''._ZNITEMCACHE2.''; } function getURL() { ! return 'http://wa.otesei.com/NP_znItemCache'; } function supportsFeature($w) { --- 35,45 ---- } function getAuthor() { ! return ''._ZNITEMCACHE2.' + akebia'; } function getURL() { ! return 'http://nyan.co.uk/akebia/item/231'; } function supportsFeature($w) { *************** *** 125,130 **** --- 125,139 ---- function event_PreSkinParse() { global $CONF; + //NP_Revision + $this->rev = requestVar('rev'); + if ($CONF['URLMode'] == 'pathinfo') { + global $virtualpath; + if (preg_match('/revision\/([0-9]+\.[0-9]+)/', $virtualpath, $matches)) { + $this->rev = $matches[1]; + } + } + //$CONF['Self'] $confSelf = $this->getOption('confSelf'); $this->selfArray = array_map('trim', preg_split("/[\r\n]+/", $confSelf)); *************** *** 203,208 **** --- 212,232 ---- function event_PreItem($data) { global $manager; + //NP_Revision + if ($this->rev != '') { + $manager->_loadPlugin('NP_Revision'); $o = $manager->plugins['NP_Revision']; + if($this->rev == $o->eval_Last($data['item']->itemid)) { + $this->rev = ''; + } else { + if ($this->cacheExist($data['item']->itemid)) { + $o->event_PreItem($data); + if($data['item']->body) $this->cacheFound($data); + $manager->subscriptions['PreItem'] = array('NP_znItemCache'); // + return; + } + } + } + // if ($this->cacheExist($data['item']->itemid)) { $this->cacheFound($data); *************** *** 224,230 **** $data['item']->more = $cache['more']; // $manager->subscriptions['PreItem'] = $this->notcachePlugins; ! $manager->notify('PreItem', array('blog' => &$data['blog'], 'item' => &$data['item'])); } else { //unserialize $this->cacheNotFound($data); --- 248,254 ---- $data['item']->more = $cache['more']; // $manager->subscriptions['PreItem'] = $this->notcachePlugins; ! $_ = array('blog' => &$data['blog'], 'item' => &$data['item']); $manager->notify('PreItem', $_); } else { //unserialize $this->cacheNotFound($data); *************** *** 238,244 **** global $manager; // $manager->subscriptions['PreItem'] = array_diff($this->subscriptionsPreItem, $this->notcachePlugins); ! $manager->notify('PreItem', array('blog' => &$data['blog'], 'item' => &$data['item'])); // $ibody = $data['item']->body; $imore = $data['item']->more; --- 262,268 ---- global $manager; // $manager->subscriptions['PreItem'] = array_diff($this->subscriptionsPreItem, $this->notcachePlugins); ! $_ = array('blog' => &$data['blog'], 'item' => &$data['item']); $manager->notify('PreItem', $_); // $ibody = $data['item']->body; $imore = $data['item']->more; *************** *** 250,256 **** } // $manager->subscriptions['PreItem'] = $this->notcachePlugins; ! $manager->notify('PreItem', array('blog' => &$data['blog'], 'item' => &$data['item'])); } // // --- 274,280 ---- } // $manager->subscriptions['PreItem'] = $this->notcachePlugins; ! $_ = array('blog' => &$data['blog'], 'item' => &$data['item']); $manager->notify('PreItem', $_); } // // *************** *** 276,281 **** --- 300,311 ---- //global $manager; //$cacheFileName = $manager->getParserProperty('znItemCachePrefix') . $itemid; global $CONF; + //NP_Revision + if ($this->rev != '') { + $cacheFileName = $CONF['Self'] . $itemid . '/' . $this->rev; + return $this->getDirectory().'cache/'.md5('i'.$cacheFileName); + } + $cacheFileName = $CONF['Self'] . $itemid; return $this->getDirectory().'cache/'.md5('i'.$cacheFileName); } NP_MarkdownEditor.php.patch
NP_MarkdownEditor.php.patch *** NP_MarkdownEditor.php 2007-11-24 00:27:40.000000000 +0900 --- NP_MarkdownEditor.php 2013-08-16 16:18:56.533786622 +0900 *************** *** 32,40 **** class NP_MarkdownEditor extends NucleusPlugin { function getName() { return 'Markdown Editor for Nucleus'; } ! function getAuthor() { return 'yu'; } ! function getVersion() { return '0.1'; } ! function getURL() { return 'http://nucleus.datoka.jp/';} function getMinNucleusVersion() { return 250; } function getDescription() { return _MARKDOWNEDITOR_DESCRIPTION; } function supportsFeature($what) { return (int)($what=='SqlTablePrefix'); } --- 32,40 ---- class NP_MarkdownEditor extends NucleusPlugin { function getName() { return 'Markdown Editor for Nucleus'; } ! function getAuthor() { return 'yu + akebia'; } ! function getVersion() { return '0.1-1'; } ! function getURL() { return 'http://nyan.co.uk/akebia/item/884';} function getMinNucleusVersion() { return 250; } function getDescription() { return _MARKDOWNEDITOR_DESCRIPTION; } function supportsFeature($what) { return (int)($what=='SqlTablePrefix'); } *************** *** 96,102 **** $script=''; $pattern='/<div([^>]*?)class="jsbuttonbar"([^>]*?)>/'; if (preg_match($pattern,$buff,$matches)){ ! $manager->notify('PreToolbarParse',array('lbutton' => &$lbutton, 'rbutton' => &$rbutton, 'script' => &$script)); //$buff=str_replace($matches[0],$matches[0].$lbutton,$buff); $pattern=array('/<\/div>([^<]*?)<textarea([^>]*?)id="inputbody"([^>]*?)>/', --- 96,102 ---- $script=''; $pattern='/<div([^>]*?)class="jsbuttonbar"([^>]*?)>/'; if (preg_match($pattern,$buff,$matches)){ ! $_ = array('lbutton' => &$lbutton, 'rbutton' => &$rbutton, 'script' => &$script); $manager->notify('PreToolbarParse',$_); //$buff=str_replace($matches[0],$matches[0].$lbutton,$buff); $pattern=array('/<\/div>([^<]*?)<textarea([^>]*?)id="inputbody"([^>]*?)>/', NP_znShowDraft.php.patch
NP_znShowDraft.php.patch *** NP_znShowDraft.php 2007-05-21 20:57:12.000000000 +0900 --- NP_znShowDraft.php 2016-03-12 20:58:47.337823500 +0900 *************** *** 5,12 **** */ class NP_znShowDraft extends NucleusPlugin { function getName() { return 'ShowDraft'; } ! function getURL() { return 'http://wa.otesei.com/NP_znShowDraft'; } ! function getVersion() { return '0.02'; } function supportsFeature($w) { return ($w == 'SqlTablePrefix') ? 1 : 0; } function getDescription() { --- 5,12 ---- */ class NP_znShowDraft extends NucleusPlugin { function getName() { return 'ShowDraft'; } ! function getURL() { return 'http://2hz.org/akebia/item/1002'; } ! function getVersion() { return '0.02-2'; } function supportsFeature($w) { return ($w == 'SqlTablePrefix') ? 1 : 0; } function getDescription() { *************** *** 15,21 **** function getAuthor() { $this->languageInclude(); ! return ''._ZNSD2.''; } function install() { --- 15,21 ---- function getAuthor() { $this->languageInclude(); ! return ''._ZNSD2.' + akebia'; } function install() { *************** *** 75,87 **** global $itemid, $highlight; if (!$member->canAlterItem($itemid)) return; // if ($manager->existsItem($itemid, 1, 0)) return; // ! $manager->notify('PreBlogContent',array('blog' => &$blog, 'type' => 'item')); $query = $blog->getSqlBlog('AND 0 OR i.inumber='.intval($itemid)).' limit 1'; $numrows = $this->numrows($query); if ($numrows) echo $this->getOption('draftHeader'); $blog->showUsingQuery($template, $query, '', 1, 1); if ($numrows) echo $this->getOption('draftfooter'); ! $manager->notify('PostBlogContent',array('blog' => &$blog, 'type' => 'item')); break; } } --- 75,87 ---- global $itemid, $highlight; if (!$member->canAlterItem($itemid)) return; // if ($manager->existsItem($itemid, 1, 0)) return; // ! $_ = array('blog' => &$blog, 'type' => 'item'); $manager->notify('PreBlogContent',$_); $query = $blog->getSqlBlog('AND 0 OR i.inumber='.intval($itemid)).' limit 1'; $numrows = $this->numrows($query); if ($numrows) echo $this->getOption('draftHeader'); $blog->showUsingQuery($template, $query, '', 1, 1); if ($numrows) echo $this->getOption('draftfooter'); ! $_ = array('blog' => &$blog, 'type' => 'item'); $manager->notify('PostBlogContent',$_); break; } } *************** *** 152,158 **** $skin = new SKIN($skinid); if (!$skin->isValid) doError(_ERROR_NOSUCHSKIN); // parse the skin ! $skin->parse('item'); } } ?> --- 152,159 ---- $skin = new SKIN($skinid); if (!$skin->isValid) doError(_ERROR_NOSUCHSKIN); // parse the skin ! $output = $skin->parse('item'); ! echo $output; } } ?> NP_ExtraSkinJP.php.patch
NP_ExtraSkinJP.php.patch *** NP_ExtraSkinJP.php 2007-10-10 16:48:14.000000000 +0900 --- NP_ExtraSkinJP.php 2013-08-16 16:16:12.073238610 +0900 *************** *** 33,41 **** class NP_ExtraSkinJP extends NucleusPlugin { function getName() { return 'ExtraSkinJP'; } ! function getAuthor() { return 'Radek HULAN + Taka + Nucleus(JP) team'; } ! function getURL() { return 'http://japan.nucleuscms.org/wiki/plugins:extraskinjp'; } ! function getVersion() { return '0.4.7'; } function getDescription() { return ''._LANG_NP_EXTRASKINJP10.''; } function supportsFeature($what) { --- 33,41 ---- class NP_ExtraSkinJP extends NucleusPlugin { function getName() { return 'ExtraSkinJP'; } ! function getAuthor() { return 'Radek HULAN + Taka + Nucleus(JP) team + akebia'; } ! function getURL() { return 'http://nyan.co.uk/akebia/item/884'; } ! function getVersion() { return '0.4.7-1'; } function getDescription() { return ''._LANG_NP_EXTRASKINJP10.''; } function supportsFeature($what) { *************** *** 576,588 **** $contenttype = 'text/html'; } if (function_exists("sendContentType")) { ! $manager->notify( ! 'PreSendContentType', ! array( 'contentType' => &$contenttype, 'charset' => &$charset, 'pageType' => 'skin' ! ) ); } if (!headers_sent()) --- 576,589 ---- $contenttype = 'text/html'; } if (function_exists("sendContentType")) { ! $_ = array( 'contentType' => &$contenttype, 'charset' => &$charset, 'pageType' => 'skin' ! ); ! $manager->notify( ! 'PreSendContentType', ! $_ ); } if (!headers_sent()) *************** *** 593,606 **** $skinType = ($o->skintype == 'same') ? $o->skinvartype : 'pageparser'; if (!isset($skin)) $skin = new SKIN($CONF['BaseSkin']); ! $manager->notify('PreSkinParse',array('skin' => &$skin, 'type' => $skinType)); $handler =& new ACTIONS($skinType); $parser =& new PARSER(SKIN::getAllowedActionsForType($o->skinvartype), $handler); $handler->setParser($parser); $parser->parse($o->skin); ! $manager->notify('PostSkinParse',array('skin' => &$skin, 'type' => $skinType)); } } --- 594,607 ---- $skinType = ($o->skintype == 'same') ? $o->skinvartype : 'pageparser'; if (!isset($skin)) $skin = new SKIN($CONF['BaseSkin']); ! $_ = array('skin' => &$skin, 'type' => $skinType); $manager->notify('PreSkinParse',$_); $handler =& new ACTIONS($skinType); $parser =& new PARSER(SKIN::getAllowedActionsForType($o->skinvartype), $handler); $handler->setParser($parser); $parser->parse($o->skin); ! $_ = array('skin' => &$skin, 'type' => $skinType); $manager->notify('PostSkinParse',$_); } } *** extraskinjp/class.php 2004-12-18 23:08:00.000000000 +0900 --- extraskinjp/class.php 2013-08-14 22:30:40.662692313 +0900 *************** *** 16,22 **** function action($action) { $methodName = 'action_' . $action; if (method_exists($this, $methodName)) { ! call_user_func(array(&$this, $methodName)); } else { $this->error(_BADACTION . " ($action)"); } --- 16,22 ---- function action($action) { $methodName = 'action_' . $action; if (method_exists($this, $methodName)) { ! call_user_func(array($this, $methodName)); } else { $this->error(_BADACTION . " ($action)"); } NP_TrackBack.php.patch
NP_TrackBack.php.patch *** NP_TrackBack.php 2008-12-14 21:39:20.000000000 +0900 --- NP_TrackBack.php 2013-08-16 17:14:24.927015497 +0900 *************** *** 1160,1166 **** 'ipblock' => true, ); ! $manager->notify('SpamCheck', array ('spamcheck' => & $spamcheck)); if (isset($spamcheck['result']) && $spamcheck['result'] == true) { --- 1160,1166 ---- 'ipblock' => true, ); ! $_ = array ('spamcheck' => & $spamcheck); $manager->notify('SpamCheck', $_); if (isset($spamcheck['result']) && $spamcheck['result'] == true) { *************** *** 2442,2450 **** /* Plugin API calls, for installation, configuration and setup */ function getName() { return 'TrackBack'; } ! function getAuthor() { return 'rakaz + nakahara21 + hsur'; } ! function getURL() { return 'http://blog.cles.jp/np_cles/category/31/subcatid/3'; } ! function getVersion() { return '2.0.3 jp13'; } function getDescription() { return '[$Revision: 1.311 $]<br />' . _TB_DESCRIPTION; } //modify start+++++++++ --- 2442,2450 ---- /* Plugin API calls, for installation, configuration and setup */ function getName() { return 'TrackBack'; } ! function getAuthor() { return 'rakaz + nakahara21 + hsur + akebia'; } ! function getURL() { return 'http://nyan.co.uk/akebia/item/884'; } ! function getVersion() { return '2.0.3 jp13-1'; } function getDescription() { return '[$Revision: 1.311 $]<br />' . _TB_DESCRIPTION; } //modify start+++++++++ sdl2ics.pl
sdl2ics.pl #!/usr/bin/perl # sdl2ics.pl 2017-1-3 by akebia # Calender.sdl to iCal converter # http://2hz.org/akebia/item/1030 use utf8; use Encode; use Data::ICal; use Data::ICal::Entry::Event; use Data::ICal::Entry::Todo; my @a = (), $w, $event = 0, $todo = 0, $due = 0, $comp = 0; foreach $_ (@ARGV[1..$#ARGV]) { if($_ =~ /^\d+$/){push(@a, $_); next;} $w = lc($_); if($w eq 'event'){$event = 1; next;} if($w eq 'todo'){$todo = 1; next;} if($w eq 'due'){$due = 1; next;} if($w eq 'completed'){$comp = 1; next;} if($w ne ''){die "'$w' is unknown option";} } my $sd = $a[0] ? $a[0] : '00000000'; my $ed = $a[1] ? $a[1] : '99999999'; @a = (); my $b = []; my $i, $fh, $fn = $ARGV[0]; open($fh, $fn) or die "$!"; binmode($fh); while(read($fh, $_, 2) == 2){ for($i = unpack("S<", $_); $i && read($fh, $_, 1); $i--){ $_ = $_ ne "\xff" ? unpack("C", $_) : read($fh, $_, 2) == 2 ? unpack("S<", $_) : 0; unless(read($fh, $_, $_)){$_ = "";} push(@$b, $_); } push(@a, $b); $b = []; } close($fh); my $y = shift(@a); splice(@$y, 0, 100); my $m = shift(@a); splice(@$m, 0, 100); my $d = shift(@a); splice(@$d, 0, 100); $b = shift(@a); splice(@$b, 0, 100); my $ic = Data::ICal->new, $ie; my $ymd, $c = 0; for($i = @$y; $i; $i--){ $ymd = sprintf('%02d%02d%02d', shift(@$y), shift(@$m), shift(@$d)); if($ymd lt $sd or $ymd gt $ed){shift(@$b); next;} $_ = decode('cp932', shift(@$b)); $_ =~ s/\r//g; if($_ =~ /([^\s ][^\n]*)/){$w = $1; $w =~ s/[\s ]+$//;}else{$w = '';} if($event){ $ie = Data::ICal::Entry::Event->new; $ie->add_properties( "UID" => "e$ymd\@$fn", "DTSTART" => ["$ymd", {"VALUE" => "DATE"}], "SUMMARY" => $w, "DESCRIPTION" => $_); $ic->add_entry($ie); $c++; } if($todo){ $ie = Data::ICal::Entry::Todo->new; $ie->add_properties( "UID" => "t$ymd\@$fn", "DTSTART" => ["$ymd", {"VALUE" => "DATE"}], "SUMMARY" => $w, "DESCRIPTION" => $_); $due and $ie->add_property("DUE" => ["$ymd", {"VALUE" => "DATE"}]); $comp and $ie->add_property("STATUS" => "COMPLETED"); $ic->add_entry($ie); $c++; } } binmode(STDOUT); print Encode::encode('utf8', $ic->as_string); print STDERR "$c item(s)\n";
<
|