Changeset 38603
- Timestamp:
- 10/20/10 14:59:04 (3 years ago)
- Files:
-
- 1 modified
-
platform/tdiary/util/posttdiary/posttdiary-ex.rb (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
platform/tdiary/util/posttdiary/posttdiary-ex.rb
r37368 r38603 1 1 #!/usr/bin/env ruby 2 $KCODE= 'u'3 2 # 4 # posttdiary-ex: update tDiary via e-mail. $Revision: 1. 6.2.4$3 # posttdiary-ex: update tDiary via e-mail. $Revision: 1.2 $ 5 4 # 6 5 # Copyright (C) 2002, All right reserved by TADA Tadashi <sho@spc.gr.jp> 7 6 # You can redistribute it and/or modify it under GPL2. 8 7 # 9 # 20 07.9.22: v.1.66: Modified by K.Sakurai (http://ks.nwr.jp)8 # 2010.10.19: v.1.71: Modified by K.Sakurai (http://ks.nwr.jp) 10 9 # Acknowledgements: 11 # * Based on posttdiary.rb v1.2by TADA.10 # * Based on posttdiary.rb & tdiary.rb by TADA. 12 11 # * Some codes partially imported from Enikki Plugin Ex. : 13 12 # http://shimoi.s26.xrea.com/hiki/hiki.cgi?TdiaryEnikkiEx … … 16 15 # * Thanks to tamo (http://tamo.tdiary.net) for image-POSTing codes & testing. 17 16 # 17 18 # language setup for tdiary.conf (for both @data_path & @tdiary_dirname) 19 @tdencoding = 'UTF-8' 20 # @tdencoding = 'US-ASCII' 21 # @tdencoding = 'EUC-JP' 22 # @tdencoding = 'Big5' 18 23 19 24 #---------------------------------------------- … … 166 171 text.gsub!( /\![^\r\n]*[\r\n]+/, '' ) 167 172 end 168 text.delete( "\t")173 text.delete( /\t/ ) 169 174 end 170 175 … … 183 188 @data_path = add_delimiter( @data_path ) 184 189 raise TDiaryError, 'posttdiary-ex: Do not set @data_path as same as tDiary system directory.' if @data_path == @tdiary_dirname 185 190 def_vars1 = '' 191 def_vars2 = '' 186 192 variables = [:author_name, :author_mail, :index_page, :hour_offset] 193 variables.each do |var| 194 def_vars1 << "#{var} = nil\n" 195 def_vars2 << "@#{var} = #{var} unless #{var} == nil\n" 196 end 197 187 198 begin 188 199 cgi_conf = File::open( "#{@data_path}tdiary.conf" ){|f| f.read } 189 200 cgi_conf.untaint unless @secure 190 eval( cgi_conf, binding, "(cgi_conf)", 1 ) 191 variables.each do |var| eval "@#{var} = #{var} if #{var} != nil" end 192 rescue IOError, Errno::ENOENT 201 cgi_conf.force_encoding( @tdencoding ) 202 b = binding.taint 203 eval( cgi_conf, b, "(cgi_conf)", 1 ) 204 eval( def_vars2, b ) 205 rescue IOError, Errno::ENOENT 193 206 end 194 207 end … … 211 224 @options = {} 212 225 # evaluate tdiary.conf (load_cgi_conf() would be called as well, via tdiary.conf) 213 eval( File::open( @tdiary_dirname + @tdiary_conf_file ){|f| f.read }.untaint, binding, "(tdiary.conf)", 1 ) 226 227 f = File::open( @tdiary_dirname + @tdiary_conf_file ){|f| f.read }.untaint.force_encoding(@tdencoding) 228 eval( f, binding, "(tdiary.conf)", 1 ) 214 229 215 230 Dir.chdir( orgdir ) … … 296 311 cmdstr = @magickpath + "identify" 297 312 check_command( cmdstr ) 313 return false if !FileTest::exist?( name ) 298 314 begin 299 315 imgsize = %x[#{cmdstr} '#{name}'].sub(/#{name}/, '').split[1][/\d+x\d+/] … … 323 339 v = "" 324 340 check_command( @exifpath ) 341 return "" if !FileTest::exist?( fullpath_imgname ) 325 342 open( "| #{@exifpath} -t \"User Comment\" #{fullpath_imgname}", "r" ) do |f| 326 343 s = f.readlines 327 344 s.each do |t| 328 345 t.gsub!( /.*Value:/, '' ) 329 v = NKF::nkf( '-m0 - wXd', t ).gsub!( /^\s+/, '' ).chomp! if $&346 v = NKF::nkf( '-m0 -Xwd', t ).gsub!( /^\s+/, '' ).chomp! if $& 330 347 end 331 348 end … … 343 360 v = '' 344 361 check_command( @exifpath ) 362 return 1 if !FileTest::exist?( fullpath_imgname ) 345 363 open( "| #{@exifpath} -t \"Orientation\" #{fullpath_imgname}", "r" ) do |f| 346 364 s = f.readlines … … 740 758 case opt 741 759 when '--read-conffile' 742 conf_df_name = arg 760 conf_df_name = arg.dup 743 761 when '--image-path' 744 image_dir = arg 762 image_dir = arg.dup 745 763 when '--image-url' 746 image_url = arg 764 image_url = arg.dup 747 765 when '--use-subject' 748 766 use_subject = true 749 767 when '--make-thumbnail' 750 thumbnail_size = arg 768 thumbnail_size = arg.dup 751 769 when '--image-geometry' 752 image_geometry = arg 770 image_geometry = arg.dup 753 771 when '--use-image-ex' 754 772 use_image_ex = true … … 762 780 763 781 when '--convert-path' 764 convertpath_specified = arg 782 convertpath_specified = arg.dup 765 783 when '--exif-path' 766 exifpath_specified = arg 784 exifpath_specified = arg.dup 767 785 read_exif = true 768 786 when '--remote-mode' 769 787 remote_mode = true 770 788 when '--remote-image-path' 771 remote_image_dir = add_delimiter(arg )789 remote_image_dir = add_delimiter(arg.dup) 772 790 when '--remote-yearly-dir' 773 remote_yearly_dir = (arg =~ /[1yt]/i)791 remote_yearly_dir = (arg.dup =~ /[1yt]/i) 774 792 when '--preserve-local-images' 775 793 preserve_local_images = true … … 780 798 if arg =~ /\D/ then 781 799 require 'etc' 782 group_id = Etc.getgrnam( arg )['gid']800 group_id = Etc.getgrnam( arg.dup )['gid'] 783 801 else 784 802 group_id = arg.to_i … … 788 806 add_div_imgnum_specified = arg.to_i 789 807 when '--threshold-size' 790 threshold_size = arg 808 threshold_size = arg.dup 791 809 when '--image-format' 792 image_format_specified = arg 810 image_format_specified = arg.dup 793 811 when '--use-original-name' 794 812 use_original_name = true … … 806 824 when '--write-to-file' 807 825 filter_mode = true 808 writeout_filename = arg 826 writeout_filename = arg.dup 809 827 when '--date-margin' 810 828 date_margin = arg.to_i … … 882 900 883 901 if filter_mode == false then 884 url = ARGV.shift 902 url = ARGV.shift.dup 885 903 if %r|http://([^:/]*):?(\d*)(/.*)| =~ url then 886 904 host = $1 … … 892 910 raise 'posttdiary-ex: invalid url for update.rb.' 893 911 end 894 user = ARGV.shift 895 pass = ARGV.shift 912 user = ARGV.shift.dup 913 pass = ARGV.shift.dup 896 914 end 897 915 … … 902 920 Net::HTTP.version_1_2 903 921 904 mail = NKF::nkf( '-m0 - wXd', ARGF.read )922 mail = NKF::nkf( '-m0 -Xwd', ARGF.read ) 905 923 raise "posttdiary-ex: no mail text." if not mail or mail.length == 0 906 924 … … 994 1012 image_name = now.strftime( "%Y%m%d" ) + "_" + nextnum.to_s + image_ext 995 1013 nextnum += 1 996 sh. move( tmpimgname , image_dir + image_name )1014 sh.rename( tmpimgname , image_dir + image_name ) 997 1015 exif_comment[image_name] = (read_exif ? read_exif_comment(image_dir + image_name) : "" ) 998 1016 exif_orientation[image_name] = (read_exif ? read_exif_orientation(image_dir + image_name) : "" ) … … 1112 1130 Net::HTTP.start( host, port ) do |http| 1113 1131 protection_key = nil 1114 res ,= http.get( cgi,1132 res = http.get( cgi, 1115 1133 'Authorization' => "Basic #{auth}", 1116 1134 'Referer' => url ) … … 1128 1146 end 1129 1147 end 1130 response ,= http.post( cgi, data, 'Authorization' => "Basic #{auth}", 'Referer' => url )1148 response = http.post( cgi, data, 'Authorization' => "Basic #{auth}", 'Referer' => url ) 1131 1149 end 1132 1150 end
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)