PDF转swf

PDF\WORD\JPG等文件的FLEX读取器:

示例请查看:

http://flexpaper.devaldi.com/demo/

PDF阅读功能:http://flexpaper.devaldi.com/examples/unencrypted/view_unencrypted.jsp?doc=Report

PDF阅读+编辑功能:http://flexpaper.devaldi.com/annotations.jsp

照片浏览功能:http://flexpaper.devaldi.com/slide.jsp

下载地址:

http://flexpaper.devaldi.com/download/

或:

http://code.google.com/p/flexpaper/downloads/list

下载后配置下lib/config.ini.win.php或lib/config.ini.nix.php(根据服务器操作系统决定要修改哪个)

中path.pdf及path.swf的路径

注意:服务器需要安装SWFTools

SWFTools 是一组用来处理 Flash 的 swf 文件的工具包,包括:

1. 合并工具 swfcombine
2. 抽取工具 swfextract
3. PDF/JPEG/PNG/AVI/TTF/WAV 到 SWF 的转换工具 :pdf2swf, jpeg2swf, png2swf, avi2swf, font2swf, and wav2swf|
4. 文本解析工具 swfstrings
5. SWF 解析器 swfdump
6. SWF 读写库 rfxswflib

一个简单的将PDF文档转成SWF的用法:

C:\SWFTools\pdf2swf Paper3.pdf -o Paper3.swf -f -T 9

下载地址:http://www.swftools.org/download.html

sql注入攻击

近几年来sql注入攻击非常常见,组合查询语句的编程方式是罪魁祸首。曾有一段时间,为了避免这个问题,抛弃了asp,投入asp.net的怀抱,因为asp.net可以方便的参数化查询,避免sql注入攻击。
近日发现微软有一个文档专门讲这个问题:http://technet.microsoft.com/zh-cn/library/ms161953.aspx
才豁然开朗,原来攻击来源于sql本身的特性。如果编程者不注意审核传入的参数,就很容易被黑客有机可乘。摘录部分内容如下:
如果可能,拒绝包含以下字符的输入。

输入字符 在 Transact-SQL 中的含义

; 查询分隔符。
‘ 字符数据字符串分隔符。
– 注释分隔符。
/* … */ 注释分隔符。服务器不对 /* 和 */ 之间的注释进行处理。
xp_ 用于目录扩展存储过程的名称的开头,如 xp_cmdshell。

请注意,如果要使用 LIKE 子句,还必须对通配符字符进行转义:

s = s.Replace(“[", "[[]“);
s = s.Replace(“%”, “[%]“);
s = s.Replace(“_”, “[_]“);

另外,字段长度不够,很容易造成截断启用的注入攻击。所以比如对传入的数据做长度检查。

基本上就这些要点吧,更详细的内容上微软看文档。

sql like 通配符

很羞愧的忏悔一下,以前我以为就只有百分号一个通配符。
_ 与任意单字符匹配

% 与包含一个或多个字符的字符串匹配

[ ] 与特定范围(例如,[a-f])或特定集(例如,[abcdef])中的任意单字符匹配。

[^] 与特定范围(例如,[^a-f])或特定集(例如,[^abcdef])之外的任意单字符匹配。
使用like比较字,加上SQL里的通配符,请参考以下:
a.. LIKE ‘Mc%’ 将搜索以字母 Mc 开头的所有字符串(如 McBadden)。
b.. LIKE ‘%inger’ 将搜索以字母 inger 结尾的所有字符串(如 Ringer、
Stringer)。
c.. LIKE ‘%en%’ 将搜索在任何位置包含字母 en 的所有字符串(如 Bennet、
Green、McBadden)。
d.. LIKE ‘_heryl’ 将搜索以字母 heryl 结尾的所有六个字母的名称(如 Cheryl、
Sheryl)。
e.. LIKE ‘[CK]ars[eo]n’ 将搜索下列字符串:Carsen、Karsen、Carson 和 Karson
(如 Carson)。
f.. LIKE ‘[M-Z]inger’ 将搜索以字符串 inger 结尾、以从 M 到 Z 的任何单个字
母开头的所有名称(如 Ringer)。
g.. LIKE ‘M[^c]%’ 将搜索以字母 M 开头,并且第二个字母不是 c 的所有名称(如
MacFeather)。

例子:
? WHERE FirstName LIKE ‘_im’ 可以找到所有三个字母的、以 im 结尾的名字(例如,Jim、Tim)。

? WHERE LastName LIKE ‘%stein’ 可以找到姓以 stein 结尾的所有员工。

? WHERE LastName LIKE ‘%stein%’ 可以找到姓中任意位置包括 stein 的所有员工。

? WHERE FirstName LIKE ‘[JT]im’ 可以找到三个字母的、以 im 结尾并以 J 或 T 开始的名字(即仅有 Jim 和 Tim)

? WHERE LastName LIKE ‘m[^c]%’ 可以找到以 m 开始的、后面的(第二个)字母不为 c 的所有姓。

DeBug:从windows日志追寻到网站程序的性能瓶颈

上文提到,在windows日志中,经常看到这样的错误:

查询处理器用尽了内部资源,无法生成查询计划。这种情况很少出现,只有在查询极其复杂或引用了大量表或分区时才会出现。请简化查询。如果您认为该消息的出现纯属错误,请与客户支持服务部门联系,了解详细信息。

这对于一个拥有十来个二级栏目,每个栏目都是一套独立的程序,并且集中在一个站点的网站来说,找出发生错误的那部分程序,是相当不容易的事情。

第一步,通过日志的来源,确定错误来源于MSSQL SERVER。上文提到,这是使用IN关键词产生的错误描述。并且已经明确,是由于查询的数据量太大,导致资源耗尽还没有得到查询结果。

第二步,通过SQL Server Profiler追踪数据库的查询情况。我把追踪结果存入数据库,然后通过查询Duration数值最大的前100条数据,结果有一个惊人的发现。一条类似这样的查询语句让我震惊了:

[pre]

select * from (select top 1520 articleid,classId,classname,articlemark,articletitle,hits,case smallpic when ” then ‘jnews/images/newslist_26.gif’ else smallpic end as smallpic,description,addtime,author,tag from cms_article where classID=3 and ischeck=1  and articleid in (316577,112553,59078,332886,255516,381339,98365,368853,50991,…..(此处省略一万字以上)

[/pre]

打开项目源代码,查找该查询语句的某些特征字符串,例如:“case smallpic when ” then ‘jnews/images/newslist_26.gif’ else ”,很快找到了相应的函数。

第三步,分析了一下原查询语句的意图,无非是想对符合某些条件的文章进行分页读取。明白了意图,剩下来的工作就是重写这个方法,以相对高效的方式实现相同的任务。利用MSSQL Server 2005之后新增的row_number()属性,将该功能的查询修改成:

[pre]

string ausql = “select * from ( ” +                 “select row_number() over(order by articleid desc) as rownumber,* ” +                 “from cms_article where ischeck = 1 and ” +                 “classid in (select classid from cms_artclass where ” +                 ” classid = ” + classID + ” or parentid = ” + classID +                 ” or parentpath like ‘%,” + classID + “,%’) ” + str + ” ) as t ” +                 “where rownumber between ” + startpage + ” and ” + endpage;

[/pre]

条件中也许会由于使用到LIKE关键词而降低效率,不过该字段类型通常为nvarchar(50)左右,应该在可接受的范围之内。相对原来的查询,显得微不足道了。这从Duration的值就可以看出来。新查询的Duration是700左右,旧查询的某次Duration是5500314!

 

 

Transact-SQL:数据量大是慎重使用IN关键字

使用IN关键字的查询语句效率是非常低下的。不是万不得已,费用不可的情况,千万别用!当数据量巨大时,还可能会产生以下错误:

在 IN 子句中包括数量非常多的值(数以千计)可能会消耗资源并返回错误 8623 或 8632。若要解决这一问题,请将这些项存储于某个表的 IN 列表中。

错误 8623:   查询处理器用尽了内部资源,无法生成查询计划。这种情况很少出现,只有在查询极其复杂或引用了大量表或分区时才会出现。请简化查询。如果您认为该消息的出现纯属错误,请与客户支持服务部门联系,了解详细信息。

错误 8632:   内部错误: 达到了表达式服务限制。请在您的查询中查找潜在的复杂表达式,并尝试简化它们。

参考:http://msdn.microsoft.com/zh-cn/library/ms177682.aspx

解决办法只有一种:修改查询语句,不要用IN语法。

而更麻烦的问题是,当程序相对复杂时,你可能要通过数据库工具找到产生错误的查询语句,然后改善之!

FastCGI设置解决大量php-cgi.exe进程导致服务器堵塞

这几天服务器出现了一个问题,流量不高,但是服务器打开超级慢,往往超时了还没有加载完页面。检查了服务器,发现有大量的php-cgi.exe进程,用netstat查询,发现有大量CLOSE_WAIT的链接。用360检查了连接数,居然达到1500个连接以上!

服务器只有不到5个的php站点,怎么会出现这么多的php-cgi.exe进程呢?程序池中,已经设置了“最大工作进程”为1啦!

经过研究,发现在FastCGI中也有类似的设置。把“最大实例数”由0改成1即可解决问题。可是在流量不高的情况下,站点打开的速度还是不快,不明白是什么原因。

vim快捷键


basic:
↑
←   h   j   k   l   →
↓

:w
write / save
:w {file}       write to file / save as
:wq / ZZ
write and quit / save and quit
:q! / ZQ        force quit / quit without
saving

d{motion}       delete / cut
y{motion}       yank / copy
p
put / paste

cursor -> line:
a               append
after the cursor
A               append after the line
i
insert before the cursor
I               insert before the line
r
replace at the cursor
R               replace the line
s
substitute at the cursor
S               substitute the line
u
undo            CTRL-R      undo the undo
U               undo the
line
v               start visual mode per character
V               start
visual mode line-wise

forward -> backward:
x               delete
characters forward
X               delete characters backward
p
put after the cursor
P               put before the cursor
o
open a line below
O               open a line above

f{char}
find {char} forward
F{char}         find {char} backward
t{char}
till {char} forward
T{char}         till {char} backward
;
next {char} occurrence
,               previous {char}
occurrence

/{pattern}      search {pattern} forward
?{pattern}
search {pattern} backward
n               next {pattern} occurrence
N
previous {pattern} occurrence

motion / word -> WORD:
w
forward to the start of word
W               forward to the start
of WORD
e               forward to the end of word
E               forward
to the end of WORD
b               backward to the start of word
B
backward to the start of WORD
ge              backward to the end of
word
gE              backward to the end of WORD

0               to
the first character of the line
^               to the first non-blank
character of the line
$               to the last character of the
line
g_              to the last non-blank character of the line

d
-> dd -> D:
d{motion}       delete
dd              delete a
line
D               delete to the end of the line
c{motion}
change
cc              change a line
C               change to the end of
the line
y{motion}       yank/copy
yy              yank/copy a line
Y
same as yy, unfortunately we are not in a perfect
world

advanced:
H               High / to first line on the
window
M               Middle / to middle line of the window
L
Low / to last line on the window

:1 / gg         to first line of the
file
:[+/-]{number}  to relative/absolute line number
:$ / G          to
last line of the file

%               find a matching

:s/old/new
substitute once
:s/old/new/g    substitute all on a
line
:%s/old/new/g   substitute all in the file
:%s/old/new/gi  substitute
all in the file, ignore case
:%s/old/new/gn  count occurrence only, do not
substitute
:%s/old/new/gc  substitute all in the file, with
confirmation

:!{cmd}         execute {cmd} with the shell
:!!
repeat last shell command

:w !sudo tee %  save as root

来源:http://forum.ubuntu.org.cn/viewtopic.php?f=68&t=290466

其实记住vim有两个状态就好:插入状态和命令状态。i,进入插入文本状态,ESC,返回命令状态。输入命令前记得先打冒号:

windows7:清理远程桌面连接历史记录

一、清除远程桌面连接下拉地址列表,具体操作:定位注册表到“HKEY_CURRENT_USER\Software\Microsoft \Terminal Server Client\Default”,将右侧所有以“MRU”开头的值删除,如“MR0,MR1,MR2”等

二、清除远程桌面连接主机名和用户名,具体操作:定位注册表到“HKEY_CURRENT_USER\Software\Microsoft \Terminal Server Client\Servers\”,在左侧将其下所有类型为IP地址的项删除。

安全要从细节抓起,共用电脑,更加要注意安全,防止泄露敏感信息。

Pages: 1 2 3 4 5 6 7 8 9 10 ...193 194 195 Next