+
+ + +
+
+
+ \ No newline at end of file diff --git a/back/templates/privilege_allot.htm b/back/templates/privilege_allot.htm new file mode 100755 index 0000000..523c2f1 --- /dev/null +++ b/back/templates/privilege_allot.htm @@ -0,0 +1,85 @@ + +{include file="pageheader.htm"} +
+
+ +{foreach from=$priv_arr item=priv} + + + +{/foreach} + + + +
+ {$lang.$priv.action_code} + + {foreach from=$priv.priv key=priv_list item=list} +
+ +
+ {/foreach} +
+ {$lang.check_all} +      + + + + +
+
+
+ +{literal} + +{/literal} +{include file="pagefooter.htm"} diff --git a/back/templates/privilege_info.htm b/back/templates/privilege_info.htm new file mode 100755 index 0000000..42d819c --- /dev/null +++ b/back/templates/privilege_info.htm @@ -0,0 +1,219 @@ + +{include file="pageheader.htm"} +
+
+ + + + + + {if $action eq "add"} + + + + + + + + + {/if} + {if $action neq "add"} + + + + + + + + + + + + + {if $user.agency_name} + + + + + {/if} + {/if} + {if $select_role} + + + + + {/if} + {if $action eq "modif"} + + + + + {/if} + + + +
{$lang.user_name}{$lang.require_field}
{$lang.password} + {$lang.require_field}
{$lang.pwd_confirm} + {$lang.require_field}
+ + {$lang.form_notice}{$lang.old_password} + {$lang.require_field} +
{$lang.new_password} + {$lang.require_field}
{$lang.pwd_confirm} + {$lang.require_field}
{$lang.agency}{$user.agency_name}
{$lang.select_role} + +
{$lang.edit_navi} + + + + + + +
+ + + + +
+
+
+     + + + +
+
+
+{insert_scripts files="../js/utils.js,validator.js"} + +{include file="pagefooter.htm"} \ No newline at end of file diff --git a/back/templates/privilege_list.htm b/back/templates/privilege_list.htm new file mode 100755 index 0000000..52d1b7b --- /dev/null +++ b/back/templates/privilege_list.htm @@ -0,0 +1,45 @@ + + +{if $full_page} +{include file="pageheader.htm"} +{insert_scripts files="../js/utils.js,listtable.js"} + +
+{/if} + + + + + + + + + + {foreach from=$admin_list item=list} + + + + + + + + {/foreach} +
{$lang.user_name}{$lang.email}{$lang.join_time}{$lang.last_time}{$lang.handler}
{$list.user_name}{$list.email}{$list.add_time}{$list.last_login|default:N/A} +    + +    +
+ +{if $full_page} +
+ +{include file="pagefooter.htm"} +{/if} diff --git a/back/templates/room_info.htm b/back/templates/room_info.htm new file mode 100755 index 0000000..c66f767 --- /dev/null +++ b/back/templates/room_info.htm @@ -0,0 +1,653 @@ + +{include file="pageheader.htm"} +{insert_scripts files="../js/utils.js"} + + + + + + +{if $warning} +
    +
  • {$warning}
  • +
+{/if} + + +
+ +
+

+ 一般信息 + 房間介紹 + 注意事項 + 房間相片 +

+
+ + +
+
+ + + + + + + + + + + + + +
名稱 + {$lang.require_field}
價格 +
上傳圖片 + + {if $room.image1} + + + + + {else} + + {/if} +
+ + + + + + + + + + + + + + {if $cfg.use_storage} + + + + + + + + + + {/if} + + + + + + + + + + + + + + + + + + + {if $goods_type_list} + + + + + + + + + + {/if} + + + + + + + + + + + +
+ + + +
+ +
+
+
+ +{insert_scripts files="validator.js,tab.js"} + + +{include file="pagefooter.htm"} diff --git a/back/templates/room_list.htm b/back/templates/room_list.htm new file mode 100755 index 0000000..bf639aa --- /dev/null +++ b/back/templates/room_list.htm @@ -0,0 +1,117 @@ + + +{if $full_page} +{include file="pageheader.htm"} +{insert_scripts files="../js/utils.js,listtable.js"} + + +{include file="goods_search.htm"} + +
+ +
+{/if} + + + + + + + + + {foreach from=$room_list item=room} + + + + + + + + {foreachelse} + + {/foreach} +
+ {$lang.record_id}{$sort_id} + 名稱{$sort_cname}是否上架{$sort_is_on_sale}{$lang.handler}
 {$room.id}{$room.name|escape:html} + + +
{$lang.no_records}
+ + + + + + + +
+ {include file="page.htm"} +
+ +{if $full_page} +
+
+ + +{include file="pagefooter.htm"} +{/if} \ No newline at end of file diff --git a/back/templates/show_image.htm b/back/templates/show_image.htm new file mode 100755 index 0000000..f5ade0c --- /dev/null +++ b/back/templates/show_image.htm @@ -0,0 +1,12 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/back/templates/start.htm b/back/templates/start.htm new file mode 100755 index 0000000..4f67b4c --- /dev/null +++ b/back/templates/start.htm @@ -0,0 +1,41 @@ + +{include file="pageheader.htm"} + +
    + +
+ + +{if $admin_msg} +
+ + + + + + + {foreach from=$admin_msg item=msg} + + + + + + {/foreach} +
{$lang.pm_title}{$lang.pm_username}{$lang.pm_time}
{$msg.title|truncate:60:"..."}{$msg.user_name}{$msg.send_date}
+
+
+{/if} + + + +{literal} +{insert_scripts files="../js/utils.js"} + +{/literal} +{include file="pagefooter.htm"} diff --git a/data/captcha/Thumbs.db b/data/captcha/Thumbs.db new file mode 100755 index 0000000..4a09aea Binary files /dev/null and b/data/captcha/Thumbs.db differ diff --git a/data/captcha/arial.ttf b/data/captcha/arial.ttf new file mode 100755 index 0000000..ff0815c Binary files /dev/null and b/data/captcha/arial.ttf differ diff --git a/data/captcha/captcha_bg1.gif b/data/captcha/captcha_bg1.gif new file mode 100755 index 0000000..97f79cd Binary files /dev/null and b/data/captcha/captcha_bg1.gif differ diff --git a/data/captcha/captcha_bg1.jpg b/data/captcha/captcha_bg1.jpg new file mode 100755 index 0000000..3045acc Binary files /dev/null and b/data/captcha/captcha_bg1.jpg differ diff --git a/data/captcha/captcha_bg2.gif b/data/captcha/captcha_bg2.gif new file mode 100755 index 0000000..5f7e99d Binary files /dev/null and b/data/captcha/captcha_bg2.gif differ diff --git a/data/captcha/captcha_bg2.jpg b/data/captcha/captcha_bg2.jpg new file mode 100755 index 0000000..1183d0b Binary files /dev/null and b/data/captcha/captcha_bg2.jpg differ diff --git a/data/captcha/captcha_bg3.gif b/data/captcha/captcha_bg3.gif new file mode 100755 index 0000000..b7abc31 Binary files /dev/null and b/data/captcha/captcha_bg3.gif differ diff --git a/data/captcha/captcha_bg3.jpg b/data/captcha/captcha_bg3.jpg new file mode 100755 index 0000000..c7bdf5d Binary files /dev/null and b/data/captcha/captcha_bg3.jpg differ diff --git a/data/captcha/captcha_bg4.gif b/data/captcha/captcha_bg4.gif new file mode 100755 index 0000000..6f7ed8d Binary files /dev/null and b/data/captcha/captcha_bg4.gif differ diff --git a/data/captcha/captcha_bg4.jpg b/data/captcha/captcha_bg4.jpg new file mode 100755 index 0000000..340906a Binary files /dev/null and b/data/captcha/captcha_bg4.jpg differ diff --git a/data/captcha/captcha_bg5.gif b/data/captcha/captcha_bg5.gif new file mode 100755 index 0000000..c45a4fc Binary files /dev/null and b/data/captcha/captcha_bg5.gif differ diff --git a/data/captcha/captcha_bg5.jpg b/data/captcha/captcha_bg5.jpg new file mode 100755 index 0000000..7396b14 Binary files /dev/null and b/data/captcha/captcha_bg5.jpg differ diff --git a/data/captcha/captcha_bg6.gif b/data/captcha/captcha_bg6.gif new file mode 100755 index 0000000..91ce7e9 Binary files /dev/null and b/data/captcha/captcha_bg6.gif differ diff --git a/data/captcha/captcha_bg6.jpg b/data/captcha/captcha_bg6.jpg new file mode 100755 index 0000000..a6dd750 Binary files /dev/null and b/data/captcha/captcha_bg6.jpg differ diff --git a/data/captcha/captcha_bg7.gif b/data/captcha/captcha_bg7.gif new file mode 100755 index 0000000..e8d910c Binary files /dev/null and b/data/captcha/captcha_bg7.gif differ diff --git a/data/captcha/captcha_bg7.jpg b/data/captcha/captcha_bg7.jpg new file mode 100755 index 0000000..aab7da1 Binary files /dev/null and b/data/captcha/captcha_bg7.jpg differ diff --git a/data/config.php b/data/config.php new file mode 100755 index 0000000..b5f3a90 --- /dev/null +++ b/data/config.php @@ -0,0 +1,50 @@ + diff --git a/data/sqldata/index.htm b/data/sqldata/index.htm new file mode 100755 index 0000000..0519ecb --- /dev/null +++ b/data/sqldata/index.htm @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/data/sqldata/run.log b/data/sqldata/run.log new file mode 100755 index 0000000..5c4e031 --- /dev/null +++ b/data/sqldata/run.log @@ -0,0 +1,17 @@ +ecs_admin_action:-1; +ecs_admin_log:-1; +ecs_admin_user:-1; +ecs_facility:-1; +ecs_hs_gallery:-1; +ecs_hs_news:-1; +ecs_hs_room:-1; +ecs_hs_web:-1; +ecs_plugins:-1; +ecs_portal:-1; +ecs_rm_gallery:-1; +ecs_role:-1; +ecs_shop_config:-1; +ecs_template:-1; +ecs_user_ad:-1; +ecs_user_log:-1; +ecs_users:-1; diff --git a/googlec2302caef97322e5.html b/googlec2302caef97322e5.html new file mode 100755 index 0000000..4fc2edd --- /dev/null +++ b/googlec2302caef97322e5.html @@ -0,0 +1 @@ +google-site-verification: googlec2302caef97322e5.html \ No newline at end of file diff --git a/images/File/index.htm b/images/File/index.htm new file mode 100755 index 0000000..0519ecb --- /dev/null +++ b/images/File/index.htm @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/Image/index.htm b/images/Image/index.htm new file mode 100755 index 0000000..0519ecb --- /dev/null +++ b/images/Image/index.htm @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/Media/index.htm b/images/Media/index.htm new file mode 100755 index 0000000..0519ecb --- /dev/null +++ b/images/Media/index.htm @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/close.gif b/images/close.gif new file mode 100755 index 0000000..5022b9b Binary files /dev/null and b/images/close.gif differ diff --git a/images/upload/File/index.htm b/images/upload/File/index.htm new file mode 100755 index 0000000..0519ecb --- /dev/null +++ b/images/upload/File/index.htm @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/upload/Media/index.htm b/images/upload/Media/index.htm new file mode 100755 index 0000000..0519ecb --- /dev/null +++ b/images/upload/Media/index.htm @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/upload/image/index.htm b/images/upload/image/index.htm new file mode 100755 index 0000000..0519ecb --- /dev/null +++ b/images/upload/image/index.htm @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/includes/cls_aes.php b/includes/cls_aes.php new file mode 100755 index 0000000..343c3cc --- /dev/null +++ b/includes/cls_aes.php @@ -0,0 +1,157 @@ +cipher = $cipher; + } + + public function set_mode($mode) + { + $this->mode = $mode; + } + + public function set_iv($iv) + { + $this->iv = $iv; + } + + public function set_key($key) + { + $this->secret_key = $key; + } + + public function require_pkcs5() + { + $this->pad_method = 'pkcs5'; + } + + protected function pad_or_unpad($str, $ext) + { + if ( is_null($this->pad_method) ) + { + return $str; + } + else + { + $func_name = __CLASS__ . '::' . $this->pad_method . '_' . $ext . 'pad'; + if ( is_callable($func_name) ) + { + $size = @mcrypt_get_block_size($this->cipher, $this->mode); + return call_user_func($func_name, $str, $size); + } + } + return $str; + } + + protected function pad($str) + { + return $this->pad_or_unpad($str, ''); + } + + protected function unpad($str) + { + return $this->pad_or_unpad($str, 'un'); + } + + public function encrypt($str) + { + $str = $this->pad($str); + $td = mcrypt_module_open($this->cipher, '', $this->mode, ''); + + if ( empty($this->iv) ) + { + $iv = @mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); + } + else + { + $iv = $this->iv; + } + + mcrypt_generic_init($td, hex2bin($this->secret_key), $iv); + $cyper_text = mcrypt_generic($td, $str); + $rt = strtoupper(bin2hex($cyper_text)); + mcrypt_generic_deinit($td); + mcrypt_module_close($td); + + return $rt; + } + + public function encryptNew($str) + { + $str = $this->pad($str); + $td = @mcrypt_module_open($this->cipher, '', $this->mode, ''); + + if ( empty($this->iv) ) + { + $iv = @mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); + } + else + { + $iv = $this->iv; + } + + //mcrypt_generic_init($td, hex2bin($this->secret_key), $iv); + @mcrypt_generic_init($td, $this->secret_key, $iv); + $cyper_text = @mcrypt_generic($td, $str); + //$rt = strtoupper(bin2hex($cyper_text)); + $rt = base64_encode($cyper_text); + @mcrypt_generic_deinit($td); + @mcrypt_module_close($td); + + return $rt; + } + + public function decrypt($str){ + $td = @mcrypt_module_open($this->cipher, '', $this->mode, ''); + + if ( empty($this->iv) ) + { + $iv = @mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); + } + else + { + $iv = $this->iv; + } + + @mcrypt_generic_init($td, $this->secret_key, $iv); + //$decrypted_text = mdecrypt_generic($td, self::hex2bin($str)); + $decrypted_text = @mdecrypt_generic($td, base64_decode($str)); + $rt = $decrypted_text; + @mcrypt_generic_deinit($td); + @mcrypt_module_close($td); + + return $this->unpad($rt); + } + + public static function hex2bin($hexdata) { + $bindata = ''; + $length = strlen($hexdata); + for ($i=0; $i< $length; $i += 2) + { + $bindata .= chr(hexdec(substr($hexdata, $i, 2))); + } + return $bindata; + } + + public static function pkcs5_pad($text, $blocksize) + { + $pad = $blocksize - (strlen($text) % $blocksize); + return $text . str_repeat(chr($pad), $pad); + } + + public static function pkcs5_unpad($text) + { + $pad = ord($text{strlen($text) - 1}); + if ($pad > strlen($text)) return false; + if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) return false; + return substr($text, 0, -1 * $pad); + } +} \ No newline at end of file diff --git a/includes/cls_captcha.php b/includes/cls_captcha.php new file mode 100755 index 0000000..c3cdb84 --- /dev/null +++ b/includes/cls_captcha.php @@ -0,0 +1,322 @@ + 背景图片的文件名 + * 1 => Red, 2 => Green, 3 => Blue + * @var array $themes + */ + var $themes_jpg = array( + 1 => array('captcha_bg6.jpg', 16, 138, 205), + 2 => array('captcha_bg6.jpg', 46, 46, 46), + 3 => array('captcha_bg6.jpg', 176, 46, 56), + 4 => array('captcha_bg6.jpg', 18, 18, 18), + 5 => array('captcha_bg6.jpg', 248, 3, 0), +// 2 => array('captcha_bg2.jpg', 0, 0, 0), +// 3 => array('captcha_bg3.jpg', 0, 0, 0), +// 4 => array('captcha_bg4.jpg', 255, 255, 255), +// 5 => array('captcha_bg5.jpg', 255, 255, 255), + ); + + var $themes_gif = array( +// 1 => array('captcha_bg1.gif', 255, 255, 255), +// 2 => array('captcha_bg2.gif', 0, 0, 0), +// 3 => array('captcha_bg3.gif', 0, 0, 0), +// 4 => array('captcha_bg4.gif', 255, 255, 255), +// 5 => array('captcha_bg5.gif', 255, 255, 255), + 1 => array('captcha_bg6.gif', 16, 138, 205), + 2 => array('captcha_bg6.gif', 46, 46, 46), + 3 => array('captcha_bg6.gif', 176, 46, 56), + 4 => array('captcha_bg6.gif', 18, 18, 18), + 5 => array('captcha_bg6.gif', 248, 3, 0), + ); + + /** + * 图片的宽度 + * + * @var integer $width + */ + var $width = 100; + + /** + * 图片的高度 + * + * @var integer $height + */ + var $height = 20; + + + /* 代码修改_start By www.68ecshop.com */ + + /** + * 构造函数 + * + * @access public + * @param + * + * @return void + */ + function __construct($folder = '', $width = 100, $height = 33) + { + $this->captcha($folder, $width, $height); + } + + /** + * 构造函数 + * + * @access public + * @param string $folder 背景图片所在目录 + * @param integer $width 图片宽度 + * @param integer $height 图片高度 + * @return bool + */ + function captcha($folder = '', $width = 145, $height = 20) + { + if (!empty($folder)) + { + $this->folder = $folder; + } + + $this->width = $width; + $this->height = $height; + + /* 检查是否支持 GD */ + if (PHP_VERSION >= '4.3') + { + + return (function_exists('imagecreatetruecolor') || function_exists('imagecreate')); + } + else + { + + return (((imagetypes() & IMG_GIF) > 0) || ((imagetypes() & IMG_JPG)) > 0 ); + } + } + + /** + * 检查给出的验证码是否和session中的一致 + */ + + function check_word($word, $clear = false) + { + $recorded = isset($_SESSION[$this->session_word]) ? base64_decode($_SESSION[$this->session_word]) : ''; + $given = $this->encrypts_word(strtoupper($word)); + + if($clear) + { + $this->clear_captcha(); + } + + return (preg_match("/$given/", $recorded)); + } + + /** + * 清空验证码,使当前验证码失效 + */ + function clear_captcha(){ + if($_SESSION[$this->session_word]) + { + unset($_SESSION[$this->session_word]); + } + } + + /** + * 生成图片并输出到浏览器 + * + * @access public + * @param string $word 验证码 + * @return mix + */ + function generate_image($word = false) + { + if (!$word) + { + $word = $this->generate_word(); + } + + /* 记录验证码到session */ + $this->record_word($word); + + /* 验证码长度 */ + $letters = strlen($word); + + /* 选择一个随机的方案 */ + mt_srand((double) microtime() * 1000000); + + if (function_exists('imagecreatefromjpeg') && ((imagetypes() & IMG_JPG) > 0)) + { + $theme = $this->themes_jpg[mt_rand(1, count($this->themes_jpg))]; + } + else + { + $theme = $this->themes_gif[mt_rand(1, count($this->themes_gif))]; + } + + if (!file_exists($this->folder . $theme[0])) + { + return false; + } + else + { + $img_bg = (function_exists('imagecreatefromjpeg') && ((imagetypes() & IMG_JPG) > 0)) ? + imagecreatefromjpeg($this->folder . $theme[0]) : imagecreatefromgif($this->folder . $theme[0]); + $bg_width = imagesx($img_bg); + $bg_height = imagesy($img_bg); + + $img_org = ((function_exists('imagecreatetruecolor')) && PHP_VERSION >= '4.3') ? + imagecreatetruecolor($this->width, $this->height) : imagecreate($this->width, $this->height); + + /* 将背景图象复制原始图象并调整大小 */ + if (function_exists('imagecopyresampled') && PHP_VERSION >= '4.3') // GD 2.x + { + imagecopyresampled($img_org, $img_bg, 0, 0, 0, 0, $this->width, $this->height, $bg_width, $bg_height); + } + else // GD 1.x + { + imagecopyresized($img_org, $img_bg, 0, 0, 0, 0, $this->width, $this->height, $bg_width, $bg_height); + } + imagedestroy($img_bg); + + //$clr = imagecolorallocate($img_org, $theme[1], $theme[2], $theme[3]); + $clr = imagecolorallocate($img_org, 0, 0, 0); + + /* 绘制边框 */ + //imagerectangle($img_org, 0, 0, $this->width - 1, $this->height - 1, $clr); + + /* 获得验证码的高度和宽度 */ + $x = ($this->width - (imagefontwidth(5) * $letters)) / 2; + $y = ($this->height - imagefontheight(5)) / 2; + + //imagestring($img_org, 5, $x, $y, $word, $clr); + + //倾斜角度、X、Y位置 + $position = null; + if(rand(0, 1) == 0) + { + $position = array('-'.rand(0, 10), 10, 20); + } + else + { + $position = array(rand(0, 10), 10, 23); + } + //字体 + $ttf_font = $this->folder.'/arial.ttf'; + + if(function_exists('ImageTTFText')) + { + ImageTTFText($img_org, 14, $position[0], $position[1], $position[2], $clr, $ttf_font, $word); + } + else + { + imagestring($img_org, 14, $x, $y, $word, $clr); + } + + header('Expires: Thu, 01 Jan 1970 00:00:00 GMT'); + + // HTTP/1.1 + header('Cache-Control: private, no-store, no-cache, must-revalidate'); + header('Cache-Control: post-check=0, pre-check=0, max-age=0', false); + + // HTTP/1.0 + header('Pragma: no-cache'); + if ($this->img_type == 'jpeg' && function_exists('imagecreatefromjpeg')) + { + header('Content-type: image/jpeg'); + imageinterlace($img_org, 1); + imagejpeg($img_org, false, 95); + } + else + { + header('Content-type: image/png'); + imagepng($img_org); + } + + imagedestroy($img_org); + + return true; + } + } + + /*------------------------------------------------------ */ + //-- PRIVATE METHODs + /*------------------------------------------------------ */ + + /** + * 对需要记录的串进行加密 + * + * @access private + * @param string $word 原始字符串 + * @return string + */ + function encrypts_word($word) + { + return substr(md5($word), 1, 10); + } + + /** + * 将验证码保存到session + * + * @access private + * @param string $word 原始字符串 + * @return void + */ + function record_word($word) + { + $_SESSION[$this->session_word] = base64_encode($this->encrypts_word($word)); + } + + /** + * 生成随机的验证码 + * + * @access private + * @param integer $length 验证码长度 + * @return string + */ + function generate_word($length = 4) + { + $chars = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ'; + + for ($i = 0, $count = strlen($chars); $i < $count; $i++) + { + $arr[$i] = $chars[$i]; + } + + mt_srand((double) microtime() * 1000000); + shuffle($arr); + + return substr(implode('', $arr), 5, $length); + } +} + +?> \ No newline at end of file diff --git a/includes/cls_ecshop.php b/includes/cls_ecshop.php new file mode 100755 index 0000000..5f2dc79 --- /dev/null +++ b/includes/cls_ecshop.php @@ -0,0 +1,194 @@ +db_name = $db_name; + $this->prefix = $prefix; + } + + /** + * 将指定的表名加上前缀后返回 + * + * @access public + * @param string $str 表名 + * + * @return string + */ + function table($str) + { + return '`' . $this->db_name . '`.`' . $this->prefix . $str . '`'; + } + + /** + * ECSHOP 密码编译方法; + * + * @access public + * @param string $pass 需要编译的原始密码 + * + * @return string + */ + function compile_password($pass) + { + return md5($pass); + } + + /** + * 取得当前的域名 + * + * @access public + * + * @return string 当前的域名 + */ + function get_domain() + { + /* 协议 */ + $protocol = $this->http(); + + /* 域名或IP地址 */ + if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) + { + $host = $_SERVER['HTTP_X_FORWARDED_HOST']; + } + elseif (isset($_SERVER['HTTP_HOST'])) + { + $host = $_SERVER['HTTP_HOST']; + } + else + { + /* 端口 */ + if (isset($_SERVER['SERVER_PORT'])) + { + $port = ':' . $_SERVER['SERVER_PORT']; + + if ((':80' == $port && 'http://' == $protocol) || (':443' == $port && 'https://' == $protocol)) + { + $port = ''; + } + } + else + { + $port = ''; + } + + if (isset($_SERVER['SERVER_NAME'])) + { + $host = $_SERVER['SERVER_NAME'] . $port; + } + elseif (isset($_SERVER['SERVER_ADDR'])) + { + $host = $_SERVER['SERVER_ADDR'] . $port; + } + } + + return $protocol . $host; + } + + /** + * 获得 ECSHOP 当前环境的 URL 地址 + * + * @access public + * + * @return void + */ + function url() + { + $curr = strpos(PHP_SELF, ADMIN_PATH . '/') !== false ? + preg_replace('/(.*)(' . ADMIN_PATH . ')(\/?)(.)*/i', '\1', dirname(PHP_SELF)) : + dirname(PHP_SELF); + + $root = str_replace('\\', '/', $curr); + + if (substr($root, -1) != '/') + { + $root .= '/'; + } + + return $this->get_domain() . $root; + } + + /** + * 获得 ECSHOP 当前环境的 HTTP 协议方式 + * + * @access public + * + * @return void + */ + function http() + { + if(isset($_SERVER['HTTP_X_FORWARDED_PROTO'])){ + return $_SERVER['HTTP_X_FORWARDED_PROTO']."://"; + }else{ + return (isset($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://'; + } + } + + /** + * 获得数据目录的路径 + * + * @param int $sid + * + * @return string 路径 + */ + function data_dir($sid = 0) + { + if (empty($sid)) + { + $s = 'data'; + } + else + { + $s = 'user_files/'; + $s .= ceil($sid / 3000) . '/'; + $s .= $sid % 3000; + } + return $s; + } + + /** + * 获得图片的目录路径 + * + * @param int $sid + * + * @return string 路径 + */ + function image_dir($sid = 0) + { + if (empty($sid)) + { + $s = 'images'; + } + else + { + $s = 'user_files/'; + $s .= ceil($sid / 3000) . '/'; + $s .= ($sid % 3000) . '/'; + $s .= 'images'; + } + return $s; + } + +} + +?> diff --git a/includes/cls_error.php b/includes/cls_error.php new file mode 100755 index 0000000..5b064a0 --- /dev/null +++ b/includes/cls_error.php @@ -0,0 +1,148 @@ +ecs_error($tpl); + } + + /** + * 构造函数 + * + * @access public + * @param string $tpl + * @return void + */ + function ecs_error($tpl) + { + $this->_template = $tpl; + } + + /** + * 添加一条错误信息 + * + * @access public + * @param string $msg + * @param integer $errno + * @return void + */ + function add($msg, $errno=1) + { + if (is_array($msg)) + { + $this->_message = array_merge($this->_message, $msg); + } + else + { + $this->_message[] = $msg; + } + + $this->error_no = $errno; + } + + /** + * 清空错误信息 + * + * @access public + * @return void + */ + function clean() + { + $this->_message = array(); + $this->error_no = 0; + } + + /** + * 返回所有的错误信息的数组 + * + * @access public + * @return array + */ + function get_all() + { + return $this->_message; + } + + /** + * 返回最后一条错误信息 + * + * @access public + * @return void + */ + function last_message() + { + return array_slice($this->_message, -1); + } + + /** + * 显示错误信息 + * + * @access public + * @param string $link + * @param string $href + * @return void + */ + function show($link = '', $href = '') + { + if ($this->error_no > 0) + { + $message = array(); + + $link = (empty($link)) ? $GLOBALS['_LANG']['back_up_page'] : $link; + $href = (empty($href)) ? 'javascript:history.back();' : $href; + $message['url_info'][$link] = $href; + $message['back_url'] = $href; + + foreach ($this->_message AS $msg) + { + $message['content'] = '
' . htmlspecialchars($msg) . '
'; + } + + if (isset($GLOBALS['smarty'])) + { + assign_template(); + $GLOBALS['smarty']->assign('auto_redirect', true); + $GLOBALS['smarty']->assign('message', $message); + $GLOBALS['smarty']->display($this->_template); + } + else + { + die($message['content']); + } + + exit; + } + } +} + +?> \ No newline at end of file diff --git a/includes/cls_iconv.php b/includes/cls_iconv.php new file mode 100755 index 0000000..fb797d6 --- /dev/null +++ b/includes/cls_iconv.php @@ -0,0 +1,677 @@ + UNICODE 对照表的内容 + * @变量类型 + * @访问 内部 + */ + var $unicode_table = array(); + + /** + * 访问中文繁简互换表的文件指针 + * + * @变量类型 对象 + * @访问 内部 + */ + var $ctf; + + /** + * 等待转换的字符串 + * @变量类型 + * @访问 内部 + */ + var $SourceText = ''; + + /** + * Chinese 的运行配置 + * + * @变量类型 数组 + * @访问 公开 + */ + var $config = array( + 'codetable_dir' => '', // 存放各种语言互换表的目录 + 'source_lang' => '', // 字符的原编码 + 'target_lang' => '', // 转换后的编码 + 'GBtoBIG5_table' => 'gb-big5.table', // 简体中文转换为繁体中文的对照表 + 'BIG5toGB_table' => 'big5-gb.table', // 繁体中文转换为简体中文的对照表 + 'GBtoUTF8_table' => 'gb_utf8.php', // 简体中文转换为UTF-8的对照表 + 'BIG5toUTF8_table' => 'big5_utf8.php' // 繁体中文转换为UTF-8的对照表 + ); + + var $iconv_enabled = false; // 是否存在 ICONV 模块,默认为否 + var $mbstring_enabled = false; // 是否存在 MBSTRING 模块,默认为否 + + + /** + * Chinese 的悉构函数 + * + * 详细说明 + * @形参 字符串 $source_lang 为需要转换的字符串的原编码 + * 字符串 $target_lang 为转换的目标编码 + * 字符串 $SourceText 为等待转换的字符串 + * @访问 公开 + * @返回值 无 + * @throws + */ + function Chinese($dir = './') + { + $this->config['codetable_dir'] = $dir . "includes/codetable/"; + + if (function_exists('iconv')) + { + $this->iconv_enabled = true; + } + + if (PHP_VERSION >= '5.0' && function_exists('mb_convert_encoding') && function_exists('mb_list_encodings')) + { + $encodings = mb_list_encodings(); + + if (in_array('UTF-8', $encodings) == true && in_array('BIG-5', $encodings) == true && in_array('CP936', $encodings) == true) // CP936 就是 GBK 字符集的别名 + { + $this->mbstring_enabled = true; + } + } + } + + function Convert($source_lang, $target_lang, $source_string = '') + { + /* 如果字符串为空或者字符串不需要转换,直接返回 */ + if ($source_string == '' || preg_match("/[\x80-\xFF]+/", $source_string) == 0) + { + return $source_string; + } + + if ($source_lang) + { + $this->config['source_lang'] = $this->_lang($source_lang); + } + + if ($target_lang) + { + $this->config['target_lang'] = $this->_lang($target_lang); + } + + /* 如果编码相同,直接返回 */ + if ($this->config['source_lang'] == $this->config['target_lang']) + { + return $source_string; + } + + $this->SourceText = $source_string; + + if (($this->iconv_enabled || $this->mbstring_enabled) && !($this->config['source_lang'] == 'GBK' && $this->config['target_lang'] == 'BIG-5')) + { + if ($this->config['target_lang'] != 'UNICODE') + { + $string = $this->_convert_iconv_mbstring($this->SourceText, $this->config['target_lang'], $this->config['source_lang']); + + /* 如果正确转换 */ + if ($string) + { + return $string; + } + } + else + { + $string = ''; + $text = $SourceText; + while ($text) + { + if (ord(substr($text, 0, 1)) > 127) + { + if ($this->config['source_lang'] != 'UTF-8') + { + $char = $this->_convert_iconv_mbstring(substr($text, 0, 2), 'UTF-8', $this->config['source_lang']); + } + else + { + $char = substr($text, 0, 3); + } + /* 如果转换出错 */ + if ($char == '') + { + $string = ''; + + break; + } + + switch (strlen($char)) + { + case 1: + $uchar = ord($char); + break; + + case 2: + $uchar = (ord($char[0]) & 0x3f) << 6; + $uchar += ord($char[1]) & 0x3f; + break; + + case 3: + $uchar = (ord($char[0]) & 0x1f) << 12; + $uchar += (ord($char[1]) & 0x3f) << 6; + $uchar += ord($char[2]) & 0x3f; + break; + + case 4: + $uchar = (ord($char[0]) & 0x0f) << 18; + $uchar += (ord($char[1]) & 0x3f) << 12; + $uchar += (ord($char[2]) & 0x3f) << 6; + $uchar += ord($char[3]) & 0x3f; + break; + } + $string .= '&#x' . dechex($uchar) . ';'; + + if ($this->config['source_lang'] != 'UTF-8') + { + $text = substr($text, 2); + } + else + { + $text = substr($text, 3); + } + } + else + { + $string .= substr($text, 0, 1); + $text = substr($text, 1); + } + } + + /* 如果正确转换 */ + if ($string) + { + return $string; + } + } + } + + $this->OpenTable(); + // 判断是否为中文繁、简转换 + if (($this->config['source_lang'] == 'GBK' || $this->config['source_lang'] == 'BIG-5') && ($this->config['target_lang'] == 'GBK' || $this->config['target_lang'] == 'BIG-5')) + { + return $this->GBtoBIG5(); + } + + // 判断是否为简体、繁体中文与UTF8转换 + if (($this->config['source_lang'] == 'GBK' || $this->config['source_lang'] == 'BIG-5' || $this->config['source_lang'] == 'UTF-8') && ($this->config['target_lang'] == 'UTF-8' || $this->config['target_lang'] == 'GBK' || $this->config['target_lang'] == 'BIG-5')) + { + return $this->CHStoUTF8(); + } + + // 判断是否为简体、繁体中文与UNICODE转换 + if (($this->config['source_lang'] == 'GBK' || $this->config['source_lang'] == 'BIG-5') && $this->config['target_lang'] == 'UNICODE') + { + return $this->CHStoUNICODE(); + } + } + + function _lang($lang) + { + $lang = strtoupper($lang); + + if (substr($lang, 0, 2) == 'GB') + { + return 'GBK'; + } + else + { + switch(substr($lang, 0, 3)) + { + case 'BIG': + return 'BIG-5'; + + case 'UTF': + return 'UTF-8'; + + case 'UNI': + return 'UNICODE'; + + default: + return ''; + } + } + } + + function _convert_iconv_mbstring($string, $target_lang, $source_lang) + { + if ($this->iconv_enabled) + { + $return_string = @iconv($source_lang, $target_lang, $string); + if ($return_string !== false) + { + return $return_string; + } + } + + if ($this->mbstring_enabled) + { + if ($source_lang == 'GBK') + { + $source_lang = 'CP936'; + } + if ($target_lang == 'GBK') + { + $target_lang = 'CP936'; + } + + $return_string = @mb_convert_encoding($string, $target_lang, $source_lang); + if ($return_string !== false) + { + return $return_string; + } + else + { + return false; + } + } + } + + /** + * 将 16 进制转换为 2 进制字符 + * + * 详细说明 + * @形参 $hexdata 为16进制的编码 + * @访问 内部 + * @返回 字符串 + * @throws + */ + function _hex2bin($hexdata) + { + $bindata = ''; + + for ($i = 0, $count = strlen($hexdata); $i < $count; $i += 2) + { + $bindata .= chr(hexdec($hexdata{$i} . $hexdata{$i + 1})); + } + + return $bindata; + } + + /** + * 打开对照表 + * + * 详细说明 + * @形参 + * @访问 内部 + * @返回 无 + * @throws + */ + function OpenTable() + { + static $gb_utf8_table = NULL; + static $gb_unicode_table = NULL; + static $utf8_gb_table = NULL; + + static $big5_utf8_table = NULL; + static $big5_unicode_table = NULL; + static $utf8_big5_table = NULL; + + // 假如原编码为简体中文的话 + if ($this->config['source_lang'] == 'GBK') + { + // 假如转换目标编码为繁体中文的话 + if ($this->config['target_lang'] == 'BIG-5') + { + $this->ctf = @fopen($this->config['codetable_dir'] . $this->config['GBtoBIG5_table'], 'rb'); + if (is_null($this->ctf)) + { + echo '打开打开转换表文件失败!'; + + exit; + } + } + + // 假如转换目标编码为 UTF8 的话 + if ($this->config['target_lang'] == 'UTF-8') + { + if ($gb_utf8_table === NULL) + { + require_once($this->config['codetable_dir'] . $this->config['GBtoUTF8_table']); + } + $this->unicode_table = $gb_utf8_table; + } + + // 假如转换目标编码为 UNICODE 的话 + if ($this->config['target_lang'] == 'UNICODE') + { + if ($gb_unicode_table === NULL) + { + if (isset($gb_utf8_table) === false) + { + require_once($this->config['codetable_dir'] . $this->config['GBtoUTF8_table']); + } + foreach ($gb_utf8_table AS $key => $value) + { + $gb_unicode_table[$key] = substr($value, 2); + } + } + $this->unicode_table = $gb_unicode_table; + } + } + + // 假如原编码为繁体中文的话 + if ($this->config['source_lang'] == 'BIG-5') + { + // 假如转换目标编码为简体中文的话 + if ($this->config['target_lang'] == 'GBK') + { + $this->ctf = @fopen($this->config['codetable_dir'] . $this->config['BIG5toGB_table'], 'rb'); + if (is_null($this->ctf)) + { + echo '打开打开转换表文件失败!'; + + exit; + } + } + // 假如转换目标编码为 UTF8 的话 + if ($this->config['target_lang'] == 'UTF-8') + { + if ($big5_utf8_table === NULL) + { + require_once($this->config['codetable_dir'] . $this->config['BIG5toUTF8_table']); + } + $this->unicode_table = $big5_utf8_table; + } + + // 假如转换目标编码为 UNICODE 的话 + if ($this->config['target_lang'] == 'UNICODE') + { + if ($big5_unicode_table === NULL) + { + if (isset($big5_utf8_table) === false) + { + require_once($this->config['codetable_dir'] . $this->config['BIG5toUTF8_table']); + } + foreach ($big5_utf8_table AS $key => $value) + { + $big5_unicode_table[$key] = substr($value, 2); + } + } + $this->unicode_table = $big5_unicode_table; + } + } + + // 假如原编码为 UTF8 的话 + if ($this->config['source_lang'] == 'UTF-8') + { + // 假如转换目标编码为 GBK 的话 + if ($this->config['target_lang'] == 'GBK') + { + if ($utf8_gb_table === NULL) + { + if (isset($gb_utf8_table) === false) + { + require_once($this->config['codetable_dir'] . $this->config['GBtoUTF8_table']); + } + foreach ($gb_utf8_table AS $key => $value) + { + $utf8_gb_table[hexdec($value)] = '0x' . dechex($key); + } + } + $this->unicode_table = $utf8_gb_table; + } + + // 假如转换目标编码为 BIG5 的话 + if ($this->config['target_lang'] == 'BIG-5') + { + if ($utf8_big5_table === NULL) + { + if (isset($big5_utf8_table) === false) + { + require_once($this->config['codetable_dir'] . $this->config['BIG5toUTF8_table']); + } + foreach ($big5_utf8_table AS $key => $value) + { + $utf8_big5_table[hexdec($value)] = '0x' . dechex($key); + } + } + $this->unicode_table = $utf8_big5_table; + } + } + } + + /** + * 将简体、繁体中文的 UNICODE 编码转换为 UTF8 字符 + * + * 详细说明 + * @形参 数字 $c 简体中文汉字的UNICODE编码的10进制 + * @访问 内部 + * @返回 字符串 + * @throws + */ + function CHSUtoUTF8($c) + { + $str=''; + + if ($c < 0x80) + { + $str .= $c; + } + elseif ($c < 0x800) + { + $str .= (0xC0 | $c >> 6); + $str .= (0x80 | $c & 0x3F); + } + elseif ($c < 0x10000) + { + $str .= (0xE0 | $c >> 12); + $str .= (0x80 | $c >> 6 & 0x3F); + $str .= (0x80 | $c & 0x3F); + } + elseif ($c < 0x200000) + { + $str .= (0xF0 | $c >> 18); + $str .= (0x80 | $c >> 12 & 0x3F); + $str .= (0x80 | $c >> 6 & 0x3F); + $str .= (0x80 | $c & 0x3F); + } + + return $str; + } + + /** + * 简体、繁体中文 <-> UTF8 互相转换的函数 + * + * 详细说明 + * @形参 + * @访问 内部 + * @返回 字符串 + * @throws + */ + function CHStoUTF8() + { + if ($this->config['source_lang'] == 'BIG-5' || $this->config['source_lang'] == 'GBK') + { + $ret = ''; + + while ($this->SourceText) + { + if (ord($this->SourceText{0}) > 127) + { + if ($this->config['source_lang'] == 'BIG-5') + { + $utf8 = $this->CHSUtoUTF8(hexdec(@$this->unicode_table[hexdec(bin2hex($this->SourceText{0} . $this->SourceText{1}))])); + } + if ($this->config['source_lang'] == 'GBK') + { + $utf8 = $this->CHSUtoUTF8(hexdec(@$this->unicode_table[hexdec(bin2hex($this->SourceText{0} . $this->SourceText{1})) - 0x8080])); + } + for ($i = 0, $count = strlen($utf8); $i < $count; $i += 3) + { + $ret .= chr(substr($utf8, $i, 3)); + } + + $this->SourceText = substr($this->SourceText, 2, strlen($this->SourceText)); + } + else + { + $ret .= $this->SourceText{0}; + $this->SourceText = substr($this->SourceText, 1, strlen($this->SourceText)); + } + } + $this->unicode_table = array(); + $this->SourceText = ''; + + return $ret; + } + + if ($this->config['source_lang'] == 'UTF-8') + { + $i = 0; + $out = ''; + $len = strlen($this->SourceText); + while ($i < $len) + { + $c = ord($this->SourceText{$i++}); + switch($c >> 4) + { + case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: + // 0xxxxxxx + $out .= $this->SourceText{$i - 1}; + break; + case 12: case 13: + // 110x xxxx 10xx xxxx + $char2 = ord($this->SourceText{$i++}); + $char3 = @$this->unicode_table[(($c & 0x1F) << 6) | ($char2 & 0x3F)]; + + if ($this->config['target_lang'] == 'GBK') + { + $out .= $this->_hex2bin(dechex($char3 + 0x8080)); + } + elseif ($this->config['target_lang'] == 'BIG-5') + { + $out .= $this->_hex2bin(dechex($char3 + 0x0000)); + } + break; + case 14: + // 1110 xxxx 10xx xxxx 10xx xxxx + $char2 = ord($this->SourceText{$i++}); + $char3 = ord($this->SourceText{$i++}); + $char4 = @$this->unicode_table[(($c & 0x0F) << 12) | (($char2 & 0x3F) << 6) | (($char3 & 0x3F) << 0)]; + + if ($this->config['target_lang'] == 'GBK') + { + $out .= $this->_hex2bin(dechex($char4 + 0x8080)); + } elseif ($this->config['target_lang'] == 'BIG-5') + { + $out .= $this->_hex2bin(dechex($char4 + 0x0000)); + } + + break; + } + } + + // 返回结果 + return $out; + } + } + + /** + * 简体、繁体中文转换为 UNICODE编码 + * + * 详细说明 + * @形参 + * @访问 内部 + * @返回 字符串 + * @throws + */ + function CHStoUNICODE() + { + $utf = ''; + + while ($this->SourceText) + { + if (ord($this->SourceText{0}) > 127) + { + if ($this->config['source_lang'] == 'GBK') + { + $utf .= '&#x' . $this->unicode_table[hexdec(bin2hex($this->SourceText{0} . $this->SourceText{1})) - 0x8080] . ';'; + } + elseif ($this->config['source_lang'] == 'BIG-5') + { + $utf .= '&#x' . $this->unicode_table[hexdec(bin2hex($this->SourceText{0} . $this->SourceText{1}))] . ';'; + } + + $this->SourceText = substr($this->SourceText, 2, strlen($this->SourceText)); + } + else + { + $utf .= $this->SourceText{0}; + $this->SourceText = substr($this->SourceText, 1, strlen($this->SourceText)); + } + } + + return $utf; + } + + /** + * 简体中文 <-> 繁体中文 互相转换的函数 + * + * 详细说明 + * @访问 内部 + * @返回值 经过编码的utf8字符 + * @throws + */ + function GBtoBIG5() + { + // 获取等待转换的字符串的总长度 + $max = strlen($this->SourceText) - 1; + + for ($i = 0; $i < $max; $i++) + { + $h = ord($this->SourceText{$i}); + if ($h >= 160) + { + $l = ord($this->SourceText{$i + 1}); + + if ($h == 161 && $l == 64) + { + $gb = ' '; + } + else + { + fseek($this->ctf, ($h - 160) * 510 + ($l - 1) * 2); + $gb = fread($this->ctf, 2); + } + + $this->SourceText{$i} = $gb{0}; + $this->SourceText{$i + 1} = $gb{1}; + + $i++; + } + } + fclose($this->ctf); + + // 将转换后的结果赋予 $result; + $result = $this->SourceText; + + // 清空 $thisSourceText + $this->SourceText = ''; + + // 返回转换结果 + return $result; + } +} + +?> diff --git a/includes/cls_image.php b/includes/cls_image.php new file mode 100755 index 0000000..3d90ae4 --- /dev/null +++ b/includes/cls_image.php @@ -0,0 +1,809 @@ + 'image/gif', 2 => 'image/jpeg', 3 => 'image/png'); + + function __construct($bgcolor='') + { + $this->cls_image($bgcolor); + } + + function cls_image($bgcolor='') + { + if ($bgcolor) + { + $this->bgcolor = $bgcolor; + } + else + { + $this->bgcolor = "#FFFFFF"; + } + } + + /** + * 图片上传的处理函数 + * + * @access public + * @param array upload 包含上传的图片文件信息的数组 + * @param array dir 文件要上传在$this->data_dir下的目录名。如果为空图片放在则在$this->images_dir下以当月命名的目录下 + * @param array img_name 上传图片名称,为空则随机生成 + * @return mix 如果成功则返回文件名,否则返回false + */ + function upload_image($upload, $dir = '', $img_name = '') + { + /* 没有指定目录默认为根目录images */ + if (empty($dir)) + { + /* 创建当月目录 */ + $dir = date('Ym'); + $dir = ROOT_PATH . $this->images_dir . '/' . $dir . '/'; + } + else + { + /* 创建目录 */ + $dir = ROOT_PATH . $this->data_dir . '/' . $dir . '/'; + if ($img_name) + { + $img_name = $dir . $img_name; // 将图片定位到正确地址 + } + } + + /* 如果目标目录不存在,则创建它 */ + if (!file_exists($dir)) + { + if (!make_dir($dir)) + { + /* 创建目录失败 */ + $this->error_msg = sprintf($GLOBALS['_LANG']['directory_readonly'], $dir); + $this->error_no = ERR_DIRECTORY_READONLY; + + return false; + } + } + + if (empty($img_name)) + { + $img_name = $this->unique_name($dir); + $img_name = $dir . $img_name . $this->get_filetype($upload['name']); + } + + if (!$this->check_img_type($upload['type'])) + { + $this->error_msg = $GLOBALS['_LANG']['invalid_upload_image_type']; + $this->error_no = ERR_INVALID_IMAGE_TYPE; + return false; + } + + /* 允许上传的文件类型 */ + $allow_file_types = '|GIF|JPG|JPEG|PNG|BMP|SWF|'; + if (!check_file_type($upload['tmp_name'], $img_name, $allow_file_types)) + { + $this->error_msg = $GLOBALS['_LANG']['invalid_upload_image_type']; + $this->error_no = ERR_INVALID_IMAGE_TYPE; + return false; + } + + if ($this->move_file($upload, $img_name)) + { + return str_replace(ROOT_PATH, '', $img_name); + } + else + { + $this->error_msg = sprintf($GLOBALS['_LANG']['upload_failure'], $upload['name']); + $this->error_no = ERR_UPLOAD_FAILURE; + + return false; + } + } + + /** + * 创建图片的缩略图 + * + * @access public + * @param string $img 原始图片的路径 + * @param int $thumb_width 缩略图宽度 + * @param int $thumb_height 缩略图高度 + * @param strint $path 指定生成图片的目录名 + * @return mix 如果成功返回缩略图的路径,失败则返回false + */ + function make_thumb($img, $thumb_width = 0, $thumb_height = 0, $path = '', $bgcolor='') + { + $gd = $this->gd_version(); //获取 GD 版本。0 表示没有 GD 库,1 表示 GD 1.x,2 表示 GD 2.x + if ($gd == 0) + { + $this->error_msg = $GLOBALS['_LANG']['missing_gd']; + return false; + } + + /* 检查缩略图宽度和高度是否合法 */ + if ($thumb_width == 0 && $thumb_height == 0) + { + return str_replace(ROOT_PATH, '', str_replace('\\', '/', realpath($img))); + } + + /* 检查原始文件是否存在及获得原始文件的信息 */ + $org_info = @getimagesize($img); + if (!$org_info) + { + $this->error_msg = sprintf($GLOBALS['_LANG']['missing_orgin_image'], $img); + $this->error_no = ERR_IMAGE_NOT_EXISTS; + + return false; + } + + if (!$this->check_img_function($org_info[2])) + { + $this->error_msg = sprintf($GLOBALS['_LANG']['nonsupport_type'], $this->type_maping[$org_info[2]]); + $this->error_no = ERR_NO_GD; + + return false; + } + + $img_org = $this->img_resource($img, $org_info[2]); + + /* 原始图片以及缩略图的尺寸比例 */ + $scale_org = $org_info[0] / $org_info[1]; + /* 处理只有缩略图宽和高有一个为0的情况,这时背景和缩略图一样大 */ + if ($thumb_width == 0) + { + $thumb_width = $thumb_height * $scale_org; + } + if ($thumb_height == 0) + { + $thumb_height = $thumb_width / $scale_org; + } + + /* 创建缩略图的标志符 */ + if ($gd == 2) + { + $img_thumb = imagecreatetruecolor($thumb_width, $thumb_height); + } + else + { + $img_thumb = imagecreate($thumb_width, $thumb_height); + } + + /* 背景颜色 */ + if (empty($bgcolor)) + { + $bgcolor = $this->bgcolor; + } + $bgcolor = trim($bgcolor,"#"); + sscanf($bgcolor, "%2x%2x%2x", $red, $green, $blue); + $clr = imagecolorallocate($img_thumb, $red, $green, $blue); + imagefilledrectangle($img_thumb, 0, 0, $thumb_width, $thumb_height, $clr); + + if ($org_info[0] / $thumb_width > $org_info[1] / $thumb_height) + { + $lessen_width = $thumb_width; + $lessen_height = $thumb_width / $scale_org; + } + else + { + /* 原始图片比较高,则以高度为准 */ + $lessen_width = $thumb_height * $scale_org; + $lessen_height = $thumb_height; + } + + $dst_x = ($thumb_width - $lessen_width) / 2; + $dst_y = ($thumb_height - $lessen_height) / 2; + + /* 将原始图片进行缩放处理 */ + if ($gd == 2) + { + imagecopyresampled($img_thumb, $img_org, $dst_x, $dst_y, 0, 0, $lessen_width, $lessen_height, $org_info[0], $org_info[1]); + } + else + { + imagecopyresized($img_thumb, $img_org, $dst_x, $dst_y, 0, 0, $lessen_width, $lessen_height, $org_info[0], $org_info[1]); + } + + /* 创建当月目录 */ + if (empty($path)) + { + $dir = ROOT_PATH . $this->images_dir . '/' . date('Ym').'/'; + } + else + { + $dir = $path; + } + + + /* 如果目标目录不存在,则创建它 */ + if (!file_exists($dir)) + { + if (!make_dir($dir)) + { + /* 创建目录失败 */ + $this->error_msg = sprintf($GLOBALS['_LANG']['directory_readonly'], $dir); + $this->error_no = ERR_DIRECTORY_READONLY; + return false; + } + } + + /* 如果文件名为空,生成不重名随机文件名 */ + $filename = $this->unique_name($dir); + + /* 生成文件 */ + if (function_exists('imagejpeg')) + { + $filename .= '.jpg'; + imagejpeg($img_thumb, $dir . $filename); + } + elseif (function_exists('imagegif')) + { + $filename .= '.gif'; + imagegif($img_thumb, $dir . $filename); + } + elseif (function_exists('imagepng')) + { + $filename .= '.png'; + imagepng($img_thumb, $dir . $filename); + } + else + { + $this->error_msg = $GLOBALS['_LANG']['creating_failure']; + $this->error_no = ERR_NO_GD; + + return false; + } + + imagedestroy($img_thumb); + imagedestroy($img_org); + + //确认文件是否生成 + if (file_exists($dir . $filename)) + { + return str_replace(ROOT_PATH, '', $dir) . $filename; + } + else + { + $this->error_msg = $GLOBALS['_LANG']['writting_failure']; + $this->error_no = ERR_DIRECTORY_READONLY; + + return false; + } + } + + /** + * 为图片增加水印 + * + * @access public + * @param string filename 原始图片文件名,包含完整路径 + * @param string target_file 需要加水印的图片文件名,包含完整路径。如果为空则覆盖源文件 + * @param string $watermark 水印完整路径 + * @param int $watermark_place 水印位置代码 + * @return mix 如果成功则返回文件路径,否则返回false + */ + function add_watermark($filename, $target_file='', $watermark='', $watermark_place='', $watermark_alpha = 0.65) + { + // 是否安装了GD + $gd = $this->gd_version(); + if ($gd == 0) + { + $this->error_msg = $GLOBALS['_LANG']['missing_gd']; + $this->error_no = ERR_NO_GD; + + return false; + } + + // 文件是否存在 + if ((!file_exists($filename)) || (!is_file($filename))) + { + $this->error_msg = sprintf($GLOBALS['_LANG']['missing_orgin_image'], $filename); + $this->error_no = ERR_IMAGE_NOT_EXISTS; + + return false; + } + + /* 如果水印的位置为0,则返回原图 */ + if ($watermark_place == 0 || empty($watermark)) + { + return str_replace(ROOT_PATH, '', str_replace('\\', '/', realpath($filename))); + } + + if (!$this->validate_image($watermark)) + { + /* 已经记录了错误信息 */ + return false; + } + + // 获得水印文件以及源文件的信息 + $watermark_info = @getimagesize($watermark); + $watermark_handle = $this->img_resource($watermark, $watermark_info[2]); + + if (!$watermark_handle) + { + $this->error_msg = sprintf($GLOBALS['_LANG']['create_watermark_res'], $this->type_maping[$watermark_info[2]]); + $this->error_no = ERR_INVALID_IMAGE; + + return false; + } + + // 根据文件类型获得原始图片的操作句柄 + $source_info = @getimagesize($filename); + $source_handle = $this->img_resource($filename, $source_info[2]); + if (!$source_handle) + { + $this->error_msg = sprintf($GLOBALS['_LANG']['create_origin_image_res'], $this->type_maping[$source_info[2]]); + $this->error_no = ERR_INVALID_IMAGE; + + return false; + } + + // 根据系统设置获得水印的位置 + switch ($watermark_place) + { + case '1': + $x = 0; + $y = 0; + break; + case '2': + $x = $source_info[0] - $watermark_info[0]; + $y = 0; + break; + case '4': + $x = 0; + $y = $source_info[1] - $watermark_info[1]; + break; + case '5': + $x = $source_info[0] - $watermark_info[0]; + $y = $source_info[1] - $watermark_info[1]; + break; + default: + $x = $source_info[0]/2 - $watermark_info[0]/2; + $y = $source_info[1]/2 - $watermark_info[1]/2; + } + + if (strpos(strtolower($watermark_info['mime']), 'png') !== false) + { + imageAlphaBlending($watermark_handle, true); + imagecopy($source_handle, $watermark_handle, $x, $y, 0, 0,$watermark_info[0], $watermark_info[1]); + } + else + { + imagecopymerge($source_handle, $watermark_handle, $x, $y, 0, 0,$watermark_info[0], $watermark_info[1], $watermark_alpha); + } + $target = empty($target_file) ? $filename : $target_file; + + switch ($source_info[2] ) + { + case 'image/gif': + case 1: + imagegif($source_handle, $target); + break; + + case 'image/pjpeg': + case 'image/jpeg': + case 2: + imagejpeg($source_handle, $target); + break; + + case 'image/x-png': + case 'image/png': + case 3: + imagepng($source_handle, $target); + break; + + default: + $this->error_msg = $GLOBALS['_LANG']['creating_failure']; + $this->error_no = ERR_NO_GD; + + return false; + } + + imagedestroy($source_handle); + + $path = realpath($target); + if ($path) + { + return str_replace(ROOT_PATH, '', str_replace('\\', '/', $path)); + } + else + { + $this->error_msg = $GLOBALS['_LANG']['writting_failure']; + $this->error_no = ERR_DIRECTORY_READONLY; + + return false; + } + } + + /** + * 检查水印图片是否合法 + * + * @access public + * @param string $path 图片路径 + * + * @return boolen + */ + function validate_image($path) + { + if (empty($path)) + { + $this->error_msg = $GLOBALS['_LANG']['empty_watermark']; + $this->error_no = ERR_INVALID_PARAM; + + return false; + } + + /* 文件是否存在 */ + if (!file_exists($path)) + { + $this->error_msg = sprintf($GLOBALS['_LANG']['missing_watermark'], $path); + $this->error_no = ERR_IMAGE_NOT_EXISTS; + return false; + } + + // 获得文件以及源文件的信息 + $image_info = @getimagesize($path); + + if (!$image_info) + { + $this->error_msg = sprintf($GLOBALS['_LANG']['invalid_image_type'], $path); + $this->error_no = ERR_INVALID_IMAGE; + return false; + } + + /* 检查处理函数是否存在 */ + if (!$this->check_img_function($image_info[2])) + { + $this->error_msg = sprintf($GLOBALS['_LANG']['nonsupport_type'], $this->type_maping[$image_info[2]]); + $this->error_no = ERR_NO_GD; + return false; + } + + return true; + } + + /** + * 返回错误信息 + * + * @return string 错误信息 + */ + function error_msg() + { + return $this->error_msg; + } + + /*------------------------------------------------------ */ + //-- 工具函数 + /*------------------------------------------------------ */ + + /** + * 检查图片类型 + * @param string $img_type 图片类型 + * @return bool + */ + function check_img_type($img_type) + { + return $img_type == 'image/pjpeg' || + $img_type == 'image/x-png' || + $img_type == 'image/png' || + $img_type == 'image/gif' || + $img_type == 'image/jpeg'; + } + + /** + * 检查图片处理能力 + * + * @access public + * @param string $img_type 图片类型 + * @return void + */ + function check_img_function($img_type) + { + switch ($img_type) + { + case 'image/gif': + case 1: + + if (PHP_VERSION >= '4.3') + { + return function_exists('imagecreatefromgif'); + } + else + { + return (imagetypes() & IMG_GIF) > 0; + } + break; + + case 'image/pjpeg': + case 'image/jpeg': + case 2: + if (PHP_VERSION >= '4.3') + { + return function_exists('imagecreatefromjpeg'); + } + else + { + return (imagetypes() & IMG_JPG) > 0; + } + break; + + case 'image/x-png': + case 'image/png': + case 3: + if (PHP_VERSION >= '4.3') + { + return function_exists('imagecreatefrompng'); + } + else + { + return (imagetypes() & IMG_PNG) > 0; + } + break; + + default: + return false; + } + } + + /** + * 生成随机的数字串 + * + * @author: weber liu + * @return string + */ + function random_filename() + { + $str = ''; + for($i = 0; $i < 9; $i++) + { + $str .= mt_rand(0, 9); + } + + return gmtime() . $str; + } + + /** + * 生成指定目录不重名的文件名 + * + * @access public + * @param string $dir 要检查是否有同名文件的目录 + * + * @return string 文件名 + */ + function unique_name($dir) + { + $filename = ''; + while (empty($filename)) + { + $filename = cls_image::random_filename(); + if (file_exists($dir . $filename . '.jpg') || file_exists($dir . $filename . '.gif') || file_exists($dir . $filename . '.png')) + { + $filename = ''; + } + } + + return $filename; + } + + /** + * 返回文件后缀名,如‘.php’ + * + * @access public + * @param + * + * @return string 文件后缀名 + */ + function get_filetype($path) + { + $pos = strrpos($path, '.'); + if ($pos !== false) + { + return substr($path, $pos); + } + else + { + return ''; + } + } + + /** + * 根据来源文件的文件类型创建一个图像操作的标识符 + * + * @access public + * @param string $img_file 图片文件的路径 + * @param string $mime_type 图片文件的文件类型 + * @return resource 如果成功则返回图像操作标志符,反之则返回错误代码 + */ + function img_resource($img_file, $mime_type) + { + switch ($mime_type) + { + case 1: + case 'image/gif': + $res = imagecreatefromgif($img_file); + break; + + case 2: + case 'image/pjpeg': + case 'image/jpeg': + $res = imagecreatefromjpeg($img_file); + break; + + case 3: + case 'image/x-png': + case 'image/png': + $res = imagecreatefrompng($img_file); + break; + + default: + return false; + } + + return $res; + } + + /** + * 获得服务器上的 GD 版本 + * + * @access public + * @return int 可能的值为0,1,2 + */ + function gd_version() + { + static $version = -1; + + if ($version >= 0) + { + return $version; + } + + if (!extension_loaded('gd')) + { + $version = 0; + } + else + { + // 尝试使用gd_info函数 + if (PHP_VERSION >= '4.3') + { + if (function_exists('gd_info')) + { + $ver_info = gd_info(); + preg_match('/\d/', $ver_info['GD Version'], $match); + $version = $match[0]; + } + else + { + if (function_exists('imagecreatetruecolor')) + { + $version = 2; + } + elseif (function_exists('imagecreate')) + { + $version = 1; + } + } + } + else + { + if (preg_match('/phpinfo/', ini_get('disable_functions'))) + { + /* 如果phpinfo被禁用,无法确定gd版本 */ + $version = 1; + } + else + { + // 使用phpinfo函数 + ob_start(); + phpinfo(8); + $info = ob_get_contents(); + ob_end_clean(); + $info = stristr($info, 'gd version'); + preg_match('/\d/', $info, $match); + $version = $match[0]; + } + } + } + + return $version; + } + + /** + * + * + * @access public + * @param + * + * @return void + */ + function move_file($upload, $target) + { + if (isset($upload['error']) && $upload['error'] > 0) + { + return false; + } + + if (!move_upload_file($upload['tmp_name'], $target)) + { + return false; + } + + return true; + } + + function image_fix_orientation($path,$type){ +// $image = imagecreatefromjpeg($path); + $image = $this->img_resource($path, $type); + $exif = exif_read_data($path); + + if (!empty($exif['Orientation'])) { + switch ($exif['Orientation']) { + case 3: + $image = imagerotate($image, 180, 0); + break; + case 6: + $image = imagerotate($image, -90, 0); + break; + case 8: + $image = imagerotate($image, 90, 0); + break; + } + + switch ($type) + { + case 'image/gif': + case 1: + $res=imagegif($image, $path); + break; + + case 'image/pjpeg': + case 'image/jpeg': + case 2: + $res=imagejpeg($image, $path); + break; + + case 'image/x-png': + case 'image/png': + case 3: + $res=imagepng($image, $path); + break; + + default: + + return false; + } +// $res=imagejpeg($image, $path); + return $res; + } + return false; + } +} + +?> \ No newline at end of file diff --git a/includes/cls_ip_location.php b/includes/cls_ip_location.php new file mode 100755 index 0000000..5ae0513 --- /dev/null +++ b/includes/cls_ip_location.php @@ -0,0 +1,229 @@ +fp = 0; + if (($this->fp = fopen($filename, 'rb')) !== false) { + $this->firstip = $this->getlong(); + $this->lastip = $this->getlong(); + $this->totalip = ($this->lastip - $this->firstip) / 7; + //注册析构函数,使其在程序执行结束时执行 + register_shutdown_function(array( + &$this, + '__destruct' + )); + } + } + + /** + * 析构函数,用于在页面执行结束后自动关闭打开的文件。 + * + */ + public function __destruct() + { + if ($this->fp) { + fclose($this->fp); + } + $this->fp = 0; + } + + /** + * 返回读取的长整型数 + * + * @access private + * @return int + */ + private function getlong() + { + //将读取的little-endian编码的4个字节转化为长整型数 + $result = unpack('Vlong', fread($this->fp, 4)); + return $result['long']; + } + + /** + * 返回读取的3个字节的长整型数 + * + * @access private + * @return int + */ + private function getlong3() + { + //将读取的little-endian编码的3个字节转化为长整型数 + $result = unpack('Vlong', fread($this->fp, 3) . chr(0)); + return $result['long']; + } + + /** + * 返回压缩后可进行比较的IP地址 + * + * @access private + * @param string $ip + * @return string + */ + private function packip($ip) + { + // 将IP地址转化为长整型数,如果在PHP5中,IP地址错误,则返回False, + // 这时intval将Flase转化为整数-1,之后压缩成big-endian编码的字符串 + return pack('N', intval(ip2long($ip))); + } + + /** + * 返回读取的字符串 + * + * @access private + * @param string $data + * @return string + */ + private function getstring($data = "") + { + $char = fread($this->fp, 1); + while (ord($char) > 0) { // 字符串按照C格式保存,以结束 + $data .= $char; // 将读取的字符连接到给定字符串之后 + $char = fread($this->fp, 1); + } + return iconv('gbk', 'utf-8', $data); + } + + /** + * 返回地区信息 + * + * @access private + * @return string + */ + private function getarea() + { + $byte = fread($this->fp, 1); // 标志字节 + switch (ord($byte)) { + case 0: // 没有区域信息 + $area = ""; + break; + case 1: + case 2: // 标志字节为1或2,表示区域信息被重定向 + fseek($this->fp, $this->getlong3()); + $area = $this->getstring(); + break; + default: // 否则,表示区域信息没有被重定向 + $area = $this->getstring($byte); + break; + } + return $area; + } + + /** + * 根据所给 IP 地址或域名返回所在地区信息 + * + * @access public + * @param string $ip + * @return array + */ + public function getlocation($ip) + { + if (!$this->fp) + return null; // 如果数据文件没有被正确打开,则直接返回空 + $location['ip'] = gethostbyname($ip); // 将输入的域名转化为IP地址 + $ip = $this->packip($location['ip']); // 将输入的IP地址转化为可比较的IP地址 + // 不合法的IP地址会被转化为255.255.255.255 + // 对分搜索 + $l = 0; // 搜索的下边界 + $u = $this->totalip; // 搜索的上边界 + $findip = $this->lastip; // 如果没有找到就返回最后一条IP记录(QQWry.Dat的版本信息) + while ($l <= $u) { // 当上边界小于下边界时,查找失败 + $i = floor(($l + $u) / 2); // 计算近似中间记录 + fseek($this->fp, $this->firstip + $i * 7); + $beginip = strrev(fread($this->fp, 4)); // 获取中间记录的开始IP地址 + // strrev函数在这里的作用是将little-endian的压缩IP地址转化为big-endian的格式 + // 以便用于比较,后面相同。 + if ($ip < $beginip) { // 用户的IP小于中间记录的开始IP地址时 + $u = $i - 1; // 将搜索的上边界修改为中间记录减一 + } else { + fseek($this->fp, $this->getlong3()); + $endip = strrev(fread($this->fp, 4)); // 获取中间记录的结束IP地址 + if ($ip > $endip) { // 用户的IP大于中间记录的结束IP地址时 + $l = $i + 1; // 将搜索的下边界修改为中间记录加一 + } else { // 用户的IP在中间记录的IP范围内时 + $findip = $this->firstip + $i * 7; + break; // 则表示找到结果,退出循环 + } + } + } + //获取查找到的IP地理位置信息 + fseek($this->fp, $findip); + $location['beginip'] = long2ip($this->getlong()); // 用户IP所在范围的开始地址 + $offset = $this->getlong3(); + fseek($this->fp, $offset); + $location['endip'] = long2ip($this->getlong()); // 用户IP所在范围的结束地址 + $byte = fread($this->fp, 1); // 标志字节 + switch (ord($byte)) { + case 1: // 标志字节为1,表示国家和区域信息都被同时重定向 + $countryOffset = $this->getlong3(); // 重定向地址 + fseek($this->fp, $countryOffset); + $byte = fread($this->fp, 1); // 标志字节 + switch (ord($byte)) { + case 2: // 标志字节为2,表示国家信息又被重定向 + fseek($this->fp, $this->getlong3()); + $location['country'] = $this->getstring(); + fseek($this->fp, $countryOffset + 4); + $location['area'] = $this->getarea(); + break; + default: // 否则,表示国家信息没有被重定向 + $location['country'] = $this->getstring($byte); + $location['area'] = $this->getarea(); + break; + } + break; + case 2: // 标志字节为2,表示国家信息被重定向 + fseek($this->fp, $this->getlong3()); + $location['country'] = $this->getstring(); + fseek($this->fp, $offset + 8); + $location['area'] = $this->getarea(); + break; + default: // 否则,表示国家信息没有被重定向 + $location['country'] = $this->getstring($byte); + $location['area'] = $this->getarea(); + break; + } + if ($location['country'] == " CZ88.NET") { // CZ88.NET表示没有有效信息 + $location['country'] = "未知"; + } + if ($location['area'] == " CZ88.NET") { + $location['area'] = ""; + } + return $location; + } +} +?> \ No newline at end of file diff --git a/includes/cls_json.php b/includes/cls_json.php new file mode 100755 index 0000000..cb53b57 --- /dev/null +++ b/includes/cls_json.php @@ -0,0 +1,595 @@ + $v) + { + if (!is_numeric($i)) + { + $numeric = false; + break; + } + } + + if ($numeric) + { + foreach ($arg AS $i => $v) + { + if (strlen($s) > 0) + { + $s .= ','; + } + $s .= $this->encode($arg[$i]); + } + + $returnValue = '[' . $s . ']'; + } + else + { + foreach ($arg AS $i => $v) + { + if (strlen($s) > 0) + { + $s .= ','; + } + $s .= $this->encode($i) . ':' . $this->encode($arg[$i]); + } + + $returnValue = '{' . $s . '}'; + } + break; + + case 'object': + foreach (get_object_vars($arg) AS $i => $v) + { + $v = $this->encode($v); + + if (strlen($s) > 0) + { + $s .= ','; + } + $s .= $this->encode($i) . ':' . $v; + } + + $returnValue = '{' . $s . '}'; + break; + + case 'integer': + case 'double': + $returnValue = is_numeric($arg) ? (string) $arg : 'null'; + break; + + case 'string': + $returnValue = '"' . strtr($arg, array( + "\r" => '\\r', "\n" => '\\n', "\t" => '\\t', "\b" => '\\b', + "\f" => '\\f', '\\' => '\\\\', '"' => '\"', + "\x00" => '\u0000', "\x01" => '\u0001', "\x02" => '\u0002', "\x03" => '\u0003', + "\x04" => '\u0004', "\x05" => '\u0005', "\x06" => '\u0006', "\x07" => '\u0007', + "\x08" => '\b', "\x0b" => '\u000b', "\x0c" => '\f', "\x0e" => '\u000e', + "\x0f" => '\u000f', "\x10" => '\u0010', "\x11" => '\u0011', "\x12" => '\u0012', + "\x13" => '\u0013', "\x14" => '\u0014', "\x15" => '\u0015', "\x16" => '\u0016', + "\x17" => '\u0017', "\x18" => '\u0018', "\x19" => '\u0019', "\x1a" => '\u001a', + "\x1b" => '\u001b', "\x1c" => '\u001c', "\x1d" => '\u001d', "\x1e" => '\u001e', + "\x1f" => '\u001f' + )) . '"'; + break; + + case 'boolean': + $returnValue = $arg?'true':'false'; + break; + + default: + $returnValue = 'null'; + } + + return $returnValue; + } + + function decode($text,$type=0) // 榛樿?type=0杩斿洖obj,type=1杩斿洖array + { + if (empty($text)) + { + return ''; + } + elseif (!is_string($text)) + { + return false; + } + + if (EC_CHARSET === 'utf-8' && function_exists('json_decode')) + { + return addslashes_deep_obj(json_decode(stripslashes($text),$type)); + } + + $this->at = 0; + $this->ch = ''; + $this->text = strtr(stripslashes($text), array( + "\r" => '', "\n" => '', "\t" => '', "\b" => '', + "\x00" => '', "\x01" => '', "\x02" => '', "\x03" => '', + "\x04" => '', "\x05" => '', "\x06" => '', "\x07" => '', + "\x08" => '', "\x0b" => '', "\x0c" => '', "\x0e" => '', + "\x0f" => '', "\x10" => '', "\x11" => '', "\x12" => '', + "\x13" => '', "\x14" => '', "\x15" => '', "\x16" => '', + "\x17" => '', "\x18" => '', "\x19" => '', "\x1a" => '', + "\x1b" => '', "\x1c" => '', "\x1d" => '', "\x1e" => '', + "\x1f" => '' + )); + + $this->next(); + $return = $this->val(); + + $result = empty($type) ? $return : $this->object_to_array($return); + + return addslashes_deep_obj($result); + } + + /** + * triggers a PHP_ERROR + * + * @access private + * @param string $m error message + * + * @return void + */ + function error($m) + { + echo($m . ' at offset ' . $this->at . ': ' . $this->text); + } + + /** + * returns the next character of a JSON string + * + * @access private + * + * @return string + */ + function next() + { + $this->ch = !isset($this->text{$this->at}) ? '' : $this->text{$this->at}; + $this->at++; + + return $this->ch; + } + + /** + * handles strings + * + * @access private + * + * @return void + */ + function str() + { + $i = ''; + $s = ''; + $t = ''; + $u = ''; + + if ($this->ch == '"') + { + while ($this->next() !== null) + { + if ($this->ch == '"') + { + $this->next(); + + return $s; + } + elseif ($this->ch == '\\') + { + switch ($this->next()) + { + case 'b': + $s .= '\b'; + break; + + case 'f': + $s .= '\f'; + break; + + case 'n': + $s .= '\n'; + break; + + case 'r': + $s .= '\r'; + break; + + case 't': + $s .= '\t'; + break; + + case 'u': + $u = 0; + + for ($i = 0; $i < 4; $i++) + { + $t = (integer) sprintf('%01c', hexdec($this->next())); + + if (!is_numeric($t)) + { + break 2; + } + $u = $u * 16 + $t; + } + + $s .= chr($u); + break; + case '\'': + $s .= '\''; + break; + default: + $s .= $this->ch; + } + } + else + { + $s .= $this->ch; + } + } + } + + $this->error('Bad string'); + } + + /** + * handless arrays + * + * @access private + * + * @return void + */ + function arr() + { + $a = array(); + + if ($this->ch == '[') + { + $this->next(); + + if ($this->ch == ']') + { + $this->next(); + + return $a; + } + + while (isset($this->ch)) + { + array_push($a, $this->val()); + + if ($this->ch == ']') + { + $this->next(); + + return $a; + + } + elseif ($this->ch != ',') + { + break; + } + + $this->next(); + + } + + $this->error('Bad array'); + } + } + + /** + * handles objects + * + * @access public + * + * @return void + */ + function obj() + { + $k = ''; + $o = new StdClass(); + + if ($this->ch == '{') + { + $this->next(); + + if ($this->ch == '}') + { + $this->next(); + + return $o; + } + + while ($this->ch) + { + $k = $this->str(); + + if ($this->ch != ':') + { + break; + } + + $this->next(); + $o->$k = $this->val(); + + if ($this->ch == '}') + { + $this->next(); + + return $o; + } + elseif ($this->ch != ',') + { + break; + } + + $this->next(); + } + } + + $this->error('Bad object'); + } + + /** + * handles objects + * + * @access public + * + * @return void + */ + function assoc() + { + $k = ''; + $a = array(); + + if ($this->ch == '<') + { + $this->next(); + + if ($this->ch == '>') + { + $this->next(); + + return $a; + } + + while ($this->ch) + { + $k = $this->str(); + + if ($this->ch != ':') + { + break; + } + + $this->next(); + $a[$k] = $this->val(); + + if ($this->ch == '>') + { + $this->next(); + + return $a; + } + elseif ($this->ch != ',') + { + break; + } + + $this->next(); + } + } + + $this->error('Bad associative array'); + } + + /** + * handles numbers + * + * @access private + * + * @return void + */ + function num() + { + $n = ''; + $v = ''; + + if ($this->ch == '-') + { + $n = '-'; + $this->next(); + } + + while ($this->ch >= '0' && $this->ch <= '9') + { + $n .= $this->ch; + $this->next(); + } + + if ($this->ch == '.') + { + $n .= '.'; + + while ($this->next() && $this->ch >= '0' && $this->ch <= '9') + { + $n .= $this->ch; + } + } + + if ($this->ch == 'e' || $this->ch == 'E') + { + $n .= 'e'; + $this->next(); + + if ($this->ch == '-' || $this->ch == '+') + { + $n .= $this->ch; + $this->next(); + } + + while ($this->ch >= '0' && $this->ch <= '9') + { + $n .= $this->ch; + $this->next(); + } + } + + $v += $n; + + if (!is_numeric($v)) + { + $this->error('Bad number'); + } + else + { + return $v; + } + } + + /** + * handles words + * + * @access private + * + * @return mixed + */ + function word() + { + switch ($this->ch) + { + case 't': + + if ($this->next() == 'r' && $this->next() == 'u' && $this->next() == 'e') + { + $this->next(); + + return true; + } + break; + + case 'f': + if ($this->next() == 'a' && $this->next() == 'l' && $this->next() == 's' && $this->next() == 'e') + { + $this->next(); + + return false; + } + break; + + case 'n': + if ($this->next() == 'u' && $this->next() == 'l' && $this->next() == 'l') + { + $this->next(); + + return null; + } + break; + } + + $this->error('Syntax error'); + } + + /** + * generic value handler + * + * @access private + * + * @return mixed + */ + function val() + { + switch ($this->ch) + { + case '{': + return $this->obj(); + + case '[': + return $this->arr(); + + case '<': + return $this->assoc(); + + case '"': + return $this->str(); + + case '-': + return $this->num(); + + default: + return ($this->ch >= '0' && $this->ch <= '9') ? $this->num() : $this->word(); + } + } + + /** + * Gets the properties of the given object recursion + * + * @access private + * + * @return array + */ + function object_to_array($obj) + { + $_arr = is_object($obj) ? get_object_vars($obj) : $obj; + foreach ($_arr as $key => $val) + { + $val = (is_array($val) || is_object($val)) ? $this->object_to_array($val) : $val; + $arr[$key] = $val; + } + return $arr; + } +} + +?> \ No newline at end of file diff --git a/includes/cls_matrix.php b/includes/cls_matrix.php new file mode 100755 index 0000000..29f4dd0 --- /dev/null +++ b/includes/cls_matrix.php @@ -0,0 +1,997 @@ +transport = new transport; + $this->shopex_app = array('taodali','ecos.ome'); + $this->db = $GLOBALS['db']; + $this->ecs = $GLOBALS['ecs']; + } + + /** + * 功能:查询绑定详情 + * + * @param array $node_type 绑定类型 + * @return array + */ + function get_bind_info($node_type) + { + if (!is_array($node_type)) { + $node_type = array($node_type); + } + $sql = "SELECT * + FROM " . $this->ecs->table('shop_bind') . " + WHERE node_type in ('".implode("','", $node_type)."') AND status='bind'"; + $bind_info = $this->db->getRow($sql); + $bind_info = is_array($bind_info) ? $bind_info : array(); + return $bind_info; + } + + /** + * 功能:保存矩阵绑定关系 + * + * @param array $data 绑定信息 + * @return string + */ + function save_shop_bind($data) + { + $sql = "INSERT INTO ".$this->ecs->table('shop_bind')." (name, node_id, node_type, status, app_url) ". + "VALUES ('".$data['name']."','".$data['node_id']."','".$data['node_type']."','".$data['status']."','".$data['app_url']."')"; + + error_log(date("c")."\t".$sql."\n\n",3,LOG_DIR."/api.log"); + + $this->db->query($sql); + /* 转入权限分配列表 */ + $new_id = $this->db->Insert_ID(); + /* 将矩阵的绑定节点状态写入config */ + $this->bind_config($data['node_type']); + return $new_id; + } + + /** + * 功能:删除矩阵绑定关系 + * + * @param array $node_type 绑定类型 + */ + function delete_shop_bind($node_type){ + error_log(date("c")."\t".__LINE__."\n\n",3,LOG_DIR."/api.log"); + if(!$node_type) return false; + $sql = "delete from ".$this->ecs->table('shop_bind')." where node_type = '".$node_type."'"; + error_log(date("c")."delete_shop_bind:\t".__LINE__.print_r($sql,1)."\n\n",3,LOG_DIR."/api.log"); + $this->db->query($sql); + /* 将矩阵的绑定节点状态写入configg */ + $this->bind_config($node_type,'false'); + return true; + } + + /** + * 功能:将矩阵的绑定节点状态写入config + * + * @param array $code 绑定类型 + * @param strint $status true:绑定 false:解绑 + */ + function bind_config($code,$status='true'){ + if(!$code || $code=='') return false; + $sql = "select value from ".$this->ecs->table('shop_config')." where code ='bind_list'"; + $bind_row = $this->db->getOne($sql); + $bind_row and $list = json_decode($bind_row,1); + error_log(date("c")."\t".__LINE__.print_r($list,1)."\n\n",3,LOG_DIR."/api.log"); + if($list){ + if($status=='true'){ + $list = array_push($list, $code); + }else{ + unset($list[array_search($code,$list)]); + } + error_log(date("c")."list:\t".__LINE__.print_r($list,1)."\n\n",3,LOG_DIR."/api.log"); + $sql = "update from ".$this->ecs->table('shop_config')." set value='".json_encode($list)."' where code='bind_list"; + if(empty($list)) $sql = "delete from ".$this->ecs->table('shop_config')." where code='bind_list'"; + error_log(date("c")."bind_config:\t".__LINE__.print_r($sql,1)."\n\n",3,LOG_DIR."/api.log"); + $this->db->query($sql); + }else{ + if($status=='true'){ + $list = array($code); + $sql = "insert into ".$this->ecs->table('shop_config')." set parent_id=2,code='bind_list',type='hidden',value='".json_encode($list)."',sort_order=1"; + $this->db->query($sql); + } + } + + } + + /** + * 功能:获取支付方式 + * + * @param int $pay_id 支付方式ID + */ + function get_payment($pay_id){ + $sql = "SELECT pay_id, pay_name,pay_code FROM ".$this->ecs->table('payment'). + " WHERE enabled = 1 AND pay_id = ".$pay_id; + return $this->db->getRow($sql); + } + + + function getItemNum($order_id){ + $sql = "SELECT SUM(goods_number) as itemnum from ".$this->ecs->table('order_goods')." where order_id=".$order_id; + return $this->db->getRow($sql); + } + + + function http_request_matrix($paramss,$bind_type='ecos.ome'){ + //sync同步 + foreach($this->shopex_app as $k){ + switch($k){ + case 'taodali': + $commit_setting[$k]['commit_url'] = MATRIX_COMMIT_URL_SYNC; + $commit_setting[$k]['real_time'] = 'true'; + $commit_setting[$k]['callback_type'] = $paramss['callback_type']; + break; + case 'ecos.ome': + $commit_setting[$k]['commit_url'] = MATRIX_COMMIT_URL_SYNC; + $commit_setting[$k]['real_time'] = 'true'; + $commit_setting[$k]['callback_type'] = $paramss['callback_type']; + break; + } + } + include_once(ROOT_PATH."includes/cls_certificate.php"); + $cert = new certificate(); + //系统级参数 + $paramss['app_id'] = VERIFY_APP_ID; + $certificate = $cert->get_shop_certificate(); + $paramss['certi_id'] = $certificate['certificate_id']; + $paramss['from_node_id'] = $certificate['node_id']; + $paramss['date'] = time(); + // $paramss['timestamp'] = microtime(true); + $paramss['timestamp'] = date('Y-m-d H:i:s',time()); + $paramss['refresh_time'] = date('Y-m-d H:i:s',time()); + $paramss['format'] = "json"; + $paramss['v'] = "1.0"; + $paramss['from_api_v'] = '1.0'; + $http_type = $paramss['type']; + unset($paramss['type']); + $bind_type=='retry' and $bind_type = $this->shopex_app; + $shop = $this->get_bind_info($bind_type); + $paramss['node_type'] = $shop['node_type']; + $paramss['to_node_id'] = $shop['node_id']; + $paramss['_id'] = "rel_".$paramss['from_node_id']."_".$paramss['method']."_".$paramss['to_node_id']; + $paramss['task'] = $this->create_task_id(); + $paramss['real_time'] = $commit_setting[$shop['node_type']]['real_time']; + $paramss['callback_type'] = $commit_setting[$shop['node_type']]['callback_type']; + $paramss['callback_url'] = $this->ecs->url(); + unset($paramss['sign']); + $paramss['sign'] = $this->get_matrix_sign($paramss,$certificate['token']); + if ( @constant( "DEBUG_API" ) ) { + foreach ($paramss as $key=>$val) { + $array_debug_info[] = $key."=".stripslashes($val); + } + $str_debug_info = implode("&", $array_debug_info); + if(!is_dir(LOG_DIR)){ + mkdir(LOG_DIR,0777); + } + error_log(date("c")."\t".rawurldecode($str_debug_info)."\n".stripslashes(var_export($paramss,true))."\n\n",3,LOG_DIR."/api_".date("Y-m-d",time()).".log"); + unset($str_debug_info,$array_debug_info); + } + error_log(date("c")."\t".__LINE__.print_r($commit_setting,1)."\n\n",3,LOG_DIR."/api.log"); + error_log(date("c")."\t".__LINE__.print_r($shop,1)."\n\n",3,LOG_DIR."/api.log"); + $i=0; + do{ + $i++; + $response = $this->transport->request($commit_setting[$shop['node_type']]['commit_url'], $paramss); + }while(strlen(trim($response['body']))==0&&$i<0); + + if ( @constant( "DEBUG_API" ) ) { + error_log(date("c")."\t"."\n".stripslashes(var_export($response,true))."\n\n",3,LOG_DIR."/api_".date("Y-m-d",time()).".log"); + } + + $callback = json_decode($response['body'],true); + $status = $callback['rsp']=='succ'?'true':'false'; + $this->set_callback($callback,$http_type,$commit_setting[$shop['node_type']]['callback_type'],$paramss['callback_type_id'],$paramss['method'],$paramss,$status); + } + + + //创建订单 + function createOrder($order_sn,$type='ecos.ome'){ + include_once(ROOT_PATH.'includes/cls_certificate.php'); + $cert = new certificate(); + if(!$cert->is_bind_sn($type,'bind_type')) return false; + + //订单总体信息 + $paramss = $this->getOrderStruct($order_sn); + if(!$paramss['orders']) return null; + + $paramss['method'] = 'store.trade.add'; + $paramss['callback_type'] = 'CREATEORDER'; + $paramss['callback_type_id'] = $paramss['tid']; + $paramss['type'] = 'request'; + $paramss['from_type'] = VERIFY_APP_ID; + $this->http_request_matrix($paramss,$type); + } + + + //更新订单 + function updateOrder($order_sn,$type='ecos.ome'){ + include_once(ROOT_PATH.'includes/cls_certificate.php'); + $cert = new certificate(); + $flag = false; + foreach($this->shopex_app as $shopex_app){ + if($cert->is_bind_sn($shopex_app,'bind_type')) $flag = true; + } + if($flag==false) return false; + //订单总体信息 + $paramss = $this->getOrderStruct($order_sn); + $paramss['method'] = 'store.trade.update'; + $paramss['callback_type'] = 'UPDATEORDER'; + $paramss['callback_type_id'] = $paramss['tid']; + $paramss['type'] = 'request'; + $paramss['from_type'] = VERIFY_APP_ID; + $this->http_request_matrix($paramss,$type); + } + + //获取货品列表 + function getProductList($items,$p_real_price){ + if( !empty($items) ){ + $sql = "select p.product_id,p.goods_id as iid,p.goods_id,p.goods_attr,attr.attr_price,attr.attr_value,g.shop_price as price,g.goods_name as name from ".$this->ecs->table('products')." as p LEFT join ".$this->ecs->table('goods_attr')." as attr on p.goods_attr=attr.goods_attr_id and p.goods_id=attr.goods_id LEFT join ".$this->ecs->table('goods')." as g on p.goods_id=g.goods_id where p.product_id in (".join(',',$items[1]).")"; + $rows = $this->db->getAll($sql); + $datas = array(); + $goods_ids = array(); + foreach($rows as $k => $val){ + if($val['attr_value']){ + $val['name'] .= "(".$val['attr_value'].")"; + $val['sku_properties'] = $val['attr_value']; + } + $val['num']=$items[0][$val['product_id']]['goods_number']; + + $val['total_item_fee'] = $this->format_number($items[0][$val['product_id']]['goods_price'] * $val['num']); + $val['sendnum'] = 0; + $val['item_type'] = 'product'; + $val['sale_price'] = $this->format_number($p_real_price[$val['product_id']] * $val['num']); + $val['discount_fee'] = $this->format_number(($val['price']+$val['attr_price'])*$val['num']-$val['sale_price']); //商品差价 + $this->_total_products_price += ($val['price']+$val['attr_price'])*$val['num']; //未打折之前总的商品价格 + $this->_total_discount_fee +=$val['discount_fee']; //总商品差价 + $datas[$val['iid']][$val['product_id']] = $val; + $goods_ids[$val['iid']] = $val['iid']; + $goods_total[$val['iid']][$val['product_id']]['product_id'] = $val['product_id']; + $goods_total[$val['iid']][$val['product_id']]['num'] = $val['num']; + $goods_total[$val['iid']][$val['product_id']]['total'] = $val['total_item_fee']; + //unset($datas[$val['iid']][$k]['product_id']); + } + if( !empty($goods_total) ){ + foreach( $goods_total as $key=>$val ){ + foreach($val as $v){ + $goods[$key]['items_num'] += $v['num']; + $goods[$key]['total_order_fee'] += $v['total']; + } + } + } + } + return array($datas,$goods,$goods_ids);//列表数据,商品个数和总价,商品id列表 + } + + //获取商品列表 + function getGoodsList($goods_ids){ + if( !empty($goods_ids) ){ + $sql = "select goods_id as iid,goods_name as title,goods_sn as bn from ".$this->ecs->table('goods')." where goods_id in (".join(',',$goods_ids).")"; + $rows = $this->db->getAll($sql); + } + return $rows; + } + + //获取订单信息 + function get_order_info($order_sn,$params=''){ + $params = $params?$params:'*'; + $sql = "select ".$params." from ".$this->ecs->table('order_info')." where order_sn='".$order_sn."'"; + $row = $this->db->getRow($sql); + return $row; + } + + //获取订单货品信息order_goods + function get_order_items($order_id){ + $sql = "select distinct product_id,goods_name,goods_sn,goods_price,market_price,goods_number,goods_attr,rec_id from ".$this->ecs->table('order_goods')." where order_id='".$order_id."' and is_gift =0"; + if($rs = $this->db->getAll($sql)){ + foreach($rs as $k=>$v){ + $product_ids[$v['product_id']] = $v['product_id']; + $v['goods_attr'] = str_replace("\n", "", $v['goods_attr']); + $items[$v['product_id']] = $v; + $items_id[] = $v['rec_id']; + $p_items_id[$v['product_id']] = $v['rec_id']; + } + } + $diff_items_id = array_diff($items_id, array_values($p_items_id)); + return array($items,$product_ids,$diff_items_id); + } + + //根据order_id获取order_goods货品信息 + function getGoodsInfoByOid($order_id){ + $sql = "select product_id,goods_price from ".$this->ecs->table('order_goods')." where order_id='".$order_id."' and is_gift = 0"; + $row = $this->db->getAll($sql); + foreach($row as $k=>$v){ + $p_real_price[$v['product_id']] = $v['goods_price']; + } + return $p_real_price; + } + + //插入callback记录 写返回日志 + function set_callback($msg,$http_type,$type,$tpye_id,$method,$data=array(),$status=""){ + $time = time(); + $status or $status = $msg['msg_id'] ? "running":"false"; + $data = addslashes(serialize(array('params'=>$data,'result'=>$msg))); + if( $this->checkCallbackExit($type,$tpye_id) ){ + $data and $data = ",data='$data'"; + $sql = "update ".$this->ecs->table('callback_status')." set msg_id='".$msg['msg_id']."',status='".$status."',date_time='".$time."',times=times+1 {$data} WHERE method='".$method."' AND type_id='".$tpye_id."' "; + }else{ + $sql = "insert into ".$this->ecs->table('callback_status')." set msg_id='".$msg['msg_id']."',type='".$type."',http_type='".$http_type."',status='".$status."',type_id='".$tpye_id."',method='".$method."',date_time='".$time."',data='".$data."',times=1"; + } + error_log(date('c')."set_callback sql:\n".print_r($sql,1),3,__FILE__.".log"); + $this->db->query($sql); + //接口失败,修改订单的返回状态 order_info 的 callback_status + if($status=='false' || $status=='true'){ + $order_sql = "update ".$this->ecs->table('order_info')." set callback_status='".$status."' where order_sn='".$tpye_id."'"; + $this->db->query($order_sql); + } + + } + + /** + * 根据type_id 获取 矩阵返回日志 + * @param $type_id 日志id + * @return array + */ + function get_callback($type_id){ + $sql = "select * from ".$GLOBALS['ecs']->table('callback_status')." where type_id='".$type_id."' and status='false'"; + $row = $GLOBALS['db']->getRow($sql,1); + if(!$row) return false; + $row['data'] = unserialize($row['data']); + return $row; + } + + //验证重试次数 + function checkCallbackCount($type,$type_id){ + $sql = "select times from ".$this->ecs->table('callback_status')." where type='".$type."' and type_id='".$type_id."'"; + $row = $this->db->getRow($sql); + return $row['times']; + } + + //验证重试次数 + function checkCallbackExit($type,$type_id){ + $sql = "select times from ".$this->ecs->table('callback_status')." where type='".$type."' and type_id='".$type_id."'"; + if($row = $this->db->getRow($sql)){ + return true; + } + return false; + } + + //更新callback记录 + function update_callback($msg_id,$data="",$status='true'){ + $status = $status=='true'?$status:"false"; + $data and $sqlstr = ",data=CONCAT(data,'\n".addslashes(serialize($data))."')"; + $set_times = $status=='true'?'times=0,':'times=times+1,';//成功后置0 + if( is_array($data) && $data['type'] && $data['type_id'] ){ + $sql = "update ".$this->ecs->table('callback_status')." set {$set_times}status='{$status}' {$sqlstr} where type='".$data['type']."' AND type_id='".$data['type_id']."' and status!='true' "; + }else{ + $sql = "update ".$this->ecs->table('callback_status')." set {$set_times}status='{$status}' {$sqlstr} where msg_id='".$msg_id."' and status!='true' "; + } + error_log(date("c")."\t sql :".$sql."\n",3,__FILE__.".log"); + if( $this->db->query($sql) === false ){ + // error_log(date("c")."\t error sql :".$sql."\n",3,__FILE__.".log"); + } + //修改订单的返回状态 order_info 的 callback_status + $order_sql = "update ".$this->ecs->table('order_info')." set callback_status='".$status."' where order_sn='".$data['type_id']."'"; + $this->db->query($order_sql); + } + + + function get_card_info($order_sn,$card){ + $gift_value = array(); + $sql = "SELECT * FROM ".$GLOBALS['ecs']->table('card')." WHERE card_name = '{$card['card_name']}'"; + $res = $GLOBALS['db']->getRow($sql); + if ($res) { + $gift_value = array( + 'iid' => '0', + 'title' => $res['card_name'], + 'bn' => 'ECS_CARD', + // 'orders_bn' => 'ECS_CARD', + 'orders_bn' => 'ECS_CARD_'.$res['card_id'], //erp要求传跟order_items里的一样 + 'items_num' => '1', + 'total_order_fee' => $card['card_fee'], + 'oid' => $order_sn, + 'status' => 'TRADE_ACTIVE', + 'type' => 'goods', + 'order_items' => array( + 'item'=> array( + 0=>array( + 'iid' => '0', + 'bn' => 'ECS_CARD_'.$res['card_id'], + 'price' => $card['card_fee']>0?$res['card_fee']:'0.00', + 'name' => $res['card_name'], + 'weight' => '0.00', + 'num' => '1', + 'total_item_fee' => $card['card_fee'], + 'sku_properties' => $res['card_name'], + 'sendnum' => '0', + 'item_type' => 'product', + 'sale_price' => $card['card_fee']>0?$res['card_fee']:'0.00', + 'discount_fee' => '0.00', + 'score' => '', + 'item_status' => 'normal', + ) + ) + ) + + ); + } + return $gift_value; + } + + + function get_order_goods($res,$has_product){ + $return_value = array(); + foreach ($res as $key => $value) { + // if (isset($value['p_goods_attr']) && strstr($value['p_goods_attr'],"|")) { + // $sql = "SELECT sum(attr_price) as attr_price FROM ".$GLOBALS['ecs']->table('goods_attr')." WHERE goods_id = '".$value['goods_id']."' AND goods_attr_id in (".str_replace("|", ",", $value['p_goods_attr']).")"; + // $attr_price = $GLOBALS['db']->getOne($sql); + // $attr_price && $value['shop_price'] = $value['shop_price']+$attr_price; + // } + + // if ($return_value[$value['goods_id']]) { + // $return_value[$value['goods_id']]['items_num'] = $return_value[$value['goods_id']]['items_num']+$value['goods_number']; + // $return_value[$value['goods_id']]['order_items']['item'][] = array( + // 'iid' => $value['product_id'], + // 'bn' => $has_product?$value['product_sn']:$value['goods_sn'], + // 'price' => $value['goods_price'], + // 'name' => $value['goods_name'], + // 'weight' => $value['goods_weight'], + // 'num' => $value['goods_number'], + // 'total_item_fee' => $value['goods_price'], + // 'sku_properties' => str_replace(array("\r\n", "\r", "\n"), " ", $value['goods_attr']), + // 'sendnum' => $value['send_number'], + // 'item_type' => 'product', + // 'sale_price' => $value['goods_price'], + // 'discount_fee' => '0', + // 'score' => $value['give_integral']<0?$value['goods_price']:$value['give_integral'], + // 'item_status' => 'normal' + // ); + // }else{ + + $sku_properties = ''; + if ($value['goods_attr']) { + $sku_properties = str_replace(' ','',$value['goods_attr']); + $sku_properties = str_replace(array("\r\n", "\r", "\n"), ";", $sku_properties); + $sku_properties = trim($sku_properties,';'); + } + $return_value[] = array( + 'iid' => $value['goods_id'], + 'title' => $value['goods_name'], + 'weight' => $value['goods_weight'], + 'bn' => $value['goods_sn'], + // 'orders_bn' => $value['goods_sn'], + 'orders_bn' => $has_product?$value['product_sn']:$value['goods_sn'], //erp要求传跟order_items里的一样 + 'items_num' => $value['goods_number'], + 'total_order_fee' => $value['goods_price'], + 'oid' => $order_sn, + 'status' => 'TRADE_ACTIVE', + 'type' => $value['is_gift']?'gift':'goods', + 'order_items' => array( + 'item' => array( + 0 => array( + 'iid' => $value['product_id'], + 'bn' => $has_product?$value['product_sn']:$value['goods_sn'], + 'price' => $value['goods_price'], + // 'price' => $value['shop_price'], + 'name' => $value['goods_name'], + 'weight' => $value['goods_weight'], + 'num' => $value['goods_number'], + 'total_item_fee' => $value['goods_price'], + 'sku_properties' => $sku_properties, + 'sendnum' => $value['send_number'], + 'item_type' => 'product', + 'sale_price' => $this->format_number($value['goods_price']*$value['goods_number']-$value['discount_fee']), + 'discount_fee' => $value['discount_fee'], + 'score' => $value['give_integral']<0?$value['goods_price']:$value['give_integral'], + 'item_status' => 'normal' + ) + ) + ) + ); + // } + } + return $return_value; + } + + + function getGoods($order_id,$order_sn,$card=false,$use_gift=false,$card_fee=0){ + $return_has_pro = $return_no_pro = array(); + $sql = "SELECT og.*,p.product_sn,g.goods_weight,g.give_integral,g.shop_price,p.goods_attr as p_goods_attr FROM ".$GLOBALS['ecs']->table('order_goods')." as og LEFT JOIN ".$GLOBALS['ecs']->table('products')." as p on og.product_id = p.product_id LEFT JOIN ".$GLOBALS['ecs']->table('goods')." as g on p.goods_id = g.goods_id WHERE og.order_id = {$order_id} AND og.product_id>0"; + $res = $GLOBALS['db']->getAll($sql); + if ($res) { + $return_has_pro = $this->get_order_goods($res,$has_product=true); + } + $sql = "SELECT og.*,g.goods_weight,g.give_integral,g.shop_price FROM ".$GLOBALS['ecs']->table('order_goods')." as og LEFT JOIN ".$GLOBALS['ecs']->table('goods')." as g on og.goods_id = g.goods_id WHERE og.order_id = {$order_id} AND og.product_id=0"; + $res = $GLOBALS['db']->getAll($sql); + if ($res) { + $return_no_pro = $this->get_order_goods($res,$has_product=false); + } + if ($card) { + $gift_value[] = $this->get_card_info($order_sn,$card); + }else{ + $gift_value = array(); + } + $return_value = array_merge($return_has_pro,$return_no_pro,$gift_value); + return $return_value; + } + + + function getGoods_old($order_id,$order_sn,$card=false,$use_gift=false){ + + $p_real_price = $this->getGoodsInfoByOid($order_id); + $order_items = $this->get_order_items($order_id);//order_items数据 + $prduct_list = $this->getProductList($order_items,$p_real_price); + $goods_list = $this->getGoodsList($prduct_list[2]); + // $sql = "SELECT o.*, IF(o.product_id > 0, p.product_number, g.goods_number) AS storage, o.goods_attr, g.suppliers_id, IFNULL(b.brand_name, '') AS brand_name, p.product_sn + // FROM " . $ecs->table('order_goods') . " AS o + // LEFT JOIN " . $ecs->table('products') . " AS p + // ON p.product_id = o.product_id + // LEFT JOIN " . $ecs->table('goods') . " AS g + // ON o.goods_id = g.goods_id + // LEFT JOIN " . $ecs->table('brand') . " AS b + // ON g.brand_id = b.brand_id + // WHERE o.order_id = '$order_id'"; + $return_value = array(); + if( !empty($goods_list) ){ + foreach( $goods_list as $k=>$value ){ + $value['orders_bn'] = $value['bn']; + $value['items_num'] = $prduct_list[1][$value['iid']]['items_num']; + $value['total_order_fee'] = $this->format_number($prduct_list[1][$value['iid']]['total_order_fee']); + $value['oid'] = $order_sn; + $value['status'] = 'TRADE_ACTIVE'; + foreach($prduct_list[0][$value['iid']] as $v ){ + $v['score'] = 0; + $v['item_status'] = 'normal'; + $v['bn'] = $value['bn']; + unset($v['product_id'],$v['goods_id'],$v['goods_attr'],$v['attr_price'],$v['attr_value']); + $items[] = $v; + $tmp_items[$v['bn']] = $v; + $value['sale_price'] = $this->format_number($v['sale_price']); + $value['discount_fee'] = $this->format_number($v['discount_fee']); + } + $value['type'] = 'goods'; + $value['order_items']['order_item'] = $items; + unset($value['goods_sn']); + unset($items); + $tmp_return_value[$value['iid']] = $value; + } + foreach($tmp_return_value as $v) $return_value[]=$v; + return $return_value; + } + } + + //返回订单所有支付单信息 + function get_order_payments($order_id){ + $payment_list = array(); + $sql = 'select p.*,m.`name` as buy_name from sdb_payments as p LEFT JOIN sdb_members as m on m.member_id = p.member_id where p.order_id ='.$order_id.' '; + + foreach($this->db->select($sql) as $data){ + $send_data = array(); + if ($data['status'] == 'succ' || ($data['status'] == 'progress' && $data['pay_type'] == 'online') ){ + $send_data['payment_id']=$data['payment_id']; + $send_data['tid']=$data['order_id']; + $send_data['seller_bank']=$data['bank']; + $send_data['seller_account']=$data['account']; + $send_data['buyer_id']=$data['member_id']; + $send_data['buy_name']=$data['buy_name']; + $send_data['buyer_account']=$data['pay_account']; + $send_data['pay_fee']=$this->format_number($data['money']); + $send_data['paycost']=$this->format_number($data['paycost']); + $send_data['currency']=$data['currency']; + $send_data['currency_fee']=$this->format_number($data['cur_money']); + $send_data['pay_type']=$data['pay_type']; + $send_data['payment_code']=$data['payment']; + $send_data['payment_name']=$data['paymethod']; + $send_data['pay_time']=date('Y-m-d H:i:s',$data['t_begin']); + $send_data['t_begin']=date('Y-m-d H:i:s',$data['t_begin']); + $send_data['t_end']=date('Y-m-d H:i:s',$data['t_end']); + $send_data['status']=strtoupper($data['status']); + $send_data['memo']=$data['memo']; + $send_data['outer_no']=$data['trade_no']; + + $payment_list['payment_list'][] = $send_data; + } + + } + return $payment_list; + } + + //生成发给taoex 订单结构体 + function getOrderStruct($order_sn,$fields='*',$is_create=FALSE){ + include_once(ROOT_PATH . 'includes/lib_order.php'); + $order_status['status']=array(0=>'TRADE_ACTIVE',1=>'TRADE_ACTIVE',2=>'TRADE_CLOSED',3=>'TRADE_CLOSED',4=>'TRADE_CLOSED',5=>'TRADE_FINISHED'); + $order_status['ship_status']=array(0=>'SHIP_NO',1=>'SHIP_FINISH',4=>'SHIP_PART'); + $order_status['pay_status']=array(0=>'PAY_NO',1=>'PAY_TO_MEDIUM',2=>'PAY_FINISH',3=>'REFUND_PART',4=>'REFUND_ALL'); + + $fields = '*'==$fields?$fields:explode(',',$fields); + //订单总体信息 + if (!$order_info = $this->get_order_info($order_sn)) return ''; + + + $paramss['tid'] = $order_info['order_sn'];//订单号 + $paramss['trade_valid_time'] = 0;//订单失效时间 + $paramss['out_time'] = '0';//订单失效时间 + + + $paramss['lastmodify'] = date('Y-m-d H:i:s',$order_info['lastmodify']); + $paramss['pmt_order'] = '0.00'; + $paramss['pmt_goods'] = '0.00'; + $paramss['promotion_details'][] = array( + 'promotion_name' => '', + 'promotion_fee' => $order_info['discount'],//折扣价减不用减去去包装费用 + ); + $paramss['promotion_details'] = json_encode($paramss['promotion_details']); + $paramss['total_weight'] = '0'; + + + $paramss['created'] = date('Y-m-d H:i:s',$order_info['add_time']);//订单创建时间 + // $paramss['modified'] = date('Y-m-d H:i:s',$order_info['add_time']);//订单修改时间,没有则用创建时间 + if(in_array($order_info['pay_status'], array(1,2))){ //订单支付时间 已支付或付款中 + $paramss['pay_time'] = date('Y-m-d H:i:s',$order_info['pay_time']); + } + + // 订单支付信息详情 + $paramss['payment_lists'] = $this->get_payment_list($order_info); + $paramss['payment_lists'] = json_encode($paramss['payment_lists']); + + $paramss['status'] = $order_status['status'][$order_info['order_status']];//交易状态 + // $paramss['pay_status'] = $order_status['pay_status'][$order_info['pay_status']];//支付状态 + // 如果是未支付,判断是否是全部退款 + if ($order_info['pay_status'] == '0' && $order_info['pay_time']>0) { + $sql = "select count(user_money) as user_money from ".$GLOBALS['ecs']->table('account_log')." where user_id = '".$order_info[ + 'user_id']."' and user_money>0 and change_desc like '%".$order_info['order_sn']."%'"; + $user_money = $GLOBALS['db']->getOne($sql); + if (isset($user_money) && $user_money>0) { + $paramss['pay_status'] = $order_status['pay_status'][4];//退款 + }else{ + $paramss['pay_status'] = $order_status['pay_status'][$order_info['pay_status']];//支付状态 + } + }else{ + $paramss['pay_status'] = $order_status['pay_status'][$order_info['pay_status']];//支付状态 + } + $paramss['ship_status'] = $order_status['ship_status'][$order_info['shipping_status']];//发货状态 + $paramss['payed_fee'] = $this->format_number($order_info['surplus'] + $order_info['money_paid']);//已支付金额 + // $paramss['total_goods_fee'] = $order_info['card_fee']?$this->format_number($order_info['goods_amount']+$order_info['card_fee']):$this->format_number($order_info['goods_amount']);//商品总额 + $paramss['total_goods_fee'] = $this->format_number($order_info['goods_amount']);//商品总额 + $total_fee = $order_info['goods_amount'] - $order_info['discount'] - $order_info['goods_discount_fee'] + $order_info['tax'] + $order_info['shipping_fee'] + $order_info['insure_fee'] + $order_info['pay_fee'] + $order_info['pack_fee'] + $order_info['card_fee']; + $paramss['total_trade_fee'] = $this->format_number($total_fee);//交易总额 + + // ECSHOP没有部分支付,如果部分支付,将ecshop的未支付改成部分支付 + if ($paramss['pay_status'] == 'PAY_NO' && $paramss['payed_fee']>0) { + $paramss['pay_status'] = 'PAY_PART'; + } + + // 获取退款费用 + // if($paramss['payed_fee'] > 0){ + $refund_money = 0; + $sql = "select action_note from ".$GLOBALS['ecs']->table('order_action')." where order_id = ".$order_info['order_id']." and order_status = 4 "; + $refund_data = $this->db->getAll($sql); + if($refund_data){ + foreach ($refund_data as $v) { + $_refund_money = 0; + if($pos = strpos($v['action_note'], '部分退款金额:')){ + $_refund_money = substr($v['action_note'], $pos+21); + if(is_numeric($_refund_money)) $refund_money += $_refund_money; + } + } + } + // $paramss['payed_fee'] = $this->format_number($paramss['payed_fee'] - $refund_money); + // $paramss['total_trade_fee'] = $this->format_number($paramss['total_trade_fee'] - $refund_money); + //纯退款 + if($refund_money > 0 and $paramss['total_trade_fee'] > ( $paramss['payed_fee'] + $order_info['bonus'] + $order_info['integral_money'] ) ){ + if($paramss['payed_fee'] > 0){ + $paramss['pay_status'] = 'REFUND_PART'; + // $paramss['status'] = 'TRADE_ACTIVE'; + $order_info['shipping_status'] == 1 and $paramss['status'] = 'TRADE_FINISHED';//已发货 订单状态就变成完成 + }else{ + $paramss['pay_status'] = 'REFUND_ALL'; + $paramss['status'] = 'TRADE_CLOSED'; + } + } + // } + + $sql = "select back_id from ".$GLOBALS['ecs']->table('back_order')." where order_id = ".$order_info['order_id']." AND order_sn='".$order_info['order_sn']."'"; + $back_id = $this->db->getOne($sql); + if($back_id){ + $paramss['status'] = 'TRADE_FINISHED'; + $paramss['ship_status'] = $order_info['shipping_status']?'RESHIP_PART':'RESHIP_ALL'; + } + + + $paramss['currency'] = 'CNY';//货币类型 + $paramss['currency_rate'] = 1;//货别汇率 + $paramss['buyer_obtain_point_fee'] = 0;//获得积分 + $paramss['is_protect'] = $order_info['insure_fee']>0?'true':'false';//是否保价 + $paramss['protect_fee'] = $this->format_number($order_info['insure_fee']);//保价费用 + $paramss['discount_fee'] = $this->format_number((-1)*($order_info['discount']-$order_info['pack_fee']));//折扣优惠金额 + $payment = $this->get_payment($order_info['pay_id']); + + $paramss['is_cod'] = $payment['pay_code']=='cod'?'true':'false';//是否货到付款 + + $paramss['payment_tid'] = $order_info['pay_id'];//支付方式ID + $paramss['payment_type'] = $order_info['pay_name'];//支付方式名名称 + + $item = $this->getItemNum($order_info['order_id']); + $paramss['orders_number'] = $item['itemnum'];//订单商品总数量 + $weight = order_weight_price($order_info['order_id']); + $paramss['total_weight'] = $weight['weight'];//订单商品总重量 + $memberinfo = $this->getMemberByMid($order_info['user_id']); + //订单购买者信息 + $paramss['buyer_uname'] = $memberinfo['user_name']?$memberinfo['user_name']:'匿名用户';//账号 + $paramss['buyer_name'] = $memberinfo['alias'];//姓名 + $paramss['buyer_mobile'] = $memberinfo['mobile_phone'];//移动电话 + $paramss['buyer_state'] = '';//省 + + //订单收货者信息 + $paramss['receiver_name'] = $order_info['consignee'];//姓名 + $paramss['receiver_phone'] = $order_info['tel'];//固定电话 + $paramss['receiver_mobile'] = $order_info['mobile'];//移动电话 + $paramss['receiver_state'] = $this->get_region($order_info['province'],1);//省 + $paramss['receiver_city'] = $this->get_region($order_info['city'],2);//市 + $paramss['receiver_district'] = $this->get_region($order_info['district'],3);//区 + $paramss['receiver_address'] = $order_info['address'];//详细地区 + $paramss['receiver_zip'] = $order_info['zipcode'];//邮编 + + // 红包+积分兑换金额 + $paramss['orders_discount_fee'] = 0; + $bonus_integral = $order_info['bonus'] + $order_info['integral_money']; + $orders_discount_fee = $paramss['total_trade_fee'] - $paramss['payed_fee']; + + if($bonus_integral > 0 and $orders_discount_fee > 0 and $bonus_integral >= $orders_discount_fee){ + $paramss['orders_discount_fee'] = $orders_discount_fee; + $paramss['total_trade_fee'] = $this->format_number($paramss['total_trade_fee'] - $orders_discount_fee); + } + // $paramss['orders_discount_fee'] = $order_info['bonus'] + $order_info['integral_money']; + + //订单商品信息 + if($this->_filterParams('orders', $fields)){ + $order_card = array(); + if ($order_info['card_name']) { + $order_card['card_name'] = $order_info['card_name']; + $order_card['card_fee'] = $order_info['card_fee']; + $paramss['discount_fee'] = $this->format_number($paramss['discount_fee']+ $order_card['card_fee']);//折扣优惠金额 + } + $goods_orders = $this->getGoods($order_info['order_id'],$order_info['order_sn'],$order_card,true); + $paramss['orders']['order'] = $goods_orders; + $paramss['orders'] = json_encode($paramss['orders']); + // $paramss['orders_discount_fee'] = 0; + $paramss['goods_discount_fee'] = $this->format_number($order_info['goods_discount_fee']); + } + //订单配送信息 + $paramss['shipping_tid'] = $order_info['shipping_id'];//物流方式ID + $paramss['shipping_type'] = $order_info['shipping_name'];//物流方式 + $paramss['shipping_fee'] = $this->format_number($order_info['shipping_fee']);//物流费用 + + //订单详细信息 + $paramss['has_invoice'] = $order_info['inv_type'];//是否开发票 + $paramss['invoice_title'] = $order_info['inv_payee'];//发票抬头 + $paramss['invoice_fee'] = $this->format_number($order_info['tax']);//发票税金 + $paramss['pay_cost'] = $this->format_number($order_info['pay_fee']);//支付手续费 + $paramss['buyer_memo'] = $this->buyer_memo($order_info); + $paramss['trade_memo'] = $order_info['to_buyer'];//订单附言 + $paramss['channel_ver'] = ""; + $paramss['consign_time'] = ""; + $paramss['step_trade_status'] = ""; + $paramss['invoice_desc'] = ""; + $paramss['trade_type'] = ""; + $paramss['buyer_email'] = ""; + $paramss['cod_status'] = ""; + $paramss['step_paid_fee'] = ""; + $paramss['end_time'] = ""; + $paramss['channel'] = "fast"; + $paramss['order_source'] = $order_info['referer'];//创建订单接口增加订单类型参数 + + $paramss['logistics_no'] = $order_info['invoice_no']; + + $allow_params = array('rights_level','lastmodify','payment_lists','promotion_details','total_weight','buyer_name','currency_rate','app_id','shipping_type','receiver_address','has_invoice','receiver_district','from_type','callback_type','protect_fee','receiver_phone','to_node_id','order_source','logistics_no','pay_cost','buyer_uname','timestamp','_id','tid','receiver_mobile','goods_discount_fee','orders_number','invoice_fee','discount_fee','pay_status','buyer_obtain_point_fee','payment_type','v','real_time','shipping_fee','refresh_time','is_cod','msg_id','currency','node_type','pay_time','payment_tid','orders','receiver_city','channel_ver','orders_discount_fee','format','buyer_memo','from_node_id','shipping_tid','method','channel','status','total_trade_fee','buyer_state','receiver_zip','callback_type_id','to_type','node_id','total_goods_fee','date','buyer_mobile','task','created','ship_status','payed_fee','is_protect','receiver_state','receiver_name','consign_time','step_trade_status','trade_memo','invoice_desc ','invoice_title','trade_type','buyer_email','cod_status','step_paid_fee','modified','end_time'); + + foreach($paramss as $k=>$v){ + if(!in_array($k, $allow_params)) unset($paramss[$k]); + } + return $paramss; + } + + + function get_payment_list($order_info){ + $payment_list = array(); + $sql = "SELECT * FROM ".$GLOBALS['ecs']->table('account_log')." WHERE change_desc like '%".$order_info['order_sn']."%' AND user_money<0 order by change_time asc"; + $res = $GLOBALS['db']->getAll($sql); + if ($res) { + foreach ($res as $key => $list) { + $payment_list['payment_list'][] = array( + 'tid' => $order_info['order_sn'], + 'seller_bank' => '', + 'seller_account' => '', + 'buyer_id' => $_SESSION['user_id'], + 'buy_name' => $_SESSION['user_name'], + 'buyer_account' => '', + 'pay_fee' => abs($list['user_money']), + 'paycost' => abs($list['user_money']), + 'currency' => 'CNY', + 'currency_fee' => abs($list['user_money']), + 'pay_type' => 'deposit', + 'payment_code' => 'deposit', + 'payment_name' => $order_info['pay_name'], + 't_begin' => date('Y-m-d H:i:s',$list['change_time']), + 't_end' => date('Y-m-d H:i:s',$list['change_time']), + 'pay_time' => date('Y-m-d H:i:s',$list['change_time']), + 'status' => 'SUCC', + 'memo' => '', + 'outer_no' => '', + ); + } + } + $sql = "SELECT * FROM ".$GLOBALS['ecs']->table('account_other_log')." WHERE order_sn='".$order_info['order_sn']."'"; + $pay_list = $GLOBALS['db']->getAll($sql); + if ($pay_list) { + foreach ($pay_list as $list) { + $payment_list['payment_list'][] = array( + 'tid' => $order_info['order_sn'], + 'seller_bank' => '', + 'seller_account' => '', + 'buyer_id' => $_SESSION['user_id'], + 'buy_name' => $_SESSION['user_name'], + 'buyer_account' => '', + 'pay_fee' => abs($list['money']), + 'paycost' => abs($list['money']), + 'currency' => 'CNY', + 'currency_fee' => abs($list['money']), + 'pay_type' => $list['pay_type']?$list['pay_type']:'deposit', + 'payment_code' => $list['pay_type']?$list['pay_type']:'deposit', + 'payment_name' => $order_info['pay_name'], + 't_begin' => date('Y-m-d H:i:s',$list['pay_time']), + 't_end' => date('Y-m-d H:i:s',$list['pay_time']), + 'pay_time' => date('Y-m-d H:i:s',$list['pay_time']), + 'status' => 'SUCC', + 'memo' => '', + 'outer_no' => '', + ); + } + } + return $payment_list; + } + + + function buyer_memo($order_info){ + $buyer_memo = '缺货处理:'.$order_info['how_oos']; + // 包装 + if ($order_info['pack_name']) { + $buyer_memo .= " 使用包装:(".$order_info['pack_name'].");"; + } + if ($order_info['card_name']) { + $buyer_memo .= " 贺卡:(".$order_info['card_name']."),祝福语:(".$order_info['card_message'].");"; + } + if ($buyer_memo && $order_info['postscript']) { + $buyer_memo .= "以下是客户留言:"; + } + + return $buyer_memo.$order_info['postscript']; + } + + + function get_region($region_id,$region_type){ + $msg = ''; + $sql = "select region_name FROM ".$GLOBALS['ecs']->table('region')." WHERE region_id = {$region_id} AND region_type = {$region_type}"; + $msg = $GLOBALS['db']->getOne($sql); + if ($msg) { + return $msg; + }else{ + return $region_id; + } + } + + function _filterParams($needle,$haystack){ + if('*'==$haystack) return true; + return in_array($needle,$haystack); + } + + //签名 + function get_matrix_sign($params,$token){ + //如果参数是数组的话将参数json + foreach($params as $k=>$v){ + if(is_array($v)){ + $params[$k] = json_encode($v); + } + } + return strtoupper(md5(strtoupper(md5($this->assemble($params))).$token)); + } + + function assemble($params){ + if(!is_array($params)) return null; + ksort($params,SORT_STRING); + $sign = ''; + foreach($params AS $key=>$val){ + $sign .= $key . (is_array($val) ? $this->assemble($val) : $val); + } + return $sign; + } + + function create_task_id(){ + $i = rand(0,9999); + if(9999==$i){ + $i=0; + } + $task_id = time().str_pad($i,4,'0',STR_PAD_LEFT); + return $task_id; + } + + function format_number($number){ + return number_format($number, 2, '.', ''); + + } + + function getMemberByMid($user_id,$cols='*'){ + $sql = "SELECT ".$cols." FROM ".$this->ecs->table('users')." WHERE user_id = ".$user_id; + return $this->db->getRow($sql); + } + + // 取消订单 + function set_dead_order($order_id){ + if(!$this->get_bind_info($this->shopex_app)) return null; + $sql = "update ".$this->ecs->table('order_info')." set lastmodify = ".time().",order_status = ".OS_CANCELED." where order_id = ".$order_id; + $this->db->query($sql); + $sql = "SELECT order_sn FROM ".$this->ecs->table('order_info')." WHERE order_id = ".$order_id; + $order_sn = $this->db->getOne($sql); + $this->createOrder($order_sn); + } + + // 更新订单买家留言 + function update_order_buyer_message($data){ + if(!$this->get_bind_info($this->shopex_app)) return null; + + $params['tid'] = $data['order_id'];//订单号 + $params['message'] = $data['msg_content'];//留言内容 + $params['title'] = $data['msg_title'];//标题 + $params['sender'] = $data['user_name']?$data['user_name']:'system';//'system';//发送者 + $params['add_time'] = date('Y-m-d H:i:s',time());//添加时间 + + $params['method'] = 'store.trade.buyer_message.add'; + $params['callback_type'] = 'UPDATEORDERMESSAGE'; + $params['callback_type_id'] = $params['tid']; + + $this->http_request_matrix($params); + } + + // 退款通知到erp + function send_refund_to_matrix($msg){ + if(!$this->get_bind_info($this->shopex_app)) return null; + $msg['method'] = 'store.trade.refund.add'; + $msg['callback_type'] = 'CREATEREFUND'; + $msg['callback_type_id'] = $msg['refund_id']; + $this->http_request_matrix($msg); + } + + + + +} +?> \ No newline at end of file diff --git a/includes/cls_mysql.php b/includes/cls_mysql.php new file mode 100755 index 0000000..595f324 --- /dev/null +++ b/includes/cls_mysql.php @@ -0,0 +1,943 @@ +cls_mysql($dbhost, $dbuser, $dbpw, $dbname, $charset, $pconnect, $quiet); +// } + + function __construct($dbhost, $dbuser, $dbpw, $dbname = '', $charset = 'gbk', $pconnect = 0, $quiet = 0) + { + if (defined('EC_CHARSET')) + { + $charset = strtolower(str_replace('-', '', EC_CHARSET)); + } + + if (defined('ROOT_PATH') && !$this->root_path) + { + $this->root_path = ROOT_PATH; + } + + if ($quiet) + { + $this->connect($dbhost, $dbuser, $dbpw, $dbname, $charset, $pconnect, $quiet); + } + else + { + $this->settings = array( + 'dbhost' => $dbhost, + 'dbuser' => $dbuser, + 'dbpw' => $dbpw, + 'dbname' => $dbname, + 'charset' => $charset, + 'pconnect' => $pconnect + ); + } + } + + function connect($dbhost, $dbuser, $dbpw, $dbname = '', $charset = 'utf8', $pconnect = 0, $quiet = 0) + { + if ($pconnect) + { + $this->link_id = new mysqli('p:'.$dbhost, $dbuser, $dbpw); + if ($this->link_id->connect_error) + { + if (!$quiet) + { + $this->ErrorMsg("Can't pConnect MySQL Server($dbhost)!"); + } + + return false; + } + } + else + { + $this->link_id = new mysqli($dbhost, $dbuser, $dbpw); + if ($this->link_id->connect_error) + { + if (!$quiet) + { + $this->ErrorMsg("Can't Connect MySQL Server($dbhost)!"); + } + + return false; + } + } + + $this->dbhash = md5($this->root_path . $dbhost . $dbuser . $dbpw . $dbname); + $this->version = $this->link_id->server_version; + + /* 对字符集进行初始化 */ + $this->link_id->set_charset($charset); + + $this->link_id->query("SET sql_mode=''"); + $sqlcache_config_file = $this->root_path . $this->cache_data_dir . 'sqlcache_config_file_' . $this->dbhash . '.php'; + + @include($sqlcache_config_file); + + $this->starttime = time(); + + if ($this->max_cache_time && $this->starttime > $this->mysql_config_cache_file_time + $this->max_cache_time) + { + if ($dbhost != '.') + { + $result = $this->link_id->query("SHOW VARIABLES LIKE 'basedir'"); + $row = $result->fetch_array(MYSQLI_ASSOC); + $result->free(); + if (!empty($row['Value']{1}) && $row['Value']{1} == ':' && !empty($row['Value']{2}) && $row['Value']{2} == "/") + { + $this->platform = 'WINDOWS'; + } + else + { + $this->platform = 'OTHER'; + } + } + else + { + $this->platform = 'WINDOWS'; + } + + if ($this->platform == 'OTHER' && + ($dbhost != '.' && strtolower($dbhost) != 'localhost:3306' && $dbhost != '127.0.0.1:3306') || + date_default_timezone_get() == 'UTC') + { + $result = $this->link_id->query("SELECT UNIX_TIMESTAMP() AS timeline, UNIX_TIMESTAMP('" . date('Y-m-d H:i:s', $this->starttime) . "') AS timezone"); + $row = $result->fetch_array(MYSQLI_ASSOC); + $result->free(); + if ($dbhost != '.' && strtolower($dbhost) != 'localhost:3306' && $dbhost != '127.0.0.1:3306') + { + $this->timeline = $this->starttime - $row['timeline']; + } + if (date_default_timezone_get() == 'UTC') + { + $this->timezone = $this->starttime - $row['timezone']; + } + } + + $content = '<' . "?php\r\n" . + '$this->mysql_config_cache_file_time = ' . $this->starttime . ";\r\n" . + '$this->timeline = ' . $this->timeline . ";\r\n" . + '$this->timezone = ' . $this->timezone . ";\r\n" . + '$this->platform = ' . "'" . $this->platform . "';\r\n?" . '>'; + + @file_put_contents($sqlcache_config_file, $content); + } + + /* 选择数据库 */ + if ($dbname) + { + + if ($this->link_id->select_db($dbname) === false ) + { + if (!$quiet) + { + $this->ErrorMsg("Can't select MySQL database($dbname)!"); + } + + return false; + } + else + { + return true; + } + } + else + { + return true; + } + } + + function select_database($dbname) + { + return $this->link_id->select_db($dbname); + } + + function set_mysql_charset($charset) + { + if (in_array(strtolower($charset), array('gbk', 'big5', 'utf-8', 'utf8'))) + { + $charset = str_replace('-', '', $charset); + } + $this->link_id->set_charset($charset); + } + + function fetch_array($query, $result_type = MYSQLI_ASSOC) + { + $row = $query->fetch_array($result_type); + $query->free(); + return $row; + } + + function query($sql, $type = '') + { + if ($this->link_id === NULL) + { + $this->connect($this->settings['dbhost'], $this->settings['dbuser'], $this->settings['dbpw'], $this->settings['dbname'], $this->settings['charset'], $this->settings['pconnect']); + $this->settings = array(); + } + + if ($this->queryCount++ <= 99) + { + $this->queryLog[] = $sql; + } + if ($this->queryTime == '') + { + if (PHP_VERSION >= '5.0.0') + { + $this->queryTime = microtime(true); + } + else + { + $this->queryTime = microtime(); + } + } + + /* 当当前的时间大于类初始化时间的时候,自动执行 ping 这个自动重新连接操作 */ + if (time() > $this->starttime + 1) + { + $this->link_id->ping(); + } + + if (!($query = $this->link_id->query($sql)) && $type != 'SILENT') + { + $this->error_message[]['message'] = 'MySQL Query Error'; + $this->error_message[]['sql'] = $sql; + $this->error_message[]['error'] = $this->link_id->error; + $this->error_message[]['errno'] = $this->link_id->errno; + + $this->ErrorMsg(); + + return false; + } + + if (defined('DEBUG_MODE') && (DEBUG_MODE & 8) == 8) + { + $logfilename = $this->root_path . DATA_DIR . '/mysql_query_' . $this->dbhash . '_' . date('Y_m_d') . '.log'; + $str = $sql . "\n\n"; + + if (PHP_VERSION >= '5.0') + { + file_put_contents($logfilename, $str, FILE_APPEND); + } + else + { + $fp = @fopen($logfilename, 'ab+'); + if ($fp) + { + fwrite($fp, $str); + fclose($fp); + } + } + } + + return $query; + } + + function affected_rows() + { + return $this->link_id->affected_rows; + } + + function error() + { + return $this->link_id->error; + } + + function errno() + { + return $this->link_id->errno; + } + + function result($query, $row) + { + $query->data_seek($row); + $result = $query->fetch_row(); + $query->free(); + return $result; + } + + function num_rows($query) + { + return $query->num_rows; + } + + function num_fields($query) + { + return $this->link_id->field_count; + } + + function free_result($query) + { + return $query->free(); + } + + function insert_id() + { + return $this->link_id->insert_id; + } + + function fetchRow($query) + { + return $query->fetch_assoc(); + } + + function fetch_fields($query) + { + return $query->fetch_field(); + } + + function version() + { + return $this->version; + } + + function ping() + { + return $this->link_id->ping(); + } + + function escape_string($unescaped_string) + { + return $this->link_id->real_escape_string($unescaped_string); + } + + function close() + { + return $this->link_id->close(); + } + + function ErrorMsg($message = '', $sql = '') + { + if ($message) + { + echo "DTXB info: $message\n\n

"; + //print('http://faq.comsenz.com/'); + } + else + { + echo "MySQL server error report:"; + print_r($this->error_message); + //echo "

http://faq.comsenz.com/"; + } + + exit; + } + +/* 仿真 Adodb 函数 */ + function selectLimit($sql, $num, $start = 0) + { + if ($start == 0) + { + $sql .= ' LIMIT ' . $num; + } + else + { + $sql .= ' LIMIT ' . $start . ', ' . $num; + } + + return $this->query($sql); + } + + function getOne($sql, $limited = false) + { + if ($limited == true) + { + $sql = trim($sql . ' LIMIT 1'); + } + + $res = $this->query($sql); + if ($res !== false) + { + $row = $res->fetch_row(); + $res->free(); + if ($row !== false) + { + return $row[0]; + } + else + { + return ''; + } + } + else + { + return false; + } + } + + function getOneCached($sql, $cached = 'FILEFIRST') + { + $sql = trim($sql . ' LIMIT 1'); + + $cachefirst = ($cached == 'FILEFIRST' || ($cached == 'MYSQLFIRST' && $this->platform != 'WINDOWS')) && $this->max_cache_time; + if (!$cachefirst) + { + return $this->getOne($sql, true); + } + else + { + $result = $this->getSqlCacheData($sql, $cached); + if (empty($result['storecache']) == true) + { + return $result['data']; + } + } + + $arr = $this->getOne($sql, true); + + if ($arr !== false && $cachefirst) + { + $this->setSqlCacheData($result, $arr); + } + + return $arr; + } + + function getAll($sql) + { + $res = $this->query($sql); + if ($res !== false) + { + $arr = $res->fetch_all(MYSQLI_ASSOC); + $res->free(); + return $arr; + } + else + { + return false; + } + } + + function getAllCached($sql, $cached = 'FILEFIRST') + { + $cachefirst = ($cached == 'FILEFIRST' || ($cached == 'MYSQLFIRST' && $this->platform != 'WINDOWS')) && $this->max_cache_time; + if (!$cachefirst) + { + return $this->getAll($sql); + } + else + { + $result = $this->getSqlCacheData($sql, $cached); + if (empty($result['storecache']) == true) + { + return $result['data']; + } + } + + $arr = $this->getAll($sql); + + if ($arr !== false && $cachefirst) + { + $this->setSqlCacheData($result, $arr); + } + + return $arr; + } + + function getRow($sql, $limited = false) + { + if ($limited == true) + { + $sql = trim($sql . ' LIMIT 1'); + } +//echo $sql; + + $res = $this->query($sql); + if ($res !== false) + { + $result = $res->fetch_assoc(); + $res->free(); + return $result; + } + else + { + return false; + } + } + + function getRowCached($sql, $cached = 'FILEFIRST') + { + $cachefirst = ($cached == 'FILEFIRST' || ($cached == 'MYSQLFIRST' && $this->platform != 'WINDOWS')) && $this->max_cache_time; + if (!$cachefirst) + { + return $this->getRow($sql, true); + } + else + { + $result = $this->getSqlCacheData($sql, $cached); + if (empty($result['storecache']) == true) + { + return $result['data']; + } + } + + $arr = $this->getRow($sql, true); + + if ($arr !== false && $cachefirst) + { + $this->setSqlCacheData($result, $arr); + } + + return $arr; + } + + function getCol($sql) + { + $res = $this->query($sql); + if ($res !== false) + { + $arr = array(); + while ($row = $res->fetch_row()) + { + $arr[] = $row[0]; + } + $res->free(); + return $arr; + } + else + { + return false; + } + } + + function getColCached($sql, $cached = 'FILEFIRST') + { + $cachefirst = ($cached == 'FILEFIRST' || ($cached == 'MYSQLFIRST' && $this->platform != 'WINDOWS')) && $this->max_cache_time; + if (!$cachefirst) + { + return $this->getCol($sql); + } + else + { + $result = $this->getSqlCacheData($sql, $cached); + if (empty($result['storecache']) == true) + { + return $result['data']; + } + } + + $arr = $this->getCol($sql); + + if ($arr !== false && $cachefirst) + { + $this->setSqlCacheData($result, $arr); + } + + return $arr; + } + + function autoExecute($table, $field_values, $mode = 'INSERT', $where = '', $querymode = '') + { + $field_names = $this->getCol('DESC ' . $table); + + $sql = ''; + if ($mode == 'INSERT') + { + $fields = $values = array(); + foreach ($field_names AS $value) + { + if (array_key_exists($value, $field_values) == true) + { + $fields[] = $value; + $values[] = "'" . $field_values[$value] . "'"; + } + } + + if (!empty($fields)) + { + $sql = 'INSERT INTO ' . $table . ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')'; + } + } + else + { + $sets = array(); + foreach ($field_names AS $value) + { + if (array_key_exists($value, $field_values) == true) + { + $sets[] = $value . " = '" . $field_values[$value] . "'"; + } + } + + if (!empty($sets)) + { + $sql = 'UPDATE ' . $table . ' SET ' . implode(', ', $sets) . ' WHERE ' . $where; + } + } + + if ($sql) + { + return $this->query($sql, $querymode); + } + else + { + return false; + } + } + + function autoReplace($table, $field_values, $update_values, $where = '', $querymode = '') + { + $field_descs = $this->getAll('DESC ' . $table); + + $primary_keys = array(); + foreach ($field_descs AS $value) + { + $field_names[] = $value['Field']; + if ($value['Key'] == 'PRI') + { + $primary_keys[] = $value['Field']; + } + } + + $fields = $values = array(); + foreach ($field_names AS $value) + { + if (array_key_exists($value, $field_values) == true) + { + $fields[] = $value; + $values[] = "'" . $field_values[$value] . "'"; + } + } + + $sets = array(); + foreach ($update_values AS $key => $value) + { + if (array_key_exists($key, $field_values) == true) + { + if (is_int($value) || is_float($value)) + { + $sets[] = $key . ' = ' . $key . ' + ' . $value; + } + else + { + $sets[] = $key . " = '" . $value . "'"; + } + } + } + + $sql = ''; + if (empty($primary_keys)) + { + if (!empty($fields)) + { + $sql = 'INSERT INTO ' . $table . ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')'; + } + } + else + { + if ($this->version() >= '4.1') + { + if (!empty($fields)) + { + $sql = 'INSERT INTO ' . $table . ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')'; + if (!empty($sets)) + { + $sql .= 'ON DUPLICATE KEY UPDATE ' . implode(', ', $sets); + } + } + } + else + { + if (empty($where)) + { + $where = array(); + foreach ($primary_keys AS $value) + { + if (is_numeric($value)) + { + $where[] = $value . ' = ' . $field_values[$value]; + } + else + { + $where[] = $value . " = '" . $field_values[$value] . "'"; + } + } + $where = implode(' AND ', $where); + } + + if ($where && (!empty($sets) || !empty($fields))) + { + if (intval($this->getOne("SELECT COUNT(*) FROM $table WHERE $where")) > 0) + { + if (!empty($sets)) + { + $sql = 'UPDATE ' . $table . ' SET ' . implode(', ', $sets) . ' WHERE ' . $where; + } + } + else + { + if (!empty($fields)) + { + $sql = 'REPLACE INTO ' . $table . ' (' . implode(', ', $fields) . ') VALUES (' . implode(', ', $values) . ')'; + } + } + } + } + } + + if ($sql) + { + return $this->query($sql, $querymode); + } + else + { + return false; + } + } + + function setMaxCacheTime($second) + { + $this->max_cache_time = $second; + } + + function getMaxCacheTime() + { + return $this->max_cache_time; + } + + function getSqlCacheData($sql, $cached = '') + { + $sql = trim($sql); + + $result = array(); + $result['filename'] = $this->root_path . $this->cache_data_dir . 'sqlcache_' . abs(crc32($this->dbhash . $sql)) . '_' . md5($this->dbhash . $sql) . '.php'; + + $data = @file_get_contents($result['filename']); + if (isset($data{23})) + { + $filetime = substr($data, 13, 10); + $data = substr($data, 23); + + if (($cached == 'FILEFIRST' && time() > $filetime + $this->max_cache_time) || ($cached == 'MYSQLFIRST' && $this->table_lastupdate($this->get_table_name($sql)) > $filetime)) + { + $result['storecache'] = true; + } + else + { + $result['data'] = @unserialize($data); + if ($result['data'] === false) + { + $result['storecache'] = true; + } + else + { + $result['storecache'] = false; + } + } + } + else + { + $result['storecache'] = true; + } + + return $result; + } + + function setSqlCacheData($result, $data) + { + if ($result['storecache'] === true && $result['filename']) + { + @file_put_contents($result['filename'], '' . time() . serialize($data)); + clearstatcache(); + } + } + + /* 获取 SQL 语句中最后更新的表的时间,有多个表的情况下,返回最新的表的时间 */ + function table_lastupdate($tables) + { + if ($this->link_id === NULL) + { + $this->connect($this->settings['dbhost'], $this->settings['dbuser'], $this->settings['dbpw'], $this->settings['dbname'], $this->settings['charset'], $this->settings['pconnect']); + $this->settings = array(); + } + + $lastupdatetime = '0000-00-00 00:00:00'; + + $tables = str_replace('`', '', $tables); + $this->mysql_disable_cache_tables = str_replace('`', '', $this->mysql_disable_cache_tables); + + foreach ($tables AS $table) + { + if (in_array($table, $this->mysql_disable_cache_tables) == true) + { + $lastupdatetime = '2037-12-31 23:59:59'; + + break; + } + + if (strstr($table, '.') != NULL) + { + $tmp = explode('.', $table); + $sql = 'SHOW TABLE STATUS FROM `' . trim($tmp[0]) . "` LIKE '" . trim($tmp[1]) . "'"; + } + else + { + $sql = "SHOW TABLE STATUS LIKE '" . trim($table) . "'"; + } + $result = $this->link_id->query($sql); + $row = $result->fetch_assoc(); + if ($row['Update_time'] > $lastupdatetime) + { + $lastupdatetime = $row['Update_time']; + } + } + $lastupdatetime = strtotime($lastupdatetime) - $this->timezone + $this->timeline; + + return $lastupdatetime; + } + + function get_table_name($query_item) + { + $query_item = trim($query_item); + $table_names = array(); + + /* 判断语句中是不是含有 JOIN */ + if (stristr($query_item, ' JOIN ') == '') + { + /* 解析一般的 SELECT FROM 语句 */ + if (preg_match('/^SELECT.*?FROM\s*((?:`?\w+`?\s*\.\s*)?`?\w+`?(?:(?:\s*AS)?\s*`?\w+`?)?(?:\s*,\s*(?:`?\w+`?\s*\.\s*)?`?\w+`?(?:(?:\s*AS)?\s*`?\w+`?)?)*)/is', $query_item, $table_names)) + { + $table_names = preg_replace('/((?:`?\w+`?\s*\.\s*)?`?\w+`?)[^,]*/', '\1', $table_names[1]); + + return preg_split('/\s*,\s*/', $table_names); + } + } + else + { + /* 对含有 JOIN 的语句进行解析 */ + if (preg_match('/^SELECT.*?FROM\s*((?:`?\w+`?\s*\.\s*)?`?\w+`?)(?:(?:\s*AS)?\s*`?\w+`?)?.*?JOIN.*$/is', $query_item, $table_names)) + { + $other_table_names = array(); + preg_match_all('/JOIN\s*((?:`?\w+`?\s*\.\s*)?`?\w+`?)\s*/i', $query_item, $other_table_names); + + return array_merge(array($table_names[1]), $other_table_names[1]); + } + } + + return $table_names; + } + + /* 设置不允许进行缓存的表 */ + function set_disable_cache_tables($tables) + { + if (!is_array($tables)) + { + $tables = explode(',', $tables); + } + + foreach ($tables AS $table) + { + $this->mysql_disable_cache_tables[] = $table; + } + + array_unique($this->mysql_disable_cache_tables); + } + + + /** + +---------------------------------------------------------- + * 启动事务 + +---------------------------------------------------------- + * @access public + +---------------------------------------------------------- + * @return void + +---------------------------------------------------------- + */ + public function startTrans() { + //$this->initConnect(true); + if ( !$this->link_id ) return false; + //数据rollback 支持 + if ($this->transTimes == 0) { + $this->link_id->autocommit(FALSE); + } + $this->transTimes++; + return ; + } + + /** + +---------------------------------------------------------- + * 用于非自动提交状态下面的查询提交 + +---------------------------------------------------------- + * @access public + +---------------------------------------------------------- + * @return boolen + +---------------------------------------------------------- + */ + public function commit() + { + if ($this->transTimes > 0) { + $result = $this->link_id->commit(); + $this->transTimes = 0; + if(!$result){ + $this->error_message[]['message'] = 'MySQL Query Error'; + $this->error_message[]['sql'] = $sql; + $this->error_message[]['error'] = $this->link_id->error; + $this->error_message[]['errno'] = $this->link_id->errno; + $this->ErrorMsg(); + return false; + } + } + return true; + } + + /** + +---------------------------------------------------------- + * 事务回滚 + +---------------------------------------------------------- + * @access public + +---------------------------------------------------------- + * @return boolen + +---------------------------------------------------------- + */ + public function rollback() + { + if ($this->transTimes > 0) { + $result = $this->link_id->rollback(); + $this->transTimes = 0; + if(!$result){ + $this->error_message[]['message'] = 'MySQL Query Error'; + $this->error_message[]['sql'] = $sql; + $this->error_message[]['error'] = $this->link_id->error; + $this->error_message[]['errno'] = $this->link_id->errno; + $this->ErrorMsg(); + return false; + } + } + return true; + } + +} \ No newline at end of file diff --git a/includes/cls_rss.php b/includes/cls_rss.php new file mode 100755 index 0000000..22dde00 --- /dev/null +++ b/includes/cls_rss.php @@ -0,0 +1,1725 @@ + +// @copyright Michael Wimmer +// @link http://www.flaimo.com/ +// @global array $GLOBALS['_TICKER_ini_settings'] +// @abstract +// @package RSSBuilder +// @category FLP +// @version 1.001 +/*-----------------------------------------------------------------------*/ + +class RSSBase +{ + /*-----------------------*/ + /* C O N S T R U C T O R */ + /*-----------------------*/ + + //------------------------------------------------- + // Constructor + //------------------------------------------------- + // @desc Constructor + // @return (void) + // @access private + //------------------------------------------------- + function RSSBase() { + } // end constructor + +} // end class RSSBase + +//--------------------------------------------------------------------------- + +/*-----------------------------------------------------------------------*/ +// Class for creating a RSS file +//------------------------------------------------- +// Tested with WAMP (XP-SP1/1.3.24/4.0.12/4.3.0) +// Last change: 2003-05-30 +//------------------------------------------------- +// @desc Class for creating a RSS file +// @access public +// @author Michael Wimmer +// @copyright Michael Wimmer +// @link http://www.flaimo.com/ +// @example rss_sample_script.php Sample script +// @package RSSBuilder +// @category FLP +// @version 1.001 +/*-----------------------------------------------------------------------*/ +class RSSBuilder extends RSSBase +{ + /*-----------------------------------------------------------------------*/ + /* V A R I A B L E S + /*-----------------------------------------------------------------------*/ + + //------------------------------------------------- + // encoding of the XML file + //------------------------------------------------- + // @desc encoding of the XML file + // @var string + // @access private + //------------------------------------------------- + var $encoding; + + //------------------------------------------------- + // URL where the RSS document will be made available + //------------------------------------------------- + // @desc URL where the RSS document will be made available + // @var string + // @access private + //------------------------------------------------- + var $about; + + //------------------------------------------------- + // title of the rss stream + //------------------------------------------------- + // @desc title of the rss stream + // @var string + // @access private + //------------------------------------------------- + var $title; + + //------------------------------------------------- + // description of the rss stream + //------------------------------------------------- + // @desc description of the rss stream + // @var string + // @access private + //------------------------------------------------- + var $description; + + //------------------------------------------------- + // publisher of the rss stream (person, an organization, or a service) + //------------------------------------------------- + // @desc publisher of the rss stream + // @var string + // @access private + //------------------------------------------------- + var $publisher; + + //------------------------------------------------- + // creator of the rss stream (person, an organization, or a service) + //------------------------------------------------- + // @desc creator of the rss stream + // @var string + // @access private + //------------------------------------------------- + var $creator; + + //------------------------------------------------- + // creation date of the file (format: 2003-05-29T00:03:07+0200) + //------------------------------------------------- + // @desc creation date of the file (format: 2003-05-29T00:03:07+0200) + // @var string + // @access private + //------------------------------------------------- + var $date; + + //------------------------------------------------- + // iso format language + //------------------------------------------------- + // @desc iso format language + // @var string + // @access private + //------------------------------------------------- + var $language; + + //------------------------------------------------- + // copyrights for the rss stream + //------------------------------------------------- + // @desc copyrights for the rss stream + // @var string + // @access private + //------------------------------------------------- + var $rights; + + //------------------------------------------------- + // URL to an small image + //------------------------------------------------- + // @desc URL to an small image + // @var string + // @access private + //------------------------------------------------- + var $image_link; + + //------------------------------------------------- + // spatial location (a place name or geographic coordinates), temporal period (a period label, date, or date range) or jurisdiction (such as a named administrative entity) + //------------------------------------------------- + // @desc spatial location (a place name or geographic coordinates), temporal period (a period label, date, or date range) or jurisdiction (such as a named administrative entity) + // @var string + // @access private + //------------------------------------------------- + var $coverage; + + //------------------------------------------------- + // person, an organization, or a service + //------------------------------------------------- + // @desc person, an organization, or a service + // @var string + // @access private + //------------------------------------------------- + var $contributor; + + //------------------------------------------------- + // 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' + //------------------------------------------------- + // @desc 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' + // @var string + // @access private + //------------------------------------------------- + var $period; + + //------------------------------------------------- + // every X hours/days/weeks/... + //------------------------------------------------- + // @desc every X hours/days/weeks/... + // @var int + // @access private + //------------------------------------------------- + var $frequency; + + //------------------------------------------------- + // date (format: 2003-05-29T00:03:07+0200) + //------------------------------------------------- + // Defines a base date to be used in concert with updatePeriod and + // updateFrequency to calculate the publishing schedule. + //------------------------------------------------- + // @desc base date to calculate from (format: 2003-05-29T00:03:07+0200) + // @var string + // @access private + //------------------------------------------------- + var $base; + + //------------------------------------------------- + // category (rss 2.0) + //------------------------------------------------- + // @desc category (rss 2.0) + // @var string + // @access private + // @since 1.001 - 2003/05/30 + //------------------------------------------------- + var $category; + + //------------------------------------------------- + // caching time in minutes (rss 2.0) + //------------------------------------------------- + // @desc caching time in minutes (rss 2.0) + // @var int + // @access private + // @since 1.001 - 2003/05/30 + //------------------------------------------------- + var $cache; + + //------------------------------------------------- + // array wich all the rss items + //------------------------------------------------- + // @desc array wich all the rss items + // @var array + // @access private + //------------------------------------------------- + var $items = array(); + + //------------------------------------------------- + // compiled outputstring + //------------------------------------------------- + // @desc compiled outputstring + // @var string + // @access private + //------------------------------------------------- + var $output; + + //------------------------------------------------- + // use DC data + //------------------------------------------------- + // @desc use DC data + // @var boolean + // @access private + //------------------------------------------------- + var $use_dc_data = false; + + //------------------------------------------------- + // use SY data + //------------------------------------------------- + // @desc use SY data + // @var boolean + // @access private + //------------------------------------------------- + var $use_sy_data = false; + + /*-----------------------*/ + /* C O N S T R U C T O R */ + /*-----------------------*/ + + //------------------------------------------------- + // Constructor + //------------------------------------------------- + // @desc Constructor + // @param (string) $encoding encoding of the xml file + // @param (string) $about URL where the RSS document will be made available + // @param (string) $title + // @param (string) $description + // @param (string) $image_link URL + // @return (void) + // @uses setEncoding(), setAbout(), setTitle(), setDescription(), setImageLink(), setCategory(), setCache() + // @access private + //------------------------------------------------- + function RSSBuilder($encoding = '', + $about = '', + $title = '', + $description = '', + $image_link = '', + $category = '', + $cache = '') { + $this->setEncoding($encoding); + $this->setAbout($about); + $this->setTitle($title); + $this->setDescription($description); + $this->setImageLink($image_link); + $this->setCategory($category); + $this->setCache($cache); + } // end constructor + + /*-----------------------------------------------------------------------*/ + /* F U N C T I O N S */ + /*-----------------------------------------------------------------------*/ + + //------------------------------------------------- + // add additional DC data + //------------------------------------------------- + // @desc add additional DC data + // @param (string) $publisher person, an organization, or a service + // @param (string) $creator person, an organization, or a service + // @param (string) $date format: 2003-05-29T00:03:07+0200 + // @param (string) $language iso-format + // @param (string) $rights copyright information + // @param (string) $coverage spatial location (a place name or geographic coordinates), temporal period (a period label, date, or date range) or jurisdiction (such as a named administrative entity) + // @param (string) $contributor person, an organization, or a service + // @return (void) + // @uses setPublisher(), setCreator(), setDate(), setLanguage(), setRights(), setCoverage(), setContributor() + // @access public + //------------------------------------------------- + function addDCdata($publisher = '', + $creator = '', + $date = '', + $language = '', + $rights = '', + $coverage = '', + $contributor = '') { + $this->setPublisher($publisher); + $this->setCreator($creator); + $this->setDate($date); + $this->setLanguage($language); + $this->setRights($rights); + $this->setCoverage($coverage); + $this->setContributor($contributor); + $this->use_dc_data = (boolean) true; + } // end function + + //------------------------------------------------- + // add additional SY data + //------------------------------------------------- + // @desc add additional DC data + // @param (string) $period 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' + // @param (int) $frequency every x hours/days/weeks/... + // @param (string) $base format: 2003-05-29T00:03:07+0200 + // @return (void) + // @uses setPeriod(), setFrequency(), setBase() + // @access public + //------------------------------------------------- + function addSYdata($period = '', $frequency = '', $base = '') { + $this->setPeriod($period); + $this->setFrequency($frequency); + $this->setBase($base); + $this->use_sy_data = (boolean) true; + } // end function + + //------------------------------------------------- + // Checks if a given string is a valid iso-language-code + //------------------------------------------------- + // @desc Checks if a given string is a valid iso-language-code + // @param (string) $code String that should validated + // @return (boolean) $isvalid If string is valid or not + // @access public + // @static + //------------------------------------------------- + function isValidLanguageCode($code = '') { + return (boolean) ((preg_match('(^([a-zA-Z]{2})$)',$code) > 0) ? true : false); + } // end function + + //------------------------------------------------- + // Sets $encoding variable + //------------------------------------------------- + // @desc Sets $encoding variable + // @param (string) $encoding encoding of the xml file + // @return (void) + // @access private + // @see $encoding + //------------------------------------------------- + function setEncoding($encoding = '') { + if (!isset($this->encoding)) { + $this->encoding = (string) ((strlen(trim($encoding)) > 0) ? trim($encoding) : 'UTF-8'); + } // end if + } // end function + + //------------------------------------------------- + // Sets $about variable + //------------------------------------------------- + // @desc Sets $about variable + // @param (string) $about + // @return (void) + // @access private + // @see $about + //------------------------------------------------- + function setAbout($about = '') { + if (!isset($this->about) && strlen(trim($about)) > 0) { + $this->about = (string) trim($about); + } // end if + } // end function + + //------------------------------------------------- + // Sets $title variable + //------------------------------------------------- + // @desc Sets $title variable + // @param (string) $title + // @return (void) + // @access private + // @see $title + //------------------------------------------------- + function setTitle($title = '') { + if (!isset($this->title) && strlen(trim($title)) > 0) { + $this->title = (string) trim($title); + } // end if + } // end function + + //------------------------------------------------- + // Sets $description variable + //------------------------------------------------- + // @desc Sets $description variable + // @param (string) $description + // @return (void) + // @access private + // @see $description + //------------------------------------------------- + function setDescription($description = '') { + if (!isset($this->description) && strlen(trim($description)) > 0) { + $this->description = (string) trim($description); + } // end if + } // end function + + //------------------------------------------------- + // Sets $publisher variable + //------------------------------------------------- + // @desc Sets $publisher variable + // @param (string) $publisher + // @return (void) + // @access private + // @see $publisher + //------------------------------------------------- + function setPublisher($publisher = '') { + if (!isset($this->publisher) && strlen(trim($publisher)) > 0) { + $this->publisher = (string) trim($publisher); + } // end if + } // end function + + //------------------------------------------------- + // Sets $creator variable + //------------------------------------------------- + // @desc Sets $creator variable + // @param (string) $creator + // @return (void) + // @access private + // @see $creator + //------------------------------------------------- + function setCreator($creator = '') { + if (!isset($this->creator) && strlen(trim($creator)) > 0) { + $this->creator = (string) trim($creator); + } // end if + } // end function + + //------------------------------------------------- + // Sets $date variable + //------------------------------------------------- + // @desc Sets $date variable + // @param (string) $date format: 2003-05-29T00:03:07+0200 + // @return (void) + // @access private + // @see $date + //------------------------------------------------- + function setDate($date = '') { + if (!isset($this->date) && strlen(trim($date)) > 0) { + $this->date = (string) trim($date); + } // end if + } // end function + + //------------------------------------------------- + // Sets $language variable + //------------------------------------------------- + // @desc Sets $language variable + // @param (string) $language + // @return (void) + // @access private + // @see $language + // @uses isValidLanguageCode() + //------------------------------------------------- + function setLanguage($language = '') { + if (!isset($this->language) && $this->isValidLanguageCode($language) === true) { + $this->language = (string) trim($language); + } // end if + } // end function + + //------------------------------------------------- + // Sets $rights variable + //------------------------------------------------- + // @desc Sets $rights variable + // @param (string) $rights + // @return (void) + // @access private + // @see $rights + //------------------------------------------------- + function setRights($rights = '') { + if (!isset($this->rights) && strlen(trim($rights)) > 0) { + $this->rights = (string) trim($rights); + } // end if + } // end function + + //------------------------------------------------- + // Sets $coverage variable + //------------------------------------------------- + // @desc Sets $coverage variable + // @param (string) $coverage + // @return (void) + // @access private + // @see $coverage + //------------------------------------------------- + function setCoverage($coverage = '') { + if (!isset($this->coverage) && strlen(trim($coverage)) > 0) { + $this->coverage = (string) trim($coverage); + } // end if + } // end function + + //------------------------------------------------- + // Sets $contributor variable + //------------------------------------------------- + // @desc Sets $contributor variable + // @param (string) $contributor + // @return (void) + // @access private + // @see $contributor + //------------------------------------------------- + function setContributor($contributor = '') { + if (!isset($this->contributor) && strlen(trim($contributor)) > 0) { + $this->contributor = (string) trim($contributor); + } // end if + } // end function + + //------------------------------------------------- + // Sets $image_link variable + //------------------------------------------------- + // @desc Sets $image_link variable + // @param (string) $image_link + // @return (void) + // @access private + // @see $image_link + //------------------------------------------------- + function setImageLink($image_link = '') { + if (!isset($this->image_link) && strlen(trim($image_link)) > 0) { + $this->image_link = (string) trim($image_link); + } // end if + } // end function + + //------------------------------------------------- + // Sets $period variable + //------------------------------------------------- + // @desc Sets $period variable + // @param (string) $period 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' + // @return (void) + // @access private + // @see $period + //------------------------------------------------- + function setPeriod($period = '') { + if (!isset($this->period) && strlen(trim($period)) > 0) { + switch ($period) { + case 'hourly': + case 'daily': + case 'weekly': + case 'monthly': + case 'yearly': + $this->period = (string) trim($period); + break; + default: + $this->period = (string) ''; + break; + } // end switch + } // end if + } // end function + + //------------------------------------------------- + // Sets $frequency variable + //------------------------------------------------- + // @desc Sets $frequency variable + // @param (int) $frequency + // @return (void) + // @access private + // @see $frequency + //------------------------------------------------- + function setFrequency($frequency = '') { + if (!isset($this->frequency) && strlen(trim($frequency)) > 0) { + $this->frequency = (int) $frequency; + } // end if + } // end function + + //------------------------------------------------- + // Sets $base variable + //------------------------------------------------- + // @desc Sets $base variable + // @param (string) $base + // @return (void) + // @access private + // @see $base + //------------------------------------------------- + function setBase($base = '') { + if (!isset($this->base) && strlen(trim($base)) > 0) { + $this->base = (string) trim($base); + } // end if + } // end function + + //------------------------------------------------- + // Sets $category variable + //------------------------------------------------- + // @desc Sets $category variable + // @param (string) $category + // @return (void) + // @access private + // @see $category + // @since 1.001 - 2003/05/30 + //------------------------------------------------- + function setCategory($category = '') { + if (strlen(trim($category)) > 0) { + $this->category = (string) trim($category); + } // end if + } // end function + + //------------------------------------------------- + // Sets $cache variable + //------------------------------------------------- + // @desc Sets $cache variable + // @param (int) $cache + // @return (void) + // @access private + // @see $cache + // @since 1.001 - 2003/05/30 + //------------------------------------------------- + function setCache($cache = '') { + if (strlen(trim($cache)) > 0) { + $this->cache = (int) $cache; + } // end if + } // end function + + //------------------------------------------------- + // Returns $encoding variable + //------------------------------------------------- + // @desc Returns $encoding variable + // @return (string) $encoding + // @access public + // @see $image_link + //------------------------------------------------- + function getEncoding() { + return (string) $this->encoding; + } // end function + + //------------------------------------------------- + // Returns $about variable + //------------------------------------------------- + // @desc Returns $about variable + // @return (string) $about + // @access public + // @see $about + //------------------------------------------------- + function getAbout() { + return (string) $this->about; + } // end function + + //------------------------------------------------- + // Returns $title variable + //------------------------------------------------- + // @desc Returns $title variable + // @return (string) $title + // @access public + // @see $title + //------------------------------------------------- + function getTitle() { + return (string) $this->title; + } // end function + + //------------------------------------------------- + // Returns $description variable + //------------------------------------------------- + // @desc Returns $description variable + // @return (string) $description + // @access public + // @see $description + //------------------------------------------------- + function getDescription() { + return (string) $this->description; + } // end function + + //------------------------------------------------- + // Returns $publisher variable + //------------------------------------------------- + // @desc Returns $publisher variable + // @return (string) $publisher + // @access public + // @see $publisher + //------------------------------------------------- + function getPublisher() { + return (string) $this->publisher; + } // end function + + //------------------------------------------------- + // Returns $creator variable + //------------------------------------------------- + // @desc Returns $creator variable + // @return (string) $creator + // @access public + // @see $creator + //------------------------------------------------- + function getCreator() { + return (string) $this->creator; + } // end function + + //------------------------------------------------- + // Returns $date variable + //------------------------------------------------- + // @desc Returns $date variable + // @return (string) $date + // @access public + // @see $date + //------------------------------------------------- + function getDate() { + return (string) $this->date; + } // end function + + //------------------------------------------------- + // Returns $language variable + //------------------------------------------------- + // @desc Returns $language variable + // @return (string) $language + // @access public + // @see $language + //------------------------------------------------- + function getLanguage() { + return (string) $this->language; + } // end function + + //------------------------------------------------- + // Returns $rights variable + //------------------------------------------------- + // @desc Returns $rights variable + // @return (string) $rights + // @access public + // @see $rights + //------------------------------------------------- + function getRights() { + return (string) $this->rights; + } // end function + + //------------------------------------------------- + // Returns $coverage variable + //------------------------------------------------- + // @desc Returns $coverage variable + // @return (string) $coverage + // @access public + // @see $coverage + //------------------------------------------------- + function getCoverage() { + return (string) $this->coverage; + } // end function + + //------------------------------------------------- + // Returns $contributor variable + //------------------------------------------------- + // @desc Returns $contributor variable + // @return (string) $contributor + // @access public + // @see $contributor + //------------------------------------------------- + function getContributor() { + return (string) $this->contributor; + } // end function + + //------------------------------------------------- + // Returns $image_link variable + //------------------------------------------------- + // @desc Returns $image_link variable + // @return (string) $image_link + // @access public + // @see $image_link + //------------------------------------------------- + function getImageLink() { + return (string) $this->image_link; + } // end function + + //------------------------------------------------- + // Returns $period variable + //------------------------------------------------- + // @desc Returns $period variable + // @return (string) $period + // @access public + // @see $period + //------------------------------------------------- + function getPeriod() { + return (string) $this->period; + } // end function + + //------------------------------------------------- + // Returns $frequency variable + //------------------------------------------------- + // @desc Returns $frequency variable + // @return (string) $frequency + // @access public + // @see $frequency + //------------------------------------------------- + function getFrequency() { + return (int) $this->frequency; + } // end function + + //------------------------------------------------- + // Returns $base variable + //------------------------------------------------- + // @desc Returns $base variable + // @return (string) $base + // @access public + // @see $base + //------------------------------------------------- + function getBase() { + return (string) $this->base; + } // end function + + //------------------------------------------------- + // Returns $category variable + //------------------------------------------------- + // @desc Returns $category variable + // @return (string) $category + // @access public + // @see $category + // @since 1.001 - 2003/05/30 + //------------------------------------------------- + function getCategory() { + return (string) $this->category; + } // end function + + //------------------------------------------------- + // Returns $cache variable + //------------------------------------------------- + // @desc Returns $cache variable + // @return (int) $cache + // @access public + // @see $cache + // @since 1.001 - 2003/05/30 + //------------------------------------------------- + function getCache() { + return (int) $this->cache; + } // end function + + //------------------------------------------------- + // Adds another rss item to the object + //------------------------------------------------- + // @desc Adds another rss item to the object + // @param (string) $about URL + // @param (string) $title + // @param (string) $link URL + // @param (string) $description (optional) + // @param (string) $subject some sort of category (optional dc value - only shows up if DC data has been set before) + // @param (string) $date format: 2003-05-29T00:03:07+0200 (optional dc value - only shows up if DC data has been set before) + // @return (void) + // @access public + // @see $items + // @uses RSSItem + //------------------------------------------------- + function addItem($about = '', + $title = '', + $link = '', + $description = '', + $subject = '', + $date = '', + $author = '', + $comments = '') + { + $item = new RSSItem($about, + $title, + $link, + $description, + $subject, + $date, + $author = '', + $comments = ''); + $this->items[] = $item; + } // end function + + //------------------------------------------------- + // Deletes a rss item from the array + //------------------------------------------------- + // @desc Deletes a rss item from the array + // @param (int) $id id of the element in the $items array + // @return (boolean) true if item was deleted + // @access public + // @see $items + //------------------------------------------------- + function deleteItem($id = -1) { + if (array_key_exists($id, $this->items)) { + unset($this->items[$id]); + return (boolean) true; + } else { + return (boolean) false; + } // end if + } // end function + + //------------------------------------------------- + // Returns an array with all the keys of the $items array + //------------------------------------------------- + // @desc Returns an array with all the keys of the $items array + // @return (array) array with all the keys of the $items array + // @access public + // @see $items + //------------------------------------------------- + function getItemList() { + return (array) array_keys($this->items); + } // end function + + //------------------------------------------------- + // Returns the $items array + //------------------------------------------------- + // @desc Returns the $items array + // @return (array) $items + // @access public + //------------------------------------------------- + function getItems() { + return (array) $this->items; + } // end function + + //------------------------------------------------- + // Returns a single rss item by ID + //------------------------------------------------- + // @desc Returns a single rss item by ID + // @param (int) $id id of the element in the $items array + // @return (mixed) RSSItem or false + // @access public + // @see RSSItem + //------------------------------------------------- + function getItem($id = -1) { + if (array_key_exists($id, $this->items)) { + return (object) $this->items[$id]; + } else { + return (boolean) false; + } // end if + } // end function + + //------------------------------------------------- + // creates the output based on the 0.91 rss version + //------------------------------------------------- + // @desc creates the output based on the 0.91 rss version + // @return (void) + // @access private + // @see $output + //------------------------------------------------- + function createOutputV090() { + // not implemented + $this->createOutputV100(); + } // end function + + //------------------------------------------------- + // creates the output based on the 0.91 rss version + //------------------------------------------------- + // @desc creates the output based on the 0.91 rss version + // @return (void) + // @access private + // @see $output + // @since 1.001 - 2003/05/30 + //------------------------------------------------- + function createOutputV091() { + $this->output = (string) '' . "\n"; + $this->output .= (string) '' . "\n"; + $this->output .= (string) '' . "\n"; + + if (strlen($this->rights) > 0) { + $this->output .= (string) '' . $this->rights . '' . "\n"; + } // end if + + if (strlen($this->date) > 0) { + $this->output .= (string) '' .$this->date . '' . "\n"; + $this->output .= (string) '' .$this->date . '' . "\n"; + } // end if + + if (strlen($this->about) > 0) { + $this->output .= (string) '' . $this->about . '' . "\n"; + } // end if + + if (strlen($this->description) > 0) { + $this->output .= (string) '' . $this->description . '' . "\n"; + } // end if + + if (strlen($this->about) > 0) { + $this->output .= (string) '' . $this->about . '' . "\n"; + } // end if + + if (strlen($this->title) > 0) { + $this->output .= (string) '' . $this->title . '' . "\n"; + } // end if + + if (strlen($this->image_link) > 0) { + $this->output .= (string) '' . "\n"; + $this->output .= (string) '' . $this->title . '' . "\n"; + $this->output .= (string) '' . $this->image_link . '' . "\n"; + $this->output .= (string) '' . $this->about . '' . "\n"; + if (strlen($this->description) > 0) { + $this->output .= (string) '' . $this->description . '' . "\n"; + } // end if + $this->output .= (string) '' . "\n"; + } // end if + + if (strlen($this->publisher) > 0) { + $this->output .= (string) '' . $this->publisher . '' . "\n"; + } // end if + + if (strlen($this->creator) > 0) { + $this->output .= (string) '' . $this->creator . '' . "\n"; + } // end if + + if (strlen($this->language) > 0) { + $this->output .= (string) '' . $this->language . '' . "\n"; + } // end if + + if (count($this->getItemList()) > 0) { + foreach ($this->getItemList() AS $id) { + $item =& $this->items[$id]; + + if (strlen($item->getTitle()) > 0 && strlen($item->getLink()) > 0) { + $this->output .= (string) '' . "\n"; + $this->output .= (string) '' . $item->getTitle() . '' . "\n"; + $this->output .= (string) '' . $item->getLink() . '' . "\n"; + if (strlen($item->getDescription()) > 0) { + $this->output .= (string) '' . $item->getDescription() . '' . "\n"; + } // end if + $this->output .= (string) '' . "\n"; + } // end if + } // end foreach + } // end if + + $this->output .= (string) '' . "\n"; + $this->output .= (string) '' . "\n"; + } // end function + + //------------------------------------------------- + // creates the output based on the 1.0 rss version + //------------------------------------------------- + // @desc creates the output based on the 1.0 rss version + // @return (void) + // @access private + // @see $output + //------------------------------------------------- + function createOutputV100() { + $this->output = (string) 'use_dc_data === true) { + $this->output .= (string) 'xmlns:dc="http://purl.org/dc/elements/1.1/" '; + } // end if + + if ($this->use_sy_data === true) { + $this->output .= (string) 'xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" '; + } // end if + + $this->output .= (string) 'xmlns="http://purl.org/rss/1.0/">' . "\n"; + + if (strlen($this->about) > 0) { + $this->output .= (string) '' . "\n"; + } else { + $this->output .= (string) '' . "\n"; + } // end if + + if (strlen($this->title) > 0) { + $this->output .= (string) '' . $this->title . '' . "\n"; + } // end if + + if (strlen($this->about) > 0) { + $this->output .= (string) '' . $this->about . '' . "\n"; + } // end if + + if (strlen($this->description) > 0) { + $this->output .= (string) '' . $this->description . '' . "\n"; + } // end if + + // additional dc data + if (strlen($this->publisher) > 0) { + $this->output .= (string) '' . $this->publisher . '' . "\n"; + } // end if + + if (strlen($this->creator) > 0) { + $this->output .= (string) '' . $this->creator . '' . "\n"; + } // end if + + if (strlen($this->date) > 0) { + $this->output .= (string) '' .$this->date . '' . "\n"; + } // end if + + if (strlen($this->language) > 0) { + $this->output .= (string) '' . $this->language . '' . "\n"; + } // end if + + if (strlen($this->rights) > 0) { + $this->output .= (string) '' . $this->rights . '' . "\n"; + } // end if + + if (strlen($this->coverage) > 0) { + $this->output .= (string) '' . $this->coverage . '' . "\n"; + } // end if + + if (strlen($this->contributor) > 0) { + $this->output .= (string) '' . $this->contributor . '' . "\n"; + } // end if + + // additional SY data + if (strlen($this->period) > 0) { + $this->output .= (string) '' . $this->period . '' . "\n"; + } // end if + + if (strlen($this->frequency) > 0) { + $this->output .= (string) '' . $this->frequency . '' . "\n"; + } // end if + + if (strlen($this->base) > 0) { + $this->output .= (string) '' . $this->base . '' . "\n"; + } // end if + + if (strlen($this->image_link) > 0) { + $this->output .= (string) '' . "\n"; + } // end if + + if (strlen($this->image_link) > 0) { + $this->output .= (string) '' . "\n"; + $this->output .= (string) '' . $this->title . '' . "\n"; + $this->output .= (string) '' . $this->image_link . '' . "\n"; + $this->output .= (string) '' . $this->about . '' . "\n"; + if (strlen($this->description) > 0) { + $this->output .= (string) '' . $this->description . '' . "\n"; + } // end if + $this->output .= (string) '' . "\n"; + } // end if + + if (count($this->getItemList()) > 0) { + $this->output .= (string) '' . "\n"; + foreach ($this->getItemList() as $id) { + $item =& $this->items[$id]; + if (strlen($item->getAbout()) > 0) { + $this->output .= (string) ' ' . "\n"; + } // end if + } // end foreach + $this->output .= (string) '' . "\n"; + } // end if + $this->output .= (string) '' . "\n"; + + if (count($this->getItemList()) > 0) { + foreach ($this->getItemList() as $id) { + $item =& $this->items[$id]; + + if (strlen($item->getTitle()) > 0 && strlen($item->getLink()) > 0) { + if (strlen($item->getAbout()) > 0) { + $this->output .= (string) '' . "\n"; + } else { + $this->output .= (string) '' . "\n"; + } // end if + + $this->output .= (string) '' . $item->getTitle() . '' . "\n"; + $this->output .= (string) '' . $item->getLink() . '' . "\n"; + + if (strlen($item->getDescription()) > 0) { + $this->output .= (string) '' . $item->getDescription() . '' . "\n"; + } // end if + + if ($this->use_dc_data === true && strlen($item->getSubject()) > 0) { + $this->output .= (string) '' . $item->getSubject() . '' . "\n"; + } // end if + + if ($this->use_dc_data === true && strlen($item->getDate()) > 0) { + $this->output .= (string) '' . $item->getDate() . '' . "\n"; + } // end if + + $this->output .= (string) '' . "\n"; + } // end if + } // end foreach + } // end if + + $this->output .= (string) ''; + } // end function + + //------------------------------------------------- + // creates the output based on the 2.0 rss draft + //------------------------------------------------- + // @desc creates the output based on the 0.91 rss draft + // @return (void) + // @access private + // @see $output + // @since 1.001 - 2003/05/30 + //------------------------------------------------- + function createOutputV200() { + // not implemented + $this->createOutputV100(); + //--------------------- + $this->output = (string) '' . "\n"; + $this->output .= (string) '' . "\n"; + + if (strlen($this->rights) > 0) { + $this->output .= (string) '' . $this->rights . '' . "\n"; + } // end if + + if (strlen($this->date) > 0) { + $this->output .= (string) '' .$this->date . '' . "\n"; + //xuanyan 2007.5.8 edit + //$this->output .= (string) '' .$this->date . '' . "\n"; + } // end if + + if (strlen($this->about) > 0) { + $this->output .= (string) '' . $this->about . '' . "\n"; + } // end if + + if (strlen($this->description) > 0) { + $this->output .= (string) '' . $this->description . '' . "\n"; + } // end if + + if (strlen($this->about) > 0) { + $this->output .= (string) '' . $this->about . '' . "\n"; + } // end if + + if (strlen($this->title) > 0) { + $this->output .= (string) '' . $this->title . '' . "\n"; + } // end if + + if (strlen($this->image_link) > 0) { + $this->output .= (string) '' . "\n"; + $this->output .= (string) '' . $this->title . '' . "\n"; + $this->output .= (string) '' . $this->image_link . '' . "\n"; + $this->output .= (string) '' . $this->about . '' . "\n"; + if (strlen($this->description) > 0) { + $this->output .= (string) '' . $this->description . '' . "\n"; + } // end if + $this->output .= (string) '' . "\n"; + } // end if + + if (strlen($this->publisher) > 0) { + $this->output .= (string) '' . $this->publisher . '' . "\n"; + } // end if + + if (strlen($this->creator) > 0) { + //xuanyan 2007.5.8 edit + //$this->output .= (string) '' . $this->creator . '' . "\n"; + $this->output .= (string) '' . $this->creator . '' . "\n"; + } // end if + + if (strlen($this->language) > 0) { + $this->output .= (string) '' . $this->language . '' . "\n"; + } // end if + + if (strlen($this->category) > 0) { + $this->output .= (string) '' . $this->category . '' . "\n"; + } // end if + + if (strlen($this->cache) > 0) { + $this->output .= (string) '' . $this->cache . '' . "\n"; + } // end if + + if (count($this->getItemList()) > 0) { + foreach ($this->getItemList() as $id) { + $item =& $this->items[$id]; + + if (strlen($item->getTitle()) > 0 && strlen($item->getLink()) > 0) { + $this->output .= (string) '' . "\n"; + $this->output .= (string) '' . $item->getTitle() . '' . "\n"; + $this->output .= (string) '' . $item->getLink() . '' . "\n"; + + if (strlen($item->getDescription()) > 0) { + $this->output .= (string) '' . $item->getDescription() . '' . "\n"; + } // end if + + if ($this->use_dc_data === true && strlen($item->getSubject()) > 0) { + $this->output .= (string) '' . $item->getSubject() . '' . "\n"; + } // end if + + if ($this->use_dc_data === true && strlen($item->getDate()) > 0) { + $this->output .= (string) '' . $item->getDate() . '' . "\n"; + } // end if + + if (strlen($item->getAbout()) > 0) { + $this->output .= (string) '' . $item->getAbout() . '' . "\n"; + } // end if + + if (strlen($item->getAuthor()) > 0) { + $this->output .= (string) '' . $item->getAuthor() . '' . "\n"; + } // end if + + if (strlen($item->getComments()) > 0) { + $this->output .= (string) '' . $item->getComments() . '' . "\n"; + } // end if + + $this->output .= (string) '' . "\n"; + } // end if + } // end foreach + } // end if + + $this->output .= (string) '' . "\n"; + $this->output .= (string) '' . "\n"; + } // end function + + //------------------------------------------------- + // creates the output + //------------------------------------------------- + // @desc creates the output + // @return (void) + // @access private + // @uses createOutputV100() + //------------------------------------------------- + function createOutput($version = '') { + if (strlen(trim($version)) === 0) { + $version = (string) '1.0'; + } // end if + + switch ($version) { + case '0.9': + $this->createOutputV090(); + break; + case '0.91': + $this->createOutputV091(); + break; + case '2.00': + $this->createOutputV200(); + break; + case '1.0': + default: + $this->createOutputV100(); + break; + } // end switch + } // end function + + //------------------------------------------------- + // echos the output + //------------------------------------------------- + // use this function if you want to directly output the rss stream + //------------------------------------------------- + // @desc echos the output + // @return (void) + // @access public + // @uses createOutput() + //------------------------------------------------- + function outputRSS($version = '') { + if (!isset($this->output)) { + $this->createOutput($version); + } // end if +// header('Content-Disposition: inline; filename=rss_' . str_replace(' ', '', $this->title) . '.xml'); + $this->output = '<' . '?xml version="1.0" encoding="' . $this->encoding . '"?' .'>' . "\n" . + '' . "\n" . $this->output; + echo $this->output; + } // end function + + //------------------------------------------------- + // returns the output + //------------------------------------------------- + // use this function if you want to have the output stream as a string (for example to write it in a cache file) + //------------------------------------------------- + // @desc returns the output + // @return (void) + // @access public + // @uses createOutput() + //------------------------------------------------- + function getRSSOutput($version = '') { + if (!isset($this->output)) { + $this->createOutput($version); + } // end if + + return (string) '<' . '?xml version="1.0" encoding="' . $this->encoding . '"?' . '>' . "\n" . + ' ' . "\n" . $this->output; + } // end function +} // end class RSSBuilder + +//--------------------------------------------------------------------------- + +/*-----------------------------------------------------------------------*/ +// single rss item object +//------------------------------------------------- +// Tested with WAMP (XP-SP1/1.3.24/4.0.12/4.3.0) +// Last change: 2003-05-30 +//------------------------------------------------- +// @desc single rss item object +// @access private +// @author Michael Wimmer +// @copyright Michael Wimmer +// @link http://www.flaimo.com/ +// @package RSSBuilder +// @category FLP +// @version 1.001 +/*-----------------------------------------------------------------------*/ +class RSSItem extends RSSBase +{ + /*-----------------------------------------------------------------------*/ + /* V A R I A B L E S */ + /*-----------------------------------------------------------------------*/ + + //------------------------------------------------- + // URL + //------------------------------------------------- + // @desc URL + // @var string + // @access private + //------------------------------------------------- + var $about; + + //------------------------------------------------- + // headline + //------------------------------------------------- + // @desc headline + // @var string + // @access private + //------------------------------------------------- + var $title; + + //------------------------------------------------- + // URL to the full item + //------------------------------------------------- + // @desc URL to the full item + // @var string + // @access private + //------------------------------------------------- + var $link; + + //------------------------------------------------- + // optional description + //------------------------------------------------- + // @desc optional description + // @var string + // @access private + //------------------------------------------------- + var $description; + + //------------------------------------------------- + // optional subject (category) + //------------------------------------------------- + // @desc optional subject (category) + // @var string + // @access private + //------------------------------------------------- + var $subject; + + //------------------------------------------------- + // optional date + //------------------------------------------------- + // @desc optional date + // @var string + // @access private + //------------------------------------------------- + var $date; + + //------------------------------------------------- + // author of item + //------------------------------------------------- + // @desc author of item + // @var string + // @access private + // @since 1.001 - 2003/05/30 + //------------------------------------------------- + var $author; + + //------------------------------------------------- + // url to comments page (rss 2.0) + //------------------------------------------------- + // @desc url to comments page (rss 2.0) + // @var string + // @access private + // @since 1.001 - 2003/05/30 + //------------------------------------------------- + var $comments; + + /*-----------------------*/ + /* C O N S T R U C T O R */ + /*-----------------------*/ + + //------------------------------------------------- + // Constructor + //------------------------------------------------- + // @desc Constructor + // @param (string) $about URL + // @param (string) $title + // @param (string) $link URL + // @param (string) $description (optional) + // @param (string) $subject some sort of category (optional) + // @param (string) $date format: 2003-05-29T00:03:07+0200 (optional) + // @return (void) + // @uses setAbout(), setTitle(), setLink(), setDescription(), setSubject(), setDate(), setAuthor(), setComments() + // @access private + //------------------------------------------------- + function RSSItem($about = '', + $title = '', + $link = '', + $description = '', + $subject = '', + $date = '', + $author = '', + $comments = '') { + $this->setAbout($about); + $this->setTitle($title); + $this->setLink($link); + $this->setDescription($description); + $this->setSubject($subject); + $this->setDate($date); + $this->setAuthor($author); + $this->setComments($comments); + } // end constructor + + //------------------------------------------------- + // Sets $about variable + //------------------------------------------------- + // @desc Sets $about variable + // @param (string) $about + // @return (void) + // @access private + // @see $about + //------------------------------------------------- + function setAbout($about = '') { + if (!isset($this->about) && strlen(trim($about)) > 0) { + $this->about = (string) trim($about); + } // end if + } // end function + + //------------------------------------------------- + // Sets $title variable + //------------------------------------------------- + // @desc Sets $title variable + // @param (string) $title + // @return (void) + // @access private + // @see $title + //------------------------------------------------- + function setTitle($title = '') { + if (!isset($this->title) && strlen(trim($title)) > 0) { + $this->title = (string) trim($title); + } // end if + } // end function + + //------------------------------------------------- + // Sets $link variable + //------------------------------------------------- + // @desc Sets $link variable + // @param (string) $link + // @return (void) + // @access private + // @see $link + //------------------------------------------------- + function setLink($link = '') { + if (!isset($this->link) && strlen(trim($link)) > 0) { + $this->link = (string) trim($link); + } // end if + } // end function + + //------------------------------------------------- + // Sets $description variable + //------------------------------------------------- + // @desc Sets $description variable + // @param (string) $description + // @return (void) + // @access private + // @see $description + //------------------------------------------------- + function setDescription($description = '') { + if (!isset($this->description) && strlen(trim($description)) > 0) { + $this->description = (string) trim($description); + } // end if + } // end function + + //------------------------------------------------- + // Sets $subject variable + //------------------------------------------------- + // @desc Sets $subject variable + // @param (string) $subject + // @return (void) + // @access private + // @see $subject + //------------------------------------------------- + function setSubject($subject = '') { + if (!isset($this->subject) && strlen(trim($subject)) > 0) { + $this->subject = (string) trim($subject); + } // end if + } // end function + + //------------------------------------------------- + // Sets $date variable + //------------------------------------------------- + // @desc Sets $date variable + // @param (string) $date + // @return (void) + // @access private + // @see $date + //------------------------------------------------- + function setDate($date = '') { + if (!isset($this->date) && strlen(trim($date)) > 0) { + $this->date = (string) trim($date); + } // end if + } // end function + + //------------------------------------------------- + // Sets $author variable + //------------------------------------------------- + // @desc Sets $author variable + // @param (string) $author + // @return (void) + // @access private + // @see $author + // @since 1.001 - 2003/05/30 + //------------------------------------------------- + function setAuthor($author = '') { + if (!isset($this->author) && strlen(trim($author)) > 0) { + $this->author = (string) trim($author); + } // end if + } // end function + + //------------------------------------------------- + // Sets $comments variable + //------------------------------------------------- + // @desc Sets $comments variable + // @param (string) $comments + // @return (void) + // @access private + // @see $comments + // @since 1.001 - 2003/05/30 + //------------------------------------------------- + function setComments($comments = '') { + if (!isset($this->comments) && strlen(trim($comments)) > 0) { + $this->comments = (string) trim($comments); + } // end if + } // end function + + //------------------------------------------------- + // Returns $about variable + //------------------------------------------------- + // @desc Returns $about variable + // @return (string) $about + // @access public + // @see $about + //------------------------------------------------- + function getAbout() { + return (string) $this->about; + } // end function + + //------------------------------------------------- + // Returns $title variable + //------------------------------------------------- + // @desc Returns $title variable + // @return (string) $title + // @access public + // @see $title + //------------------------------------------------- + function getTitle() { + return (string) $this->title; + } // end function + + //------------------------------------------------- + // Returns $link variable + //------------------------------------------------- + // @desc Returns $link variable + // @return (string) $link + // @access public + // @see $link + //------------------------------------------------- + function getLink() { + return (string) $this->link; + } // end function + + //------------------------------------------------- + // Returns $description variable + //------------------------------------------------- + // @desc Returns $description variable + // @return (string) $description + // @access public + // @see $description + //------------------------------------------------- + function getDescription() { + return (string) $this->description; + } // end function + + //------------------------------------------------- + // Returns $subject variable + //------------------------------------------------- + // @desc Returns $subject variable + // @return (string) $subject + // @access public + // @see $subject + //------------------------------------------------- + function getSubject() { + return (string) $this->subject; + } // end function + + //------------------------------------------------- + // Returns $date variable + //------------------------------------------------- + // @desc Returns $date variable + // @return (string) $date + // @access public + // @see $date + //------------------------------------------------- + function getDate() { + return (string) $this->date; + } // end function + + //------------------------------------------------- + // Returns $author variable + //------------------------------------------------- + // @desc Returns $author variable + // @return (string) $author + // @access public + // @see $author + // @since 1.001 - 2003/05/30 + //------------------------------------------------- + function getAuthor() { + return (string) $this->author; + } // end function + + //------------------------------------------------- + // Returns $comments variable + //------------------------------------------------- + // @desc Returns $comments variable + // @return (string) $comments + // @access public + // @see $comments + // @since 1.001 - 2003/05/30 + //------------------------------------------------- + function getComments() { + return (string) $this->comments; + } // end function +} // end class RSSItem + +?> \ No newline at end of file diff --git a/includes/cls_session.php b/includes/cls_session.php new file mode 100755 index 0000000..24caf23 --- /dev/null +++ b/includes/cls_session.php @@ -0,0 +1,279 @@ +cls_session($db, $session_table, $session_data_table, $session_name, $session_id); + } + + function cls_session(&$db, $session_table, $session_data_table, $session_name = 'ECS_ID', $session_id = '') + { + $GLOBALS['_SESSION'] = array(); + + if (!empty($GLOBALS['cookie_path'])) + { + $this->session_cookie_path = $GLOBALS['cookie_path']; + } + else + { + $this->session_cookie_path = '/'; + } + + if (!empty($GLOBALS['cookie_domain'])) + { + $this->session_cookie_domain = $GLOBALS['cookie_domain']; + } + else + { + $this->session_cookie_domain = ''; + } + + if (!empty($GLOBALS['cookie_secure'])) + { + $this->session_cookie_secure = $GLOBALS['cookie_secure']; + } + else + { + $this->session_cookie_secure = false; + } + + $this->session_name = $session_name; + $this->session_table = $session_table; + $this->session_data_table = $session_data_table; + + $this->db = $db; + $this->_ip = real_ip(); + + if ($session_id == '' && !empty($_COOKIE[$this->session_name])) + { + $this->session_id = $_COOKIE[$this->session_name]; + } + else + { + $this->session_id = $session_id; + } + + if ($this->session_id) + { + $tmp_session_id = substr($this->session_id, 0, 32); + if ($this->gen_session_key($tmp_session_id) == substr($this->session_id, 32)) + { + $this->session_id = $tmp_session_id; + } + else + { + $this->session_id = ''; + } + } + + $this->_time = time(); + + if ($this->session_id) + { + $this->load_session(); + } + else + { + $this->gen_session_id(); + + setcookie($this->session_name, $this->session_id . $this->gen_session_key($this->session_id), 0, $this->session_cookie_path, $this->session_cookie_domain, $this->session_cookie_secure); + } + + register_shutdown_function(array(&$this, 'close_session')); + } + + function gen_session_id() + { + $this->session_id = md5(uniqid(mt_rand(), true)); + + return $this->insert_session(); + } + + function gen_session_key($session_id) + { + static $ip = ''; + +// if ($ip == '') +// { +// $ip = substr($this->_ip, 0, strrpos($this->_ip, '.')); +// } + +// return sprintf('%08x', crc32(ROOT_PATH . $session_id . $ip)); + return sprintf('%08x', crc32(!empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] . ROOT_PATH . $ip . $session_id : ROOT_PATH . $ip . $session_id)); + } + + function insert_session() + { + return $this->db->query('INSERT INTO ' . $this->session_table . " (sesskey, expiry, ip, data) VALUES ('" . $this->session_id . "', '". $this->_time ."', '". $this->_ip ."', 'a:0:{}')"); + } + + function load_session() + { + $session = $this->db->getRow('SELECT userid, agentid, adminid, user_name, user_rank, discount, email, data, expiry FROM ' . $this->session_table . " WHERE sesskey = '" . $this->session_id . "'"); + if (empty($session)) + { + $this->insert_session(); + + $this->session_expiry = 0; + $this->session_md5 = '40cd750bba9870f18aada2478b24840a'; + $GLOBALS['_SESSION'] = array(); + } + else + { + if (!empty($session['data']) && $this->_time - $session['expiry'] <= $this->login_max_life_time) + { + $this->session_expiry = $session['expiry']; + $this->session_md5 = md5($session['data']); + $GLOBALS['_SESSION'] = unserialize($session['data']); + $GLOBALS['_SESSION']['user_id'] = $session['userid']; + $GLOBALS['_SESSION']['agent_id'] = $session['agentid']; + $GLOBALS['_SESSION']['admin_id'] = $session['adminid']; + $GLOBALS['_SESSION']['user_name'] = $session['user_name']; + $GLOBALS['_SESSION']['user_rank'] = $session['user_rank']; + $GLOBALS['_SESSION']['discount'] = $session['discount']; + $GLOBALS['_SESSION']['email'] = $session['email']; + } + else + { + $session_data = $this->db->getRow('SELECT data, expiry FROM ' . $this->session_data_table . " WHERE sesskey = '" . $this->session_id . "'"); + if (!empty($session_data['data']) && $this->_time - $session_data['expiry'] <= $this->login_max_life_time) + { + $this->session_expiry = $session_data['expiry']; + $this->session_md5 = md5($session_data['data']); + $GLOBALS['_SESSION'] = unserialize($session_data['data']); + $GLOBALS['_SESSION']['user_id'] = $session['userid']; + $GLOBALS['_SESSION']['agent_id'] = $session['agentid']; + $GLOBALS['_SESSION']['admin_id'] = $session['adminid']; + $GLOBALS['_SESSION']['user_name'] = $session['user_name']; + $GLOBALS['_SESSION']['user_rank'] = $session['user_rank']; + $GLOBALS['_SESSION']['discount'] = $session['discount']; + $GLOBALS['_SESSION']['email'] = $session['email']; + } + else + { + $this->session_expiry = 0; + $this->session_md5 = '40cd750bba9870f18aada2478b24840a'; + $GLOBALS['_SESSION'] = array(); + } + } + } + } + + function update_session() + { + $adminid = !empty($GLOBALS['_SESSION']['admin_id']) ? intval($GLOBALS['_SESSION']['admin_id']) : 0; + $agentid = !empty($GLOBALS['_SESSION']['agent_id']) ? intval($GLOBALS['_SESSION']['agent_id']) : 0; + $userid = !empty($GLOBALS['_SESSION']['user_id']) ? intval($GLOBALS['_SESSION']['user_id']) : 0; + $user_name = !empty($GLOBALS['_SESSION']['user_name']) ? trim($GLOBALS['_SESSION']['user_name']) : 0; + $user_rank = !empty($GLOBALS['_SESSION']['user_rank']) ? intval($GLOBALS['_SESSION']['user_rank']) : 0; + $discount = !empty($GLOBALS['_SESSION']['discount']) ? round($GLOBALS['_SESSION']['discount'], 2) : 0; + $email = !empty($GLOBALS['_SESSION']['email']) ? trim($GLOBALS['_SESSION']['email']) : 0; + unset($GLOBALS['_SESSION']['admin_id']); + unset($GLOBALS['_SESSION']['user_id']); + unset($GLOBALS['_SESSION']['user_name']); + unset($GLOBALS['_SESSION']['user_rank']); + unset($GLOBALS['_SESSION']['discount']); + unset($GLOBALS['_SESSION']['email']); + + $data = serialize($GLOBALS['_SESSION']); + $this->_time = time(); + + if ($this->session_md5 == md5($data) && $this->_time < $this->session_expiry + 10) + { + return true; + } + + $data = addslashes($data); + + if (isset($data{255})) + { + $this->db->autoReplace($this->session_data_table, array('sesskey' => $this->session_id, 'expiry' => $this->_time, 'data' => $data), array('expiry' => $this->_time,'data' => $data)); + + $data = ''; + } + + return $this->db->query('UPDATE ' . $this->session_table . " SET expiry = '" . $this->_time . "', ip = '" . $this->_ip . "', userid = '" . $userid . "', agentid = '" . $agentid . "', adminid = '" . $adminid . "', user_name='" . $user_name . "', user_rank='" . $user_rank . "', discount='" . $discount . "', email='" . $email . "', data = '$data' WHERE sesskey = '" . $this->session_id . "' LIMIT 1"); + } + + function close_session() + { + $this->update_session(); + + /* 随机对 sessions_data 的库进行删除操作 */ + if (mt_rand(0, 2) == 2) + { + $this->db->query('DELETE FROM ' . $this->session_data_table . ' WHERE expiry < ' . ($this->_time - $this->max_life_time)); + } + + if ((time() % 2) == 0) + { + $this->db->query('DELETE FROM ' . $this->session_table . ' WHERE userid=0 and adminid=0 and agentid=0 and expiry < ' . ($this->_time - $this->max_life_time)); + } + + $this->db->query('DELETE FROM ' . $this->session_table . ' WHERE expiry < ' . ($this->_time - $this->login_max_life_time)); + + return true; + } + + function delete_spec_admin_session($adminid) + { + if (!empty($GLOBALS['_SESSION']['admin_id']) && $adminid) + { + return $this->db->query('DELETE FROM ' . $this->session_table . " WHERE adminid = '$adminid'"); + } + else + { + return false; + } + } + + function destroy_session() + { + $GLOBALS['_SESSION'] = array(); + + setcookie($this->session_name, $this->session_id, 1, $this->session_cookie_path, $this->session_cookie_domain, $this->session_cookie_secure); + + /* ECSHOP 自定义执行部分 */ + + $this->db->query('DELETE FROM ' . $this->session_data_table . " WHERE sesskey = '" . $this->session_id . "' LIMIT 1"); + + return $this->db->query('DELETE FROM ' . $this->session_table . " WHERE sesskey = '" . $this->session_id . "' LIMIT 1"); + } + + function get_session_id() + { + return $this->session_id; + } + + function get_users_count() + { + return $this->db->getOne('SELECT count(*) FROM ' . $this->session_table); + } +} + +?> \ No newline at end of file diff --git a/includes/cls_sms.php b/includes/cls_sms.php new file mode 100755 index 0000000..5f35365 --- /dev/null +++ b/includes/cls_sms.php @@ -0,0 +1,397 @@ + 'http://api.sms.shopex.cn', + 'send' => 'http://api.sms.shopex.cn', + 'servertime' => 'http://webapi.sms.shopex.cn' + + ); + /** + * 存放MYSQL对象 + * + * @access private + * @var object $db + */ + var $db = null; + + /** + * 存放ECS对象 + * + * @access private + * @var object $ecs + */ + var $ecs = null; + + /** + * 存放transport对象 + * + * @access private + * @var object $t + */ + var $t = null; + + /** + * 存放程序执行过程中的错误信息,这样做的一个好处是:程序可以支持多语言。 + * 程序在执行相关的操作时,error_no值将被改变,可能被赋为空或大等0的数字. + * 为空或0表示动作成功;大于0的数字表示动作失败,该数字代表错误号。 + * + * @access public + * @var array $errors + */ + var $errors = array('api_errors' => array('error_no' => -1, 'error_msg' => ''), + 'server_errors' => array('error_no' => -1, 'error_msg' => '')); + + /** + * 构造函数 + * + * @access public + * @return void + */ + function __construct() + { + $this->sms(); + } + + /** + * 构造函数 + * + * @access public + * @return void + */ + function sms() + { + /* 由于要包含init.php,所以这两个对象一定是存在的,因此直接赋值 */ + $this->db = $GLOBALS['db']; + $this->ecs = $GLOBALS['ecs']; + + /* 此处最好不要从$GLOBALS数组里引用,防止出错 */ + $this->t = new transport(-1, -1, -1, false); + $this->json = new Services_JSON; + } + + /* 发送短消息 + * + * @access public + * @param string $phone 要发送到哪些个手机号码,传的值是一个数组 + * @param string $msg 发送的消息内容 + */ + function send($phones,$msg,$send_date = '', $send_num = 1,$sms_type='',$version='1.0') + { + + /* 检查发送信息的合法性 */ + $contents=$this->get_contents($phones, $msg); + if(!$contents) + { + $this->errors['server_errors']['error_no'] = 3;//发送的信息有误 + return false; + } + + $login_info = $this->getSmsInfo(); + if (!$login_info) + { + $this->errors['server_errors']['error_no'] = 5;//无效的身份信息 + + return false; + } + else + { + if($login_info['info']['account_info']['active']!='1') + { + $this->errors['server_errors']['error_no'] = 11;//短信功能没有激活 + return false; + } + + } + /* 获取API URL */ + $sms_url = $this->get_url('send'); + + if (!$sms_url) + { + $this->errors['server_errors']['error_no'] = 6;//URL不对 + + return false; + } + + $send_str['contents']= $this->json->encode($contents); + $send_str['certi_app']='sms.send'; + $send_str['entId']=$GLOBALS['_CFG']['ent_id']; + $send_str['entPwd']=$GLOBALS['_CFG']['ent_ac']; + $send_str['license']=$GLOBALS['_CFG']['certificate_id']; + $send_str['source']=SOURCE_ID; + $send_str['sendType'] = 'notice'; + $send_str['use_backlist'] = '1'; + $send_str['version'] = $version; + $send_str['format']='json'; + $send_str['timestamp'] = $this->getTime(); + $send_str['certi_ac']=$this->make_shopex_ac($send_str,SOURCE_TOKEN); + $sms_url= $this->get_url('send'); + /* 发送HTTP请求 */ + $response = $this->t->request($sms_url, $send_str,'POST'); + $result = $this->json->decode($response['body'], true); + + if($result['res'] == 'succ') + { + return true; + } + elseif($result['res'] == 'fail') + { + return false; + } + + } + + + + + /** + * 检测启用短信服务需要的信息 + * + * @access private + * @param string $email 邮箱 + * @param string $password 密码 + * @return boolean 如果启用信息格式合法就返回true,否则返回false。 + */ + function check_enable_info($email, $password) + { + if (empty($email) || empty($password)) + { + return false; + } + + return true; + } + + //查询是否已有通行证 + function has_registered() + { + $sql = 'SELECT `value` + FROM ' . $this->ecs->table('shop_config') . " + WHERE `code` = 'ent_id'"; + + $result = $this->db->getOne($sql); + + if (empty($result)) + { + return false; + } + + return true; + } + function get_site_info() + { + /* 获得当前处于会话状态的管理员的邮箱 */ + $email = $this->get_admin_email(); + $email = $email ? $email : ''; + /* 获得当前网店的域名 */ + $domain = $this->ecs->get_domain(); + $domain = $domain ? $domain : ''; + /* 赋给smarty模板 */ + $sms_site_info['email'] = $email; + $sms_site_info['domain'] = $domain; + + return $sms_site_info; + } + function get_site_url() + { + $url = $this->ecs->url(); + $url = $url ? $url : ''; + return $url; + } + /** + * 获得当前处于会话状态的管理员的邮箱 + * + * @access private + * @return string or boolean 成功返回管理员的邮箱,否则返回false。 + */ + function get_admin_email() + { + $sql = 'SELECT `email` FROM ' . $this->ecs->table('admin_user') . " WHERE `user_id` = '" . $_SESSION['admin_id'] . "'"; + $email = $this->db->getOne($sql); + + if (empty($email)) + { + return false; + } + + return $email; + } + //用户短信账户信息获取 + function getSmsInfo($certi_app='sms.info',$version='1.0', $format='json'){ + $send_str['certi_app'] = $certi_app; + $send_str['entId'] = $GLOBALS['_CFG']['ent_id']; + $send_str['entPwd'] = $GLOBALS['_CFG']['ent_ac']; + $send_str['source'] = SOURCE_ID; + $send_str['version'] = $version; + $send_str['format'] = $format; + $send_str['timestamp'] = $this->getTime(); + $send_str['certi_ac'] = $this->make_shopex_ac($send_str,SOURCE_TOKEN); + $sms_url = $this->get_url('info'); + $response = $this->t->request($sms_url, $send_str,'POST'); + $result = $this->json->decode($response['body'],true); + if($result['res'] == 'succ') + { + return $result; + } + elseif($result['res'] == 'fail') + { + return false; + } + } + + //检查手机号和发送的内容并生成生成短信队列 + function get_contents($phones,$msg) + { + if (empty($phones) || empty($msg)) + { + return false; + } + $phone_key=0; + + $phones=explode(',',$phones); + foreach($phones as $key => $value) + { + if($i<200) + { + $i++; + } + else + { + $i=0; + $phone_key++; + } + if($this->is_moblie($value)) + { + $phone[$phone_key][]=$value; + } + else + { + $i--; + } + } + if(!empty($phone)) + { + foreach($phone as $phone_key => $val) + { + if (EC_CHARSET != 'utf-8') + { + $phone_array[$phone_key]['phones']=implode(',',$val); + $phone_array[$phone_key]['content']=iconv('gb2312','utf-8',$msg); + } + else + { + $phone_array[$phone_key]['phones']=implode(',',$val); + $phone_array[$phone_key]['content']=$msg; + } + + } + return $phone_array; + } + else + { + return false; + } + + } + + //获得服务器时间 + function getTime(){ + $Tsend_str['certi_app'] = 'sms.servertime'; + $Tsend_str['version'] = '1.0' ; + $Tsend_str['format'] = 'json' ; + $Tsend_str['certi_ac'] = $this->make_shopex_ac($Tsend_str,'SMS_TIME'); + $sms_url = $this->get_url('servertime'); + $response = $this->t->request($sms_url, $Tsend_str,'POST'); + + $result = $this->json->decode($response['body'], true); + return $result['info']; + + } + /** + * 返回指定键名的URL + * + * @access public + * @param string $key URL的名字,即数组的键名 + * @return string or boolean 如果由形参指定的键名对应的URL值存在就返回该URL,否则返回false。 + */ + function get_url($key) + { + $url = $this->api_urls[$key]; + + if (empty($url)) + { + return false; + } + + return $url; + } + /** + * 检测手机号码是否正确 + * + */ + function is_moblie($moblie) + { + return preg_match("/^0?1((3|8)[0-9]|5[0-35-9]|4[57])\d{8}$/", $moblie); + } + + //加密算法 + function make_shopex_ac($temp_arr,$token) + { + ksort($temp_arr); + $str = ''; + foreach($temp_arr as $key=>$value) + { + if($key!=' certi_ac') + { + $str.= $value; + } + } + return strtolower(md5($str.strtolower(md5($token)))); + } + function base_encode($str) + { + $str = base64_encode($str); + return strtr($str, $this->pattern()); + } + function pattern() + { + return array( + '+'=>'_1_', + '/'=>'_2_', + '='=>'_3_', + ); + } + +} + +?> \ No newline at end of file diff --git a/includes/cls_smtp.php b/includes/cls_smtp.php new file mode 100755 index 0000000..a9e555a --- /dev/null +++ b/includes/cls_smtp.php @@ -0,0 +1,346 @@ +timeout = 10; + $this->status = SMTP_STATUS_NOT_CONNECTED; + $this->host = 'localhost'; + $this->port = 25; + $this->auth = false; + $this->user = ''; + $this->pass = ''; + $this->errors = array(); + + foreach ($params AS $key => $value) + { + $this->$key = $value; + } + + $this->helo = $this->host; + + // 如果没有设置用户名则不验证 + $this->auth = ('' == $this->user) ? false : true; + } + + function connect($params = array()) + { + if (!isset($this->status)) + { + $obj = new smtp($params); + + if ($obj->connect()) + { + $obj->status = SMTP_STATUS_CONNECTED; + } + + return $obj; + } + else + { + if (!empty($GLOBALS['_CFG']['smtp_ssl'])) + { + $this->host = "ssl://" . $this->host; + } + $this->connection = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout); + + if ($this->connection === false) + { + $this->errors[] = 'Access is denied.'; + + return false; + } + + @socket_set_timeout($this->connection, 0, 250000); + + $greeting = $this->get_data(); + + if (is_resource($this->connection)) + { + $this->status = 2; + + return $this->auth ? $this->ehlo() : $this->helo(); + } + else + { + log_write($errstr, __FILE__, __LINE__); + $this->errors[] = 'Failed to connect to server: ' . $errstr; + + return false; + } + } + } + + /** + * 参数为数组 + * recipients 接收人的数组 + * from 发件人的地址,也将作为回复地址 + * headers 头部信息的数组 + * body 邮件的主体 + */ + + function send($params = array()) + { + foreach ($params AS $key => $value) + { + $this->$key = $value; + } + + if ($this->is_connected()) + { + // 服务器是否需要验证 + if ($this->auth) + { + if (!$this->auth()) + { + return false; + } + } + + $this->mail($this->from); + + if (is_array($this->recipients)) + { + foreach ($this->recipients AS $value) + { + $this->rcpt($value); + } + } + else + { + $this->rcpt($this->recipients); + } + + if (!$this->data()) + { + return false; + } + + $headers = str_replace(CRLF . '.', CRLF . '..', trim(implode(CRLF, $this->headers))); + $body = str_replace(CRLF . '.', CRLF . '..', $this->body); + $body = substr($body, 0, 1) == '.' ? '.' . $body : $body; + + $this->send_data($headers); + $this->send_data(''); + $this->send_data($body); + $this->send_data('.'); + + return (substr($this->get_data(), 0, 3) === '250'); + } + else + { + $this->errors[] = 'Not connected!'; + + return false; + } + } + + function helo() + { + if (is_resource($this->connection) + AND $this->send_data('HELO ' . $this->helo) + AND substr($error = $this->get_data(), 0, 3) === '250' ) + { + return true; + } + else + { + $this->errors[] = 'HELO command failed, output: ' . trim(substr($error, 3)); + + return false; + } + } + + function ehlo() + { + if (is_resource($this->connection) + AND $this->send_data('EHLO ' . $this->helo) + AND substr($error = $this->get_data(), 0, 3) === '250' ) + { + return true; + } + else + { + $this->errors[] = 'EHLO command failed, output: ' . trim(substr($error, 3)); + + return false; + } + } + + function auth() + { + if (is_resource($this->connection) + AND $this->send_data('AUTH LOGIN') + AND substr($error = $this->get_data(), 0, 3) === '334' + AND $this->send_data(base64_encode($this->user)) // Send username + AND substr($error = $this->get_data(),0,3) === '334' + AND $this->send_data(base64_encode($this->pass)) // Send password + AND substr($error = $this->get_data(),0,3) === '235' ) + { + return true; + } + else + { + $this->errors[] = 'AUTH command failed: ' . trim(substr($error, 3)); + + return false; + } + } + + function mail($from) + { + if ($this->is_connected() + AND $this->send_data('MAIL FROM:<' . $from . '>') + AND substr($this->get_data(), 0, 2) === '250' ) + { + return true; + } + else + { + return false; + } + } + + function rcpt($to) + { + if ($this->is_connected() + AND $this->send_data('RCPT TO:<' . $to . '>') + AND substr($error = $this->get_data(), 0, 2) === '25') + { + return true; + } + else + { + $this->errors[] = trim(substr($error, 3)); + + return false; + } + } + + function data() + { + if ($this->is_connected() + AND $this->send_data('DATA') + AND substr($error = $this->get_data(), 0, 3) === '354' ) + { + return true; + } + else + { + $this->errors[] = trim(substr($error, 3)); + + return false; + } + } + + function is_connected() + { + return (is_resource($this->connection) AND ($this->status === SMTP_STATUS_CONNECTED)); + } + + function send_data($data) + { + if (is_resource($this->connection)) + { + return fwrite($this->connection, $data . CRLF, strlen($data) + 2); + } + else + { + return false; + } + } + + function get_data() + { + $return = ''; + $line = ''; + + if (is_resource($this->connection)) + { + while (strpos($return, CRLF) === false OR $line{3} !== ' ') + { + $line = fgets($this->connection, 512); + $return .= $line; + } + + return trim($return); + } + else + { + return ''; + } + } + + /** + * 获得最后一个错误信息 + * + * @access public + * @return string + */ + function error_msg() + { + if (!empty($this->errors)) + { + $len = count($this->errors) - 1; + return $this->errors[$len]; + } + else + { + return ''; + } + } +} + +?> \ No newline at end of file diff --git a/includes/cls_sql_executor.php b/includes/cls_sql_executor.php new file mode 100755 index 0000000..0a45aa0 --- /dev/null +++ b/includes/cls_sql_executor.php @@ -0,0 +1,912 @@ +sql_executor($db, $charset, $sprefix, $tprefix, $log_path, $auto_match, $ignored_errors); + } + + /** + * 构造函数 + * + * @access public + * @param mysql $db mysql类对象 + * @param string $charset 字符集 + * @param string $sprefix 替换前表前缀 + * @param string $tprefix 替换后表前缀 + * @param string $log_path 日志路径 + * @param boolean $auto_match 是否进行智能化查询 + * @param array $ignored_errors 忽略的错误号数组 + * @return void + */ + function sql_executor($db, $charset = 'gbk', $sprefix = 'ecs_', $tprefix = 'ecs_', $log_path = '', $auto_match = false, $ignored_errors = array()) + { + $this->db = $db; + $this->db_charset = $charset; + $this->source_prefix = $sprefix; + $this->target_prefix = $tprefix; + $this->log_path = $log_path; + $this->auto_match = $auto_match; + $this->ignored_errors = $ignored_errors; + } + + /** + * 执行所有SQL文件中所有的SQL语句 + * + * @access public + * @param array $sql_files 文件绝对路径组成的一维数组 + * @return boolean 执行成功返回true,失败返回false。 + */ + function run_all($sql_files) + { + /* 如果传入参数不是数组,程序直接返回 */ + if (!is_array($sql_files)) + { + return false; + } + + foreach ($sql_files AS $sql_file) + { + $query_items = $this->parse_sql_file($sql_file); + + /* 如果解析失败,则跳过 */ + if (!$query_items) + { + continue; + } + + foreach ($query_items AS $query_item) + { + /* 如果查询项为空,则跳过 */ + if (!$query_item) + { + continue; + } + + if (!$this->query($query_item)) + { + return false; + } + } + } + + return true; + } + + /** + * 获得分散的查询项 + * + * @access public + * @param string $file_path 文件的绝对路径 + * @return mixed 解析成功返回分散的查询项数组,失败返回false。 + */ + function parse_sql_file($file_path) + { + /* 如果SQL文件不存在则返回false */ + if (!file_exists($file_path)) + { + return false; + } + + /* 记录当前正在运行的SQL文件 */ + $this->current_file = $file_path; + + /* 读取SQL文件 */ + $sql = implode('', file($file_path)); + + /* 删除SQL注释,由于执行的是replace操作,所以不需要进行检测。下同。 */ + $sql = $this->remove_comment($sql); + + /* 删除SQL串首尾的空白符 */ + $sql = trim($sql); + + /* 如果SQL文件中没有查询语句则返回false */ + if (!$sql) + { + return false; + } + + /* 替换表前缀 */ + $sql = $this->replace_prefix($sql); + + /* 解析查询项 */ + $sql = str_replace("\r", '', $sql); + $query_items = explode(";\n", $sql); + + return $query_items; + } + + /** + * 执行某一个查询项 + * + * @access public + * @param string $query_item 查询项 + * @return boolean 成功返回true,失败返回false。 + */ + function query($query_item) + { + /* 删除查询项首尾的空白符 */ + $query_item = trim($query_item); + + /* 如果查询项为空则返回false */ + if (!$query_item) + { + return false; + } + + /* 处理建表操作 */ + if (preg_match('/^\s*CREATE\s+TABLE\s*/i', $query_item)) + { + if (!$this->create_table($query_item)) + { + return false; + } + } + /* 处理ALTER TABLE语句,此时程序将对表的结构进行修改 */ + elseif ($this->auto_match && preg_match('/^\s*ALTER\s+TABLE\s*/i', $query_item)) + { + if (!$this->alter_table($query_item)) + { + return false; + } + } + /* 处理其它修改操作,如数据添加、更新、删除等 */ + else + { + if (!$this->do_other($query_item)) + { + return false; + } + } + + return true; + } + + /** + * 过滤SQL查询串中的注释。该方法只过滤SQL文件中独占一行或一块的那些注释。 + * + * @access public + * @param string $sql SQL查询串 + * @return string 返回已过滤掉注释的SQL查询串。 + */ + function remove_comment($sql) + { + /* 删除SQL行注释,行注释不匹配换行符 */ + $sql = preg_replace('/^\s*(?:--|#).*/m', '', $sql); + + /* 删除SQL块注释,匹配换行符,且为非贪婪匹配 */ + //$sql = preg_replace('/^\s*\/\*(?:.|\n)*\*\//m', '', $sql); + $sql = preg_replace('/^\s*\/\*.*?\*\//ms', '', $sql); + + return $sql; + } + + /** + * 替换查询串中数据表的前缀。该方法只对下列查询有效:CREATE TABLE, + * DROP TABLE, ALTER TABLE, UPDATE, REPLACE INTO, INSERT INTO + * + * @access public + * @param string $sql SQL查询串 + * @return string 返回已替换掉前缀的SQL查询串。 + */ + function replace_prefix($sql) + { + $keywords = 'CREATE\s+TABLE(?:\s+IF\s+NOT\s+EXISTS)?|' + . 'DROP\s+TABLE(?:\s+IF\s+EXISTS)?|' + . 'ALTER\s+TABLE|' + . 'UPDATE|' + . 'REPLACE\s+INTO|' + . 'DELETE\s+FROM|' + . 'INSERT\s+INTO'; + + $pattern = '/(' . $keywords . ')(\s*)`?' . $this->source_prefix . '(\w+)`?(\s*)/i'; + $replacement = '\1\2`' . $this->target_prefix . '\3`\4'; + $sql = preg_replace($pattern, $replacement, $sql); + + $pattern = '/(UPDATE.*?WHERE)(\s*)`?' . $this->source_prefix . '(\w+)`?(\s*\.)/i'; + $replacement = '\1\2`' . $this->target_prefix . '\3`\4'; + $sql = preg_replace($pattern, $replacement, $sql); + + return $sql; + } + + /** + * 获取表的名字。该方法只对下列查询有效:CREATE TABLE, + * DROP TABLE, ALTER TABLE, UPDATE, REPLACE INTO, INSERT INTO + * + * @access public + * @param string $query_item SQL查询项 + * @param string $query_type 查询类型 + * @return mixed 成功返回表的名字,失败返回false。 + */ + function get_table_name($query_item, $query_type = '') + { + $pattern = ''; + $matches = array(); + $table_name = ''; + + /* 如果没指定$query_type,则自动获取 */ + if (!$query_type && preg_match('/^\s*(\w+)/', $query_item, $matches)) + { + $query_type = $matches[1]; + } + + /* 获取相应的正则表达式 */ + $query_type = strtoupper($query_type); + switch ($query_type) + { + case 'ALTER' : + $pattern = '/^\s*ALTER\s+TABLE\s*`?(\w+)/i'; + break; + case 'CREATE' : + $pattern = '/^\s*CREATE\s+TABLE(?:\s+IF\s+NOT\s+EXISTS)?\s*`?(\w+)/i'; + break; + case 'DROP' : + $pattern = '/^\s*DROP\s+TABLE(?:\s+IF\s+EXISTS)?\s*`?(\w+)/i'; + break; + case 'INSERT' : + $pattern = '/^\s*INSERT\s+INTO\s*`?(\w+)/i'; + break; + case 'REPLACE' : + $pattern = '/^\s*REPLACE\s+INTO\s*`?(\w+)/i'; + break; + case 'UPDATE' : + $pattern = '/^\s*UPDATE\s*`?(\w+)/i'; + break; + default : + return false; + } + + if (!preg_match($pattern, $query_item, $matches)) + { + return false; + } + $table_name = $matches[1]; + + return $table_name; + } + + /** + * 获得SQL文件中指定的查询项 + * + * @access public + * @param string $file_path SQL查询项 + * @param int $pos 查询项的索引号 + * @return mixed 成功返回该查询项,失败返回false。 + */ + function get_spec_query_item($file_path, $pos) + { + $query_items = $this->parse_sql_file($file_path); + + if (empty($query_items) + || empty($query_items[$pos])) + { + return false; + } + + return $query_items[$pos]; + } + + /** + * 概据MYSQL版本,创建数据表 + * + * @access public + * @param string $query_item SQL查询项 + * @return boolean 成功返回true,失败返回false。 + */ + function create_table($query_item) + { + /* 获取建表主体串以及表属性声明串,不区分大小写,匹配换行符,且为贪婪匹配 */ + $pattern = '/^\s*(CREATE\s+TABLE[^(]+\(.*\))(.*)$/is'; + if (!preg_match($pattern, $query_item, $matches)) + { + return false; + } + $main = $matches[1]; + $postfix = $matches[2]; + + /* 从表属性声明串中查找表的类型 */ + $pattern = '/.*(?:ENGINE|TYPE)\s*=\s*([a-z]+).*$/is'; + $type = preg_match($pattern, $postfix, $matches) ? $matches[1] : 'MYISAM'; + + /* 从表属性声明串中查找自增语句 */ + $pattern = '/.*(AUTO_INCREMENT\s*=\s*\d+).*$/is'; + $auto_incr = preg_match($pattern, $postfix, $matches) ? $matches[1] : ''; + + /* 重新设置表属性声明串 */ + $postfix = $this->db->version() > '4.1' ? " ENGINE=$type DEFAULT CHARACTER SET " . $this->db_charset + : " TYPE=$type"; + $postfix .= ' ' . $auto_incr; + + /* 重新构造建表语句 */ + $sql = $main . $postfix; + + /* 开始创建表 */ + if (!$this->db->query($sql, 'SILENT')) + { + $this->handle_error($sql); + return false; + } + + return true; + } + + /** + * 修改数据表的方法。算法设计思路: + * 1. 先进行字段修改操作。CHANGE + * 2. 然后进行字段移除操作。DROP [COLUMN] + * 3. 接着进行字段添加操作。ADD [COLUMN] + * 4. 进行索引移除操作。DROP INDEX + * 5. 进行索引添加操作。ADD INDEX + * 6. 最后进行其它操作。 + * + * @access public + * @param string $query_item SQL查询项 + * @return boolean 修改成功返回true,否则返回false + */ + function alter_table($query_item) + { + /* 获取表名 */ + $table_name = $this->get_table_name($query_item, 'ALTER'); + if (!$table_name) + { + return false; + } + + /* 先把CHANGE操作提取出来执行,再过滤掉它们 */ + $result = $this->parse_change_query($query_item, $table_name); + if ($result[0] && !$this->db->query($result[0], 'SILENT')) + { + $this->handle_error($result[0]); + return false; + } + if (!$result[1]) + { + return true; + } + + /* 把DROP [COLUMN]提取出来执行,再过滤掉它们 */ + $result = $this->parse_drop_column_query($result[1], $table_name); + if ($result[0] && !$this->db->query($result[0], 'SILENT')) + { + $this->handle_error($result[0]); + return false; + } + if (!$result[1]) + { + return true; + } + + /* 把ADD [COLUMN]提取出来执行,再过滤掉它们 */ + $result = $this->parse_add_column_query($result[1], $table_name); + if ($result[0] && !$this->db->query($result[0], 'SILENT')) + { + $this->handle_error($result[0]); + return false; + } + if (!$result[1]) + { + return true; + } + + /* 把DROP INDEX提取出来执行,再过滤掉它们 */ + $result = $this->parse_drop_index_query($result[1], $table_name); + if ($result[0] && !$this->db->query($result[0], 'SILENT')) + { + $this->handle_error($result[0]); + return false; + } + if (!$result[1]) + { + return true; + } + + /* 把ADD INDEX提取出来执行,再过滤掉它们 */ + $result = $this->parse_add_index_query($result[1], $table_name); + if ($result[0] && !$this->db->query($result[0], 'SILENT')) + { + $this->handle_error($result[0]); + return false; + } + /* 执行其它的修改操作 */ + if ($result[1] && !$this->db->query($result[1], 'SILENT')) + { + $this->handle_error($result[1]); + return false; + } + + return true; + } + + /** + * 解析出CHANGE操作 + * + * @access public + * @param string $query_item SQL查询项 + * @param string $table_name 表名 + * @return array 返回一个以CHANGE操作串和其它操作串组成的数组 + */ + function parse_change_query($query_item, $table_name = '') + { + $result = array('', $query_item); + + if (!$table_name) + { + $table_name = $this->get_table_name($query_item, 'ALTER'); + } + + $matches = array(); + /* 第1个子模式匹配old_col_name,第2个子模式匹配column_definition,第3个子模式匹配new_col_name */ + $pattern = '/\s*CHANGE\s*`?(\w+)`?\s*`?(\w+)`?([^,(]+\([^,]+?(?:,[^,)]+)*\)[^,]+|[^,;]+)\s*,?/i'; + if (preg_match_all($pattern, $query_item, $matches, PREG_SET_ORDER)) + { + $fields = $this->get_fields($table_name); + $num = count($matches); + $sql = ''; + for ($i = 0; $i < $num; $i++) + { + /* 如果表中存在原列名 */ + if (in_array($matches[$i][1], $fields)) + { + $sql .= $matches[$i][0]; + } + /* 如果表中存在新列名 */ + elseif (in_array($matches[$i][2], $fields)) + { + $sql .= 'CHANGE ' . $matches[$i][2] . ' ' . $matches[$i][2] . ' ' . $matches[$i][3] . ','; + } + else /* 如果两个列名都不存在 */ + { + $sql .= 'ADD ' . $matches[$i][2] . ' ' . $matches[$i][3] . ','; + $sql = preg_replace('/(\s+AUTO_INCREMENT)/i', '\1 PRIMARY KEY', $sql); + } + } + $sql = 'ALTER TABLE ' . $table_name . ' ' . $sql; + $result[0] = preg_replace('/\s*,\s*$/', '', $sql);//存储CHANGE操作,已过滤末尾的逗号 + $result[0] = $this->insert_charset($result[0]);//加入字符集设置 + $result[1] = preg_replace($pattern, '', $query_item);//存储其它操作 + $result[1] = $this->has_other_query($result[1]) ? $result[1]: ''; + } + + return $result; + } + + /** + * 解析出DROP COLUMN操作 + * + * @access public + * @param string $query_item SQL查询项 + * @param string $table_name 表名 + * @return array 返回一个以DROP COLUMN操作和其它操作组成的数组 + */ + function parse_drop_column_query($query_item, $table_name = '') + { + $result = array('', $query_item); + + if (!$table_name) + { + $table_name = $this->get_table_name($query_item, 'ALTER'); + } + + $matches = array(); + /* 子模式存储列名 */ + $pattern = '/\s*DROP(?:\s+COLUMN)?(?!\s+(?:INDEX|PRIMARY))\s*`?(\w+)`?\s*,?/i'; + if (preg_match_all($pattern, $query_item, $matches, PREG_SET_ORDER)) + { + $fields = $this->get_fields($table_name); + $num = count($matches); + $sql = ''; + for ($i = 0; $i < $num; $i++) + { + if (in_array($matches[$i][1], $fields)) + { + $sql .= 'DROP ' . $matches[$i][1] . ','; + } + } + if ($sql) + { + $sql = 'ALTER TABLE ' . $table_name . ' ' . $sql; + $result[0] = preg_replace('/\s*,\s*$/', '', $sql);//过滤末尾的逗号 + } + $result[1] = preg_replace($pattern, '', $query_item);//过滤DROP COLUMN操作 + $result[1] = $this->has_other_query($result[1]) ? $result[1] : ''; + } + + return $result; + } + + /** + * 解析出ADD [COLUMN]操作 + * + * @access public + * @param string $query_item SQL查询项 + * @param string $table_name 表名 + * @return array 返回一个以ADD [COLUMN]操作和其它操作组成的数组 + */ + function parse_add_column_query($query_item, $table_name = '') + { + $result = array('', $query_item); + + if (!$table_name) + { + $table_name = $this->get_table_name($query_item, 'ALTER'); + } + + $matches = array(); + /* 第1个子模式存储列定义,第2个子模式存储列名 */ + $pattern = '/\s*ADD(?:\s+COLUMN)?(?!\s+(?:INDEX|UNIQUE|PRIMARY))\s*(`?(\w+)`?(?:[^,(]+\([^,]+?(?:,[^,)]+)*\)[^,]+|[^,;]+))\s*,?/i'; + if (preg_match_all($pattern, $query_item, $matches, PREG_SET_ORDER)) + { + $fields = $this->get_fields($table_name); + $mysql_ver = $this->db->version(); + $num = count($matches); + $sql = ''; + for ($i = 0; $i < $num; $i++) + { + if (in_array($matches[$i][2], $fields)) + { + /* 如果为低版本MYSQL,则把非法关键字过滤掉 */ + if ($mysql_ver < '4.0.1' ) + { + $matches[$i][1] = preg_replace('/\s*(?:AFTER|FIRST)\s*.*$/i', '', $matches[$i][1]); + } + $sql .= 'CHANGE ' . $matches[$i][2] . ' ' . $matches[$i][1] . ','; + } + else + { + $sql .= 'ADD ' . $matches[$i][1] . ','; + } + } + $sql = 'ALTER TABLE ' . $table_name . ' ' . $sql; + $result[0] = preg_replace('/\s*,\s*$/', '', $sql);//过滤末尾的逗号 + $result[0] = $this->insert_charset($result[0]);//加入字符集设置 + $result[1] = preg_replace($pattern, '', $query_item);//过滤ADD COLUMN操作 + $result[1] = $this->has_other_query($result[1]) ? $result[1] : ''; + } + + return $result; + } + + /** + * 解析出DROP INDEX操作 + * + * @access public + * @param string $query_item SQL查询项 + * @param string $table_name 表名 + * @return array 返回一个以DROP INDEX操作和其它操作组成的数组 + */ + function parse_drop_index_query($query_item, $table_name = '') + { + $result = array('', $query_item); + + if (!$table_name) + { + $table_name = $this->get_table_name($query_item, 'ALTER'); + } + + /* 子模式存储键名 */ + $pattern = '/\s*DROP\s+(?:PRIMARY\s+KEY|INDEX\s*`?(\w+)`?)\s*,?/i'; + if (preg_match_all($pattern, $query_item, $matches, PREG_SET_ORDER)) + { + $indexes = $this->get_indexes($table_name); + $num = count($matches); + $sql = ''; + for ($i = 0; $i < $num; $i++) + { + /* 如果子模式为空,删除主键 */ + if (empty($matches[$i][1])) + { + $sql .= 'DROP PRIMARY KEY,'; + } + /* 否则删除索引 */ + elseif (in_array($matches[$i][1], $indexes)) + { + $sql .= 'DROP INDEX ' . $matches[$i][1] . ','; + } + } + if ($sql) + { + $sql = 'ALTER TABLE ' . $table_name . ' ' . $sql; + $result[0] = preg_replace('/\s*,\s*$/', '', $sql);//存储DROP INDEX操作,已过滤末尾的逗号 + } + $result[1] = preg_replace($pattern, '', $query_item);//存储其它操作 + $result[1] = $this->has_other_query($result[1]) ? $result[1] : ''; + } + + return $result; + } + + /** + * 解析出ADD INDEX操作 + * + * @access public + * @param string $query_item SQL查询项 + * @param string $table_name 表名 + * @return array 返回一个以ADD INDEX操作和其它操作组成的数组 + */ + function parse_add_index_query($query_item, $table_name = '') + { + $result = array('', $query_item); + + if (!$table_name) + { + $table_name = $this->get_table_name($query_item, 'ALTER'); + } + + /* 第1个子模式存储索引定义,第2个子模式存储"PRIMARY KEY",第3个子模式存储键名,第4个子模式存储列名 */ + $pattern = '/\s*ADD\s+((?:INDEX|UNIQUE|(PRIMARY\s+KEY))\s*(?:`?(\w+)`?)?\s*\(\s*`?(\w+)`?\s*(?:,[^,)]+)*\))\s*,?/i'; + if (preg_match_all($pattern, $query_item, $matches, PREG_SET_ORDER)) + { + $indexes = $this->get_indexes($table_name); + $num = count($matches); + $sql = ''; + for ($i = 0; $i < $num; $i++) + { + $index = !empty($matches[$i][3]) ? $matches[$i][3] : $matches[$i][4]; + if (!empty($matches[$i][2]) && in_array('PRIMARY', $indexes)) + { + $sql .= 'DROP PRIMARY KEY,'; + } + elseif (in_array($index, $indexes)) + { + $sql .= 'DROP INDEX ' . $index . ','; + } + $sql .= 'ADD ' . $matches[$i][1] . ','; + } + $sql = 'ALTER TABLE ' . $table_name . ' ' . $sql; + $result[0] = preg_replace('/\s*,\s*$/', '', $sql);//存储ADD INDEX操作,已过滤末尾的逗号 + $result[1] = preg_replace($pattern, '', $query_item);//存储其它的操作 + $result[1] = $this->has_other_query($result[1]) ? $result[1] : ''; + } + + return $result; + } + + /** + * 获取所有的indexes + * + * @access public + * @param string $table_name 数据表名 + * @return array + */ + function get_indexes($table_name) + { + $indexes = array(); + + $result = $this->db->query("SHOW INDEX FROM $table_name", 'SILENT'); + + if ($result) + { + while ($row = $this->db->fetchRow($result)) + { + $indexes[] = $row['Key_name']; + } + } + + return $indexes; + } + + /** + * 获取所有的fields + * + * @access public + * @param string $table_name 数据表名 + * @return array + */ + function get_fields($table_name) + { + $fields = array(); + + $result = $this->db->query("SHOW FIELDS FROM $table_name", 'SILENT'); + + if ($result) + { + while ($row = $this->db->fetchRow($result)) + { + $fields[] = $row['Field']; + } + } + + return $fields; + } + + /** + * 判断是否还有其它的查询 + * + * @access private + * @param string $sql_string SQL查询串 + * @return boolean 有返回true,否则返回false + */ + function has_other_query($sql_string) + { + return preg_match('/^\s*ALTER\s+TABLE\s*`\w+`\s*\w+/i', $sql_string); + } + + /** + * 在查询串中加入字符集设置 + * + * @access private + * @param string $sql_string SQL查询串 + * @return string 含有字符集设置的SQL查询串 + */ + function insert_charset($sql_string) + { + if ($this->db->version() > '4.1') + { + $sql_string = preg_replace('/(TEXT|CHAR\(.*?\)|VARCHAR\(.*?\))\s+/i', + '\1 CHARACTER SET ' . $this->db_charset . ' ', + $sql_string); + } + + return $sql_string; + } + + /** + * 处理其它的数据库操作 + * + * @access private + * @param string $query_item SQL查询项 + * @return boolean 成功返回true,失败返回false。 + */ + function do_other($query_item) + { + if (!$this->db->query($query_item, 'SILENT')) + { + $this->handle_error($query_item); + return false; + } + + return true; + } + + /** + * 处理错误信息 + * + * @access private + * @param string $query_item SQL查询项 + * @return boolean 成功返回true,失败返回false。 + */ + function handle_error($query_item) + { + $mysql_error = 'ERROR NO: ' . $this->db->errno() + . "\r\nERROR MSG: " . $this->db->error(); + + $error_str = "SQL Error:\r\n " . $mysql_error + . "\r\n\r\n" + . "Query String:\r\n ". $query_item + . "\r\n\r\n" + . "File Path:\r\n ". $this->current_file + . "\r\n\r\n\r\n\r\n"; + + /* 过滤一些错误 */ + if (!in_array($this->db->errno(), $this->ignored_errors)) + { + $this->error = $error_str; + } + + if ($this->log_path) + { + $f = @fopen($this->log_path, 'ab+'); + if (!$f) + { + return false; + } + if (!@fwrite($f, $error_str)) + { + return false; + } + } + + return true; + } +} + +?> \ No newline at end of file diff --git a/includes/cls_template.php b/includes/cls_template.php new file mode 100755 index 0000000..38211ba --- /dev/null +++ b/includes/cls_template.php @@ -0,0 +1,1428 @@ +cls_template(); + } + + function cls_template() + { + $this->_errorlevel = error_reporting(); + $this->_nowtime = time(); + if (defined('EC_CHARSET')) + { + $charset = EC_CHARSET; + } + else + { + $charset = 'utf-8'; + } + header('Content-type: text/html; charset='.$charset); + } + + /** + * 注册变量 + * + * @access public + * @param mix $tpl_var + * @param mix $value + * + * @return void + */ + function assign($tpl_var, $value = '') + { + if (is_array($tpl_var)) + { + foreach ($tpl_var AS $key => $val) + { + if ($key != '') + { + $this->_var[$key] = $val; + } + } + } + else + { + if ($tpl_var != '') + { + $this->_var[$tpl_var] = $value; + } + } + } + + /** + * 显示页面函数 + * + * @access public + * @param string $filename + * @param sting $cache_id + * + * @return void + */ + function display($filename, $cache_id = '') + { + $this->_seterror++; + error_reporting(E_ALL ^ E_NOTICE); + + $this->_checkfile = false; + $out = $this->fetch($filename, $cache_id); + + if (strpos($out, $this->_echash) !== false) + { + $k = explode($this->_echash, $out); + foreach ($k AS $key => $val) + { + if (($key % 2) == 1) + { + $k[$key] = $this->insert_mod($val); + } + } + $out = implode('', $k); + } + error_reporting($this->_errorlevel); + $this->_seterror--; + + echo $out; + } + + /** + * 处理模板文件 + * + * @access public + * @param string $filename + * @param sting $cache_id + * + * @return sring + */ + function fetch($filename, $cache_id = '') + { + if (!$this->_seterror) + { + error_reporting(E_ALL ^ E_NOTICE); + } + $this->_seterror++; + + if (strncmp($filename,'str:', 4) == 0) + { + $out = $this->_eval($this->fetch_str(substr($filename, 4))); + } + else + { + if ($this->_checkfile) + { + if (!file_exists($filename)) + { + $filename = $this->template_dir . '/' . $filename; + } + } + else + { + $filename = $this->template_dir . '/' . $filename; + } + + if ($this->direct_output) + { + $this->_current_file = $filename; + + $out = $this->_eval($this->fetch_str(file_get_contents($filename))); + } + else + { + if ($cache_id && $this->caching) + { + $out = $this->template_out; + } + else + { + if (!in_array($filename, $this->template)) + { + $this->template[] = $filename; + } + + $out = $this->make_compiled($filename); + + if ($cache_id) + { + $cachename = basename($filename, strrchr($filename, '.')) . '_' . $cache_id; + $data = serialize(array('template' => $this->template, 'expires' => $this->_nowtime + $this->cache_lifetime, 'maketime' => $this->_nowtime)); + $out = str_replace("\r", '', $out); + + while (strpos($out, "\n\n") !== false) + { + $out = str_replace("\n\n", "\n", $out); + } + + $hash_dir = $this->cache_dir . '/' . substr(md5($cachename), 0, 1); + if (!is_dir($hash_dir)) + { + mkdir($hash_dir); + } + if (file_put_contents($hash_dir . '/' . $cachename . '.php', '' . $data . $out, LOCK_EX) === false) + { + trigger_error('can\'t write:' . $hash_dir . '/' . $cachename . '.php'); + } + $this->template = array(); + } + } + } + } + + $this->_seterror--; + if (!$this->_seterror) + { + error_reporting($this->_errorlevel); + } + + return $out; // 返回html数据 + } + + /** + * 编译模板函数 + * + * @access public + * @param string $filename + * + * @return sring 编译后文件地址 + */ + function make_compiled($filename) + { + $name = $this->compile_dir . '/' . basename($filename) . '.php'; + if ($this->_expires) + { + $expires = $this->_expires - $this->cache_lifetime; + } + else + { + $filestat = @stat($name); + $expires = $filestat['mtime']; + } + + $filestat = @stat($filename); + + if ($filestat['mtime'] <= $expires && !$this->force_compile) + { + if (file_exists($name)) + { + $source = $this->_require($name); + if ($source == '') + { + $expires = 0; + } + } + else + { + $source = ''; + $expires = 0; + } + } + + if ($this->force_compile || $filestat['mtime'] > $expires) + { + $this->_current_file = $filename; + $source = $this->fetch_str(file_get_contents($filename)); + + if (file_put_contents($name, $source, LOCK_EX) === false) + { + trigger_error('can\'t write:' . $name); + } + + $source = $this->_eval($source); + } + + return $source; + } + + /** + * 处理字符串函数 + * + * @access public + * @param string $source + * + * @return sring + */ + function fetch_str($source) + { + if (!defined('ECS_ADMIN')) + { + $source = $this->smarty_prefilter_preCompile($source); + } + + if(preg_match_all('~(<\?(?:\w+|=)?|\?>|language\s*=\s*[\"\']?php[\"\']?)~is', $source, $sp_match)) + { + $sp_match[1] = array_unique($sp_match[1]); + for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) + { + $source = str_replace($sp_match[1][$curr_sp],'%%%SMARTYSP'.$curr_sp.'%%%',$source); + } + for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) + { + $source= str_replace('%%%SMARTYSP'.$curr_sp.'%%%', ''."\n", $source); + } + } + + return preg_replace_callback("/{([^\}\{\n]*)}/", function($r) { return $this->select($r[1]); }, $source); + } + + /** + * 判断是否缓存 + * + * @access public + * @param string $filename + * @param sting $cache_id + * + * @return bool + */ + function is_cached($filename, $cache_id = '') + { + $cachename = basename($filename, strrchr($filename, '.')) . '_' . $cache_id; + if ($this->caching == true && $this->direct_output == false) + { + $hash_dir = $this->cache_dir . '/' . substr(md5($cachename), 0, 1); + if ($data = @file_get_contents($hash_dir . '/' . $cachename . '.php')) + { + $data = substr($data, 13); + $pos = strpos($data, '<'); + $paradata = substr($data, 0, $pos); + $para = @unserialize($paradata); + if ($para === false || $this->_nowtime > $para['expires']) + { + $this->caching = false; + + return false; + } + $this->_expires = $para['expires']; + + $this->template_out = substr($data, $pos); + + foreach ($para['template'] AS $val) + { + $stat = @stat($val); + if ($para['maketime'] < $stat['mtime']) + { + $this->caching = false; + + return false; + } + } + } + else + { + $this->caching = false; + + return false; + } + + return true; + } + else + { + return false; + } + } + + /** + * 处理{}标签 + * + * @access public + * @param string $tag + * + * @return sring + */ + function select($tag) + { + $tag = stripslashes(trim($tag)); + + if (empty($tag)) + { + return '{}'; + } + elseif ($tag{0} == '*' && substr($tag, -1) == '*') // 注释部分 + { + return ''; + } + elseif ($tag{0} == '$') // 变量 + { + return 'get_val(substr($tag, 1)) . '; ?>'; + } + elseif ($tag{0} == '/') // 结束 tag + { + switch (substr($tag, 1)) + { + case 'if': + return ''; + break; + + case 'foreach': + if ($this->_foreachmark == 'foreachelse') + { + $output = ''; + } + else + { + array_pop($this->_patchstack); + $output = ''; + } + $output .= "pop_vars();; ?>"; + + return $output; + break; + + case 'literal': + return ''; + break; + + default: + return '{'. $tag .'}'; + break; + } + } + else + { + $tag_arr = explode(' ', $tag); + $tag_sel = array_shift($tag_arr); + switch ($tag_sel) + { + case 'if': + + return $this->_compile_if_tag(substr($tag, 3)); + break; + + case 'else': + + return ''; + break; + + case 'elseif': + + return $this->_compile_if_tag(substr($tag, 7), true); + break; + + case 'foreachelse': + $this->_foreachmark = 'foreachelse'; + + return ''; + break; + + case 'foreach': + $this->_foreachmark = 'foreach'; + if(!isset($this->_patchstack)) + { + $this->_patchstack = array(); + } + return $this->_compile_foreach_start(substr($tag, 8)); + break; + + case 'assign': + $t = $this->get_para(substr($tag, 7),0); + + if ($t['value']{0} == '$') + { + /* 如果传进来的值是变量,就不用用引号 */ + $tmp = '$this->assign(\'' . $t['var'] . '\',' . $t['value'] . ');'; + } + else + { + $tmp = '$this->assign(\'' . $t['var'] . '\',\'' . addcslashes($t['value'], "'") . '\');'; + } + // $tmp = $this->assign($t['var'], $t['value']); + + return ''; + break; + + case 'include': + $t = $this->get_para(substr($tag, 8), 0); + + return 'fetch(' . "'$t[file]'" . '); ?>'; + break; + + case 'insert_scripts': + $t = $this->get_para(substr($tag, 15), 0); + + return 'smarty_insert_scripts(' . $this->make_array($t) . '); ?>'; + break; + + case 'create_pages': + $t = $this->get_para(substr($tag, 13), 0); + + return 'smarty_create_pages(' . $this->make_array($t) . '); ?>'; + break; + + case 'insert' : + $t = $this->get_para(substr($tag, 7), false); + + $out = "_echash . $k[\'name\'] . \'|\' . serialize($k) . $this->_echash;' . "\n?>"; + + return $out; + break; + + case 'literal': + return ''; + break; + + case 'cycle' : + $t = $this->get_para(substr($tag, 6), 0); + + return 'cycle(' . $this->make_array($t) . '); ?>'; + break; + + case 'html_options': + $t = $this->get_para(substr($tag, 13), 0); + + return 'html_options(' . $this->make_array($t) . '); ?>'; + break; + + case 'html_select_date': + $t = $this->get_para(substr($tag, 17), 0); + + return 'html_select_date(' . $this->make_array($t) . '); ?>'; + break; + + case 'html_radios': + $t = $this->get_para(substr($tag, 12), 0); + + return 'html_radios(' . $this->make_array($t) . '); ?>'; + break; + + case 'html_select_time': + $t = $this->get_para(substr($tag, 12), 0); + + return 'html_select_time(' . $this->make_array($t) . '); ?>'; + break; + + default: + return '{' . $tag . '}'; + break; + } + } + } + + /** + * 处理smarty标签中的变量标签 + * + * @access public + * @param string $val + * + * @return bool + */ + function get_val($val) + { + if (strrpos($val, '[') !== false) + { + //$val = preg_replace("/\[([^\[\]]*)\]/eis", "'.'.str_replace('$','\$','\\1')", $val); + $val = preg_replace_callback("/\[([^\[\]]*)\]/is", function ($matches) { return '.'.str_replace('$','\$',$matches[1]);}, $val); + } + + if (strrpos($val, '|') !== false) + { + $moddb = explode('|', $val); + $val = array_shift($moddb); + } + + if (empty($val)) + { + return ''; + } + + if (strpos($val, '.$') !== false) + { + $all = explode('.$', $val); + + foreach ($all AS $key => $val) + { + $all[$key] = $key == 0 ? $this->make_var($val) : '['. $this->make_var($val) . ']'; + } + $p = implode('', $all); + } + else + { + $p = $this->make_var($val); + } + + if (!empty($moddb)) + { + foreach ($moddb AS $key => $mod) + { + $s = explode(':', $mod); + switch ($s[0]) + { + case 'escape': + $s[1] = trim($s[1], '"'); + if ($s[1] == 'html') + { + $p = 'htmlspecialchars(' . $p . ')'; + } + elseif ($s[1] == 'url') + { + $p = 'urlencode(' . $p . ')'; + } + elseif ($s[1] == 'decode_url') + { + $p = 'urldecode(' . $p . ')'; + } + elseif ($s[1] == 'quotes') + { + $p = 'addslashes(' . $p . ')'; + } + elseif ($s[1] == 'u8_url') + { + if (EC_CHARSET != 'utf-8') + { + $p = 'urlencode(ecs_iconv("' . EC_CHARSET . '", "utf-8",' . $p . '))'; + } + else + { + $p = 'urlencode(' . $p . ')'; + } + } + else + { + $p = 'htmlspecialchars(' . $p . ')'; + } + break; + + case 'nl2br': + $p = 'nl2br(' . $p . ')'; + break; + + case 'default': + $s[1] = $s[1]{0} == '$' ? $this->get_val(substr($s[1], 1)) : "'$s[1]'"; + $p = 'empty(' . $p . ') ? ' . $s[1] . ' : ' . $p; + break; + + case 'truncate': + $p = 'sub_str(' . $p . ",$s[1])"; + break; + + case 'strip_tags': + $p = 'strip_tags(' . $p . ')'; + break; + + default: + # code... + break; + } + } + } + + return $p; + } + + /** + * 处理去掉$的字符串 + * + * @access public + * @param string $val + * + * @return bool + */ + function make_var($val) + { + if (strrpos($val, '.') === false) + { + if (isset($this->_var[$val]) && isset($this->_patchstack[$val])) + { + $val = $this->_patchstack[$val]; + } + $p = '$this->_var[\'' . $val . '\']'; + } + else + { + $t = explode('.', $val); + $_var_name = array_shift($t); + if (isset($this->_var[$_var_name]) && isset($this->_patchstack[$_var_name])) + { + $_var_name = $this->_patchstack[$_var_name]; + } + if ($_var_name == 'smarty') + { + $p = $this->_compile_smarty_ref($t); + } + else + { + $p = '$this->_var[\'' . $_var_name . '\']'; + } + foreach ($t AS $val) + { + $p.= '[\'' . $val . '\']'; + } + } + + return $p; + } + + /** + * 处理insert外部函数/需要include运行的函数的调用数据 + * + * @access public + * @param string $val + * @param int $type + * + * @return array + */ + function get_para($val, $type = 1) // 处理insert外部函数/需要include运行的函数的调用数据 + { + $pa = $this->str_trim($val); + foreach ($pa AS $value) + { + if (strrpos($value, '=')) + { + list($a, $b) = explode('=', str_replace(array(' ', '"', "'", '"'), '', $value)); + if ($b{0} == '$') + { + if ($type) + { + eval('$para[\'' . $a . '\']=' . $this->get_val(substr($b, 1)) . ';'); + } + else + { + $para[$a] = $this->get_val(substr($b, 1)); + } + } + else + { + $para[$a] = $b; + } + } + } + + return $para; + } + + /** + * 判断变量是否被注册并返回值 + * + * @access public + * @param string $name + * + * @return mix + */ + function &get_template_vars($name = null) + { + if (empty($name)) + { + return $this->_var; + } + elseif (!empty($this->_var[$name])) + { + return $this->_var[$name]; + } + else + { + $_tmp = null; + + return $_tmp; + } + } + + /** + * 处理if标签 + * + * @access public + * @param string $tag_args + * @param bool $elseif + * + * @return string + */ + function _compile_if_tag($tag_args, $elseif = false) + { + preg_match_all('/\-?\d+[\.\d]+|\'[^\'|\s]*\'|"[^"|\s]*"|[\$\w\.]+|!==|===|==|!=|<>|<<|>>|<=|>=|&&|\|\||\(|\)|,|\!|\^|=|&|<|>|~|\||\%|\+|\-|\/|\*|\@|\S/', $tag_args, $match); + + $tokens = $match[0]; + // make sure we have balanced parenthesis + $token_count = array_count_values($tokens); + if (!empty($token_count['(']) && $token_count['('] != $token_count[')']) + { + // $this->_syntax_error('unbalanced parenthesis in if statement', E_USER_ERROR, __FILE__, __LINE__); + } + + for ($i = 0, $count = count($tokens); $i < $count; $i++) + { + $token = &$tokens[$i]; + switch (strtolower($token)) + { + case 'eq': + $token = '=='; + break; + + case 'ne': + case 'neq': + $token = '!='; + break; + + case 'lt': + $token = '<'; + break; + + case 'le': + case 'lte': + $token = '<='; + break; + + case 'gt': + $token = '>'; + break; + + case 'ge': + case 'gte': + $token = '>='; + break; + + case 'and': + $token = '&&'; + break; + + case 'or': + $token = '||'; + break; + + case 'not': + $token = '!'; + break; + + case 'mod': + $token = '%'; + break; + + default: + if ($token[0] == '$') + { + $token = $this->get_val(substr($token, 1)); + } + break; + } + } + + if ($elseif) + { + return ''; + } + else + { + return ''; + } + } + + /** + * 处理foreach标签 + * + * @access public + * @param string $tag_args + * + * @return string + */ + function _compile_foreach_start($tag_args) + { + $attrs = $this->get_para($tag_args, 0); + $arg_list = array(); + $from = $attrs['from']; + if(isset($this->_var[$attrs['item']]) && !isset($this->_patchstack[$attrs['item']])) + { + $this->_patchstack[$attrs['item']] = $attrs['item'] . '_' . str_replace(array(' ', '.'), '_', microtime()); + $attrs['item'] = $this->_patchstack[$attrs['item']]; + } + else + { + $this->_patchstack[$attrs['item']] = $attrs['item']; + } + $item = $this->get_val($attrs['item']); + + if (!empty($attrs['key'])) + { + $key = $attrs['key']; + $key_part = $this->get_val($key).' => '; + } + else + { + $key = null; + $key_part = ''; + } + + if (!empty($attrs['name'])) + { + $name = $attrs['name']; + } + else + { + $name = null; + } + + $output = 'push_vars('$attrs[key]', '$attrs[item]');"; + + if (!empty($name)) + { + $foreach_props = "\$this->_foreach['$name']"; + $output .= "{$foreach_props} = array('total' => count(\$_from), 'iteration' => 0);\n"; + $output .= "if ({$foreach_props}['total'] > 0):\n"; + $output .= " foreach (\$_from AS $key_part$item):\n"; + $output .= " {$foreach_props}['iteration']++;\n"; + } + else + { + $output .= "if (count(\$_from)):\n"; + $output .= " foreach (\$_from AS $key_part$item):\n"; + } + return $output . '?>'; + } + + /** + * 将 foreach 的 key, item 放入临时数组 + * + * @param mixed $key + * @param mixed $val + * + * @return void + */ + function push_vars($key, $val) + { + if (!empty($key)) + { + array_push($this->_temp_key, "\$this->_vars['$key']='" .$this->_vars[$key] . "';"); + } + if (!empty($val)) + { + array_push($this->_temp_val, "\$this->_vars['$val']='" .$this->_vars[$val] ."';"); + } + } + + /** + * 弹出临时数组的最后一个 + * + * @return void + */ + function pop_vars() + { + $key = array_pop($this->_temp_key); + $val = array_pop($this->_temp_val); + + if (!empty($key)) + { + eval($key); + } + } + + /** + * 处理smarty开头的预定义变量 + * + * @access public + * @param array $indexes + * + * @return string + */ + function _compile_smarty_ref(&$indexes) + { + /* Extract the reference name. */ + $_ref = $indexes[0]; + + switch ($_ref) + { + case 'now': + $compiled_ref = 'time()'; + break; + + case 'foreach': + array_shift($indexes); + $_var = $indexes[0]; + $_propname = $indexes[1]; + switch ($_propname) + { + case 'index': + array_shift($indexes); + $compiled_ref = "(\$this->_foreach['$_var']['iteration'] - 1)"; + break; + + case 'first': + array_shift($indexes); + $compiled_ref = "(\$this->_foreach['$_var']['iteration'] <= 1)"; + break; + + case 'last': + array_shift($indexes); + $compiled_ref = "(\$this->_foreach['$_var']['iteration'] == \$this->_foreach['$_var']['total'])"; + break; + + case 'show': + array_shift($indexes); + $compiled_ref = "(\$this->_foreach['$_var']['total'] > 0)"; + break; + + default: + $compiled_ref = "\$this->_foreach['$_var']"; + break; + } + break; + + case 'get': + $compiled_ref = '$_GET'; + break; + + case 'post': + $compiled_ref = '$_POST'; + break; + + case 'cookies': + $compiled_ref = '$_COOKIE'; + break; + + case 'env': + $compiled_ref = '$_ENV'; + break; + + case 'server': + $compiled_ref = '$_SERVER'; + break; + + case 'request': + $compiled_ref = '$_REQUEST'; + break; + + case 'session': + $compiled_ref = '$_SESSION'; + break; + + default: + // $this->_syntax_error('$smarty.' . $_ref . ' is an unknown reference', E_USER_ERROR, __FILE__, __LINE__); + break; + } + array_shift($indexes); + + return $compiled_ref; + } + + function smarty_insert_scripts($args) + { + static $scripts = array(); + + $arr = explode(',', str_replace(' ', '', $args['files'])); + + $str = ''; + foreach ($arr AS $val) + { + if (in_array($val, $scripts) == false) + { + $scripts[] = $val; + if ($val{0} == '.') + { + $str .= ''; + } + else + { + $str .= ''; + } + } + } + + return $str; + } + + function smarty_prefilter_preCompile($source) + { + $file_type = strtolower(strrchr($this->_current_file, '.')); + $tmp_dir = '/themes/' . $GLOBALS['_CFG']['template'] . '/' .$this->site_type .'/'; // 模板所在路径 + /** + * 处理模板文件 + */ + if ($file_type == '.dwt') + { + /* 将模板中所有library替换为链接 */ + $pattern = '/.*?/s'; + //$replacement = function ($matches) { return '{include file='.strtolower($matches[1]). '}';}; + //$source = preg_replace_callback($pattern, $replacement, $source); + $source = preg_replace_callback($pattern, + function ($matcher) { + return '{include file=' . strtolower($matcher[1]). '}'; + }, + $source); /* 检查有无动态库文件,如果有为其赋值 */ + $dyna_libs = get_dyna_libs($GLOBALS['_CFG']['template'], $this->_current_file); + if ($dyna_libs) + { + foreach ($dyna_libs AS $region => $libs) + { + $pattern = '/(.*?)/s'; + + if (preg_match($pattern, $source, $reg_match)) + { + $reg_content = $reg_match[1]; + /* 生成匹配字串 */ + $keys = array_keys($libs); + $lib_pattern = ''; + foreach ($keys AS $lib) + { + $lib_pattern .= '|' . str_replace('/', '\/', substr($lib, 1)); + } + $lib_pattern = '/{include\sfile=(' . substr($lib_pattern, 1) . ')}/'; + /* 修改$reg_content中的内容 */ + $GLOBALS['libs'] = $libs; + $reg_content = preg_replace_callback($lib_pattern, 'dyna_libs_replace', $reg_content); + + /* 用修改过的内容替换原来当前区域中内容 */ + $source = preg_replace($pattern, $reg_content, $source); + } + } + } + + /* 在头部加入版本信息 */ +// $source = preg_replace('//i', "\r\n", $source); + + /* 修正css路径 */ + $source = preg_replace('/(<\/script>)/', '\1' . $tmp_dir . '\2', $source); + + /* 更换编译模板的编码类型 */ + $source = preg_replace('/]*?>\r?\n?/i', '' . "\n", $source); + + } + + /** + * 处理库文件 + */ + elseif ($file_type == '.lbi') + { + /* 去除meta */ + $source = preg_replace('/\r?\n?/i', '', $source); + } + + /* 替换文件编码头部 */ + if (strpos($source, "\xEF\xBB\xBF") !== FALSE) + { + $source = str_replace("\xEF\xBB\xBF", '', $source); + } + + $pattern = array( + '//', // 替换smarty注释 + '//', // 替换不换行的html注释 + '/(href=["|\'])\.\.\/(.*?)(["|\'])/i', // 替换相对链接 + '/((?:background|src)\s*=\s*["|\'])(?:\.\/|\.\.\/)?(images\/.*?["|\'])/is', // 在images前加上 $tmp_dir + '/((?:background|background-image):\s*?url\()(?:\.\/|\.\.\/)?(images\/)/is', // 在images前加上 $tmp_dir + '/([\'|"])\.\.\//is', // 以../开头的路径全部修正为空 + ); + $replace = array( + '\1', + '', + '\1\2\3', + '\1' . $tmp_dir . '\2', + '\1' . $tmp_dir . '\2', + '\1' + ); + return preg_replace($pattern, $replace, $source); + } + + function insert_mod($name) // 处理动态内容 + { + list($fun, $para) = explode('|', $name); + $para = unserialize($para); + $fun = 'insert_' . $fun; + + return $fun($para); + } + + function str_trim($str) + { + /* 处理'a=b c=d k = f '类字符串,返回数组 */ + while (strpos($str, '= ') != 0) + { + $str = str_replace('= ', '=', $str); + } + while (strpos($str, ' =') != 0) + { + $str = str_replace(' =', '=', $str); + } + + return explode(' ', trim($str)); + } + + function _eval($content) + { + ob_start(); + eval('?' . '>' . trim($content)); + $content = ob_get_contents(); + ob_end_clean(); + + return $content; + } + + function _require($filename) + { + ob_start(); + include $filename; + $content = ob_get_contents(); + ob_end_clean(); + + return $content; + } + + function html_options($arr) + { + $selected = $arr['selected']; + + if ($arr['options']) + { + $options = (array)$arr['options']; + } + elseif ($arr['output']) + { + if ($arr['values']) + { + foreach ($arr['output'] AS $key => $val) + { + $options["{$arr[values][$key]}"] = $val; + } + } + else + { + $options = array_values((array)$arr['output']); + } + } + if ($options) + { + foreach ($options AS $key => $val) + { + $out .= $key == $selected ? "" : ""; + } + } + + return $out; + } + + function html_select_date($arr) + { + $pre = $arr['prefix']; + if (isset($arr['time'])) + { + if (intval($arr['time']) > 10000) + { + $arr['time'] = gmdate('Y-m-d', $arr['time'] + 8*3600); + } + $t = explode('-', $arr['time']); + $year = strval($t[0]); + $month = strval($t[1]); + $day = strval($t[2]); + } + $now = gmdate('Y', $this->_nowtime); + if (isset($arr['start_year'])) + { + if (abs($arr['start_year']) == $arr['start_year']) + { + $startyear = $arr['start_year']; + } + else + { + $startyear = $arr['start_year'] + $now; + } + } + else + { + $startyear = $now - 3; + } + + if (isset($arr['end_year'])) + { + if (strlen(abs($arr['end_year'])) == strlen($arr['end_year'])) + { + $endyear = $arr['end_year']; + } + else + { + $endyear = $arr['end_year'] + $now; + } + } + else + { + $endyear = $now + 3; + } + + $out = "  '; + } + + function html_radios($arr) + { + $name = $arr['name']; + $checked = $arr['checked']; + $options = $arr['options']; + + $out = ''; + foreach ($options AS $key => $val) + { + $out .= $key == $checked ? " {$val} " + : " {$val} "; + } + + return $out; + } + + function html_select_time($arr) + { + $pre = $arr['prefix']; + if (isset($arr['time'])) + { + $arr['time'] = gmdate('H-i-s', $arr['time'] + 8*3600); + $t = explode('-', $arr['time']); + $hour = strval($t[0]); + $minute = strval($t[1]); + $second = strval($t[2]); + } + $out = ''; + if (!isset($arr['display_hours'])) + { + $out .= " "; + } + if (!isset($arr['display_minutes'])) + { + $out .= " "; + } + if (!isset($arr['display_seconds'])) + { + $out .= " "; + } + + return $out; + } + function cycle($arr) + { + static $k, $old; + + $value = explode(',', $arr['values']); + if ($old != $value) + { + $old = $value; + $k = 0; + } + else + { + $k++; + if (!isset($old[$k])) + { + $k = 0; + } + } + + echo $old[$k]; + } + + function make_array($arr) + { + $out = ''; + foreach ($arr AS $key => $val) + { + if ($val{0} == '$') + { + $out .= $out ? ",'$key'=>$val" : "array('$key'=>$val"; + } + else + { + $out .= $out ? ",'$key'=>'$val'" : "array('$key'=>'$val'"; + } + } + + return $out . ')'; + } + + function smarty_create_pages($params) + { + extract($params); + + if (empty($page)) + { + $page = 1; + } + + if (!empty($count)) + { + $str = ""; + $min = min($count - 1, $page + 3); + for ($i = $page - 3 ; $i <= $min ; $i++) + { + if ($i < 2) + { + continue; + } + $str .= "
+ + + + \ No newline at end of file diff --git a/includes/fckeditor/editor/dialog/fck_UpFileBtn/fck_UpFileBtn.js b/includes/fckeditor/editor/dialog/fck_UpFileBtn/fck_UpFileBtn.js new file mode 100755 index 0000000..bba8474 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_UpFileBtn/fck_UpFileBtn.js @@ -0,0 +1,162 @@ +/* + * FCKeditor - The text editor for Internet - http://www.fckeditor.net + * Copyright (C) 2003-2008 Frederico Caldeira Knabben + * + * == BEGIN LICENSE == + * + * Licensed under the terms of any of the following licenses at your + * choice: + * + * - GNU General Public License Version 2 or later (the "GPL") + * http://www.gnu.org/licenses/gpl.html + * + * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") + * http://www.gnu.org/licenses/lgpl.html + * + * - Mozilla Public License Version 1.1 or later (the "MPL") + * http://www.mozilla.org/MPL/MPL-1.1.html + * + * == END LICENSE == + * + * Scripts related to the Link dialog window (see fck_link.html). + */ + +var dialog = window.parent ; +var oEditor = dialog.InnerDialogLoaded() ; + +var FCK = oEditor.FCK ; +var FCKLang = oEditor.FCKLang ; +var FCKConfig = oEditor.FCKConfig ; +var FCKRegexLib = oEditor.FCKRegexLib ; +var FCKTools = oEditor.FCKTools ; + +//#### Dialog Tabs + +// Set the dialog tabs. +dialog.AddTab( 'Upload', FCKLang.DlgLnkUpload ) ; + +// Function called when a dialog tag is selected. +function OnDialogTabChange( tabCode ) +{ + ShowE('divUpload' , ( tabCode == 'Upload' ) ) ; + + dialog.SetAutoSize( true ) ; +} + +// oLink: The actual selected link in the editor. +var oLink = dialog.Selection.GetSelection().MoveToAncestorNode( 'A' ) ; +if ( oLink ) + FCK.Selection.SelectNode( oLink ) ; + +window.onload = function() +{ + // Translate the dialog box texts. + oEditor.FCKLanguageManager.TranslatePage(document) ; + + // Show the initial dialog content. + GetE('divUpload').style.display = '' ; + + // Set the actual uploader URL. + if ( FCKConfig.FilesUploadURL ) + GetE('frmUpload').action = FCKConfig.FilesUploadURL ; + + // Activate the "OK" button. + dialog.SetOkButton( true ) ; +} + +//#### The OK button was hit. +function Ok() +{ + oEditor.FCKUndo.SaveUndoStep() ; + + return true ; +} + + +function BrowseServer() +{ + OpenFileBrowser( FCKConfig.LinkBrowserURL, FCKConfig.LinkBrowserWindowWidth, FCKConfig.LinkBrowserWindowHeight ) ; +} + +function SetUrl( url ) +{ + dialog.SetSelectedTab( 'Upload' ) ; +} + +function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg ) +{ + // Remove animation + window.parent.Throbber.Hide() ; + GetE( 'divUpload' ).style.display = '' ; + + switch ( errorNumber ) + { + case 0 : // No errors + alert( 'Your file has been successfully uploaded' ) ; + break ; + case 1 : // Custom error + alert( customMsg ) ; + return ; + case 101 : // Custom warning + alert( customMsg ) ; + break ; + case 201 : + alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ; + break ; + case 202 : + alert( 'Invalid file type' ) ; + return ; + case 203 : + alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ; + return ; + case 500 : + alert( 'The connector is disabled' ) ; + break ; + default : + alert( 'Error on file upload. Error number: ' + errorNumber ) ; + return ; + } + + SetUrl( fileUrl ) ; + GetE('frmUpload').reset() ; +} + +var oUploadAllowedExtRegex = new RegExp( FCKConfig.LinkUploadAllowedExtensions, 'i' ) ; +var oUploadDeniedExtRegex = new RegExp( FCKConfig.LinkUploadDeniedExtensions, 'i' ) ; + +function CheckUpload() +{ + var sFile; + var sFile_count = 0; + + for (var i = 0; i <= 4; i++) + { + var sFile = GetE('txtUploadFile_' + i).value ; + + if ( sFile.length == 0 ) + { + continue; + } + + sFile_count ++; + +// if ( ( FCKConfig.LinkUploadAllowedExtensions.length > 0 && !oUploadAllowedExtRegex.test( sFile ) ) || +// ( FCKConfig.LinkUploadDeniedExtensions.length > 0 && oUploadDeniedExtRegex.test( sFile ) ) ) +// { +// OnUploadCompleted( 202 ) ; +// return false ; +// } + } + + if ( sFile_count == 0 ) + { + alert( 'Please select a file to upload' ) ; + return false ; + } + + // Show animation + window.parent.Throbber.Show( 100 ) ; + GetE( 'divUpload' ).style.display = 'none' ; + + return true ; +} \ No newline at end of file diff --git a/includes/fckeditor/editor/dialog/fck_about.html b/includes/fckeditor/editor/dialog/fck_about.html new file mode 100755 index 0000000..efcfb2d --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_about.html @@ -0,0 +1,160 @@ + + + + + + + + + + + +
+ + + + + + + + + + + + +
+ + + + + +
+ +
+
+
+ + + Support Open Source Software +
+ +
+
+
+
Selected Sponsor
+ Selected Sponsor +
+
+ For further information go to http://www.fckeditor.net/. +
+ Copyright © 2003-2008 Frederico Caldeira Knabben +
+ Become a Sponsor +
+
+ + + + diff --git a/includes/fckeditor/editor/dialog/fck_about/logo_fckeditor.gif b/includes/fckeditor/editor/dialog/fck_about/logo_fckeditor.gif new file mode 100755 index 0000000..b7d6bc6 Binary files /dev/null and b/includes/fckeditor/editor/dialog/fck_about/logo_fckeditor.gif differ diff --git a/includes/fckeditor/editor/dialog/fck_about/logo_fredck.gif b/includes/fckeditor/editor/dialog/fck_about/logo_fredck.gif new file mode 100755 index 0000000..3108dd9 Binary files /dev/null and b/includes/fckeditor/editor/dialog/fck_about/logo_fredck.gif differ diff --git a/includes/fckeditor/editor/dialog/fck_about/sponsors/spellchecker_net.gif b/includes/fckeditor/editor/dialog/fck_about/sponsors/spellchecker_net.gif new file mode 100755 index 0000000..f8586f9 Binary files /dev/null and b/includes/fckeditor/editor/dialog/fck_about/sponsors/spellchecker_net.gif differ diff --git a/includes/fckeditor/editor/dialog/fck_anchor.html b/includes/fckeditor/editor/dialog/fck_anchor.html new file mode 100755 index 0000000..602a6c8 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_anchor.html @@ -0,0 +1,220 @@ + + + + + Anchor Properties + + + + + + + + + + +
+ + + + +
+ Anchor Name
+ +
+
+ + diff --git a/includes/fckeditor/editor/dialog/fck_button.html b/includes/fckeditor/editor/dialog/fck_button.html new file mode 100755 index 0000000..cc117a9 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_button.html @@ -0,0 +1,104 @@ + + + + + Button Properties + + + + + + + + + + +
+ + + + + + + + + + +
+ Name
+ +
+ Text (Value)
+ +
+ Type
+ +
+
+ + diff --git a/includes/fckeditor/editor/dialog/fck_checkbox.html b/includes/fckeditor/editor/dialog/fck_checkbox.html new file mode 100755 index 0000000..06d4549 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_checkbox.html @@ -0,0 +1,104 @@ + + + + + Checkbox Properties + + + + + + + + + + +
+ + + + + + + + + + +
+ Name
+ +
+ Value
+ +
+
+ + diff --git a/includes/fckeditor/editor/dialog/fck_colorselector.html b/includes/fckeditor/editor/dialog/fck_colorselector.html new file mode 100755 index 0000000..30d100b --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_colorselector.html @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + +
+ + + + + +
+ +
+
+ Highlight +
+
 
+ Selected +
+ +
+ +
+
+ + diff --git a/includes/fckeditor/editor/dialog/fck_docprops.html b/includes/fckeditor/editor/dialog/fck_docprops.html new file mode 100755 index 0000000..d943dd9 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_docprops.html @@ -0,0 +1,600 @@ + + + + + + + + + + + + + + + + + + +
+
+ Page Title
+ +
+ + + + + + +
+ Language Direction
+ +
+     + Language Code
+ +
+
+ + + + + + + + + + + + + + +
+ Character Set Encoding
+ +
+     + Other Character Set Encoding
+ +
+  
+ Document Type Heading
+ +
+ + Other Document Type Heading
+ +
+
+ + +
+ + + +
+ + diff --git a/includes/fckeditor/editor/dialog/fck_docprops/fck_document_preview.html b/includes/fckeditor/editor/dialog/fck_docprops/fck_document_preview.html new file mode 100755 index 0000000..0ac5acc --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_docprops/fck_document_preview.html @@ -0,0 +1,113 @@ + + + + + Document Properties - Preview + + + + + + + + + + + + + + +
+ Normal Text +
+ Visited Link + + Active Link +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + diff --git a/includes/fckeditor/editor/dialog/fck_flash.html b/includes/fckeditor/editor/dialog/fck_flash.html new file mode 100755 index 0000000..1569175 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_flash.html @@ -0,0 +1,152 @@ + + + + + Flash Properties + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + +
URL +
+
+
+ + + + + + +
+ Width
+ +
  + Height
+ +
+
+ + + + +
+ + + + + + + +
Preview
+
+
+
+ + + + diff --git a/includes/fckeditor/editor/dialog/fck_flash/fck_flash.js b/includes/fckeditor/editor/dialog/fck_flash/fck_flash.js new file mode 100755 index 0000000..993ba8c --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_flash/fck_flash.js @@ -0,0 +1,300 @@ +/* + * FCKeditor - The text editor for Internet - http://www.fckeditor.net + * Copyright (C) 2003-2008 Frederico Caldeira Knabben + * + * == BEGIN LICENSE == + * + * Licensed under the terms of any of the following licenses at your + * choice: + * + * - GNU General Public License Version 2 or later (the "GPL") + * http://www.gnu.org/licenses/gpl.html + * + * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") + * http://www.gnu.org/licenses/lgpl.html + * + * - Mozilla Public License Version 1.1 or later (the "MPL") + * http://www.mozilla.org/MPL/MPL-1.1.html + * + * == END LICENSE == + * + * Scripts related to the Flash dialog window (see fck_flash.html). + */ + +var dialog = window.parent ; +var oEditor = dialog.InnerDialogLoaded() ; +var FCK = oEditor.FCK ; +var FCKLang = oEditor.FCKLang ; +var FCKConfig = oEditor.FCKConfig ; +var FCKTools = oEditor.FCKTools ; + +//#### Dialog Tabs + +// Set the dialog tabs. +dialog.AddTab( 'Info', oEditor.FCKLang.DlgInfoTab ) ; + +if ( FCKConfig.FlashUpload ) + dialog.AddTab( 'Upload', FCKLang.DlgLnkUpload ) ; + +if ( !FCKConfig.FlashDlgHideAdvanced ) + dialog.AddTab( 'Advanced', oEditor.FCKLang.DlgAdvancedTag ) ; + +// Function called when a dialog tag is selected. +function OnDialogTabChange( tabCode ) +{ + ShowE('divInfo' , ( tabCode == 'Info' ) ) ; + ShowE('divUpload' , ( tabCode == 'Upload' ) ) ; + ShowE('divAdvanced' , ( tabCode == 'Advanced' ) ) ; +} + +// Get the selected flash embed (if available). +var oFakeImage = dialog.Selection.GetSelectedElement() ; +var oEmbed ; + +if ( oFakeImage ) +{ + if ( oFakeImage.tagName == 'IMG' && oFakeImage.getAttribute('_fckflash') ) + oEmbed = FCK.GetRealElement( oFakeImage ) ; + else + oFakeImage = null ; +} + +window.onload = function() +{ + // Translate the dialog box texts. + oEditor.FCKLanguageManager.TranslatePage(document) ; + + // Load the selected element information (if any). + LoadSelection() ; + + // Show/Hide the "Browse Server" button. + GetE('tdBrowse').style.display = FCKConfig.FlashBrowser ? '' : 'none' ; + + // Set the actual uploader URL. + if ( FCKConfig.FlashUpload ) + GetE('frmUpload').action = FCKConfig.FlashUploadURL ; + + dialog.SetAutoSize( true ) ; + + // Activate the "OK" button. + dialog.SetOkButton( true ) ; + + SelectField( 'txtUrl' ) ; +} + +function LoadSelection() +{ + if ( ! oEmbed ) return ; + + GetE('txtUrl').value = GetAttribute( oEmbed, 'src', '' ) ; + GetE('txtWidth').value = GetAttribute( oEmbed, 'width', '' ) ; + GetE('txtHeight').value = GetAttribute( oEmbed, 'height', '' ) ; + + // Get Advances Attributes + GetE('txtAttId').value = oEmbed.id ; + GetE('chkAutoPlay').checked = GetAttribute( oEmbed, 'play', 'true' ) == 'true' ; + GetE('chkLoop').checked = GetAttribute( oEmbed, 'loop', 'true' ) == 'true' ; + GetE('chkMenu').checked = GetAttribute( oEmbed, 'menu', 'true' ) == 'true' ; + GetE('cmbScale').value = GetAttribute( oEmbed, 'scale', '' ).toLowerCase() ; + + GetE('txtAttTitle').value = oEmbed.title ; + + if ( oEditor.FCKBrowserInfo.IsIE ) + { + GetE('txtAttClasses').value = oEmbed.getAttribute('className') || '' ; + GetE('txtAttStyle').value = oEmbed.style.cssText ; + } + else + { + GetE('txtAttClasses').value = oEmbed.getAttribute('class',2) || '' ; + GetE('txtAttStyle').value = oEmbed.getAttribute('style',2) || '' ; + } + + UpdatePreview() ; +} + +//#### The OK button was hit. +function Ok() +{ + if ( GetE('txtUrl').value.length == 0 ) + { + dialog.SetSelectedTab( 'Info' ) ; + GetE('txtUrl').focus() ; + + alert( oEditor.FCKLang.DlgAlertUrl ) ; + + return false ; + } + + oEditor.FCKUndo.SaveUndoStep() ; + if ( !oEmbed ) + { + oEmbed = FCK.EditorDocument.createElement( 'EMBED' ) ; + oFakeImage = null ; + } + UpdateEmbed( oEmbed ) ; + + if ( !oFakeImage ) + { + oFakeImage = oEditor.FCKDocumentProcessor_CreateFakeImage( 'FCK__Flash', oEmbed ) ; + oFakeImage.setAttribute( '_fckflash', 'true', 0 ) ; + oFakeImage = FCK.InsertElement( oFakeImage ) ; + } + + oEditor.FCKEmbedAndObjectProcessor.RefreshView( oFakeImage, oEmbed ) ; + + return true ; +} + +function UpdateEmbed( e ) +{ + SetAttribute( e, 'type' , 'application/x-shockwave-flash' ) ; + SetAttribute( e, 'pluginspage' , 'http://www.macromedia.com/go/getflashplayer' ) ; + + SetAttribute( e, 'src', GetE('txtUrl').value ) ; + SetAttribute( e, "width" , GetE('txtWidth').value ) ; + SetAttribute( e, "height", GetE('txtHeight').value ) ; + + // Advances Attributes + + SetAttribute( e, 'id' , GetE('txtAttId').value ) ; + SetAttribute( e, 'scale', GetE('cmbScale').value ) ; + + SetAttribute( e, 'play', GetE('chkAutoPlay').checked ? 'true' : 'false' ) ; + SetAttribute( e, 'loop', GetE('chkLoop').checked ? 'true' : 'false' ) ; + SetAttribute( e, 'menu', GetE('chkMenu').checked ? 'true' : 'false' ) ; + + SetAttribute( e, 'title' , GetE('txtAttTitle').value ) ; + + if ( oEditor.FCKBrowserInfo.IsIE ) + { + SetAttribute( e, 'className', GetE('txtAttClasses').value ) ; + e.style.cssText = GetE('txtAttStyle').value ; + } + else + { + SetAttribute( e, 'class', GetE('txtAttClasses').value ) ; + SetAttribute( e, 'style', GetE('txtAttStyle').value ) ; + } +} + +var ePreview ; + +function SetPreviewElement( previewEl ) +{ + ePreview = previewEl ; + + if ( GetE('txtUrl').value.length > 0 ) + UpdatePreview() ; +} + +function UpdatePreview() +{ + if ( !ePreview ) + return ; + + while ( ePreview.firstChild ) + ePreview.removeChild( ePreview.firstChild ) ; + + if ( GetE('txtUrl').value.length == 0 ) + ePreview.innerHTML = ' ' ; + else + { + var oDoc = ePreview.ownerDocument || ePreview.document ; + var e = oDoc.createElement( 'EMBED' ) ; + + SetAttribute( e, 'src', GetE('txtUrl').value ) ; + SetAttribute( e, 'type', 'application/x-shockwave-flash' ) ; + SetAttribute( e, 'width', '100%' ) ; + SetAttribute( e, 'height', '100%' ) ; + + ePreview.appendChild( e ) ; + } +} + +// + +function BrowseServer() +{ + OpenFileBrowser( FCKConfig.FlashBrowserURL, FCKConfig.FlashBrowserWindowWidth, FCKConfig.FlashBrowserWindowHeight ) ; +} + +function SetUrl( url, width, height ) +{ + GetE('txtUrl').value = url ; + + if ( width ) + GetE('txtWidth').value = width ; + + if ( height ) + GetE('txtHeight').value = height ; + + UpdatePreview() ; + + dialog.SetSelectedTab( 'Info' ) ; +} + +function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg ) +{ + // Remove animation + window.parent.Throbber.Hide() ; + GetE( 'divUpload' ).style.display = '' ; + + switch ( errorNumber ) + { + case 0 : // No errors + alert( 'Your file has been successfully uploaded' ) ; + break ; + case 1 : // Custom error + alert( customMsg ) ; + return ; + case 101 : // Custom warning + alert( customMsg ) ; + break ; + case 201 : + alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ; + break ; + case 202 : + alert( 'Invalid file type' ) ; + return ; + case 203 : + alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ; + return ; + case 500 : + alert( 'The connector is disabled' ) ; + break ; + default : + alert( 'Error on file upload. Error number: ' + errorNumber ) ; + return ; + } + + SetUrl( fileUrl ) ; + GetE('frmUpload').reset() ; +} + +var oUploadAllowedExtRegex = new RegExp( FCKConfig.FlashUploadAllowedExtensions, 'i' ) ; +var oUploadDeniedExtRegex = new RegExp( FCKConfig.FlashUploadDeniedExtensions, 'i' ) ; + +function CheckUpload() +{ + var sFile = GetE('txtUploadFile').value ; + + if ( sFile.length == 0 ) + { + alert( 'Please select a file to upload' ) ; + return false ; + } + + if ( ( FCKConfig.FlashUploadAllowedExtensions.length > 0 && !oUploadAllowedExtRegex.test( sFile ) ) || + ( FCKConfig.FlashUploadDeniedExtensions.length > 0 && oUploadDeniedExtRegex.test( sFile ) ) ) + { + OnUploadCompleted( 202 ) ; + return false ; + } + + // Show animation + window.parent.Throbber.Show( 100 ) ; + GetE( 'divUpload' ).style.display = 'none' ; + + return true ; +} diff --git a/includes/fckeditor/editor/dialog/fck_flash/fck_flash_preview.html b/includes/fckeditor/editor/dialog/fck_flash/fck_flash_preview.html new file mode 100755 index 0000000..4817c1d --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_flash/fck_flash_preview.html @@ -0,0 +1,50 @@ + + + + + + + + + + + + diff --git a/includes/fckeditor/editor/dialog/fck_form.html b/includes/fckeditor/editor/dialog/fck_form.html new file mode 100755 index 0000000..71edf49 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_form.html @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ Name
+ +
+ Action
+ +
+ Method
+ +
+
+ + diff --git a/includes/fckeditor/editor/dialog/fck_hiddenfield.html b/includes/fckeditor/editor/dialog/fck_hiddenfield.html new file mode 100755 index 0000000..3ee162f --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_hiddenfield.html @@ -0,0 +1,115 @@ + + + + + Hidden Field Properties + + + + + + + + + + +
+ + + + + + + +
+ Name
+ +
+ Value
+ +
+
+ + diff --git a/includes/fckeditor/editor/dialog/fck_image.html b/includes/fckeditor/editor/dialog/fck_image.html new file mode 100755 index 0000000..5ce5ecb --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_image.html @@ -0,0 +1,258 @@ + + + + + Image Properties + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + +
+ URL +
+ +
+
+ Short Description
+
+
+ + + + + + +
+
+ + + + + + + + + + + +
+ Width  + +
+
+
+
+
+
+ Height  +
+
+ + + + + + + + + + + + + + + + + +
+ Border  +
+ HSpace  +
+ VSpace  +
+ Align  + +
+
+     + + + + + + + +
+ Preview
+ +
+
+
+
+ + + + + diff --git a/includes/fckeditor/editor/dialog/fck_image/fck_image.js b/includes/fckeditor/editor/dialog/fck_image/fck_image.js new file mode 100755 index 0000000..7498e07 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_image/fck_image.js @@ -0,0 +1,512 @@ +/* + * FCKeditor - The text editor for Internet - http://www.fckeditor.net + * Copyright (C) 2003-2008 Frederico Caldeira Knabben + * + * == BEGIN LICENSE == + * + * Licensed under the terms of any of the following licenses at your + * choice: + * + * - GNU General Public License Version 2 or later (the "GPL") + * http://www.gnu.org/licenses/gpl.html + * + * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") + * http://www.gnu.org/licenses/lgpl.html + * + * - Mozilla Public License Version 1.1 or later (the "MPL") + * http://www.mozilla.org/MPL/MPL-1.1.html + * + * == END LICENSE == + * + * Scripts related to the Image dialog window (see fck_image.html). + */ + +var dialog = window.parent ; +var oEditor = dialog.InnerDialogLoaded() ; +var FCK = oEditor.FCK ; +var FCKLang = oEditor.FCKLang ; +var FCKConfig = oEditor.FCKConfig ; +var FCKDebug = oEditor.FCKDebug ; +var FCKTools = oEditor.FCKTools ; + +var bImageButton = ( document.location.search.length > 0 && document.location.search.substr(1) == 'ImageButton' ) ; + +//#### Dialog Tabs + +// Set the dialog tabs. +dialog.AddTab( 'Info', FCKLang.DlgImgInfoTab ) ; + +if ( !bImageButton && !FCKConfig.ImageDlgHideLink ) + dialog.AddTab( 'Link', FCKLang.DlgImgLinkTab ) ; + +if ( FCKConfig.ImageUpload ) + dialog.AddTab( 'Upload', FCKLang.DlgLnkUpload ) ; + +if ( !FCKConfig.ImageDlgHideAdvanced ) + dialog.AddTab( 'Advanced', FCKLang.DlgAdvancedTag ) ; + +// Function called when a dialog tag is selected. +function OnDialogTabChange( tabCode ) +{ + ShowE('divInfo' , ( tabCode == 'Info' ) ) ; + ShowE('divLink' , ( tabCode == 'Link' ) ) ; + ShowE('divUpload' , ( tabCode == 'Upload' ) ) ; + ShowE('divAdvanced' , ( tabCode == 'Advanced' ) ) ; +} + +// Get the selected image (if available). +var oImage = dialog.Selection.GetSelectedElement() ; + +if ( oImage && oImage.tagName != 'IMG' && !( oImage.tagName == 'INPUT' && oImage.type == 'image' ) ) + oImage = null ; + +// Get the active link. +var oLink = dialog.Selection.GetSelection().MoveToAncestorNode( 'A' ) ; + +var oImageOriginal ; + +function UpdateOriginal( resetSize ) +{ + if ( !eImgPreview ) + return ; + + if ( GetE('txtUrl').value.length == 0 ) + { + oImageOriginal = null ; + return ; + } + + oImageOriginal = document.createElement( 'IMG' ) ; // new Image() ; + + if ( resetSize ) + { + oImageOriginal.onload = function() + { + this.onload = null ; + ResetSizes() ; + } + } + + oImageOriginal.src = eImgPreview.src ; +} + +var bPreviewInitialized ; + +window.onload = function() +{ + // Translate the dialog box texts. + oEditor.FCKLanguageManager.TranslatePage(document) ; + + GetE('btnLockSizes').title = FCKLang.DlgImgLockRatio ; + GetE('btnResetSize').title = FCKLang.DlgBtnResetSize ; + + // Load the selected element information (if any). + LoadSelection() ; + + // Show/Hide the "Browse Server" button. + GetE('tdBrowse').style.display = FCKConfig.ImageBrowser ? '' : 'none' ; + GetE('divLnkBrowseServer').style.display = FCKConfig.LinkBrowser ? '' : 'none' ; + + UpdateOriginal() ; + + // Set the actual uploader URL. + if ( FCKConfig.ImageUpload ) + GetE('frmUpload').action = FCKConfig.ImageUploadURL ; + + dialog.SetAutoSize( true ) ; + + // Activate the "OK" button. + dialog.SetOkButton( true ) ; + + SelectField( 'txtUrl' ) ; +} + +function LoadSelection() +{ + if ( ! oImage ) return ; + + var sUrl = oImage.getAttribute( '_fcksavedurl' ) ; + if ( sUrl == null ) + sUrl = GetAttribute( oImage, 'src', '' ) ; + + GetE('txtUrl').value = sUrl ; + GetE('txtAlt').value = GetAttribute( oImage, 'alt', '' ) ; + GetE('txtVSpace').value = GetAttribute( oImage, 'vspace', '' ) ; + GetE('txtHSpace').value = GetAttribute( oImage, 'hspace', '' ) ; + GetE('txtBorder').value = GetAttribute( oImage, 'border', '' ) ; + GetE('cmbAlign').value = GetAttribute( oImage, 'align', '' ) ; + + var iWidth, iHeight ; + + var regexSize = /^\s*(\d+)px\s*$/i ; + + if ( oImage.style.width ) + { + var aMatchW = oImage.style.width.match( regexSize ) ; + if ( aMatchW ) + { + iWidth = aMatchW[1] ; + oImage.style.width = '' ; + SetAttribute( oImage, 'width' , iWidth ) ; + } + } + + if ( oImage.style.height ) + { + var aMatchH = oImage.style.height.match( regexSize ) ; + if ( aMatchH ) + { + iHeight = aMatchH[1] ; + oImage.style.height = '' ; + SetAttribute( oImage, 'height', iHeight ) ; + } + } + + GetE('txtWidth').value = iWidth ? iWidth : GetAttribute( oImage, "width", '' ) ; + GetE('txtHeight').value = iHeight ? iHeight : GetAttribute( oImage, "height", '' ) ; + + // Get Advances Attributes + GetE('txtAttId').value = oImage.id ; + GetE('cmbAttLangDir').value = oImage.dir ; + GetE('txtAttLangCode').value = oImage.lang ; + GetE('txtAttTitle').value = oImage.title ; + GetE('txtLongDesc').value = oImage.longDesc ; + + if ( oEditor.FCKBrowserInfo.IsIE ) + { + GetE('txtAttClasses').value = oImage.className || '' ; + GetE('txtAttStyle').value = oImage.style.cssText ; + } + else + { + GetE('txtAttClasses').value = oImage.getAttribute('class',2) || '' ; + GetE('txtAttStyle').value = oImage.getAttribute('style',2) ; + } + + if ( oLink ) + { + var sLinkUrl = oLink.getAttribute( '_fcksavedurl' ) ; + if ( sLinkUrl == null ) + sLinkUrl = oLink.getAttribute('href',2) ; + + GetE('txtLnkUrl').value = sLinkUrl ; + GetE('cmbLnkTarget').value = oLink.target ; + } + + UpdatePreview() ; +} + +//#### The OK button was hit. +function Ok() +{ + if ( GetE('txtUrl').value.length == 0 ) + { + dialog.SetSelectedTab( 'Info' ) ; + GetE('txtUrl').focus() ; + + alert( FCKLang.DlgImgAlertUrl ) ; + + return false ; + } + + var bHasImage = ( oImage != null ) ; + + if ( bHasImage && bImageButton && oImage.tagName == 'IMG' ) + { + if ( confirm( 'Do you want to transform the selected image on a image button?' ) ) + oImage = null ; + } + else if ( bHasImage && !bImageButton && oImage.tagName == 'INPUT' ) + { + if ( confirm( 'Do you want to transform the selected image button on a simple image?' ) ) + oImage = null ; + } + + oEditor.FCKUndo.SaveUndoStep() ; + if ( !bHasImage ) + { + if ( bImageButton ) + { + oImage = FCK.EditorDocument.createElement( 'input' ) ; + oImage.type = 'image' ; + oImage = FCK.InsertElement( oImage ) ; + } + else + oImage = FCK.InsertElement( 'img' ) ; + } + + UpdateImage( oImage ) ; + + var sLnkUrl = GetE('txtLnkUrl').value.Trim() ; + + if ( sLnkUrl.length == 0 ) + { + if ( oLink ) + FCK.ExecuteNamedCommand( 'Unlink' ) ; + } + else + { + if ( oLink ) // Modifying an existent link. + oLink.href = sLnkUrl ; + else // Creating a new link. + { + if ( !bHasImage ) + oEditor.FCKSelection.SelectNode( oImage ) ; + + oLink = oEditor.FCK.CreateLink( sLnkUrl )[0] ; + + if ( !bHasImage ) + { + oEditor.FCKSelection.SelectNode( oLink ) ; + oEditor.FCKSelection.Collapse( false ) ; + } + } + + SetAttribute( oLink, '_fcksavedurl', sLnkUrl ) ; + SetAttribute( oLink, 'target', GetE('cmbLnkTarget').value ) ; + } + + return true ; +} + +function UpdateImage( e, skipId ) +{ + e.src = GetE('txtUrl').value ; + SetAttribute( e, "_fcksavedurl", GetE('txtUrl').value ) ; + SetAttribute( e, "alt" , GetE('txtAlt').value ) ; + SetAttribute( e, "width" , GetE('txtWidth').value ) ; + SetAttribute( e, "height", GetE('txtHeight').value ) ; + SetAttribute( e, "vspace", GetE('txtVSpace').value ) ; + SetAttribute( e, "hspace", GetE('txtHSpace').value ) ; + SetAttribute( e, "border", GetE('txtBorder').value ) ; + SetAttribute( e, "align" , GetE('cmbAlign').value ) ; + + // Advances Attributes + + if ( ! skipId ) + SetAttribute( e, 'id', GetE('txtAttId').value ) ; + + SetAttribute( e, 'dir' , GetE('cmbAttLangDir').value ) ; + SetAttribute( e, 'lang' , GetE('txtAttLangCode').value ) ; + SetAttribute( e, 'title' , GetE('txtAttTitle').value ) ; + SetAttribute( e, 'longDesc' , GetE('txtLongDesc').value ) ; + + if ( oEditor.FCKBrowserInfo.IsIE ) + { + e.className = GetE('txtAttClasses').value ; + e.style.cssText = GetE('txtAttStyle').value ; + } + else + { + SetAttribute( e, 'class' , GetE('txtAttClasses').value ) ; + SetAttribute( e, 'style', GetE('txtAttStyle').value ) ; + } +} + +var eImgPreview ; +var eImgPreviewLink ; + +function SetPreviewElements( imageElement, linkElement ) +{ + eImgPreview = imageElement ; + eImgPreviewLink = linkElement ; + + UpdatePreview() ; + UpdateOriginal() ; + + bPreviewInitialized = true ; +} + +function UpdatePreview() +{ + if ( !eImgPreview || !eImgPreviewLink ) + return ; + + if ( GetE('txtUrl').value.length == 0 ) + eImgPreviewLink.style.display = 'none' ; + else + { + UpdateImage( eImgPreview, true ) ; + + if ( GetE('txtLnkUrl').value.Trim().length > 0 ) + eImgPreviewLink.href = 'javascript:void(null);' ; + else + SetAttribute( eImgPreviewLink, 'href', '' ) ; + + eImgPreviewLink.style.display = '' ; + } +} + +var bLockRatio = true ; + +function SwitchLock( lockButton ) +{ + bLockRatio = !bLockRatio ; + lockButton.className = bLockRatio ? 'BtnLocked' : 'BtnUnlocked' ; + lockButton.title = bLockRatio ? 'Lock sizes' : 'Unlock sizes' ; + + if ( bLockRatio ) + { + if ( GetE('txtWidth').value.length > 0 ) + OnSizeChanged( 'Width', GetE('txtWidth').value ) ; + else + OnSizeChanged( 'Height', GetE('txtHeight').value ) ; + } +} + +// Fired when the width or height input texts change +function OnSizeChanged( dimension, value ) +{ + // Verifies if the aspect ration has to be maintained + if ( oImageOriginal && bLockRatio ) + { + var e = dimension == 'Width' ? GetE('txtHeight') : GetE('txtWidth') ; + + if ( value.length == 0 || isNaN( value ) ) + { + e.value = '' ; + return ; + } + + if ( dimension == 'Width' ) + value = value == 0 ? 0 : Math.round( oImageOriginal.height * ( value / oImageOriginal.width ) ) ; + else + value = value == 0 ? 0 : Math.round( oImageOriginal.width * ( value / oImageOriginal.height ) ) ; + + if ( !isNaN( value ) ) + e.value = value ; + } + + UpdatePreview() ; +} + +// Fired when the Reset Size button is clicked +function ResetSizes() +{ + if ( ! oImageOriginal ) return ; + if ( oEditor.FCKBrowserInfo.IsGecko && !oImageOriginal.complete ) + { + setTimeout( ResetSizes, 50 ) ; + return ; + } + + GetE('txtWidth').value = oImageOriginal.width ; + GetE('txtHeight').value = oImageOriginal.height ; + + UpdatePreview() ; +} + +function BrowseServer() +{ + OpenServerBrowser( + 'Image', + FCKConfig.ImageBrowserURL, + FCKConfig.ImageBrowserWindowWidth, + FCKConfig.ImageBrowserWindowHeight ) ; +} + +function LnkBrowseServer() +{ + OpenServerBrowser( + 'Link', + FCKConfig.LinkBrowserURL, + FCKConfig.LinkBrowserWindowWidth, + FCKConfig.LinkBrowserWindowHeight ) ; +} + +function OpenServerBrowser( type, url, width, height ) +{ + sActualBrowser = type ; + OpenFileBrowser( url, width, height ) ; +} + +var sActualBrowser ; + +function SetUrl( url, width, height, alt ) +{ + if ( sActualBrowser == 'Link' ) + { + GetE('txtLnkUrl').value = url ; + UpdatePreview() ; + } + else + { + GetE('txtUrl').value = url ; + GetE('txtWidth').value = width ? width : '' ; + GetE('txtHeight').value = height ? height : '' ; + + if ( alt ) + GetE('txtAlt').value = alt; + + UpdatePreview() ; + UpdateOriginal( true ) ; + } + + dialog.SetSelectedTab( 'Info' ) ; +} + +function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg ) +{ + // Remove animation + window.parent.Throbber.Hide() ; + GetE( 'divUpload' ).style.display = '' ; + + switch ( errorNumber ) + { + case 0 : // No errors + alert( 'Your file has been successfully uploaded' ) ; + break ; + case 1 : // Custom error + alert( customMsg ) ; + return ; + case 101 : // Custom warning + alert( customMsg ) ; + break ; + case 201 : + alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ; + break ; + case 202 : + alert( 'Invalid file type' ) ; + return ; + case 203 : + alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ; + return ; + case 500 : + alert( 'The connector is disabled' ) ; + break ; + default : + alert( 'Error on file upload. Error number: ' + errorNumber ) ; + return ; + } + + sActualBrowser = '' ; + SetUrl( fileUrl ) ; + GetE('frmUpload').reset() ; +} + +var oUploadAllowedExtRegex = new RegExp( FCKConfig.ImageUploadAllowedExtensions, 'i' ) ; +var oUploadDeniedExtRegex = new RegExp( FCKConfig.ImageUploadDeniedExtensions, 'i' ) ; + +function CheckUpload() +{ + var sFile = GetE('txtUploadFile').value ; + + if ( sFile.length == 0 ) + { + alert( 'Please select a file to upload' ) ; + return false ; + } + + if ( ( FCKConfig.ImageUploadAllowedExtensions.length > 0 && !oUploadAllowedExtRegex.test( sFile ) ) || + ( FCKConfig.ImageUploadDeniedExtensions.length > 0 && oUploadDeniedExtRegex.test( sFile ) ) ) + { + OnUploadCompleted( 202 ) ; + return false ; + } + + // Show animation + window.parent.Throbber.Show( 100 ) ; + GetE( 'divUpload' ).style.display = 'none' ; + + return true ; +} diff --git a/includes/fckeditor/editor/dialog/fck_image/fck_image_preview.html b/includes/fckeditor/editor/dialog/fck_image/fck_image_preview.html new file mode 100755 index 0000000..81f44e8 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_image/fck_image_preview.html @@ -0,0 +1,72 @@ + + + + + + + + + + + +
+ + Lorem ipsum dolor sit amet, consectetuer adipiscing + elit. Maecenas feugiat consequat diam. Maecenas metus. Vivamus diam purus, cursus + a, commodo non, facilisis vitae, nulla. Aenean dictum lacinia tortor. Nunc iaculis, + nibh non iaculis aliquam, orci felis euismod neque, sed ornare massa mauris sed + velit. Nulla pretium mi et risus. Fusce mi pede, tempor id, cursus ac, ullamcorper + nec, enim. Sed tortor. Curabitur molestie. Duis velit augue, condimentum at, ultrices + a, luctus ut, orci. Donec pellentesque egestas eros. Integer cursus, augue in cursus + faucibus, eros pede bibendum sem, in tempus tellus justo quis ligula. Etiam eget + tortor. Vestibulum rutrum, est ut placerat elementum, lectus nisl aliquam velit, + tempor aliquam eros nunc nonummy metus. In eros metus, gravida a, gravida sed, lobortis + id, turpis. Ut ultrices, ipsum at venenatis fringilla, sem nulla lacinia tellus, + eget aliquet turpis mauris non enim. Nam turpis. Suspendisse lacinia. Curabitur + ac tortor ut ipsum egestas elementum. Nunc imperdiet gravida mauris. +
+ + diff --git a/includes/fckeditor/editor/dialog/fck_link.html b/includes/fckeditor/editor/dialog/fck_link.html new file mode 100755 index 0000000..6d69e6e --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_link.html @@ -0,0 +1,295 @@ + + + + + Link Properties + + + + + + + + + + + + diff --git a/includes/fckeditor/editor/dialog/fck_link/fck_link.js b/includes/fckeditor/editor/dialog/fck_link/fck_link.js new file mode 100755 index 0000000..817b3e1 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_link/fck_link.js @@ -0,0 +1,893 @@ +/* + * FCKeditor - The text editor for Internet - http://www.fckeditor.net + * Copyright (C) 2003-2008 Frederico Caldeira Knabben + * + * == BEGIN LICENSE == + * + * Licensed under the terms of any of the following licenses at your + * choice: + * + * - GNU General Public License Version 2 or later (the "GPL") + * http://www.gnu.org/licenses/gpl.html + * + * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") + * http://www.gnu.org/licenses/lgpl.html + * + * - Mozilla Public License Version 1.1 or later (the "MPL") + * http://www.mozilla.org/MPL/MPL-1.1.html + * + * == END LICENSE == + * + * Scripts related to the Link dialog window (see fck_link.html). + */ + +var dialog = window.parent ; +var oEditor = dialog.InnerDialogLoaded() ; + +var FCK = oEditor.FCK ; +var FCKLang = oEditor.FCKLang ; +var FCKConfig = oEditor.FCKConfig ; +var FCKRegexLib = oEditor.FCKRegexLib ; +var FCKTools = oEditor.FCKTools ; + +//#### Dialog Tabs + +// Set the dialog tabs. +dialog.AddTab( 'Info', FCKLang.DlgLnkInfoTab ) ; + +if ( !FCKConfig.LinkDlgHideTarget ) + dialog.AddTab( 'Target', FCKLang.DlgLnkTargetTab, true ) ; + +if ( FCKConfig.LinkUpload ) + dialog.AddTab( 'Upload', FCKLang.DlgLnkUpload, true ) ; + +if ( !FCKConfig.LinkDlgHideAdvanced ) + dialog.AddTab( 'Advanced', FCKLang.DlgAdvancedTag ) ; + +// Function called when a dialog tag is selected. +function OnDialogTabChange( tabCode ) +{ + ShowE('divInfo' , ( tabCode == 'Info' ) ) ; + ShowE('divTarget' , ( tabCode == 'Target' ) ) ; + ShowE('divUpload' , ( tabCode == 'Upload' ) ) ; + ShowE('divAttribs' , ( tabCode == 'Advanced' ) ) ; + + dialog.SetAutoSize( true ) ; +} + +//#### Regular Expressions library. +var oRegex = new Object() ; + +oRegex.UriProtocol = /^(((http|https|ftp|news):\/\/)|mailto:)/gi ; + +oRegex.UrlOnChangeProtocol = /^(http|https|ftp|news):\/\/(?=.)/gi ; + +oRegex.UrlOnChangeTestOther = /^((javascript:)|[#\/\.])/gi ; + +oRegex.ReserveTarget = /^_(blank|self|top|parent)$/i ; + +oRegex.PopupUri = /^javascript:void\(\s*window.open\(\s*'([^']+)'\s*,\s*(?:'([^']*)'|null)\s*,\s*'([^']*)'\s*\)\s*\)\s*$/ ; + +// Accessible popups +oRegex.OnClickPopup = /^\s*on[cC]lick="\s*window.open\(\s*this\.href\s*,\s*(?:'([^']*)'|null)\s*,\s*'([^']*)'\s*\)\s*;\s*return\s*false;*\s*"$/ ; + +oRegex.PopupFeatures = /(?:^|,)([^=]+)=(\d+|yes|no)/gi ; + +//#### Parser Functions + +var oParser = new Object() ; + +// This method simply returns the two inputs in numerical order. You can even +// provide strings, as the method would parseInt() the values. +oParser.SortNumerical = function(a, b) +{ + return parseInt( a, 10 ) - parseInt( b, 10 ) ; +} + +oParser.ParseEMailParams = function(sParams) +{ + // Initialize the oEMailParams object. + var oEMailParams = new Object() ; + oEMailParams.Subject = '' ; + oEMailParams.Body = '' ; + + var aMatch = sParams.match( /(^|^\?|&)subject=([^&]+)/i ) ; + if ( aMatch ) oEMailParams.Subject = decodeURIComponent( aMatch[2] ) ; + + aMatch = sParams.match( /(^|^\?|&)body=([^&]+)/i ) ; + if ( aMatch ) oEMailParams.Body = decodeURIComponent( aMatch[2] ) ; + + return oEMailParams ; +} + +// This method returns either an object containing the email info, or FALSE +// if the parameter is not an email link. +oParser.ParseEMailUri = function( sUrl ) +{ + // Initializes the EMailInfo object. + var oEMailInfo = new Object() ; + oEMailInfo.Address = '' ; + oEMailInfo.Subject = '' ; + oEMailInfo.Body = '' ; + + var aLinkInfo = sUrl.match( /^(\w+):(.*)$/ ) ; + if ( aLinkInfo && aLinkInfo[1] == 'mailto' ) + { + // This seems to be an unprotected email link. + var aParts = aLinkInfo[2].match( /^([^\?]+)\??(.+)?/ ) ; + if ( aParts ) + { + // Set the e-mail address. + oEMailInfo.Address = aParts[1] ; + + // Look for the optional e-mail parameters. + if ( aParts[2] ) + { + var oEMailParams = oParser.ParseEMailParams( aParts[2] ) ; + oEMailInfo.Subject = oEMailParams.Subject ; + oEMailInfo.Body = oEMailParams.Body ; + } + } + return oEMailInfo ; + } + else if ( aLinkInfo && aLinkInfo[1] == 'javascript' ) + { + // This may be a protected email. + + // Try to match the url against the EMailProtectionFunction. + var func = FCKConfig.EMailProtectionFunction ; + if ( func != null ) + { + try + { + // Escape special chars. + func = func.replace( /([\/^$*+.?()\[\]])/g, '\\$1' ) ; + + // Define the possible keys. + var keys = new Array('NAME', 'DOMAIN', 'SUBJECT', 'BODY') ; + + // Get the order of the keys (hold them in the array ) and + // the function replaced by regular expression patterns. + var sFunc = func ; + var pos = new Array() ; + for ( var i = 0 ; i < keys.length ; i ++ ) + { + var rexp = new RegExp( keys[i] ) ; + var p = func.search( rexp ) ; + if ( p >= 0 ) + { + sFunc = sFunc.replace( rexp, '\'([^\']*)\'' ) ; + pos[pos.length] = p + ':' + keys[i] ; + } + } + + // Sort the available keys. + pos.sort( oParser.SortNumerical ) ; + + // Replace the excaped single quotes in the url, such they do + // not affect the regexp afterwards. + aLinkInfo[2] = aLinkInfo[2].replace( /\\'/g, '###SINGLE_QUOTE###' ) ; + + // Create the regexp and execute it. + var rFunc = new RegExp( '^' + sFunc + '$' ) ; + var aMatch = rFunc.exec( aLinkInfo[2] ) ; + if ( aMatch ) + { + var aInfo = new Array(); + for ( var i = 1 ; i < aMatch.length ; i ++ ) + { + var k = pos[i-1].match(/^\d+:(.+)$/) ; + aInfo[k[1]] = aMatch[i].replace(/###SINGLE_QUOTE###/g, '\'') ; + } + + // Fill the EMailInfo object that will be returned + oEMailInfo.Address = aInfo['NAME'] + '@' + aInfo['DOMAIN'] ; + oEMailInfo.Subject = decodeURIComponent( aInfo['SUBJECT'] ) ; + oEMailInfo.Body = decodeURIComponent( aInfo['BODY'] ) ; + + return oEMailInfo ; + } + } + catch (e) + { + } + } + + // Try to match the email against the encode protection. + var aMatch = aLinkInfo[2].match( /^location\.href='mailto:'\+(String\.fromCharCode\([\d,]+\))\+'(.*)'$/ ) ; + if ( aMatch ) + { + // The link is encoded + oEMailInfo.Address = eval( aMatch[1] ) ; + if ( aMatch[2] ) + { + var oEMailParams = oParser.ParseEMailParams( aMatch[2] ) ; + oEMailInfo.Subject = oEMailParams.Subject ; + oEMailInfo.Body = oEMailParams.Body ; + } + return oEMailInfo ; + } + } + return false; +} + +oParser.CreateEMailUri = function( address, subject, body ) +{ + // Switch for the EMailProtection setting. + switch ( FCKConfig.EMailProtection ) + { + case 'function' : + var func = FCKConfig.EMailProtectionFunction ; + if ( func == null ) + { + if ( FCKConfig.Debug ) + { + alert('EMailProtection alert!\nNo function defined. Please set "FCKConfig.EMailProtectionFunction"') ; + } + return ''; + } + + // Split the email address into name and domain parts. + var aAddressParts = address.split( '@', 2 ) ; + if ( aAddressParts[1] == undefined ) + { + aAddressParts[1] = '' ; + } + + // Replace the keys by their values (embedded in single quotes). + func = func.replace(/NAME/g, "'" + aAddressParts[0].replace(/'/g, '\\\'') + "'") ; + func = func.replace(/DOMAIN/g, "'" + aAddressParts[1].replace(/'/g, '\\\'') + "'") ; + func = func.replace(/SUBJECT/g, "'" + encodeURIComponent( subject ).replace(/'/g, '\\\'') + "'") ; + func = func.replace(/BODY/g, "'" + encodeURIComponent( body ).replace(/'/g, '\\\'') + "'") ; + + return 'javascript:' + func ; + + case 'encode' : + var aParams = [] ; + var aAddressCode = [] ; + + if ( subject.length > 0 ) + aParams.push( 'subject='+ encodeURIComponent( subject ) ) ; + if ( body.length > 0 ) + aParams.push( 'body=' + encodeURIComponent( body ) ) ; + for ( var i = 0 ; i < address.length ; i++ ) + aAddressCode.push( address.charCodeAt( i ) ) ; + + return 'javascript:location.href=\'mailto:\'+String.fromCharCode(' + aAddressCode.join( ',' ) + ')+\'?' + aParams.join( '&' ) + '\'' ; + } + + // EMailProtection 'none' + + var sBaseUri = 'mailto:' + address ; + + var sParams = '' ; + + if ( subject.length > 0 ) + sParams = '?subject=' + encodeURIComponent( subject ) ; + + if ( body.length > 0 ) + { + sParams += ( sParams.length == 0 ? '?' : '&' ) ; + sParams += 'body=' + encodeURIComponent( body ) ; + } + + return sBaseUri + sParams ; +} + +//#### Initialization Code + +// oLink: The actual selected link in the editor. +var oLink = dialog.Selection.GetSelection().MoveToAncestorNode( 'A' ) ; +if ( oLink ) + FCK.Selection.SelectNode( oLink ) ; + +window.onload = function() +{ + // Translate the dialog box texts. + oEditor.FCKLanguageManager.TranslatePage(document) ; + + // Fill the Anchor Names and Ids combos. + LoadAnchorNamesAndIds() ; + + // Load the selected link information (if any). + LoadSelection() ; + + // Update the dialog box. + SetLinkType( GetE('cmbLinkType').value ) ; + + // Show/Hide the "Browse Server" button. + GetE('divBrowseServer').style.display = FCKConfig.LinkBrowser ? '' : 'none' ; + + // Show the initial dialog content. + GetE('divInfo').style.display = '' ; + + // Set the actual uploader URL. + if ( FCKConfig.LinkUpload ) + GetE('frmUpload').action = FCKConfig.LinkUploadURL ; + + // Set the default target (from configuration). + SetDefaultTarget() ; + + // Activate the "OK" button. + dialog.SetOkButton( true ) ; + + // Select the first field. + switch( GetE('cmbLinkType').value ) + { + case 'url' : + SelectField( 'txtUrl' ) ; + break ; + case 'email' : + SelectField( 'txtEMailAddress' ) ; + break ; + case 'anchor' : + if ( GetE('divSelAnchor').style.display != 'none' ) + SelectField( 'cmbAnchorName' ) ; + else + SelectField( 'cmbLinkType' ) ; + } +} + +var bHasAnchors ; + +function LoadAnchorNamesAndIds() +{ + // Since version 2.0, the anchors are replaced in the DOM by IMGs so the user see the icon + // to edit them. So, we must look for that images now. + var aAnchors = new Array() ; + var i ; + var oImages = oEditor.FCK.EditorDocument.getElementsByTagName( 'IMG' ) ; + for( i = 0 ; i < oImages.length ; i++ ) + { + if ( oImages[i].getAttribute('_fckanchor') ) + aAnchors[ aAnchors.length ] = oEditor.FCK.GetRealElement( oImages[i] ) ; + } + + // Add also real anchors + var oLinks = oEditor.FCK.EditorDocument.getElementsByTagName( 'A' ) ; + for( i = 0 ; i < oLinks.length ; i++ ) + { + if ( oLinks[i].name && ( oLinks[i].name.length > 0 ) ) + aAnchors[ aAnchors.length ] = oLinks[i] ; + } + + var aIds = FCKTools.GetAllChildrenIds( oEditor.FCK.EditorDocument.body ) ; + + bHasAnchors = ( aAnchors.length > 0 || aIds.length > 0 ) ; + + for ( i = 0 ; i < aAnchors.length ; i++ ) + { + var sName = aAnchors[i].name ; + if ( sName && sName.length > 0 ) + FCKTools.AddSelectOption( GetE('cmbAnchorName'), sName, sName ) ; + } + + for ( i = 0 ; i < aIds.length ; i++ ) + { + FCKTools.AddSelectOption( GetE('cmbAnchorId'), aIds[i], aIds[i] ) ; + } + + ShowE( 'divSelAnchor' , bHasAnchors ) ; + ShowE( 'divNoAnchor' , !bHasAnchors ) ; +} + +function LoadSelection() +{ + if ( !oLink ) return ; + + var sType = 'url' ; + + // Get the actual Link href. + var sHRef = oLink.getAttribute( '_fcksavedurl' ) ; + if ( sHRef == null ) + sHRef = oLink.getAttribute( 'href' , 2 ) || '' ; + + // Look for a popup javascript link. + var oPopupMatch = oRegex.PopupUri.exec( sHRef ) ; + if( oPopupMatch ) + { + GetE('cmbTarget').value = 'popup' ; + sHRef = oPopupMatch[1] ; + FillPopupFields( oPopupMatch[2], oPopupMatch[3] ) ; + SetTarget( 'popup' ) ; + } + + // Accessible popups, the popup data is in the onclick attribute + if ( !oPopupMatch ) + { + var onclick = oLink.getAttribute( 'onclick_fckprotectedatt' ) ; + if ( onclick ) + { + // Decode the protected string + onclick = decodeURIComponent( onclick ) ; + + oPopupMatch = oRegex.OnClickPopup.exec( onclick ) ; + if( oPopupMatch ) + { + GetE( 'cmbTarget' ).value = 'popup' ; + FillPopupFields( oPopupMatch[1], oPopupMatch[2] ) ; + SetTarget( 'popup' ) ; + } + } + } + + // Search for the protocol. + var sProtocol = oRegex.UriProtocol.exec( sHRef ) ; + + // Search for a protected email link. + var oEMailInfo = oParser.ParseEMailUri( sHRef ); + + if ( oEMailInfo ) + { + sType = 'email' ; + + GetE('txtEMailAddress').value = oEMailInfo.Address ; + GetE('txtEMailSubject').value = oEMailInfo.Subject ; + GetE('txtEMailBody').value = oEMailInfo.Body ; + } + else if ( sProtocol ) + { + sProtocol = sProtocol[0].toLowerCase() ; + GetE('cmbLinkProtocol').value = sProtocol ; + + // Remove the protocol and get the remaining URL. + var sUrl = sHRef.replace( oRegex.UriProtocol, '' ) ; + sType = 'url' ; + GetE('txtUrl').value = sUrl ; + } + else if ( sHRef.substr(0,1) == '#' && sHRef.length > 1 ) // It is an anchor link. + { + sType = 'anchor' ; + GetE('cmbAnchorName').value = GetE('cmbAnchorId').value = sHRef.substr(1) ; + } + else // It is another type of link. + { + sType = 'url' ; + + GetE('cmbLinkProtocol').value = '' ; + GetE('txtUrl').value = sHRef ; + } + + if ( !oPopupMatch ) + { + // Get the target. + var sTarget = oLink.target ; + + if ( sTarget && sTarget.length > 0 ) + { + if ( oRegex.ReserveTarget.test( sTarget ) ) + { + sTarget = sTarget.toLowerCase() ; + GetE('cmbTarget').value = sTarget ; + } + else + GetE('cmbTarget').value = 'frame' ; + GetE('txtTargetFrame').value = sTarget ; + } + } + + // Get Advances Attributes + GetE('txtAttId').value = oLink.id ; + GetE('txtAttName').value = oLink.name ; + GetE('cmbAttLangDir').value = oLink.dir ; + GetE('txtAttLangCode').value = oLink.lang ; + GetE('txtAttAccessKey').value = oLink.accessKey ; + GetE('txtAttTabIndex').value = oLink.tabIndex <= 0 ? '' : oLink.tabIndex ; + GetE('txtAttTitle').value = oLink.title ; + GetE('txtAttContentType').value = oLink.type ; + GetE('txtAttCharSet').value = oLink.charset ; + + var sClass ; + if ( oEditor.FCKBrowserInfo.IsIE ) + { + sClass = oLink.getAttribute('className',2) || '' ; + // Clean up temporary classes for internal use: + sClass = sClass.replace( FCKRegexLib.FCK_Class, '' ) ; + + GetE('txtAttStyle').value = oLink.style.cssText ; + } + else + { + sClass = oLink.getAttribute('class',2) || '' ; + GetE('txtAttStyle').value = oLink.getAttribute('style',2) || '' ; + } + GetE('txtAttClasses').value = sClass ; + + // Update the Link type combo. + GetE('cmbLinkType').value = sType ; +} + +//#### Link type selection. +function SetLinkType( linkType ) +{ + ShowE('divLinkTypeUrl' , (linkType == 'url') ) ; + ShowE('divLinkTypeAnchor' , (linkType == 'anchor') ) ; + ShowE('divLinkTypeEMail' , (linkType == 'email') ) ; + + if ( !FCKConfig.LinkDlgHideTarget ) + dialog.SetTabVisibility( 'Target' , (linkType == 'url') ) ; + + if ( FCKConfig.LinkUpload ) + dialog.SetTabVisibility( 'Upload' , (linkType == 'url') ) ; + + if ( !FCKConfig.LinkDlgHideAdvanced ) + dialog.SetTabVisibility( 'Advanced' , (linkType != 'anchor' || bHasAnchors) ) ; + + if ( linkType == 'email' ) + dialog.SetAutoSize( true ) ; +} + +//#### Target type selection. +function SetTarget( targetType ) +{ + GetE('tdTargetFrame').style.display = ( targetType == 'popup' ? 'none' : '' ) ; + GetE('tdPopupName').style.display = + GetE('tablePopupFeatures').style.display = ( targetType == 'popup' ? '' : 'none' ) ; + + switch ( targetType ) + { + case "_blank" : + case "_self" : + case "_parent" : + case "_top" : + GetE('txtTargetFrame').value = targetType ; + break ; + case "" : + GetE('txtTargetFrame').value = '' ; + break ; + } + + if ( targetType == 'popup' ) + dialog.SetAutoSize( true ) ; +} + +//#### Called while the user types the URL. +function OnUrlChange() +{ + var sUrl = GetE('txtUrl').value ; + var sProtocol = oRegex.UrlOnChangeProtocol.exec( sUrl ) ; + + if ( sProtocol ) + { + sUrl = sUrl.substr( sProtocol[0].length ) ; + GetE('txtUrl').value = sUrl ; + GetE('cmbLinkProtocol').value = sProtocol[0].toLowerCase() ; + } + else if ( oRegex.UrlOnChangeTestOther.test( sUrl ) ) + { + GetE('cmbLinkProtocol').value = '' ; + } +} + +//#### Called while the user types the target name. +function OnTargetNameChange() +{ + var sFrame = GetE('txtTargetFrame').value ; + + if ( sFrame.length == 0 ) + GetE('cmbTarget').value = '' ; + else if ( oRegex.ReserveTarget.test( sFrame ) ) + GetE('cmbTarget').value = sFrame.toLowerCase() ; + else + GetE('cmbTarget').value = 'frame' ; +} + +// Accessible popups +function BuildOnClickPopup() +{ + var sWindowName = "'" + GetE('txtPopupName').value.replace(/\W/gi, "") + "'" ; + + var sFeatures = '' ; + var aChkFeatures = document.getElementsByName( 'chkFeature' ) ; + for ( var i = 0 ; i < aChkFeatures.length ; i++ ) + { + if ( i > 0 ) sFeatures += ',' ; + sFeatures += aChkFeatures[i].value + '=' + ( aChkFeatures[i].checked ? 'yes' : 'no' ) ; + } + + if ( GetE('txtPopupWidth').value.length > 0 ) sFeatures += ',width=' + GetE('txtPopupWidth').value ; + if ( GetE('txtPopupHeight').value.length > 0 ) sFeatures += ',height=' + GetE('txtPopupHeight').value ; + if ( GetE('txtPopupLeft').value.length > 0 ) sFeatures += ',left=' + GetE('txtPopupLeft').value ; + if ( GetE('txtPopupTop').value.length > 0 ) sFeatures += ',top=' + GetE('txtPopupTop').value ; + + if ( sFeatures != '' ) + sFeatures = sFeatures + ",status" ; + + return ( "window.open(this.href," + sWindowName + ",'" + sFeatures + "'); return false" ) ; +} + +//#### Fills all Popup related fields. +function FillPopupFields( windowName, features ) +{ + if ( windowName ) + GetE('txtPopupName').value = windowName ; + + var oFeatures = new Object() ; + var oFeaturesMatch ; + while( ( oFeaturesMatch = oRegex.PopupFeatures.exec( features ) ) != null ) + { + var sValue = oFeaturesMatch[2] ; + if ( sValue == ( 'yes' || '1' ) ) + oFeatures[ oFeaturesMatch[1] ] = true ; + else if ( ! isNaN( sValue ) && sValue != 0 ) + oFeatures[ oFeaturesMatch[1] ] = sValue ; + } + + // Update all features check boxes. + var aChkFeatures = document.getElementsByName('chkFeature') ; + for ( var i = 0 ; i < aChkFeatures.length ; i++ ) + { + if ( oFeatures[ aChkFeatures[i].value ] ) + aChkFeatures[i].checked = true ; + } + + // Update position and size text boxes. + if ( oFeatures['width'] ) GetE('txtPopupWidth').value = oFeatures['width'] ; + if ( oFeatures['height'] ) GetE('txtPopupHeight').value = oFeatures['height'] ; + if ( oFeatures['left'] ) GetE('txtPopupLeft').value = oFeatures['left'] ; + if ( oFeatures['top'] ) GetE('txtPopupTop').value = oFeatures['top'] ; +} + +//#### The OK button was hit. +function Ok() +{ + var sUri, sInnerHtml ; + oEditor.FCKUndo.SaveUndoStep() ; + + switch ( GetE('cmbLinkType').value ) + { + case 'url' : + sUri = GetE('txtUrl').value ; + + if ( sUri.length == 0 ) + { + alert( FCKLang.DlnLnkMsgNoUrl ) ; + return false ; + } + + sUri = GetE('cmbLinkProtocol').value + sUri ; + + break ; + + case 'email' : + sUri = GetE('txtEMailAddress').value ; + + if ( sUri.length == 0 ) + { + alert( FCKLang.DlnLnkMsgNoEMail ) ; + return false ; + } + + sUri = oParser.CreateEMailUri( + sUri, + GetE('txtEMailSubject').value, + GetE('txtEMailBody').value ) ; + break ; + + case 'anchor' : + var sAnchor = GetE('cmbAnchorName').value ; + if ( sAnchor.length == 0 ) sAnchor = GetE('cmbAnchorId').value ; + + if ( sAnchor.length == 0 ) + { + alert( FCKLang.DlnLnkMsgNoAnchor ) ; + return false ; + } + + sUri = '#' + sAnchor ; + break ; + } + + // If no link is selected, create a new one (it may result in more than one link creation - #220). + var aLinks = oLink ? [ oLink ] : oEditor.FCK.CreateLink( sUri, true ) ; + + // If no selection, no links are created, so use the uri as the link text (by dom, 2006-05-26) + var aHasSelection = ( aLinks.length > 0 ) ; + if ( !aHasSelection ) + { + sInnerHtml = sUri; + + // Built a better text for empty links. + switch ( GetE('cmbLinkType').value ) + { + // anchor: use old behavior --> return true + case 'anchor': + sInnerHtml = sInnerHtml.replace( /^#/, '' ) ; + break ; + + // url: try to get path + case 'url': + var oLinkPathRegEx = new RegExp("//?([^?\"']+)([?].*)?$") ; + var asLinkPath = oLinkPathRegEx.exec( sUri ) ; + if (asLinkPath != null) + sInnerHtml = asLinkPath[1]; // use matched path + break ; + + // mailto: try to get email address + case 'email': + sInnerHtml = GetE('txtEMailAddress').value ; + break ; + } + + // Create a new (empty) anchor. + aLinks = [ oEditor.FCK.InsertElement( 'a' ) ] ; + } + + for ( var i = 0 ; i < aLinks.length ; i++ ) + { + oLink = aLinks[i] ; + + if ( aHasSelection ) + sInnerHtml = oLink.innerHTML ; // Save the innerHTML (IE changes it if it is like an URL). + + oLink.href = sUri ; + SetAttribute( oLink, '_fcksavedurl', sUri ) ; + + var onclick; + // Accessible popups + if( GetE('cmbTarget').value == 'popup' ) + { + onclick = BuildOnClickPopup() ; + // Encode the attribute + onclick = encodeURIComponent( " onclick=\"" + onclick + "\"" ) ; + SetAttribute( oLink, 'onclick_fckprotectedatt', onclick ) ; + } + else + { + // Check if the previous onclick was for a popup: + // In that case remove the onclick handler. + onclick = oLink.getAttribute( 'onclick_fckprotectedatt' ) ; + if ( onclick ) + { + // Decode the protected string + onclick = decodeURIComponent( onclick ) ; + + if( oRegex.OnClickPopup.test( onclick ) ) + SetAttribute( oLink, 'onclick_fckprotectedatt', '' ) ; + } + } + + oLink.innerHTML = sInnerHtml ; // Set (or restore) the innerHTML + + // Target + if( GetE('cmbTarget').value != 'popup' ) + SetAttribute( oLink, 'target', GetE('txtTargetFrame').value ) ; + else + SetAttribute( oLink, 'target', null ) ; + + // Let's set the "id" only for the first link to avoid duplication. + if ( i == 0 ) + SetAttribute( oLink, 'id', GetE('txtAttId').value ) ; + + // Advances Attributes + SetAttribute( oLink, 'name' , GetE('txtAttName').value ) ; + SetAttribute( oLink, 'dir' , GetE('cmbAttLangDir').value ) ; + SetAttribute( oLink, 'lang' , GetE('txtAttLangCode').value ) ; + SetAttribute( oLink, 'accesskey', GetE('txtAttAccessKey').value ) ; + SetAttribute( oLink, 'tabindex' , ( GetE('txtAttTabIndex').value > 0 ? GetE('txtAttTabIndex').value : null ) ) ; + SetAttribute( oLink, 'title' , GetE('txtAttTitle').value ) ; + SetAttribute( oLink, 'type' , GetE('txtAttContentType').value ) ; + SetAttribute( oLink, 'charset' , GetE('txtAttCharSet').value ) ; + + if ( oEditor.FCKBrowserInfo.IsIE ) + { + var sClass = GetE('txtAttClasses').value ; + // If it's also an anchor add an internal class + if ( GetE('txtAttName').value.length != 0 ) + sClass += ' FCK__AnchorC' ; + SetAttribute( oLink, 'className', sClass ) ; + + oLink.style.cssText = GetE('txtAttStyle').value ; + } + else + { + SetAttribute( oLink, 'class', GetE('txtAttClasses').value ) ; + SetAttribute( oLink, 'style', GetE('txtAttStyle').value ) ; + } + } + + // Select the (first) link. + oEditor.FCKSelection.SelectNode( aLinks[0] ); + + return true ; +} + +function BrowseServer() +{ + OpenFileBrowser( FCKConfig.LinkBrowserURL, FCKConfig.LinkBrowserWindowWidth, FCKConfig.LinkBrowserWindowHeight ) ; +} + +function SetUrl( url ) +{ + GetE('txtUrl').value = url ; + OnUrlChange() ; + dialog.SetSelectedTab( 'Info' ) ; +} + +function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg ) +{ + // Remove animation + window.parent.Throbber.Hide() ; + GetE( 'divUpload' ).style.display = '' ; + + switch ( errorNumber ) + { + case 0 : // No errors + alert( 'Your file has been successfully uploaded' ) ; + break ; + case 1 : // Custom error + alert( customMsg ) ; + return ; + case 101 : // Custom warning + alert( customMsg ) ; + break ; + case 201 : + alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ; + break ; + case 202 : + alert( 'Invalid file type' ) ; + return ; + case 203 : + alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ; + return ; + case 500 : + alert( 'The connector is disabled' ) ; + break ; + default : + alert( 'Error on file upload. Error number: ' + errorNumber ) ; + return ; + } + + SetUrl( fileUrl ) ; + GetE('frmUpload').reset() ; +} + +var oUploadAllowedExtRegex = new RegExp( FCKConfig.LinkUploadAllowedExtensions, 'i' ) ; +var oUploadDeniedExtRegex = new RegExp( FCKConfig.LinkUploadDeniedExtensions, 'i' ) ; + +function CheckUpload() +{ + var sFile = GetE('txtUploadFile').value ; + + if ( sFile.length == 0 ) + { + alert( 'Please select a file to upload' ) ; + return false ; + } + + if ( ( FCKConfig.LinkUploadAllowedExtensions.length > 0 && !oUploadAllowedExtRegex.test( sFile ) ) || + ( FCKConfig.LinkUploadDeniedExtensions.length > 0 && oUploadDeniedExtRegex.test( sFile ) ) ) + { + OnUploadCompleted( 202 ) ; + return false ; + } + + // Show animation + window.parent.Throbber.Show( 100 ) ; + GetE( 'divUpload' ).style.display = 'none' ; + + return true ; +} + +function SetDefaultTarget() +{ + var target = FCKConfig.DefaultLinkTarget || '' ; + + if ( oLink || target.length == 0 ) + return ; + + switch ( target ) + { + case '_blank' : + case '_self' : + case '_parent' : + case '_top' : + GetE('cmbTarget').value = target ; + break ; + default : + GetE('cmbTarget').value = 'frame' ; + break ; + } + + GetE('txtTargetFrame').value = target ; +} diff --git a/includes/fckeditor/editor/dialog/fck_listprop.html b/includes/fckeditor/editor/dialog/fck_listprop.html new file mode 100755 index 0000000..ef30a94 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_listprop.html @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + +
+ + + + + +
+ List Type
+ + +   +
+
+ + diff --git a/includes/fckeditor/editor/dialog/fck_paste.html b/includes/fckeditor/editor/dialog/fck_paste.html new file mode 100755 index 0000000..40cc6f5 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_paste.html @@ -0,0 +1,346 @@ + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ Please paste inside the following box using the keyboard + (Ctrl+V) and hit OK.
+   +
+
+ +
+ + + +
+ + + +
+ + diff --git a/includes/fckeditor/editor/dialog/fck_radiobutton.html b/includes/fckeditor/editor/dialog/fck_radiobutton.html new file mode 100755 index 0000000..eb9aa5d --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_radiobutton.html @@ -0,0 +1,104 @@ + + + + + Radio Button Properties + + + + + + + + + + +
+ + + + + + + + + + +
+ Name
+ +
+ Value
+ +
+
+ + diff --git a/includes/fckeditor/editor/dialog/fck_replace.html b/includes/fckeditor/editor/dialog/fck_replace.html new file mode 100755 index 0000000..f334d7f --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_replace.html @@ -0,0 +1,648 @@ + + + + + + + + + + + + + + + diff --git a/includes/fckeditor/editor/dialog/fck_select.html b/includes/fckeditor/editor/dialog/fck_select.html new file mode 100755 index 0000000..a1735a1 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_select.html @@ -0,0 +1,180 @@ + + + + + Select Properties + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
Name 
Value 
Size  lines
+
+
+  Available + Options  + + + + + + + + + + + + + + + + + + +
Text
+ +
Value
+ +
+ + +
+
+ +
   +
+
+ + diff --git a/includes/fckeditor/editor/dialog/fck_select/fck_select.js b/includes/fckeditor/editor/dialog/fck_select/fck_select.js new file mode 100755 index 0000000..167e24d --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_select/fck_select.js @@ -0,0 +1,194 @@ +/* + * FCKeditor - The text editor for Internet - http://www.fckeditor.net + * Copyright (C) 2003-2008 Frederico Caldeira Knabben + * + * == BEGIN LICENSE == + * + * Licensed under the terms of any of the following licenses at your + * choice: + * + * - GNU General Public License Version 2 or later (the "GPL") + * http://www.gnu.org/licenses/gpl.html + * + * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") + * http://www.gnu.org/licenses/lgpl.html + * + * - Mozilla Public License Version 1.1 or later (the "MPL") + * http://www.mozilla.org/MPL/MPL-1.1.html + * + * == END LICENSE == + * + * Scripts for the fck_select.html page. + */ + +function Select( combo ) +{ + var iIndex = combo.selectedIndex ; + + oListText.selectedIndex = iIndex ; + oListValue.selectedIndex = iIndex ; + + var oTxtText = document.getElementById( "txtText" ) ; + var oTxtValue = document.getElementById( "txtValue" ) ; + + oTxtText.value = oListText.value ; + oTxtValue.value = oListValue.value ; +} + +function Add() +{ + var oTxtText = document.getElementById( "txtText" ) ; + var oTxtValue = document.getElementById( "txtValue" ) ; + + AddComboOption( oListText, oTxtText.value, oTxtText.value ) ; + AddComboOption( oListValue, oTxtValue.value, oTxtValue.value ) ; + + oListText.selectedIndex = oListText.options.length - 1 ; + oListValue.selectedIndex = oListValue.options.length - 1 ; + + oTxtText.value = '' ; + oTxtValue.value = '' ; + + oTxtText.focus() ; +} + +function Modify() +{ + var iIndex = oListText.selectedIndex ; + + if ( iIndex < 0 ) return ; + + var oTxtText = document.getElementById( "txtText" ) ; + var oTxtValue = document.getElementById( "txtValue" ) ; + + oListText.options[ iIndex ].innerHTML = HTMLEncode( oTxtText.value ) ; + oListText.options[ iIndex ].value = oTxtText.value ; + + oListValue.options[ iIndex ].innerHTML = HTMLEncode( oTxtValue.value ) ; + oListValue.options[ iIndex ].value = oTxtValue.value ; + + oTxtText.value = '' ; + oTxtValue.value = '' ; + + oTxtText.focus() ; +} + +function Move( steps ) +{ + ChangeOptionPosition( oListText, steps ) ; + ChangeOptionPosition( oListValue, steps ) ; +} + +function Delete() +{ + RemoveSelectedOptions( oListText ) ; + RemoveSelectedOptions( oListValue ) ; +} + +function SetSelectedValue() +{ + var iIndex = oListValue.selectedIndex ; + if ( iIndex < 0 ) return ; + + var oTxtValue = document.getElementById( "txtSelValue" ) ; + + oTxtValue.value = oListValue.options[ iIndex ].value ; +} + +// Moves the selected option by a number of steps (also negative) +function ChangeOptionPosition( combo, steps ) +{ + var iActualIndex = combo.selectedIndex ; + + if ( iActualIndex < 0 ) + return ; + + var iFinalIndex = iActualIndex + steps ; + + if ( iFinalIndex < 0 ) + iFinalIndex = 0 ; + + if ( iFinalIndex > ( combo.options.length - 1 ) ) + iFinalIndex = combo.options.length - 1 ; + + if ( iActualIndex == iFinalIndex ) + return ; + + var oOption = combo.options[ iActualIndex ] ; + var sText = HTMLDecode( oOption.innerHTML ) ; + var sValue = oOption.value ; + + combo.remove( iActualIndex ) ; + + oOption = AddComboOption( combo, sText, sValue, null, iFinalIndex ) ; + + oOption.selected = true ; +} + +// Remove all selected options from a SELECT object +function RemoveSelectedOptions(combo) +{ + // Save the selected index + var iSelectedIndex = combo.selectedIndex ; + + var oOptions = combo.options ; + + // Remove all selected options + for ( var i = oOptions.length - 1 ; i >= 0 ; i-- ) + { + if (oOptions[i].selected) combo.remove(i) ; + } + + // Reset the selection based on the original selected index + if ( combo.options.length > 0 ) + { + if ( iSelectedIndex >= combo.options.length ) iSelectedIndex = combo.options.length - 1 ; + combo.selectedIndex = iSelectedIndex ; + } +} + +// Add a new option to a SELECT object (combo or list) +function AddComboOption( combo, optionText, optionValue, documentObject, index ) +{ + var oOption ; + + if ( documentObject ) + oOption = documentObject.createElement("OPTION") ; + else + oOption = document.createElement("OPTION") ; + + if ( index != null ) + combo.options.add( oOption, index ) ; + else + combo.options.add( oOption ) ; + + oOption.innerHTML = optionText.length > 0 ? HTMLEncode( optionText ) : ' ' ; + oOption.value = optionValue ; + + return oOption ; +} + +function HTMLEncode( text ) +{ + if ( !text ) + return '' ; + + text = text.replace( /&/g, '&' ) ; + text = text.replace( //g, '>' ) ; + + return text ; +} + + +function HTMLDecode( text ) +{ + if ( !text ) + return '' ; + + text = text.replace( />/g, '>' ) ; + text = text.replace( /</g, '<' ) ; + text = text.replace( /&/g, '&' ) ; + + return text ; +} diff --git a/includes/fckeditor/editor/dialog/fck_smiley.html b/includes/fckeditor/editor/dialog/fck_smiley.html new file mode 100755 index 0000000..0d6f63f --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_smiley.html @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + +
+ + diff --git a/includes/fckeditor/editor/dialog/fck_source.html b/includes/fckeditor/editor/dialog/fck_source.html new file mode 100755 index 0000000..d66c281 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_source.html @@ -0,0 +1,68 @@ + + + + + Source + + + + + + + + + + +
+ + diff --git a/includes/fckeditor/editor/dialog/fck_specialchar.html b/includes/fckeditor/editor/dialog/fck_specialchar.html new file mode 100755 index 0000000..d7fda32 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_specialchar.html @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + +
+ + +
+
     + + + + +
 
+
+ + diff --git a/includes/fckeditor/editor/dialog/fck_spellerpages.html b/includes/fckeditor/editor/dialog/fck_spellerpages.html new file mode 100755 index 0000000..87cf2c4 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_spellerpages.html @@ -0,0 +1,70 @@ + + + + + Spell Check + + + + + + + + + + + diff --git a/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/blank.html b/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/blank.html new file mode 100755 index 0000000..e69de29 diff --git a/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/controlWindow.js b/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/controlWindow.js new file mode 100755 index 0000000..80af849 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/controlWindow.js @@ -0,0 +1,87 @@ +//////////////////////////////////////////////////// +// controlWindow object +//////////////////////////////////////////////////// +function controlWindow( controlForm ) { + // private properties + this._form = controlForm; + + // public properties + this.windowType = "controlWindow"; +// this.noSuggestionSelection = "- No suggestions -"; // by FredCK + this.noSuggestionSelection = FCKLang.DlgSpellNoSuggestions ; + // set up the properties for elements of the given control form + this.suggestionList = this._form.sugg; + this.evaluatedText = this._form.misword; + this.replacementText = this._form.txtsugg; + this.undoButton = this._form.btnUndo; + + // public methods + this.addSuggestion = addSuggestion; + this.clearSuggestions = clearSuggestions; + this.selectDefaultSuggestion = selectDefaultSuggestion; + this.resetForm = resetForm; + this.setSuggestedText = setSuggestedText; + this.enableUndo = enableUndo; + this.disableUndo = disableUndo; +} + +function resetForm() { + if( this._form ) { + this._form.reset(); + } +} + +function setSuggestedText() { + var slct = this.suggestionList; + var txt = this.replacementText; + var str = ""; + if( (slct.options[0].text) && slct.options[0].text != this.noSuggestionSelection ) { + str = slct.options[slct.selectedIndex].text; + } + txt.value = str; +} + +function selectDefaultSuggestion() { + var slct = this.suggestionList; + var txt = this.replacementText; + if( slct.options.length == 0 ) { + this.addSuggestion( this.noSuggestionSelection ); + } else { + slct.options[0].selected = true; + } + this.setSuggestedText(); +} + +function addSuggestion( sugg_text ) { + var slct = this.suggestionList; + if( sugg_text ) { + var i = slct.options.length; + var newOption = new Option( sugg_text, 'sugg_text'+i ); + slct.options[i] = newOption; + } +} + +function clearSuggestions() { + var slct = this.suggestionList; + for( var j = slct.length - 1; j > -1; j-- ) { + if( slct.options[j] ) { + slct.options[j] = null; + } + } +} + +function enableUndo() { + if( this.undoButton ) { + if( this.undoButton.disabled == true ) { + this.undoButton.disabled = false; + } + } +} + +function disableUndo() { + if( this.undoButton ) { + if( this.undoButton.disabled == false ) { + this.undoButton.disabled = true; + } + } +} diff --git a/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/controls.html b/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/controls.html new file mode 100755 index 0000000..d91bcce --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/controls.html @@ -0,0 +1,153 @@ + + + + + + + +
+ + + + + + + + + + + + + + + + + + +
Not in dictionary:
Change to:
+ + + + + + + +
+ +
+ +
+
   + + + + + + + + + + + + + + + + + + + + + + +
+ +    + +
+ +    + +
+ +    + +
+
+
+ + diff --git a/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/server-scripts/spellchecker.cfm b/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/server-scripts/spellchecker.cfm new file mode 100755 index 0000000..27e368e --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/server-scripts/spellchecker.cfm @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]+>", " ", "all")> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/server-scripts/spellchecker.php b/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/server-scripts/spellchecker.php new file mode 100755 index 0000000..545d550 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/server-scripts/spellchecker.php @@ -0,0 +1,214 @@ +$val ) { + # $val = str_replace( "'", "%27", $val ); + echo "textinputs[$key] = decodeURIComponent(\"" . $val . "\");\n"; + } +} + +# make declarations for the text input index +function print_textindex_decl( $text_input_idx ) { + echo "words[$text_input_idx] = [];\n"; + echo "suggs[$text_input_idx] = [];\n"; +} + +# set an element of the JavaScript 'words' array to a misspelled word +function print_words_elem( $word, $index, $text_input_idx ) { + echo "words[$text_input_idx][$index] = '" . escape_quote( $word ) . "';\n"; +} + + +# set an element of the JavaScript 'suggs' array to a list of suggestions +function print_suggs_elem( $suggs, $index, $text_input_idx ) { + echo "suggs[$text_input_idx][$index] = ["; + foreach( $suggs as $key=>$val ) { + if( $val ) { + echo "'" . escape_quote( $val ) . "'"; + if ( $key+1 < count( $suggs )) { + echo ", "; + } + } + } + echo "];\n"; +} + +# escape single quote +function escape_quote( $str ) { + return preg_replace ( "/'/", "\\'", $str ); +} + + +# handle a server-side error. +function error_handler( $err ) { + echo "error = '" . preg_replace( "/['\\\\]/", "\\\\$0", $err ) . "';\n"; +} + +## get the list of misspelled words. Put the results in the javascript words array +## for each misspelled word, get suggestions and put in the javascript suggs array +function print_checker_results() { + + global $aspell_prog; + global $aspell_opts; + global $tempfiledir; + global $textinputs; + global $input_separator; + $aspell_err = ""; + # create temp file + $tempfile = tempnam( $tempfiledir, 'aspell_data_' ); + + # open temp file, add the submitted text. + if( $fh = fopen( $tempfile, 'w' )) { + for( $i = 0; $i < count( $textinputs ); $i++ ) { + $text = urldecode( $textinputs[$i] ); + + // Strip all tags for the text. (by FredCK - #339 / #681) + $text = preg_replace( "/<[^>]+>/", " ", $text ) ; + + $lines = explode( "\n", $text ); + fwrite ( $fh, "%\n" ); # exit terse mode + fwrite ( $fh, "^$input_separator\n" ); + fwrite ( $fh, "!\n" ); # enter terse mode + foreach( $lines as $key=>$value ) { + # use carat on each line to escape possible aspell commands + fwrite( $fh, "^$value\n" ); + } + } + fclose( $fh ); + + # exec aspell command - redirect STDERR to STDOUT + $cmd = "$aspell_prog $aspell_opts < $tempfile 2>&1"; + if( $aspellret = shell_exec( $cmd )) { + $linesout = explode( "\n", $aspellret ); + $index = 0; + $text_input_index = -1; + # parse each line of aspell return + foreach( $linesout as $key=>$val ) { + $chardesc = substr( $val, 0, 1 ); + # if '&', then not in dictionary but has suggestions + # if '#', then not in dictionary and no suggestions + # if '*', then it is a delimiter between text inputs + # if '@' then version info + if( $chardesc == '&' || $chardesc == '#' ) { + $line = explode( " ", $val, 5 ); + print_words_elem( $line[1], $index, $text_input_index ); + if( isset( $line[4] )) { + $suggs = explode( ", ", $line[4] ); + } else { + $suggs = array(); + } + print_suggs_elem( $suggs, $index, $text_input_index ); + $index++; + } elseif( $chardesc == '*' ) { + $text_input_index++; + print_textindex_decl( $text_input_index ); + $index = 0; + } elseif( $chardesc != '@' && $chardesc != "" ) { + # assume this is error output + $aspell_err .= $val; + } + } + if( $aspell_err ) { + $aspell_err = "Error executing"; + error_handler( $aspell_err ); + } + } else { + error_handler( "System error" ); + } + } else { + error_handler( "System error" ); + } + + # close temp file, delete file + unlink( $tempfile ); +} +function addslashes_d($val) +{ + if (empty($value)) + { + return $value; + } + else + { + return is_array($value) ? array_map('addslashes_d', $value) : addslashes($value); + } +} + +?> + + + + + + + + + + + + + + + diff --git a/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/server-scripts/spellchecker.pl b/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/server-scripts/spellchecker.pl new file mode 100755 index 0000000..fae010d --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/server-scripts/spellchecker.pl @@ -0,0 +1,181 @@ +#!/usr/bin/perl + +use CGI qw/ :standard /; +use File::Temp qw/ tempfile tempdir /; + +# my $spellercss = '/speller/spellerStyle.css'; # by FredCK +my $spellercss = '../spellerStyle.css'; # by FredCK +# my $wordWindowSrc = '/speller/wordWindow.js'; # by FredCK +my $wordWindowSrc = '../wordWindow.js'; # by FredCK +my @textinputs = param( 'textinputs[]' ); # array +# my $aspell_cmd = 'aspell'; # by FredCK (for Linux) +my $aspell_cmd = '"C:\Program Files\Aspell\bin\aspell.exe"'; # by FredCK (for Windows) +my $lang = 'en_US'; +# my $aspell_opts = "-a --lang=$lang --encoding=utf-8"; # by FredCK +my $aspell_opts = "-a --lang=$lang --encoding=utf-8 -H --rem-sgml-check=alt"; # by FredCK +my $input_separator = "A"; + +# set the 'wordtext' JavaScript variable to the submitted text. +sub printTextVar { + for( my $i = 0; $i <= $#textinputs; $i++ ) { + print "textinputs[$i] = decodeURIComponent('" . escapeQuote( $textinputs[$i] ) . "')\n"; + } +} + +sub printTextIdxDecl { + my $idx = shift; + print "words[$idx] = [];\n"; + print "suggs[$idx] = [];\n"; +} + +sub printWordsElem { + my( $textIdx, $wordIdx, $word ) = @_; + print "words[$textIdx][$wordIdx] = '" . escapeQuote( $word ) . "';\n"; +} + +sub printSuggsElem { + my( $textIdx, $wordIdx, @suggs ) = @_; + print "suggs[$textIdx][$wordIdx] = ["; + for my $i ( 0..$#suggs ) { + print "'" . escapeQuote( $suggs[$i] ) . "'"; + if( $i < $#suggs ) { + print ", "; + } + } + print "];\n"; +} + +sub printCheckerResults { + my $textInputIdx = -1; + my $wordIdx = 0; + my $unhandledText; + # create temp file + my $dir = tempdir( CLEANUP => 1 ); + my( $fh, $tmpfilename ) = tempfile( DIR => $dir ); + + # temp file was created properly? + + # open temp file, add the submitted text. + for( my $i = 0; $i <= $#textinputs; $i++ ) { + $text = url_decode( $textinputs[$i] ); + # Strip all tags for the text. (by FredCK - #339 / #681) + $text =~ s/<[^>]+>/ /g; + @lines = split( /\n/, $text ); + print $fh "\%\n"; # exit terse mode + print $fh "^$input_separator\n"; + print $fh "!\n"; # enter terse mode + for my $line ( @lines ) { + # use carat on each line to escape possible aspell commands + print $fh "^$line\n"; + } + + } + # exec aspell command + my $cmd = "$aspell_cmd $aspell_opts < $tmpfilename 2>&1"; + open ASPELL, "$cmd |" or handleError( "Could not execute `$cmd`\\n$!" ) and return; + # parse each line of aspell return + for my $ret ( ) { + chomp( $ret ); + # if '&', then not in dictionary but has suggestions + # if '#', then not in dictionary and no suggestions + # if '*', then it is a delimiter between text inputs + if( $ret =~ /^\*/ ) { + $textInputIdx++; + printTextIdxDecl( $textInputIdx ); + $wordIdx = 0; + + } elsif( $ret =~ /^(&|#)/ ) { + my @tokens = split( " ", $ret, 5 ); + printWordsElem( $textInputIdx, $wordIdx, $tokens[1] ); + my @suggs = (); + if( $tokens[4] ) { + @suggs = split( ", ", $tokens[4] ); + } + printSuggsElem( $textInputIdx, $wordIdx, @suggs ); + $wordIdx++; + } else { + $unhandledText .= $ret; + } + } + close ASPELL or handleError( "Error executing `$cmd`\\n$unhandledText" ) and return; +} + +sub escapeQuote { + my $str = shift; + $str =~ s/'/\\'/g; + return $str; +} + +sub handleError { + my $err = shift; + print "error = '" . escapeQuote( $err ) . "';\n"; +} + +sub url_decode { + local $_ = @_ ? shift : $_; + defined or return; + # change + signs to spaces + tr/+/ /; + # change hex escapes to the proper characters + s/%([a-fA-F0-9]{2})/pack "H2", $1/eg; + return $_; +} + +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# Display HTML +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + +print < + + + + + + + + + + + + + +EOF diff --git a/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/spellChecker.js b/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/spellChecker.js new file mode 100755 index 0000000..c85be9a --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/spellChecker.js @@ -0,0 +1,461 @@ +//////////////////////////////////////////////////// +// spellChecker.js +// +// spellChecker object +// +// This file is sourced on web pages that have a textarea object to evaluate +// for spelling. It includes the implementation for the spellCheckObject. +// +//////////////////////////////////////////////////// + + +// constructor +function spellChecker( textObject ) { + + // public properties - configurable +// this.popUpUrl = '/speller/spellchecker.html'; // by FredCK + this.popUpUrl = 'fck_spellerpages/spellerpages/spellchecker.html'; // by FredCK + this.popUpName = 'spellchecker'; +// this.popUpProps = "menu=no,width=440,height=350,top=70,left=120,resizable=yes,status=yes"; // by FredCK + this.popUpProps = null ; // by FredCK +// this.spellCheckScript = '/speller/server-scripts/spellchecker.php'; // by FredCK + //this.spellCheckScript = '/cgi-bin/spellchecker.pl'; + + // values used to keep track of what happened to a word + this.replWordFlag = "R"; // single replace + this.ignrWordFlag = "I"; // single ignore + this.replAllFlag = "RA"; // replace all occurances + this.ignrAllFlag = "IA"; // ignore all occurances + this.fromReplAll = "~RA"; // an occurance of a "replace all" word + this.fromIgnrAll = "~IA"; // an occurance of a "ignore all" word + // properties set at run time + this.wordFlags = new Array(); + this.currentTextIndex = 0; + this.currentWordIndex = 0; + this.spellCheckerWin = null; + this.controlWin = null; + this.wordWin = null; + this.textArea = textObject; // deprecated + this.textInputs = arguments; + + // private methods + this._spellcheck = _spellcheck; + this._getSuggestions = _getSuggestions; + this._setAsIgnored = _setAsIgnored; + this._getTotalReplaced = _getTotalReplaced; + this._setWordText = _setWordText; + this._getFormInputs = _getFormInputs; + + // public methods + this.openChecker = openChecker; + this.startCheck = startCheck; + this.checkTextBoxes = checkTextBoxes; + this.checkTextAreas = checkTextAreas; + this.spellCheckAll = spellCheckAll; + this.ignoreWord = ignoreWord; + this.ignoreAll = ignoreAll; + this.replaceWord = replaceWord; + this.replaceAll = replaceAll; + this.terminateSpell = terminateSpell; + this.undo = undo; + + // set the current window's "speller" property to the instance of this class. + // this object can now be referenced by child windows/frames. + window.speller = this; +} + +// call this method to check all text boxes (and only text boxes) in the HTML document +function checkTextBoxes() { + this.textInputs = this._getFormInputs( "^text$" ); + this.openChecker(); +} + +// call this method to check all textareas (and only textareas ) in the HTML document +function checkTextAreas() { + this.textInputs = this._getFormInputs( "^textarea$" ); + this.openChecker(); +} + +// call this method to check all text boxes and textareas in the HTML document +function spellCheckAll() { + this.textInputs = this._getFormInputs( "^text(area)?$" ); + this.openChecker(); +} + +// call this method to check text boxe(s) and/or textarea(s) that were passed in to the +// object's constructor or to the textInputs property +function openChecker() { + this.spellCheckerWin = window.open( this.popUpUrl, this.popUpName, this.popUpProps ); + if( !this.spellCheckerWin.opener ) { + this.spellCheckerWin.opener = window; + } +} + +function startCheck( wordWindowObj, controlWindowObj ) { + + // set properties from args + this.wordWin = wordWindowObj; + this.controlWin = controlWindowObj; + + // reset properties + this.wordWin.resetForm(); + this.controlWin.resetForm(); + this.currentTextIndex = 0; + this.currentWordIndex = 0; + // initialize the flags to an array - one element for each text input + this.wordFlags = new Array( this.wordWin.textInputs.length ); + // each element will be an array that keeps track of each word in the text + for( var i=0; i wi ) || i > ti ) { + // future word: set as "from ignore all" if + // 1) do not already have a flag and + // 2) have the same value as current word + if(( this.wordWin.getTextVal( i, j ) == s_word_to_repl ) + && ( !this.wordFlags[i][j] )) { + this._setAsIgnored( i, j, this.fromIgnrAll ); + } + } + } + } + + // finally, move on + this.currentWordIndex++; + this._spellcheck(); + return true; +} + +function replaceWord() { + var wi = this.currentWordIndex; + var ti = this.currentTextIndex; + if( !this.wordWin ) { + alert( 'Error: Word frame not available.' ); + return false; + } + if( !this.wordWin.getTextVal( ti, wi )) { + alert( 'Error: "Not in dictionary" text is missing' ); + return false; + } + if( !this.controlWin.replacementText ) { + return false ; + } + var txt = this.controlWin.replacementText; + if( txt.value ) { + var newspell = new String( txt.value ); + if( this._setWordText( ti, wi, newspell, this.replWordFlag )) { + this.currentWordIndex++; + this._spellcheck(); + } + } + return true; +} + +function replaceAll() { + var ti = this.currentTextIndex; + var wi = this.currentWordIndex; + if( !this.wordWin ) { + alert( 'Error: Word frame not available.' ); + return false; + } + var s_word_to_repl = this.wordWin.getTextVal( ti, wi ); + if( !s_word_to_repl ) { + alert( 'Error: "Not in dictionary" text is missing' ); + return false; + } + var txt = this.controlWin.replacementText; + if( !txt.value ) return false; + var newspell = new String( txt.value ); + + // set this word as a "replace all" word. + this._setWordText( ti, wi, newspell, this.replAllFlag ); + + // loop through all the words after this word + for( var i = ti; i < this.wordWin.textInputs.length; i++ ) { + for( var j = 0; j < this.wordWin.totalWords( i ); j++ ) { + if(( i == ti && j > wi ) || i > ti ) { + // future word: set word text to s_word_to_repl if + // 1) do not already have a flag and + // 2) have the same value as s_word_to_repl + if(( this.wordWin.getTextVal( i, j ) == s_word_to_repl ) + && ( !this.wordFlags[i][j] )) { + this._setWordText( i, j, newspell, this.fromReplAll ); + } + } + } + } + + // finally, move on + this.currentWordIndex++; + this._spellcheck(); + return true; +} + +function terminateSpell() { + // called when we have reached the end of the spell checking. + var msg = ""; // by FredCK + var numrepl = this._getTotalReplaced(); + if( numrepl == 0 ) { + // see if there were no misspellings to begin with + if( !this.wordWin ) { + msg = ""; + } else { + if( this.wordWin.totalMisspellings() ) { +// msg += "No words changed."; // by FredCK + msg += FCKLang.DlgSpellNoChanges ; // by FredCK + } else { +// msg += "No misspellings found."; // by FredCK + msg += FCKLang.DlgSpellNoMispell ; // by FredCK + } + } + } else if( numrepl == 1 ) { +// msg += "One word changed."; // by FredCK + msg += FCKLang.DlgSpellOneChange ; // by FredCK + } else { +// msg += numrepl + " words changed."; // by FredCK + msg += FCKLang.DlgSpellManyChanges.replace( /%1/g, numrepl ) ; + } + if( msg ) { +// msg += "\n"; // by FredCK + alert( msg ); + } + + if( numrepl > 0 ) { + // update the text field(s) on the opener window + for( var i = 0; i < this.textInputs.length; i++ ) { + // this.textArea.value = this.wordWin.text; + if( this.wordWin ) { + if( this.wordWin.textInputs[i] ) { + this.textInputs[i].value = this.wordWin.textInputs[i]; + } + } + } + } + + // return back to the calling window +// this.spellCheckerWin.close(); // by FredCK + if ( typeof( this.OnFinished ) == 'function' ) // by FredCK + this.OnFinished(numrepl) ; // by FredCK + + return true; +} + +function undo() { + // skip if this is the first word! + var ti = this.currentTextIndex; + var wi = this.currentWordIndex; + + if( this.wordWin.totalPreviousWords( ti, wi ) > 0 ) { + this.wordWin.removeFocus( ti, wi ); + + // go back to the last word index that was acted upon + do { + // if the current word index is zero then reset the seed + if( this.currentWordIndex == 0 && this.currentTextIndex > 0 ) { + this.currentTextIndex--; + this.currentWordIndex = this.wordWin.totalWords( this.currentTextIndex )-1; + if( this.currentWordIndex < 0 ) this.currentWordIndex = 0; + } else { + if( this.currentWordIndex > 0 ) { + this.currentWordIndex--; + } + } + } while ( + this.wordWin.totalWords( this.currentTextIndex ) == 0 + || this.wordFlags[this.currentTextIndex][this.currentWordIndex] == this.fromIgnrAll + || this.wordFlags[this.currentTextIndex][this.currentWordIndex] == this.fromReplAll + ); + + var text_idx = this.currentTextIndex; + var idx = this.currentWordIndex; + var preReplSpell = this.wordWin.originalSpellings[text_idx][idx]; + + // if we got back to the first word then set the Undo button back to disabled + if( this.wordWin.totalPreviousWords( text_idx, idx ) == 0 ) { + this.controlWin.disableUndo(); + } + + var i, j, origSpell ; + // examine what happened to this current word. + switch( this.wordFlags[text_idx][idx] ) { + // replace all: go through this and all the future occurances of the word + // and revert them all to the original spelling and clear their flags + case this.replAllFlag : + for( i = text_idx; i < this.wordWin.textInputs.length; i++ ) { + for( j = 0; j < this.wordWin.totalWords( i ); j++ ) { + if(( i == text_idx && j >= idx ) || i > text_idx ) { + origSpell = this.wordWin.originalSpellings[i][j]; + if( origSpell == preReplSpell ) { + this._setWordText ( i, j, origSpell, undefined ); + } + } + } + } + break; + + // ignore all: go through all the future occurances of the word + // and clear their flags + case this.ignrAllFlag : + for( i = text_idx; i < this.wordWin.textInputs.length; i++ ) { + for( j = 0; j < this.wordWin.totalWords( i ); j++ ) { + if(( i == text_idx && j >= idx ) || i > text_idx ) { + origSpell = this.wordWin.originalSpellings[i][j]; + if( origSpell == preReplSpell ) { + this.wordFlags[i][j] = undefined; + } + } + } + } + break; + + // replace: revert the word to its original spelling + case this.replWordFlag : + this._setWordText ( text_idx, idx, preReplSpell, undefined ); + break; + } + + // For all four cases, clear the wordFlag of this word. re-start the process + this.wordFlags[text_idx][idx] = undefined; + this._spellcheck(); + } +} + +function _spellcheck() { + var ww = this.wordWin; + + // check if this is the last word in the current text element + if( this.currentWordIndex == ww.totalWords( this.currentTextIndex) ) { + this.currentTextIndex++; + this.currentWordIndex = 0; + // keep going if we're not yet past the last text element + if( this.currentTextIndex < this.wordWin.textInputs.length ) { + this._spellcheck(); + return; + } else { + this.terminateSpell(); + return; + } + } + + // if this is after the first one make sure the Undo button is enabled + if( this.currentWordIndex > 0 ) { + this.controlWin.enableUndo(); + } + + // skip the current word if it has already been worked on + if( this.wordFlags[this.currentTextIndex][this.currentWordIndex] ) { + // increment the global current word index and move on. + this.currentWordIndex++; + this._spellcheck(); + } else { + var evalText = ww.getTextVal( this.currentTextIndex, this.currentWordIndex ); + if( evalText ) { + this.controlWin.evaluatedText.value = evalText; + ww.setFocus( this.currentTextIndex, this.currentWordIndex ); + this._getSuggestions( this.currentTextIndex, this.currentWordIndex ); + } + } +} + +function _getSuggestions( text_num, word_num ) { + this.controlWin.clearSuggestions(); + // add suggestion in list for each suggested word. + // get the array of suggested words out of the + // three-dimensional array containing all suggestions. + var a_suggests = this.wordWin.suggestions[text_num][word_num]; + if( a_suggests ) { + // got an array of suggestions. + for( var ii = 0; ii < a_suggests.length; ii++ ) { + this.controlWin.addSuggestion( a_suggests[ii] ); + } + } + this.controlWin.selectDefaultSuggestion(); +} + +function _setAsIgnored( text_num, word_num, flag ) { + // set the UI + this.wordWin.removeFocus( text_num, word_num ); + // do the bookkeeping + this.wordFlags[text_num][word_num] = flag; + return true; +} + +function _getTotalReplaced() { + var i_replaced = 0; + for( var i = 0; i < this.wordFlags.length; i++ ) { + for( var j = 0; j < this.wordFlags[i].length; j++ ) { + if(( this.wordFlags[i][j] == this.replWordFlag ) + || ( this.wordFlags[i][j] == this.replAllFlag ) + || ( this.wordFlags[i][j] == this.fromReplAll )) { + i_replaced++; + } + } + } + return i_replaced; +} + +function _setWordText( text_num, word_num, newText, flag ) { + // set the UI and form inputs + this.wordWin.setText( text_num, word_num, newText ); + // keep track of what happened to this word: + this.wordFlags[text_num][word_num] = flag; + return true; +} + +function _getFormInputs( inputPattern ) { + var inputs = new Array(); + for( var i = 0; i < document.forms.length; i++ ) { + for( var j = 0; j < document.forms[i].elements.length; j++ ) { + if( document.forms[i].elements[j].type.match( inputPattern )) { + inputs[inputs.length] = document.forms[i].elements[j]; + } + } + } + return inputs; +} diff --git a/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/spellchecker.html b/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/spellchecker.html new file mode 100755 index 0000000..cbcd7db --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/spellchecker.html @@ -0,0 +1,71 @@ + + + + + + +Speller Pages + + + + + + diff --git a/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/spellerStyle.css b/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/spellerStyle.css new file mode 100755 index 0000000..9928086 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/spellerStyle.css @@ -0,0 +1,49 @@ +.blend { + font-family: courier new; + font-size: 10pt; + border: 0; + margin-bottom:-1; +} +.normalLabel { + font-size:8pt; +} +.normalText { + font-family:arial, helvetica, sans-serif; + font-size:10pt; + color:000000; + background-color:FFFFFF; +} +.plainText { + font-family: courier new, courier, monospace; + font-size: 10pt; + color:000000; + background-color:FFFFFF; +} +.controlWindowBody { + font-family:arial, helvetica, sans-serif; + font-size:8pt; + padding: 7px ; /* by FredCK */ + margin: 0px ; /* by FredCK */ + /* color:000000; by FredCK */ + /* background-color:DADADA; by FredCK */ +} +.readonlyInput { + background-color:DADADA; + color:000000; + font-size:8pt; + width:392px; +} +.textDefault { + font-size:8pt; + width: 200px; +} +.buttonDefault { + width:90px; + height:22px; + font-size:8pt; +} +.suggSlct { + width:200px; + margin-top:2; + font-size:8pt; +} diff --git a/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/wordWindow.js b/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/wordWindow.js new file mode 100755 index 0000000..7990296 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_spellerpages/spellerpages/wordWindow.js @@ -0,0 +1,272 @@ +//////////////////////////////////////////////////// +// wordWindow object +//////////////////////////////////////////////////// +function wordWindow() { + // private properties + this._forms = []; + + // private methods + this._getWordObject = _getWordObject; + //this._getSpellerObject = _getSpellerObject; + this._wordInputStr = _wordInputStr; + this._adjustIndexes = _adjustIndexes; + this._isWordChar = _isWordChar; + this._lastPos = _lastPos; + + // public properties + this.wordChar = /[a-zA-Z]/; + this.windowType = "wordWindow"; + this.originalSpellings = new Array(); + this.suggestions = new Array(); + this.checkWordBgColor = "pink"; + this.normWordBgColor = "white"; + this.text = ""; + this.textInputs = new Array(); + this.indexes = new Array(); + //this.speller = this._getSpellerObject(); + + // public methods + this.resetForm = resetForm; + this.totalMisspellings = totalMisspellings; + this.totalWords = totalWords; + this.totalPreviousWords = totalPreviousWords; + //this.getTextObjectArray = getTextObjectArray; + this.getTextVal = getTextVal; + this.setFocus = setFocus; + this.removeFocus = removeFocus; + this.setText = setText; + //this.getTotalWords = getTotalWords; + this.writeBody = writeBody; + this.printForHtml = printForHtml; +} + +function resetForm() { + if( this._forms ) { + for( var i = 0; i < this._forms.length; i++ ) { + this._forms[i].reset(); + } + } + return true; +} + +function totalMisspellings() { + var total_words = 0; + for( var i = 0; i < this.textInputs.length; i++ ) { + total_words += this.totalWords( i ); + } + return total_words; +} + +function totalWords( textIndex ) { + return this.originalSpellings[textIndex].length; +} + +function totalPreviousWords( textIndex, wordIndex ) { + var total_words = 0; + for( var i = 0; i <= textIndex; i++ ) { + for( var j = 0; j < this.totalWords( i ); j++ ) { + if( i == textIndex && j == wordIndex ) { + break; + } else { + total_words++; + } + } + } + return total_words; +} + +//function getTextObjectArray() { +// return this._form.elements; +//} + +function getTextVal( textIndex, wordIndex ) { + var word = this._getWordObject( textIndex, wordIndex ); + if( word ) { + return word.value; + } +} + +function setFocus( textIndex, wordIndex ) { + var word = this._getWordObject( textIndex, wordIndex ); + if( word ) { + if( word.type == "text" ) { + word.focus(); + word.style.backgroundColor = this.checkWordBgColor; + } + } +} + +function removeFocus( textIndex, wordIndex ) { + var word = this._getWordObject( textIndex, wordIndex ); + if( word ) { + if( word.type == "text" ) { + word.blur(); + word.style.backgroundColor = this.normWordBgColor; + } + } +} + +function setText( textIndex, wordIndex, newText ) { + var word = this._getWordObject( textIndex, wordIndex ); + var beginStr; + var endStr; + if( word ) { + var pos = this.indexes[textIndex][wordIndex]; + var oldText = word.value; + // update the text given the index of the string + beginStr = this.textInputs[textIndex].substring( 0, pos ); + endStr = this.textInputs[textIndex].substring( + pos + oldText.length, + this.textInputs[textIndex].length + ); + this.textInputs[textIndex] = beginStr + newText + endStr; + + // adjust the indexes on the stack given the differences in + // length between the new word and old word. + var lengthDiff = newText.length - oldText.length; + this._adjustIndexes( textIndex, wordIndex, lengthDiff ); + + word.size = newText.length; + word.value = newText; + this.removeFocus( textIndex, wordIndex ); + } +} + + +function writeBody() { + var d = window.document; + var is_html = false; + + d.open(); + + // iterate through each text input. + for( var txtid = 0; txtid < this.textInputs.length; txtid++ ) { + var end_idx = 0; + var begin_idx = 0; + d.writeln( '
' ); + var wordtxt = this.textInputs[txtid]; + this.indexes[txtid] = []; + + if( wordtxt ) { + var orig = this.originalSpellings[txtid]; + if( !orig ) break; + + //!!! plain text, or HTML mode? + d.writeln( '
' ); + // iterate through each occurrence of a misspelled word. + for( var i = 0; i < orig.length; i++ ) { + // find the position of the current misspelled word, + // starting at the last misspelled word. + // and keep looking if it's a substring of another word + do { + begin_idx = wordtxt.indexOf( orig[i], end_idx ); + end_idx = begin_idx + orig[i].length; + // word not found? messed up! + if( begin_idx == -1 ) break; + // look at the characters immediately before and after + // the word. If they are word characters we'll keep looking. + var before_char = wordtxt.charAt( begin_idx - 1 ); + var after_char = wordtxt.charAt( end_idx ); + } while ( + this._isWordChar( before_char ) + || this._isWordChar( after_char ) + ); + + // keep track of its position in the original text. + this.indexes[txtid][i] = begin_idx; + + // write out the characters before the current misspelled word + for( var j = this._lastPos( txtid, i ); j < begin_idx; j++ ) { + // !!! html mode? make it html compatible + d.write( this.printForHtml( wordtxt.charAt( j ))); + } + + // write out the misspelled word. + d.write( this._wordInputStr( orig[i] )); + + // if it's the last word, write out the rest of the text + if( i == orig.length-1 ){ + d.write( printForHtml( wordtxt.substr( end_idx ))); + } + } + + d.writeln( '
' ); + + } + d.writeln( '
' ); + } + //for ( var j = 0; j < d.forms.length; j++ ) { + // alert( d.forms[j].name ); + // for( var k = 0; k < d.forms[j].elements.length; k++ ) { + // alert( d.forms[j].elements[k].name + ": " + d.forms[j].elements[k].value ); + // } + //} + + // set the _forms property + this._forms = d.forms; + d.close(); +} + +// return the character index in the full text after the last word we evaluated +function _lastPos( txtid, idx ) { + if( idx > 0 ) + return this.indexes[txtid][idx-1] + this.originalSpellings[txtid][idx-1].length; + else + return 0; +} + +function printForHtml( n ) { + return n ; // by FredCK +/* + var htmlstr = n; + if( htmlstr.length == 1 ) { + // do simple case statement if it's just one character + switch ( n ) { + case "\n": + htmlstr = '
'; + break; + case "<": + htmlstr = '<'; + break; + case ">": + htmlstr = '>'; + break; + } + return htmlstr; + } else { + htmlstr = htmlstr.replace( //g, '>' ); + htmlstr = htmlstr.replace( /\n/g, '
' ); + return htmlstr; + } +*/ +} + +function _isWordChar( letter ) { + if( letter.search( this.wordChar ) == -1 ) { + return false; + } else { + return true; + } +} + +function _getWordObject( textIndex, wordIndex ) { + if( this._forms[textIndex] ) { + if( this._forms[textIndex].elements[wordIndex] ) { + return this._forms[textIndex].elements[wordIndex]; + } + } + return null; +} + +function _wordInputStr( word ) { + var str = ''; + return str; +} + +function _adjustIndexes( textIndex, wordIndex, lengthDiff ) { + for( var i = wordIndex + 1; i < this.originalSpellings[textIndex].length; i++ ) { + this.indexes[textIndex][i] = this.indexes[textIndex][i] + lengthDiff; + } +} diff --git a/includes/fckeditor/editor/dialog/fck_table.html b/includes/fckeditor/editor/dialog/fck_table.html new file mode 100755 index 0000000..e3792d7 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_table.html @@ -0,0 +1,298 @@ + + + + + Table Properties + + + + + + + + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ Rows: +  
+ Columns: +  
+   +  
+ Border size: +  
+ Alignment: +  
+
+     + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Width: +   +  
+ Height: +   +  pixels
+   +   +  
+ Cell spacing: +   +  
+ Cell padding: +   +  
+
+ + + + + + + + + + + +
+ Caption +   +
+ Summary +   +
+
+ + diff --git a/includes/fckeditor/editor/dialog/fck_tablecell.html b/includes/fckeditor/editor/dialog/fck_tablecell.html new file mode 100755 index 0000000..3d74296 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_tablecell.html @@ -0,0 +1,257 @@ + + + + + Table Cell Properties + + + + + + + + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Width: +   
+ Height: +   pixels
+   +  
+ Word Wrap: +  
+   +  
+ Horizontal Alignment: +  
+ Vertical Alignment: +  
+
+     + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Rows Span: +   + +
+ Columns Span: +   + +
+   +   +  
+ Background Color: +   +   +
+ Border Color: +   +   +
+
+
+ + diff --git a/includes/fckeditor/editor/dialog/fck_template.html b/includes/fckeditor/editor/dialog/fck_template.html new file mode 100755 index 0000000..4f3629b --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_template.html @@ -0,0 +1,242 @@ + + + + + + + + + + + + + + + + + + + + + + +
+ Please select the template to open in the editor
+ (the actual contents will be lost):
+
+
+ + +
+
+ + diff --git a/includes/fckeditor/editor/dialog/fck_template/images/template1.gif b/includes/fckeditor/editor/dialog/fck_template/images/template1.gif new file mode 100755 index 0000000..efdabbe Binary files /dev/null and b/includes/fckeditor/editor/dialog/fck_template/images/template1.gif differ diff --git a/includes/fckeditor/editor/dialog/fck_template/images/template2.gif b/includes/fckeditor/editor/dialog/fck_template/images/template2.gif new file mode 100755 index 0000000..d1cebb3 Binary files /dev/null and b/includes/fckeditor/editor/dialog/fck_template/images/template2.gif differ diff --git a/includes/fckeditor/editor/dialog/fck_template/images/template3.gif b/includes/fckeditor/editor/dialog/fck_template/images/template3.gif new file mode 100755 index 0000000..db41cb4 Binary files /dev/null and b/includes/fckeditor/editor/dialog/fck_template/images/template3.gif differ diff --git a/includes/fckeditor/editor/dialog/fck_textarea.html b/includes/fckeditor/editor/dialog/fck_textarea.html new file mode 100755 index 0000000..3a1c56d --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_textarea.html @@ -0,0 +1,94 @@ + + + + + Text Area Properties + + + + + + + + + + +
+ + + + +
+ Name
+ + Collumns
+ +
+ Rows
+ +
+
+ + diff --git a/includes/fckeditor/editor/dialog/fck_textfield.html b/includes/fckeditor/editor/dialog/fck_textfield.html new file mode 100755 index 0000000..cf3ce03 --- /dev/null +++ b/includes/fckeditor/editor/dialog/fck_textfield.html @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+ Name
+ +
+ + Value
+ +
+ Character Width
+ +
+ + Maximum Characters
+ +
+ Type
+ +
+   +
+
+ + diff --git a/includes/fckeditor/editor/dtd/fck_dtd_test.html b/includes/fckeditor/editor/dtd/fck_dtd_test.html new file mode 100755 index 0000000..c149d15 --- /dev/null +++ b/includes/fckeditor/editor/dtd/fck_dtd_test.html @@ -0,0 +1,41 @@ + + + + DTD Test Page + + + + + +

+ DTD Contents +

+ + +
+ + diff --git a/includes/fckeditor/editor/dtd/fck_xhtml10strict.js b/includes/fckeditor/editor/dtd/fck_xhtml10strict.js new file mode 100755 index 0000000..0849b52 --- /dev/null +++ b/includes/fckeditor/editor/dtd/fck_xhtml10strict.js @@ -0,0 +1,116 @@ +/* + * FCKeditor - The text editor for Internet - http://www.fckeditor.net + * Copyright (C) 2003-2008 Frederico Caldeira Knabben + * + * == BEGIN LICENSE == + * + * Licensed under the terms of any of the following licenses at your + * choice: + * + * - GNU General Public License Version 2 or later (the "GPL") + * http://www.gnu.org/licenses/gpl.html + * + * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") + * http://www.gnu.org/licenses/lgpl.html + * + * - Mozilla Public License Version 1.1 or later (the "MPL") + * http://www.mozilla.org/MPL/MPL-1.1.html + * + * == END LICENSE == + * + * Contains the DTD mapping for XHTML 1.0 Strict. + * This file was automatically generated from the file: xhtml10-strict.dtd + */ +FCK.DTD = (function() +{ + var X = FCKTools.Merge ; + + var H,I,J,K,C,L,M,A,B,D,E,G,N,F ; + A = {ins:1, del:1, script:1} ; + B = {hr:1, ul:1, div:1, blockquote:1, noscript:1, table:1, address:1, pre:1, p:1, h5:1, dl:1, h4:1, ol:1, h6:1, h1:1, h3:1, h2:1} ; + C = X({fieldset:1}, B) ; + D = X({sub:1, bdo:1, 'var':1, sup:1, br:1, kbd:1, map:1, samp:1, b:1, acronym:1, '#':1, abbr:1, code:1, i:1, cite:1, tt:1, strong:1, q:1, em:1, big:1, small:1, span:1, dfn:1}, A) ; + E = X({img:1, object:1}, D) ; + F = {input:1, button:1, textarea:1, select:1, label:1} ; + G = X({a:1}, F) ; + H = {img:1, noscript:1, br:1, kbd:1, button:1, h5:1, h4:1, samp:1, h6:1, ol:1, h1:1, h3:1, h2:1, form:1, select:1, '#':1, ins:1, abbr:1, label:1, code:1, table:1, script:1, cite:1, input:1, strong:1, textarea:1, big:1, small:1, span:1, hr:1, sub:1, bdo:1, 'var':1, div:1, object:1, sup:1, map:1, dl:1, del:1, fieldset:1, ul:1, b:1, acronym:1, a:1, blockquote:1, i:1, address:1, tt:1, q:1, pre:1, p:1, em:1, dfn:1} ; + + I = X({form:1, fieldset:1}, B, E, G) ; + J = {tr:1} ; + K = {'#':1} ; + L = X(E, G) ; + M = {li:1} ; + N = X({form:1}, A, C) ; + + return { + col: {}, + tr: {td:1, th:1}, + img: {}, + colgroup: {col:1}, + noscript: N, + td: I, + br: {}, + th: I, + kbd: L, + button: X(B, E), + h5: L, + h4: L, + samp: L, + h6: L, + ol: M, + h1: L, + h3: L, + option: K, + h2: L, + form: X(A, C), + select: {optgroup:1, option:1}, + ins: I, + abbr: L, + label: L, + code: L, + table: {thead:1, col:1, tbody:1, tr:1, colgroup:1, caption:1, tfoot:1}, + script: K, + tfoot: J, + cite: L, + li: I, + input: {}, + strong: L, + textarea: K, + big: L, + small: L, + span: L, + dt: L, + hr: {}, + sub: L, + optgroup: {option:1}, + bdo: L, + param: {}, + 'var': L, + div: I, + object: X({param:1}, H), + sup: L, + dd: I, + area: {}, + map: X({form:1, area:1}, A, C), + dl: {dt:1, dd:1}, + del: I, + fieldset: X({legend:1}, H), + thead: J, + ul: M, + acronym: L, + b: L, + a: X({img:1, object:1}, D, F), + blockquote: N, + caption: L, + i: L, + tbody: J, + address: L, + tt: L, + legend: L, + q: L, + pre: X({a:1}, D, F), + p: L, + em: L, + dfn: L + } ; +})() ; diff --git a/includes/fckeditor/editor/dtd/fck_xhtml10transitional.js b/includes/fckeditor/editor/dtd/fck_xhtml10transitional.js new file mode 100755 index 0000000..5857ea9 --- /dev/null +++ b/includes/fckeditor/editor/dtd/fck_xhtml10transitional.js @@ -0,0 +1,140 @@ +/* + * FCKeditor - The text editor for Internet - http://www.fckeditor.net + * Copyright (C) 2003-2008 Frederico Caldeira Knabben + * + * == BEGIN LICENSE == + * + * Licensed under the terms of any of the following licenses at your + * choice: + * + * - GNU General Public License Version 2 or later (the "GPL") + * http://www.gnu.org/licenses/gpl.html + * + * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") + * http://www.gnu.org/licenses/lgpl.html + * + * - Mozilla Public License Version 1.1 or later (the "MPL") + * http://www.mozilla.org/MPL/MPL-1.1.html + * + * == END LICENSE == + * + * Contains the DTD mapping for XHTML 1.0 Transitional. + * This file was automatically generated from the file: xhtml10-transitional.dtd + */ +FCK.DTD = (function() +{ + var X = FCKTools.Merge ; + + var A,L,J,M,N,O,D,H,P,K,Q,F,G,C,B,E,I ; + A = {isindex:1, fieldset:1} ; + B = {input:1, button:1, select:1, textarea:1, label:1} ; + C = X({a:1}, B) ; + D = X({iframe:1}, C) ; + E = {hr:1, ul:1, menu:1, div:1, blockquote:1, noscript:1, table:1, center:1, address:1, dir:1, pre:1, h5:1, dl:1, h4:1, noframes:1, h6:1, ol:1, h1:1, h3:1, h2:1} ; + F = {ins:1, del:1, script:1} ; + G = X({b:1, acronym:1, bdo:1, 'var':1, '#':1, abbr:1, code:1, br:1, i:1, cite:1, kbd:1, u:1, strike:1, s:1, tt:1, strong:1, q:1, samp:1, em:1, dfn:1, span:1}, F) ; + H = X({sub:1, img:1, object:1, sup:1, basefont:1, map:1, applet:1, font:1, big:1, small:1}, G) ; + I = X({p:1}, H) ; + J = X({iframe:1}, H, B) ; + K = {img:1, noscript:1, br:1, kbd:1, center:1, button:1, basefont:1, h5:1, h4:1, samp:1, h6:1, ol:1, h1:1, h3:1, h2:1, form:1, font:1, '#':1, select:1, menu:1, ins:1, abbr:1, label:1, code:1, table:1, script:1, cite:1, input:1, iframe:1, strong:1, textarea:1, noframes:1, big:1, small:1, span:1, hr:1, sub:1, bdo:1, 'var':1, div:1, object:1, sup:1, strike:1, dir:1, map:1, dl:1, applet:1, del:1, isindex:1, fieldset:1, ul:1, b:1, acronym:1, a:1, blockquote:1, i:1, u:1, s:1, tt:1, address:1, q:1, pre:1, p:1, em:1, dfn:1} ; + + L = X({a:1}, J) ; + M = {tr:1} ; + N = {'#':1} ; + O = X({param:1}, K) ; + P = X({form:1}, A, D, E, I) ; + Q = {li:1} ; + + return { + col: {}, + tr: {td:1, th:1}, + img: {}, + colgroup: {col:1}, + noscript: P, + td: P, + br: {}, + th: P, + center: P, + kbd: L, + button: X(I, E), + basefont: {}, + h5: L, + h4: L, + samp: L, + h6: L, + ol: Q, + h1: L, + h3: L, + option: N, + h2: L, + form: X(A, D, E, I), + select: {optgroup:1, option:1}, + font: J, // Changed from L to J (see (1)) + ins: P, + menu: Q, + abbr: L, + label: L, + table: {thead:1, col:1, tbody:1, tr:1, colgroup:1, caption:1, tfoot:1}, + code: L, + script: N, + tfoot: M, + cite: L, + li: P, + input: {}, + iframe: P, + strong: J, // Changed from L to J (see (1)) + textarea: N, + noframes: P, + big: J, // Changed from L to J (see (1)) + small: J, // Changed from L to J (see (1)) + span: J, // Changed from L to J (see (1)) + hr: {}, + dt: L, + sub: J, // Changed from L to J (see (1)) + optgroup: {option:1}, + param: {}, + bdo: L, + 'var': J, // Changed from L to J (see (1)) + div: P, + object: O, + sup: J, // Changed from L to J (see (1)) + dd: P, + strike: J, // Changed from L to J (see (1)) + area: {}, + dir: Q, + map: X({area:1, form:1, p:1}, A, F, E), + applet: O, + dl: {dt:1, dd:1}, + del: P, + isindex: {}, + fieldset: X({legend:1}, K), + thead: M, + ul: Q, + acronym: L, + b: J, // Changed from L to J (see (1)) + a: J, + blockquote: P, + caption: L, + i: J, // Changed from L to J (see (1)) + u: J, // Changed from L to J (see (1)) + tbody: M, + s: L, + address: X(D, I), + tt: J, // Changed from L to J (see (1)) + legend: L, + q: L, + pre: X(G, C), + p: L, + em: J, // Changed from L to J (see (1)) + dfn: L + } ; +})() ; + +/* + Notes: + (1) According to the DTD, many elements, like accept elements + inside of them. But, to produce better output results, we have manually + changed the map to avoid breaking the links on pieces, having + "this is a link test", instead of + "this is a link test". +*/ diff --git a/includes/fckeditor/editor/fckdebug.html b/includes/fckeditor/editor/fckdebug.html new file mode 100755 index 0000000..ddb6224 --- /dev/null +++ b/includes/fckeditor/editor/fckdebug.html @@ -0,0 +1,153 @@ + + + + + FCKeditor Debug Window + + + + + + + + + + + +
+ + + + + +
+ FCKeditor Debug Window +
+
+ +
+ + diff --git a/includes/fckeditor/editor/fckdialog.html b/includes/fckeditor/editor/fckdialog.html new file mode 100755 index 0000000..4bbc369 --- /dev/null +++ b/includes/fckeditor/editor/fckdialog.html @@ -0,0 +1,812 @@ + + + + + + + + + + +
+ +
+
+ + + + + +
  + +   + +
+
+
+
+
+
+
+
+
+
+
+ + + + + diff --git a/includes/fckeditor/editor/fckeditor.html b/includes/fckeditor/editor/fckeditor.html new file mode 100755 index 0000000..aba4c48 --- /dev/null +++ b/includes/fckeditor/editor/fckeditor.html @@ -0,0 +1,317 @@ + + + + + FCKeditor + + + + + + + + + + + + + + + + + + + +
+ + diff --git a/includes/fckeditor/editor/fckeditor.original.html b/includes/fckeditor/editor/fckeditor.original.html new file mode 100755 index 0000000..5291486 --- /dev/null +++ b/includes/fckeditor/editor/fckeditor.original.html @@ -0,0 +1,424 @@ + + + + + FCKeditor + + + + + + + + + + + + + + + + + + + +
+ + diff --git a/includes/fckeditor/editor/filemanager/browser/default/browser.css b/includes/fckeditor/editor/filemanager/browser/default/browser.css new file mode 100755 index 0000000..9483308 --- /dev/null +++ b/includes/fckeditor/editor/filemanager/browser/default/browser.css @@ -0,0 +1,87 @@ +/* + * FCKeditor - The text editor for Internet - http://www.fckeditor.net + * Copyright (C) 2003-2008 Frederico Caldeira Knabben + * + * == BEGIN LICENSE == + * + * Licensed under the terms of any of the following licenses at your + * choice: + * + * - GNU General Public License Version 2 or later (the "GPL") + * http://www.gnu.org/licenses/gpl.html + * + * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") + * http://www.gnu.org/licenses/lgpl.html + * + * - Mozilla Public License Version 1.1 or later (the "MPL") + * http://www.mozilla.org/MPL/MPL-1.1.html + * + * == END LICENSE == + * + * CSS styles used by all pages that compose the File Browser. + */ + +body +{ + background-color: #f1f1e3; + margin-top:0; + margin-bottom:0; +} + +form +{ + margin: 0; + padding: 0; +} + +.Frame +{ + background-color: #f1f1e3; + border: thin inset #f1f1e3; +} + +body.FileArea +{ + background-color: #ffffff; + margin: 10px; +} + +body, td, input, select +{ + font-size: 11px; + font-family: 'Microsoft Sans Serif' , Arial, Helvetica, Verdana; +} + +.ActualFolder +{ + font-weight: bold; + font-size: 14px; +} + +.PopupButtons +{ + border-top: #d5d59d 1px solid; + background-color: #e3e3c7; + padding: 7px 10px 7px 10px; +} + +.Button, button +{ + color: #3b3b1f; + border: #737357 1px solid; + background-color: #c7c78f; +} + +.FolderListCurrentFolder img +{ + background-image: url(images/FolderOpened.gif); +} + +.FolderListFolder img +{ + background-image: url(images/Folder.gif); +} + +.fullHeight { + height: 100%; +} diff --git a/includes/fckeditor/editor/filemanager/browser/default/browser.html b/includes/fckeditor/editor/filemanager/browser/default/browser.html new file mode 100755 index 0000000..7a7e920 --- /dev/null +++ b/includes/fckeditor/editor/filemanager/browser/default/browser.html @@ -0,0 +1,200 @@ + + + + + FCKeditor - Resources Browser + + + + + + + + + + + + + + + + + + + + + diff --git a/includes/fckeditor/editor/filemanager/browser/default/frm.html b/includes/fckeditor/editor/filemanager/browser/default/frm.html new file mode 100755 index 0000000..e806832 --- /dev/null +++ b/includes/fckeditor/editor/filemanager/browser/default/frm.html @@ -0,0 +1,115 @@ + + + + + File Upload + + + + + + +
+ + + + +
+ Upload a new file in this folder
+ + + + + +
 
+
+
+ + diff --git a/includes/fckeditor/editor/filemanager/browser/default/frmactualfolder.html b/includes/fckeditor/editor/filemanager/browser/default/frmactualfolder.html new file mode 100755 index 0000000..1b70fa9 --- /dev/null +++ b/includes/fckeditor/editor/filemanager/browser/default/frmactualfolder.html @@ -0,0 +1,95 @@ + + + + + Folder path + + + + + + + + + +
+ +
+ + diff --git a/includes/fckeditor/editor/filemanager/browser/default/frmcreatefolder.html b/includes/fckeditor/editor/filemanager/browser/default/frmcreatefolder.html new file mode 100755 index 0000000..01ca135 --- /dev/null +++ b/includes/fckeditor/editor/filemanager/browser/default/frmcreatefolder.html @@ -0,0 +1,114 @@ + + + + + Create Folder + + + + + + + + + + +
+ +
+ + diff --git a/includes/fckeditor/editor/filemanager/browser/default/frmfolders.html b/includes/fckeditor/editor/filemanager/browser/default/frmfolders.html new file mode 100755 index 0000000..58a3c61 --- /dev/null +++ b/includes/fckeditor/editor/filemanager/browser/default/frmfolders.html @@ -0,0 +1,198 @@ + + + + + Folders + + + + + + + + + + + +
+ + diff --git a/includes/fckeditor/editor/filemanager/browser/default/frmresourceslist.html b/includes/fckeditor/editor/filemanager/browser/default/frmresourceslist.html new file mode 100755 index 0000000..e7d0e8e --- /dev/null +++ b/includes/fckeditor/editor/filemanager/browser/default/frmresourceslist.html @@ -0,0 +1,169 @@ + + + + + Resources + + + + + + + + diff --git a/includes/fckeditor/editor/filemanager/browser/default/frmresourcetype.html b/includes/fckeditor/editor/filemanager/browser/default/frmresourcetype.html new file mode 100755 index 0000000..4e87312 --- /dev/null +++ b/includes/fckeditor/editor/filemanager/browser/default/frmresourcetype.html @@ -0,0 +1,69 @@ + + + + + Available types + + + + + + + + + + +
+ Resource Type
+ +
+ + diff --git a/includes/fckeditor/editor/filemanager/browser/default/frmupload.html b/includes/fckeditor/editor/filemanager/browser/default/frmupload.html new file mode 100755 index 0000000..e806832 --- /dev/null +++ b/includes/fckeditor/editor/filemanager/browser/default/frmupload.html @@ -0,0 +1,115 @@ + + + + + File Upload + + + + + + +
+ + + + +
+ Upload a new file in this folder
+ + + + + +
 
+
+
+ + diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/ButtonArrow.gif b/includes/fckeditor/editor/filemanager/browser/default/images/ButtonArrow.gif new file mode 100755 index 0000000..a355e5a Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/ButtonArrow.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/Folder.gif b/includes/fckeditor/editor/filemanager/browser/default/images/Folder.gif new file mode 100755 index 0000000..ab6824d Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/Folder.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/Folder32.gif b/includes/fckeditor/editor/filemanager/browser/default/images/Folder32.gif new file mode 100755 index 0000000..b93b752 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/Folder32.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/FolderOpened.gif b/includes/fckeditor/editor/filemanager/browser/default/images/FolderOpened.gif new file mode 100755 index 0000000..0c5dd41 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/FolderOpened.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/FolderOpened32.gif b/includes/fckeditor/editor/filemanager/browser/default/images/FolderOpened32.gif new file mode 100755 index 0000000..3e3fcf5 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/FolderOpened32.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/FolderUp.gif b/includes/fckeditor/editor/filemanager/browser/default/images/FolderUp.gif new file mode 100755 index 0000000..ad5bc20 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/FolderUp.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/ai.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/ai.gif new file mode 100755 index 0000000..699e6a3 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/ai.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/avi.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/avi.gif new file mode 100755 index 0000000..97025bb Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/avi.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/bmp.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/bmp.gif new file mode 100755 index 0000000..f3c7f82 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/bmp.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/cs.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/cs.gif new file mode 100755 index 0000000..b62bd02 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/cs.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/default.icon.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/default.icon.gif new file mode 100755 index 0000000..976997b Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/default.icon.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/dll.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/dll.gif new file mode 100755 index 0000000..9b54964 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/dll.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/doc.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/doc.gif new file mode 100755 index 0000000..b557568 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/doc.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/exe.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/exe.gif new file mode 100755 index 0000000..7584993 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/exe.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/fla.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/fla.gif new file mode 100755 index 0000000..923079f Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/fla.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/gif.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/gif.gif new file mode 100755 index 0000000..df5f579 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/gif.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/htm.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/htm.gif new file mode 100755 index 0000000..a9bdf00 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/htm.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/html.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/html.gif new file mode 100755 index 0000000..a9bdf00 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/html.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/jpg.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/jpg.gif new file mode 100755 index 0000000..de78363 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/jpg.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/js.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/js.gif new file mode 100755 index 0000000..fe0c98e Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/js.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/mdb.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/mdb.gif new file mode 100755 index 0000000..d3af9e8 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/mdb.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/mp3.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/mp3.gif new file mode 100755 index 0000000..7d6360f Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/mp3.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/pdf.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/pdf.gif new file mode 100755 index 0000000..4950ec8 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/pdf.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/png.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/png.gif new file mode 100755 index 0000000..0a79ebf Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/png.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/ppt.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/ppt.gif new file mode 100755 index 0000000..023431c Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/ppt.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/rdp.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/rdp.gif new file mode 100755 index 0000000..b9eace7 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/rdp.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/swf.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/swf.gif new file mode 100755 index 0000000..5df7de5 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/swf.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/swt.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/swt.gif new file mode 100755 index 0000000..7807c07 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/swt.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/txt.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/txt.gif new file mode 100755 index 0000000..4e2c2e3 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/txt.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/vsd.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/vsd.gif new file mode 100755 index 0000000..7624697 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/vsd.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/xls.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/xls.gif new file mode 100755 index 0000000..afe724a Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/xls.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/xml.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/xml.gif new file mode 100755 index 0000000..4fae356 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/xml.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/zip.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/zip.gif new file mode 100755 index 0000000..7157f72 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/32/zip.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/ai.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/ai.gif new file mode 100755 index 0000000..ba5a913 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/ai.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/avi.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/avi.gif new file mode 100755 index 0000000..6f3bac9 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/avi.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/bmp.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/bmp.gif new file mode 100755 index 0000000..7708dd8 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/bmp.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/cs.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/cs.gif new file mode 100755 index 0000000..4d92723 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/cs.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/default.icon.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/default.icon.gif new file mode 100755 index 0000000..6ce26a4 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/default.icon.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/dll.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/dll.gif new file mode 100755 index 0000000..48d445a Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/dll.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/doc.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/doc.gif new file mode 100755 index 0000000..6535b4c Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/doc.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/exe.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/exe.gif new file mode 100755 index 0000000..315817f Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/exe.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/fla.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/fla.gif new file mode 100755 index 0000000..8f91a98 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/fla.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/gif.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/gif.gif new file mode 100755 index 0000000..a5e3e6c Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/gif.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/htm.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/htm.gif new file mode 100755 index 0000000..0b5d6ba Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/htm.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/html.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/html.gif new file mode 100755 index 0000000..0b5d6ba Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/html.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/jpg.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/jpg.gif new file mode 100755 index 0000000..634b386 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/jpg.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/js.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/js.gif new file mode 100755 index 0000000..4ea17d4 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/js.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/mdb.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/mdb.gif new file mode 100755 index 0000000..0d7c102 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/mdb.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/mp3.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/mp3.gif new file mode 100755 index 0000000..6f3bac9 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/mp3.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/pdf.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/pdf.gif new file mode 100755 index 0000000..ca1f94a Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/pdf.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/png.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/png.gif new file mode 100755 index 0000000..b6d1b32 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/png.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/ppt.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/ppt.gif new file mode 100755 index 0000000..877a8c8 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/ppt.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/rdp.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/rdp.gif new file mode 100755 index 0000000..916cd7e Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/rdp.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/swf.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/swf.gif new file mode 100755 index 0000000..314469d Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/swf.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/swt.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/swt.gif new file mode 100755 index 0000000..314469d Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/swt.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/txt.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/txt.gif new file mode 100755 index 0000000..1511ba3 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/txt.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/vsd.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/vsd.gif new file mode 100755 index 0000000..9be3daa Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/vsd.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/xls.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/xls.gif new file mode 100755 index 0000000..f57715d Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/xls.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/xml.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/xml.gif new file mode 100755 index 0000000..4559928 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/xml.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/icons/zip.gif b/includes/fckeditor/editor/filemanager/browser/default/images/icons/zip.gif new file mode 100755 index 0000000..b1e2492 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/icons/zip.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/images/spacer.gif b/includes/fckeditor/editor/filemanager/browser/default/images/spacer.gif new file mode 100755 index 0000000..35d42e8 Binary files /dev/null and b/includes/fckeditor/editor/filemanager/browser/default/images/spacer.gif differ diff --git a/includes/fckeditor/editor/filemanager/browser/default/js/common.js b/includes/fckeditor/editor/filemanager/browser/default/js/common.js new file mode 100755 index 0000000..02f846a --- /dev/null +++ b/includes/fckeditor/editor/filemanager/browser/default/js/common.js @@ -0,0 +1,88 @@ +/* + * FCKeditor - The text editor for Internet - http://www.fckeditor.net + * Copyright (C) 2003-2008 Frederico Caldeira Knabben + * + * == BEGIN LICENSE == + * + * Licensed under the terms of any of the following licenses at your + * choice: + * + * - GNU General Public License Version 2 or later (the "GPL") + * http://www.gnu.org/licenses/gpl.html + * + * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") + * http://www.gnu.org/licenses/lgpl.html + * + * - Mozilla Public License Version 1.1 or later (the "MPL") + * http://www.mozilla.org/MPL/MPL-1.1.html + * + * == END LICENSE == + * + * Common objects and functions shared by all pages that compose the + * File Browser dialog window. + */ + +// Automatically detect the correct document.domain (#1919). +(function() +{ + var d = document.domain ; + + while ( true ) + { + // Test if we can access a parent property. + try + { + var test = window.top.opener.document.domain ; + break ; + } + catch( e ) + {} + + // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ... + d = d.replace( /.*?(?:\.|$)/, '' ) ; + + if ( d.length == 0 ) + break ; // It was not able to detect the domain. + + try + { + document.domain = d ; + } + catch (e) + { + break ; + } + } +})() ; + +function AddSelectOption( selectElement, optionText, optionValue ) +{ + var oOption = document.createElement("OPTION") ; + + oOption.text = optionText ; + oOption.value = optionValue ; + + selectElement.options.add(oOption) ; + + return oOption ; +} + +var oConnector = window.parent.oConnector ; +var oIcons = window.parent.oIcons ; + + +function StringBuilder( value ) +{ + this._Strings = new Array( value || '' ) ; +} + +StringBuilder.prototype.Append = function( value ) +{ + if ( value ) + this._Strings.push( value ) ; +} + +StringBuilder.prototype.ToString = function() +{ + return this._Strings.join( '' ) ; +} diff --git a/includes/fckeditor/editor/filemanager/browser/default/js/fckxml.js b/includes/fckeditor/editor/filemanager/browser/default/js/fckxml.js new file mode 100755 index 0000000..82d1cbb --- /dev/null +++ b/includes/fckeditor/editor/filemanager/browser/default/js/fckxml.js @@ -0,0 +1,147 @@ +/* + * FCKeditor - The text editor for Internet - http://www.fckeditor.net + * Copyright (C) 2003-2008 Frederico Caldeira Knabben + * + * == BEGIN LICENSE == + * + * Licensed under the terms of any of the following licenses at your + * choice: + * + * - GNU General Public License Version 2 or later (the "GPL") + * http://www.gnu.org/licenses/gpl.html + * + * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") + * http://www.gnu.org/licenses/lgpl.html + * + * - Mozilla Public License Version 1.1 or later (the "MPL") + * http://www.mozilla.org/MPL/MPL-1.1.html + * + * == END LICENSE == + * + * Defines the FCKXml object that is used for XML data calls + * and XML processing. + * + * This script is shared by almost all pages that compose the + * File Browser frameset. + */ + +var FCKXml = function() +{} + +FCKXml.prototype.GetHttpRequest = function() +{ + // Gecko / IE7 + try { return new XMLHttpRequest(); } + catch(e) {} + + // IE6 + try { return new ActiveXObject( 'Msxml2.XMLHTTP' ) ; } + catch(e) {} + + // IE5 + try { return new ActiveXObject( 'Microsoft.XMLHTTP' ) ; } + catch(e) {} + + return null ; +} + +FCKXml.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer ) +{ + var oFCKXml = this ; + + var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ; + + var oXmlHttp = this.GetHttpRequest() ; + + oXmlHttp.open( "GET", urlToCall, bAsync ) ; + + if ( bAsync ) + { + oXmlHttp.onreadystatechange = function() + { + if ( oXmlHttp.readyState == 4 ) + { + var oXml ; + try + { + // this is the same test for an FF2 bug as in fckxml_gecko.js + // but we've moved the responseXML assignment into the try{} + // so we don't even have to check the return status codes. + var test = oXmlHttp.responseXML.firstChild ; + oXml = oXmlHttp.responseXML ; + } + catch ( e ) + { + try + { + oXml = (new DOMParser()).parseFromString( oXmlHttp.responseText, 'text/xml' ) ; + } + catch ( e ) {} + } + + if ( !oXml || !oXml.firstChild || oXml.firstChild.nodeName == 'parsererror' ) + { + alert( 'The server didn\'t send back a proper XML response. Please contact your system administrator.\n\n' + + 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')\n\n' + + 'Requested URL:\n' + urlToCall + '\n\n' + + 'Response text:\n' + oXmlHttp.responseText ) ; + return ; + } + + oFCKXml.DOMDocument = oXml ; + asyncFunctionPointer( oFCKXml ) ; + } + } + } + + oXmlHttp.send( null ) ; + + if ( ! bAsync ) + { + if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 ) + this.DOMDocument = oXmlHttp.responseXML ; + else + { + alert( 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ; + } + } +} + +FCKXml.prototype.SelectNodes = function( xpath ) +{ + if ( navigator.userAgent.indexOf('MSIE') >= 0 ) // IE + return this.DOMDocument.selectNodes( xpath ) ; + else // Gecko + { + var aNodeArray = new Array(); + + var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument, + this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ; + if ( xPathResult ) + { + var oNode = xPathResult.iterateNext() ; + while( oNode ) + { + aNodeArray[aNodeArray.length] = oNode ; + oNode = xPathResult.iterateNext(); + } + } + return aNodeArray ; + } +} + +FCKXml.prototype.SelectSingleNode = function( xpath ) +{ + if ( navigator.userAgent.indexOf('MSIE') >= 0 ) // IE + return this.DOMDocument.selectSingleNode( xpath ) ; + else // Gecko + { + var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument, + this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null); + + if ( xPathResult && xPathResult.singleNodeValue ) + return xPathResult.singleNodeValue ; + else + return null ; + } +} diff --git a/includes/fckeditor/editor/filemanager/connectors/php/.php b/includes/fckeditor/editor/filemanager/connectors/php/.php new file mode 100755 index 0000000..b8457b4 --- /dev/null +++ b/includes/fckeditor/editor/filemanager/connectors/php/.php @@ -0,0 +1,59 @@ + diff --git a/includes/fckeditor/editor/filemanager/connectors/php/_more.php b/includes/fckeditor/editor/filemanager/connectors/php/_more.php new file mode 100755 index 0000000..23a22c1 --- /dev/null +++ b/includes/fckeditor/editor/filemanager/connectors/php/_more.php @@ -0,0 +1,59 @@ + diff --git a/includes/fckeditor/editor/filemanager/connectors/php/basexml.php b/includes/fckeditor/editor/filemanager/connectors/php/basexml.php new file mode 100755 index 0000000..0f6326b --- /dev/null +++ b/includes/fckeditor/editor/filemanager/connectors/php/basexml.php @@ -0,0 +1,93 @@ +' ; + + // Create the main "Connector" node. + echo '' ; + + // Add the current folder node. + echo '' ; + + $GLOBALS['HeaderSent'] = true ; +} + +function CreateXmlFooter() +{ + echo '' ; +} + +function SendError( $number, $text ) +{ + if ( isset( $GLOBALS['HeaderSent'] ) && $GLOBALS['HeaderSent'] ) + { + SendErrorNode( $number, $text ) ; + CreateXmlFooter() ; + } + else + { + SetXmlHeaders() ; + + // Create the XML document header + echo '' ; + + echo '' ; + + SendErrorNode( $number, $text ) ; + + echo '' ; + } + exit ; +} + +function SendErrorNode( $number, $text ) +{ + echo '' ; +} +?> diff --git a/includes/fckeditor/editor/filemanager/connectors/php/commands.php b/includes/fckeditor/editor/filemanager/connectors/php/commands.php new file mode 100755 index 0000000..4034a16 --- /dev/null +++ b/includes/fckeditor/editor/filemanager/connectors/php/commands.php @@ -0,0 +1,435 @@ +' ; + } + + closedir( $oCurrentFolder ) ; + + // Open the "Folders" node. + echo "" ; + + natcasesort( $aFolders ) ; + foreach ( $aFolders as $sFolder ) + echo $sFolder ; + + // Close the "Folders" node. + echo "" ; +} + +function GetFoldersAndFiles( $resourceType, $currentFolder ) +{ + // Map the virtual path to the local server path. + $sServerDir = ServerMapFolder( $resourceType, $currentFolder, 'GetFoldersAndFiles' ) ; + + // Arrays that will hold the folders and files names. + $aFolders = array() ; + $aFiles = array() ; + + $oCurrentFolder = opendir( $sServerDir ) ; + + while ( $sFile = readdir( $oCurrentFolder ) ) + { + if ( $sFile != '.' && $sFile != '..' ) + { + if ( is_dir( $sServerDir . $sFile ) ) + $aFolders[] = '' ; + else + { + $iFileSize = @filesize( $sServerDir . $sFile ) ; + if ( !$iFileSize ) { + $iFileSize = 0 ; + } + if ( $iFileSize > 0 ) + { + $iFileSize = round( $iFileSize / 1024 ) ; + if ( $iFileSize < 1 ) $iFileSize = 1 ; + } + + $aFiles[] = '' ; + } + } + } + + // Send the folders + natcasesort( $aFolders ) ; + echo '' ; + + foreach ( $aFolders as $sFolder ) + echo $sFolder ; + + echo '' ; + + // Send the files + natcasesort( $aFiles ) ; + echo '' ; + + foreach ( $aFiles as $sFiles ) + echo $sFiles ; + + echo '' ; +} + +function CreateFolder( $resourceType, $currentFolder ) +{ + if (!isset($_GET)) { + global $_GET; + } + $sErrorNumber = '0' ; + $sErrorMsg = '' ; + + if ( isset( $_GET['NewFolderName'] ) ) + { + $sNewFolderName = $_GET['NewFolderName'] ; + $sNewFolderName = SanitizeFolderName( $sNewFolderName ) ; + + if ( strpos( $sNewFolderName, '..' ) !== FALSE ) + $sErrorNumber = '102' ; // Invalid folder name. + else + { + // Map the virtual path to the local server path of the current folder. + $sServerDir = ServerMapFolder( $resourceType, $currentFolder, 'CreateFolder' ) ; + + if ( is_writable( $sServerDir ) ) + { + $sServerDir .= $sNewFolderName ; + + $sErrorMsg = CreateServerFolder( $sServerDir ) ; + + switch ( $sErrorMsg ) + { + case '' : + $sErrorNumber = '0' ; + break ; + case 'Invalid argument' : + case 'No such file or directory' : + $sErrorNumber = '102' ; // Path too long. + break ; + default : + $sErrorNumber = '110' ; + break ; + } + } + else + $sErrorNumber = '103' ; + } + } + else + $sErrorNumber = '102' ; + + // Create the "Error" node. + echo '' ; +} + +function FileUpload( $resourceType, $currentFolder, $sCommand ) +{ + if (!isset($_FILES)) { + global $_FILES; + } + + $sErrorNumber = '0' ; + $sFileName = '' ; + + if ( isset( $_FILES['NewFile'] ) && !is_null( $_FILES['NewFile']['tmp_name'] ) ) + { + global $Config ; + + $oFile = $_FILES['NewFile'] ; + + // Map the virtual path to the local server path. + $sServerDir = ServerMapFolder( $resourceType, $currentFolder, $sCommand ) ; + + // Get the uploaded file name. + $sFileName = $oFile['name'] ; + $sFileName = SanitizeFileName( $sFileName ) ; + + $sOriginalFileName = $sFileName ; + + // Get the extension. + $sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ) ; + $sExtension = strtolower( $sExtension ) ; + + if ( isset( $Config['SecureImageUploads'] ) ) + { + if ( ( $isImageValid = IsImageValid( $oFile['tmp_name'], $sExtension ) ) === false ) + { + $sErrorNumber = '202' ; + } + } + + if ( isset( $Config['HtmlExtensions'] ) ) + { + if ( !IsHtmlExtension( $sExtension, $Config['HtmlExtensions'] ) && + ( $detectHtml = DetectHtml( $oFile['tmp_name'] ) ) === true ) + { + $sErrorNumber = '202' ; + } + } + + // Check if it is an allowed extension. + if ( !$sErrorNumber && IsAllowedExt( $sExtension, $resourceType ) ) + { + $iCounter = 0 ; + + while ( true ) + { + $sFilePath = $sServerDir . $sFileName ; + + if ( is_file( $sFilePath ) ) + { + $iCounter++ ; + $sFileName = RemoveExtension( $sOriginalFileName ) . '(' . $iCounter . ').' . $sExtension ; + $sErrorNumber = '201' ; + } + else + { + move_uploaded_file( $oFile['tmp_name'], $sFilePath ) ; + + //判断并给符合条件图片加上水印 + if ($sExtension == 'jpg' || $sExtension == 'jpeg' || $sExtension == 'png' || $sExtension == 'gif' || $sExtension == 'bmp' ) + { + require_once(ROOT_PATH . '/includes/cls_image.php'); + $image = new cls_image($GLOBALS['_CFG']['bgcolor']); + + if (intval($GLOBALS['_CFG']['watermark_place']) > 0 && !empty($GLOBALS['_CFG']['watermark'])) + { + $image->add_watermark($sFilePath,'','../../../../../'.$GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']); + } + } + + if ( is_file( $sFilePath ) ) + { + if ( isset( $Config['ChmodOnUpload'] ) && !$Config['ChmodOnUpload'] ) + { + break ; + } + + $permissions = 0777; + + if ( isset( $Config['ChmodOnUpload'] ) && $Config['ChmodOnUpload'] ) + { + $permissions = $Config['ChmodOnUpload'] ; + } + + $oldumask = umask(0) ; + chmod( $sFilePath, $permissions ) ; + umask( $oldumask ) ; + } + + break ; + } + } + + if ( file_exists( $sFilePath ) ) + { + //previous checks failed, try once again + if ( isset( $isImageValid ) && $isImageValid === -1 && IsImageValid( $sFilePath, $sExtension ) === false ) + { + @unlink( $sFilePath ) ; + $sErrorNumber = '202' ; + } + else if ( isset( $detectHtml ) && $detectHtml === -1 && DetectHtml( $sFilePath ) === true ) + { + @unlink( $sFilePath ) ; + $sErrorNumber = '202' ; + } + } + } + else + $sErrorNumber = '202' ; + } + else + $sErrorNumber = '202' ; + + + $sFileUrl = CombinePaths( GetResourceTypePath( $resourceType, $sCommand ) , $currentFolder ) ; + $sFileUrl = CombinePaths( $sFileUrl, $sFileName ) ; + + SendUploadResults( $sErrorNumber, $sFileUrl, $sFileName ) ; + + exit ; +} + +function MoreFileUpload( $resourceType, $currentFolder, $sCommand ) +{ + if (!isset($_FILES)) { + global $_FILES; + } + + global $Config ; + $sErrorNumber = '0' ; + $sFileName = '' ; + + if ( is_array($_FILES['NewFile']['name']) ) + { + foreach ( $_FILES['NewFile']['name'] as $key => $value ) + { + if ( !empty ( $_FILES['NewFile']['tmp_name'][$key] ) ) + { + // Map the virtual path to the local server path. + $sServerDir = ServerMapFolder( $resourceType, $currentFolder, $sCommand ) ; + + // Get the uploaded file name. + $sFileName = $_FILES['NewFile']['name'][$key] ; + $sFileName = SanitizeFileName( $sFileName ) ; + + $sOriginalFileName = $sFileName ; + + // Get the extension. + $sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ) ; + $sExtension = strtolower( $sExtension ) ; + + if ( isset( $Config['SecureImageUploads'] ) ) + { + if ( ( $isImageValid = IsImageValid( $_FILES['NewFile']['tmp_name'][$key], $sExtension ) ) === false ) + { + $sErrorNumber = '202' ; + } + } + + if ( isset( $Config['HtmlExtensions'] ) ) + { + if ( !IsHtmlExtension( $sExtension, $Config['HtmlExtensions'] ) && + ( $detectHtml = DetectHtml( $_FILES['NewFile']['tmp_name'][$key] ) ) === true ) + { + $sErrorNumber = '202' ; + } + } + + // Check if it is an allowed extension. + if ( !$sErrorNumber && IsAllowedExt( $sExtension, $resourceType ) ) + { + $iCounter = 0 ; + + while ( true ) + { + $sFilePath = $sServerDir . $sFileName ; + + if ( is_file( $sFilePath ) ) + { + $iCounter++ ; + $sFileName = RemoveExtension( $sOriginalFileName ) . '(' . $iCounter . ').' . $sExtension ; + $sErrorNumber = '201' ; + } + else + { + move_uploaded_file( $_FILES['NewFile']['tmp_name'][$key], $sFilePath ) ; + + //判断并给符合条件图片加上水印 + if ($sExtension == 'jpg' || $sExtension == 'jpeg' || $sExtension == 'png' || $sExtension == 'gif' || $sExtension == 'bmp' ) + { + require_once(ROOT_PATH . '/includes/cls_image.php'); + $image = new cls_image($GLOBALS['_CFG']['bgcolor']); + + if (intval($GLOBALS['_CFG']['watermark_place']) > 0 && !empty($GLOBALS['_CFG']['watermark'])) + { + $image->add_watermark($sFilePath,'','../../../../../'.$GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']); + } + } + + if ( is_file( $sFilePath ) ) + { + if ( isset( $Config['ChmodOnUpload'] ) && !$Config['ChmodOnUpload'] ) + { + break ; + } + + $permissions = 0777; + + if ( isset( $Config['ChmodOnUpload'] ) && $Config['ChmodOnUpload'] ) + { + $permissions = $Config['ChmodOnUpload'] ; + } + + $oldumask = umask(0) ; + chmod( $sFilePath, $permissions ) ; + umask( $oldumask ) ; + } + + break ; + } + } + + if ( file_exists( $sFilePath ) ) + { + //previous checks failed, try once again + if ( isset( $isImageValid ) && $isImageValid === -1 && IsImageValid( $sFilePath, $sExtension ) === false ) + { + @unlink( $sFilePath ) ; + $sErrorNumber = '202' ; + } + else if ( isset( $detectHtml ) && $detectHtml === -1 && DetectHtml( $sFilePath ) === true ) + { + @unlink( $sFilePath ) ; + $sErrorNumber = '202' ; + } + } + } + else + $sErrorNumber = '202' ; + + if ( $sErrorNumber == '202' ) + { + $sFileUrl = CombinePaths( GetResourceTypePath( $resourceType, $sCommand ) , $currentFolder ) ; + $sFileUrl = CombinePaths( $sFileUrl, $sFileName ) ; + + SendUploadResults( $sErrorNumber, $sFileUrl, $sFileName) ; + } + } + else + { + continue; + } + } + + $sFileUrl = CombinePaths( GetResourceTypePath( $resourceType, $sCommand ) , $currentFolder ) ; + $sFileUrl = CombinePaths( $sFileUrl, $sFileName ) ; + + SendUploadResults( $sErrorNumber, $sFileUrl, $sFileName, $key) ; + } + else + { + $sErrorNumber = '202' ; + $sFileUrl = CombinePaths( GetResourceTypePath( $resourceType, $sCommand ) , $currentFolder ) ; + $sFileUrl = CombinePaths( $sFileUrl, $sFileName ) ; + + SendUploadResults( $sErrorNumber, $sFileUrl, $sFileName ) ; + } + + exit ; +} +?> \ No newline at end of file diff --git a/includes/fckeditor/editor/filemanager/connectors/php/config.php b/includes/fckeditor/editor/filemanager/connectors/php/config.php new file mode 100755 index 0000000..1d8d2e4 --- /dev/null +++ b/includes/fckeditor/editor/filemanager/connectors/php/config.php @@ -0,0 +1,225 @@ +data_dir()); +define('IMAGE_DIR', $ecs->image_dir()); + +$db = new cls_mysql($db_host, $db_user, $db_pass, $db_name); + +/* init session */ +$sess = new cls_session($db, $ecs->table('sessions'), $ecs->table('sessions_data'), 'ECSCP_ID'); + +if (!empty($_SESSION['admin_id'])) +{ + if ($_SESSION['action_list'] == 'all') + { + $enable = true; + } + else + { + if (strpos(',' . $_SESSION['action_list'] . ',', ',goods_manage,') === false && strpos(',' . $_SESSION['action_list'] . ',', ',virualcard,') === false && strpos(',' . + $_SESSION['action_list'] . ',', ',article_manage,') === false) + { + $enable = false; + } + else + { + $enable = true; + } + } +} +else +{ + $enable = false; +} + +/* ϵͳ */ +$_CFG = load_config(); + +$Config['Enabled'] = $enable; + +// SECURITY: You must explicitly enable this "connector". (Set it to "true"). +// WARNING: don't just set "$Config['Enabled'] = true ;", you must be sure that only +// authenticated users can access this file or use some kind of session checking. +//$Config['Enabled'] = false ; + + +// Path to user files relative to the document root. +$Config['UserFilesPath'] = $root_path . IMAGE_DIR . '/upload/'; + +// Fill the following value it you prefer to specify the absolute path for the +// user files directory. Useful if you are using a virtual directory, symbolic +// link or alias. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'. +// Attention: The above 'UserFilesPath' must point to the same directory. +$Config['UserFilesAbsolutePath'] = ROOT_PATH . IMAGE_DIR . '/upload/' ; + +// Due to security issues with Apache modules, it is recommended to leave the +// following setting enabled. +$Config['ForceSingleExtension'] = true ; + +// Perform additional checks for image files. +// If set to true, validate image size (using getimagesize). +$Config['SecureImageUploads'] = true; + +// What the user can do with this connector. +$Config['ConfigAllowedCommands'] = array('QuickUpload', 'FileUpload', 'GetFolders', 'GetFoldersAndFiles', 'CreateFolder') ; + +// Allowed Resource Types. +$Config['ConfigAllowedTypes'] = array('File', 'Image', 'Flash', 'Media') ; + +// For security, HTML is allowed in the first Kb of data for files having the +// following extensions only. +$Config['HtmlExtensions'] = array("html", "htm", "xml", "xsd", "txt", "js") ; + +// After file is uploaded, sometimes it is required to change its permissions +// so that it was possible to access it at the later time. +// If possible, it is recommended to set more restrictive permissions, like 0755. +// Set to 0 to disable this feature. +// Note: not needed on Windows-based servers. +$Config['ChmodOnUpload'] = 0777 ; + +// See comments above. +// Used when creating folders that does not exist. +$Config['ChmodOnFolderCreate'] = 0777 ; + +/* + Configuration settings for each Resource Type + + - AllowedExtensions: the possible extensions that can be allowed. + If it is empty then any file type can be uploaded. + - DeniedExtensions: The extensions that won't be allowed. + If it is empty then no restrictions are done here. + + For a file to be uploaded it has to fulfill both the AllowedExtensions + and DeniedExtensions (that's it: not being denied) conditions. + + - FileTypesPath: the virtual folder relative to the document root where + these resources will be located. + Attention: It must start and end with a slash: '/' + + - FileTypesAbsolutePath: the physical path to the above folder. It must be + an absolute path. + If it's an empty string then it will be autocalculated. + Useful if you are using a virtual directory, symbolic link or alias. + Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'. + Attention: The above 'FileTypesPath' must point to the same directory. + Attention: It must end with a slash: '/' + + - QuickUploadPath: the virtual folder relative to the document root where + these resources will be uploaded using the Upload tab in the resources + dialogs. + Attention: It must start and end with a slash: '/' + + - QuickUploadAbsolutePath: the physical path to the above folder. It must be + an absolute path. + If it's an empty string then it will be autocalculated. + Useful if you are using a virtual directory, symbolic link or alias. + Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'. + Attention: The above 'QuickUploadPath' must point to the same directory. + Attention: It must end with a slash: '/' + + NOTE: by default, QuickUploadPath and QuickUploadAbsolutePath point to + "userfiles" directory to maintain backwards compatibility with older versions of FCKeditor. + This is fine, but you in some cases you will be not able to browse uploaded files using file browser. + Example: if you click on "image button", select "Upload" tab and send image + to the server, image will appear in FCKeditor correctly, but because it is placed + directly in /userfiles/ directory, you'll be not able to see it in built-in file browser. + The more expected behaviour would be to send images directly to "image" subfolder. + To achieve that, simply change + $Config['QuickUploadPath']['Image'] = $Config['UserFilesPath'] ; + $Config['QuickUploadAbsolutePath']['Image'] = $Config['UserFilesAbsolutePath'] ; + into: + $Config['QuickUploadPath']['Image'] = $Config['FileTypesPath']['Image'] ; + $Config['QuickUploadAbsolutePath']['Image'] = $Config['FileTypesAbsolutePath']['Image'] ; + +*/ + +$Config['AllowedExtensions']['File'] = array('7z', 'aiff', 'asf', 'avi', 'bmp', 'csv', 'doc', 'fla', 'flv', 'gif', 'gz', 'gzip', 'jpeg', 'jpg', 'mid', 'mov', 'mp3', 'mp4', 'mpc', 'mpeg', 'mpg', 'ods', 'odt', 'pdf', 'png', 'ppt', 'pxd', 'qt', 'ram', 'rar', 'rm', 'rmi', 'rmvb', 'rtf', 'sdc', 'sitd', 'swf', 'sxc', 'sxw', 'tar', 'tgz', 'tif', 'tiff', 'txt', 'vsd', 'wav', 'wma', 'wmv', 'xls', 'xml', 'zip') ; +$Config['FileTypesPath']['File'] = $Config['UserFilesPath'] . 'File/' ; +$Config['FileTypesAbsolutePath']['File']= ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'File/' ; +$Config['QuickUploadPath']['File'] = $Config['UserFilesPath'] . 'File/' ; +$Config['QuickUploadAbsolutePath']['File']= $Config['UserFilesAbsolutePath'] . 'File/' ; + +//$Config['AllowedExtensions']['Image'] = array('bmp','gif','jpeg','jpg','png') ; +$Config['AllowedExtensions']['Image'] = array('jpg','gif','jpeg','png') ; +$Config['DeniedExtensions']['Image'] = array() ; +$Config['FileTypesPath']['Image'] = $Config['UserFilesPath'] . 'Image/' ; +$Config['FileTypesAbsolutePath']['Image']= ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'Image/' ; +$Config['QuickUploadPath']['Image'] = $Config['UserFilesPath'] . 'Image/' ; +$Config['QuickUploadAbsolutePath']['Image']= $Config['UserFilesAbsolutePath'] . 'Image/' ; + +//$Config['AllowedExtensions']['Flash'] = array('swf','flv') ; +$Config['AllowedExtensions']['Flash'] = array('swf','fla') ; +$Config['DeniedExtensions']['Flash'] = array() ; +$Config['FileTypesPath']['Flash'] = $Config['UserFilesPath'] . 'Flash/' ; +$Config['FileTypesAbsolutePath']['Flash']= ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'Flash/' ; +$Config['QuickUploadPath']['Flash'] = $Config['UserFilesPath'] . 'Flash/' ; +$Config['QuickUploadAbsolutePath']['Flash']= $Config['UserFilesAbsolutePath'] . 'Flash/' ; + +//$Config['AllowedExtensions']['Media'] = array('aiff', 'asf', 'avi', 'bmp', 'fla', 'flv', 'gif', 'jpeg', 'jpg', 'mid', 'mov', 'mp3', 'mp4', 'mpc', 'mpeg', 'mpg', 'png', 'qt', 'ram', 'rm', 'rmi', 'rmvb', 'swf', 'tif', 'tiff', 'wav', 'wma', 'wmv') ; +$Config['AllowedExtensions']['Media'] =array('7z', 'aiff', 'asf', 'avi', 'bmp', 'csv', 'doc', 'fla', 'flv', 'gif', 'gz', 'gzip', 'jpeg', 'jpg', 'mid', 'mov', 'mp3', 'mp4', 'mpc', 'mpeg', 'mpg', 'ods', 'odt', 'pdf', 'png', 'ppt', 'pxd', 'qt', 'ram', 'rar', 'rm', 'rmi', 'rmvb', 'rtf', 'sdc', 'sitd', 'swf', 'sxc', 'sxw', 'tar', 'tgz', 'tif', 'tiff', 'txt', 'vsd', 'wav', 'wma', 'wmv', 'xls', 'xml', 'zip') ; +$Config['DeniedExtensions']['Media'] = array() ; +$Config['FileTypesPath']['Media'] = $Config['UserFilesPath'] . 'Media/' ; +$Config['FileTypesAbsolutePath']['Media']= ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'Media/' ; +$Config['QuickUploadPath']['Media'] = $Config['UserFilesPath'] . 'Media/' ; +$Config['QuickUploadAbsolutePath']['Media']= $Config['UserFilesAbsolutePath'] . 'Media/' ; + +?> diff --git a/includes/fckeditor/editor/filemanager/connectors/php/connector.php b/includes/fckeditor/editor/filemanager/connectors/php/connector.php new file mode 100755 index 0000000..d172a01 --- /dev/null +++ b/includes/fckeditor/editor/filemanager/connectors/php/connector.php @@ -0,0 +1,87 @@ + diff --git a/includes/fckeditor/editor/filemanager/connectors/php/io.php b/includes/fckeditor/editor/filemanager/connectors/php/io.php new file mode 100755 index 0000000..6a9645f --- /dev/null +++ b/includes/fckeditor/editor/filemanager/connectors/php/io.php @@ -0,0 +1,295 @@ + 0 ) + return $Config['QuickUploadAbsolutePath'][$resourceType] ; + + // Map the "UserFiles" path to a local directory. + return Server_MapPath( $Config['QuickUploadPath'][$resourceType] ) ; + } + else + { + if ( strlen( $Config['FileTypesAbsolutePath'][$resourceType] ) > 0 ) + return $Config['FileTypesAbsolutePath'][$resourceType] ; + + // Map the "UserFiles" path to a local directory. + return Server_MapPath( $Config['FileTypesPath'][$resourceType] ) ; + } +} + +function GetUrlFromPath( $resourceType, $folderPath, $sCommand ) +{ + return CombinePaths( GetResourceTypePath( $resourceType, $sCommand ), $folderPath ) ; +} + +function RemoveExtension( $fileName ) +{ + return substr( $fileName, 0, strrpos( $fileName, '.' ) ) ; +} + +function ServerMapFolder( $resourceType, $folderPath, $sCommand ) +{ + // Get the resource type directory. + $sResourceTypePath = GetResourceTypeDirectory( $resourceType, $sCommand ) ; + + // Ensure that the directory exists. + $sErrorMsg = CreateServerFolder( $sResourceTypePath ) ; + if ( $sErrorMsg != '' ) + SendError( 1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})" ) ; + + // Return the resource type directory combined with the required path. + return CombinePaths( $sResourceTypePath , $folderPath ) ; +} + +function GetParentFolder( $folderPath ) +{ + $sPattern = "-[/\\\\][^/\\\\]+[/\\\\]?$-" ; + return preg_replace( $sPattern, '', $folderPath ) ; +} + +function CreateServerFolder( $folderPath, $lastFolder = null ) +{ + global $Config ; + $sParent = GetParentFolder( $folderPath ) ; + + // Ensure the folder path has no double-slashes, or mkdir may fail on certain platforms + while ( strpos($folderPath, '//') !== false ) + { + $folderPath = str_replace( '//', '/', $folderPath ) ; + } + + // Check if the parent exists, or create it. + if ( !file_exists( $sParent ) ) + { + //prevents agains infinite loop when we can't create root folder + if ( !is_null( $lastFolder ) && $lastFolder === $sParent) { + return "Can't create $folderPath directory" ; + } + + $sErrorMsg = CreateServerFolder( $sParent, $folderPath ) ; + if ( $sErrorMsg != '' ) + return $sErrorMsg ; + } + + if ( !file_exists( $folderPath ) ) + { + // Turn off all error reporting. + error_reporting( 0 ) ; + + $php_errormsg = '' ; + // Enable error tracking to catch the error. + ini_set( 'track_errors', '1' ) ; + + if ( isset( $Config['ChmodOnFolderCreate'] ) && !$Config['ChmodOnFolderCreate'] ) + { + mkdir( $folderPath ) ; + } + else + { + $permissions = 0777 ; + if ( isset( $Config['ChmodOnFolderCreate'] ) ) + { + $permissions = $Config['ChmodOnFolderCreate'] ; + } + // To create the folder with 0777 permissions, we need to set umask to zero. + $oldumask = umask(0) ; + mkdir( $folderPath, $permissions ) ; + umask( $oldumask ) ; + } + + $sErrorMsg = $php_errormsg ; + + // Restore the configurations. + ini_restore( 'track_errors' ) ; + ini_restore( 'error_reporting' ) ; + + return $sErrorMsg ; + } + else + return '' ; +} + +function GetRootPath() +{ + if (!isset($_SERVER)) { + global $_SERVER; + } + $sRealPath = realpath( './' ) ; + // #2124 ensure that no slash is at the end + $sRealPath = rtrim($sRealPath,"\\/"); + + $sSelfPath = $_SERVER['PHP_SELF'] ; + $sSelfPath = substr( $sSelfPath, 0, strrpos( $sSelfPath, '/' ) ) ; + + $sSelfPath = str_replace( '/', DIRECTORY_SEPARATOR, $sSelfPath ) ; + + $position = strpos( $sRealPath, $sSelfPath ) ; + + // This can check only that this script isn't run from a virtual dir + // But it avoids the problems that arise if it isn't checked + if ( $position === false || $position <> strlen( $sRealPath ) - strlen( $sSelfPath ) ) + SendError( 1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".' ) ; + + return substr( $sRealPath, 0, $position ) ; +} + +// Emulate the asp Server.mapPath function. +// given an url path return the physical directory that it corresponds to +function Server_MapPath( $path ) +{ + // This function is available only for Apache + if ( function_exists( 'apache_lookup_uri' ) ) + { + $info = apache_lookup_uri( $path ) ; + return $info->filename . $info->path_info ; + } + + // This isn't correct but for the moment there's no other solution + // If this script is under a virtual directory or symlink it will detect the problem and stop + return GetRootPath() . $path ; +} + +function IsAllowedExt( $sExtension, $resourceType ) +{ + global $Config ; + // Get the allowed and denied extensions arrays. + $arAllowed = $Config['AllowedExtensions'][$resourceType] ; + $arDenied = $Config['DeniedExtensions'][$resourceType] ; + + if ( count($arAllowed) > 0 && !in_array( $sExtension, $arAllowed ) ) + return false ; + + if ( count($arDenied) > 0 && in_array( $sExtension, $arDenied ) ) + return false ; + + return true ; +} + +function IsAllowedType( $resourceType ) +{ + global $Config ; + if ( !in_array( $resourceType, $Config['ConfigAllowedTypes'] ) ) + return false ; + + return true ; +} + +function IsAllowedCommand( $sCommand ) +{ + global $Config ; + + if ( !in_array( $sCommand, $Config['ConfigAllowedCommands'] ) ) + return false ; + + return true ; +} + +function GetCurrentFolder() +{ + if (!isset($_GET)) { + global $_GET; + } + $sCurrentFolder = isset( $_GET['CurrentFolder'] ) ? $_GET['CurrentFolder'] : '/' ; + + // Check the current folder syntax (must begin and start with a slash). + if ( !preg_match( '|/$|', $sCurrentFolder ) ) + $sCurrentFolder .= '/' ; + if ( strpos( $sCurrentFolder, '/' ) !== 0 ) + $sCurrentFolder = '/' . $sCurrentFolder ; + + // Ensure the folder path has no double-slashes + while ( strpos ($sCurrentFolder, '//') !== false ) { + $sCurrentFolder = str_replace ('//', '/', $sCurrentFolder) ; + } + + // Check for invalid folder paths (..) + if ( strpos( $sCurrentFolder, '..' ) || strpos( $sCurrentFolder, "\\" )) + SendError( 102, '' ) ; + + return $sCurrentFolder ; +} + +// Do a cleanup of the folder name to avoid possible problems +function SanitizeFolderName( $sNewFolderName ) +{ + $sNewFolderName = stripslashes( $sNewFolderName ) ; + + // Remove . \ / | : ? * " < > + $sNewFolderName = preg_replace( '/\\.|\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFolderName ) ; + + return $sNewFolderName ; +} + +// Do a cleanup of the file name to avoid possible problems +function SanitizeFileName( $sNewFileName ) +{ + global $Config ; + + $sNewFileName = stripslashes( $sNewFileName ) ; + + // Replace dots in the name with underscores (only one dot can be there... security issue). + if ( $Config['ForceSingleExtension'] ) + $sNewFileName = preg_replace( '/\\.(?![^.]*$)/', '_', $sNewFileName ) ; + + // Remove \ / | : ? * " < > + $sNewFileName = preg_replace( '/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFileName ) ; + + return $sNewFileName ; +} + +// This is the function that sends the results of the uploading process. +function SendUploadResults( $errorNumber, $fileUrl = '', $fileName = '', $customMsg = '' ) +{ + // Minified version of the document.domain automatic fix script (#1919). + // The original script can be found at _dev/domain_fix_template.js + echo << +(function(){var d=document.domain;while (true){try{var A=window.parent.document.domain;break;}catch(e) {};d=d.replace(/.*?(?:\.|$)/,'');if (d.length==0) break;try{document.domain=d;}catch (e){break;}}})(); +EOF; + + $rpl = array( '\\' => '\\\\', '"' => '\\"' ) ; + echo 'window.parent.OnUploadCompleted(' . $errorNumber . ',"' . strtr( $fileUrl, $rpl ) . '","' . strtr( $fileName, $rpl ) . '", "' . strtr( $customMsg, $rpl ) . '") ;' ; + echo '' ; + exit ; +} + +?> diff --git a/includes/fckeditor/editor/filemanager/connectors/php/phpcompat.php b/includes/fckeditor/editor/filemanager/connectors/php/phpcompat.php new file mode 100755 index 0000000..6fc89e5 --- /dev/null +++ b/includes/fckeditor/editor/filemanager/connectors/php/phpcompat.php @@ -0,0 +1,17 @@ + diff --git a/includes/fckeditor/editor/filemanager/connectors/php/upload_more.php b/includes/fckeditor/editor/filemanager/connectors/php/upload_more.php new file mode 100755 index 0000000..23a22c1 --- /dev/null +++ b/includes/fckeditor/editor/filemanager/connectors/php/upload_more.php @@ -0,0 +1,59 @@ + diff --git a/includes/fckeditor/editor/filemanager/connectors/php/util.php b/includes/fckeditor/editor/filemanager/connectors/php/util.php new file mode 100755 index 0000000..cd5f6fc --- /dev/null +++ b/includes/fckeditor/editor/filemanager/connectors/php/util.php @@ -0,0 +1,220 @@ + $val ) + { + $lcaseHtmlExtensions[$key] = strtolower( $val ) ; + } + return in_array( $ext, $lcaseHtmlExtensions ) ; +} + +/** + * Detect HTML in the first KB to prevent against potential security issue with + * IE/Safari/Opera file type auto detection bug. + * Returns true if file contain insecure HTML code at the beginning. + * + * @param string $filePath absolute path to file + * @return boolean + */ +function DetectHtml( $filePath ) +{ + $fp = @fopen( $filePath, 'rb' ) ; + + //open_basedir restriction, see #1906 + if ( $fp === false || !flock( $fp, LOCK_SH ) ) + { + return -1 ; + } + + $chunk = fread( $fp, 1024 ) ; + flock( $fp, LOCK_UN ) ; + fclose( $fp ) ; + + $chunk = strtolower( $chunk ) ; + + if (!$chunk) + { + return false ; + } + + $chunk = trim( $chunk ) ; + + if ( preg_match( "/= 4.0.7 + if ( function_exists( 'version_compare' ) ) { + $sCurrentVersion = phpversion(); + if ( version_compare( $sCurrentVersion, "4.2.0" ) >= 0 ) { + $imageCheckExtensions[] = "tiff"; + $imageCheckExtensions[] = "tif"; + } + if ( version_compare( $sCurrentVersion, "4.3.0" ) >= 0 ) { + $imageCheckExtensions[] = "swc"; + } + if ( version_compare( $sCurrentVersion, "4.3.2" ) >= 0 ) { + $imageCheckExtensions[] = "jpc"; + $imageCheckExtensions[] = "jp2"; + $imageCheckExtensions[] = "jpx"; + $imageCheckExtensions[] = "jb2"; + $imageCheckExtensions[] = "xbm"; + $imageCheckExtensions[] = "wbmp"; + } + } + + if ( !in_array( $extension, $imageCheckExtensions ) ) { + return true; + } + + if ( @getimagesize( $filePath ) === false ) { + return false ; + } + + return true; +} + +?> diff --git a/includes/fckeditor/editor/images/anchor.gif b/includes/fckeditor/editor/images/anchor.gif new file mode 100755 index 0000000..5aa797b Binary files /dev/null and b/includes/fckeditor/editor/images/anchor.gif differ diff --git a/includes/fckeditor/editor/images/arrow_ltr.gif b/includes/fckeditor/editor/images/arrow_ltr.gif new file mode 100755 index 0000000..9c59bfe Binary files /dev/null and b/includes/fckeditor/editor/images/arrow_ltr.gif differ diff --git a/includes/fckeditor/editor/images/arrow_rtl.gif b/includes/fckeditor/editor/images/arrow_rtl.gif new file mode 100755 index 0000000..22e8649 Binary files /dev/null and b/includes/fckeditor/editor/images/arrow_rtl.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/angel_smile.gif b/includes/fckeditor/editor/images/smiley/msn/angel_smile.gif new file mode 100755 index 0000000..a95e053 Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/angel_smile.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/angry_smile.gif b/includes/fckeditor/editor/images/smiley/msn/angry_smile.gif new file mode 100755 index 0000000..c667c5d Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/angry_smile.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/broken_heart.gif b/includes/fckeditor/editor/images/smiley/msn/broken_heart.gif new file mode 100755 index 0000000..938cce1 Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/broken_heart.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/cake.gif b/includes/fckeditor/editor/images/smiley/msn/cake.gif new file mode 100755 index 0000000..f6489d7 Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/cake.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/confused_smile.gif b/includes/fckeditor/editor/images/smiley/msn/confused_smile.gif new file mode 100755 index 0000000..aeb0539 Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/confused_smile.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/cry_smile.gif b/includes/fckeditor/editor/images/smiley/msn/cry_smile.gif new file mode 100755 index 0000000..0758f42 Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/cry_smile.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/devil_smile.gif b/includes/fckeditor/editor/images/smiley/msn/devil_smile.gif new file mode 100755 index 0000000..15518d7 Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/devil_smile.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/embaressed_smile.gif b/includes/fckeditor/editor/images/smiley/msn/embaressed_smile.gif new file mode 100755 index 0000000..c431946 Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/embaressed_smile.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/envelope.gif b/includes/fckeditor/editor/images/smiley/msn/envelope.gif new file mode 100755 index 0000000..66d3656 Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/envelope.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/heart.gif b/includes/fckeditor/editor/images/smiley/msn/heart.gif new file mode 100755 index 0000000..305714f Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/heart.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/kiss.gif b/includes/fckeditor/editor/images/smiley/msn/kiss.gif new file mode 100755 index 0000000..f840ea6 Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/kiss.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/lightbulb.gif b/includes/fckeditor/editor/images/smiley/msn/lightbulb.gif new file mode 100755 index 0000000..863be6e Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/lightbulb.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/omg_smile.gif b/includes/fckeditor/editor/images/smiley/msn/omg_smile.gif new file mode 100755 index 0000000..aabc7fd Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/omg_smile.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/regular_smile.gif b/includes/fckeditor/editor/images/smiley/msn/regular_smile.gif new file mode 100755 index 0000000..33f297e Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/regular_smile.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/sad_smile.gif b/includes/fckeditor/editor/images/smiley/msn/sad_smile.gif new file mode 100755 index 0000000..dfb78ef Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/sad_smile.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/shades_smile.gif b/includes/fckeditor/editor/images/smiley/msn/shades_smile.gif new file mode 100755 index 0000000..157df77 Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/shades_smile.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/teeth_smile.gif b/includes/fckeditor/editor/images/smiley/msn/teeth_smile.gif new file mode 100755 index 0000000..26b5a55 Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/teeth_smile.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/thumbs_down.gif b/includes/fckeditor/editor/images/smiley/msn/thumbs_down.gif new file mode 100755 index 0000000..f53ee72 Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/thumbs_down.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/thumbs_up.gif b/includes/fckeditor/editor/images/smiley/msn/thumbs_up.gif new file mode 100755 index 0000000..7e8c746 Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/thumbs_up.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/tounge_smile.gif b/includes/fckeditor/editor/images/smiley/msn/tounge_smile.gif new file mode 100755 index 0000000..b87ec44 Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/tounge_smile.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/whatchutalkingabout_smile.gif b/includes/fckeditor/editor/images/smiley/msn/whatchutalkingabout_smile.gif new file mode 100755 index 0000000..c074122 Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/whatchutalkingabout_smile.gif differ diff --git a/includes/fckeditor/editor/images/smiley/msn/wink_smile.gif b/includes/fckeditor/editor/images/smiley/msn/wink_smile.gif new file mode 100755 index 0000000..eefe61d Binary files /dev/null and b/includes/fckeditor/editor/images/smiley/msn/wink_smile.gif differ diff --git a/includes/fckeditor/editor/images/spacer.gif b/includes/fckeditor/editor/images/spacer.gif new file mode 100755 index 0000000..5bfd67a Binary files /dev/null and b/includes/fckeditor/editor/images/spacer.gif differ diff --git a/includes/fckeditor/editor/js/fckadobeair.js b/includes/fckeditor/editor/js/fckadobeair.js new file mode 100755 index 0000000..811bd00 --- /dev/null +++ b/includes/fckeditor/editor/js/fckadobeair.js @@ -0,0 +1,176 @@ +/* + * FCKeditor - The text editor for Internet - http://www.fckeditor.net + * Copyright (C) 2003-2008 Frederico Caldeira Knabben + * + * == BEGIN LICENSE == + * + * Licensed under the terms of any of the following licenses at your + * choice: + * + * - GNU General Public License Version 2 or later (the "GPL") + * http://www.gnu.org/licenses/gpl.html + * + * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") + * http://www.gnu.org/licenses/lgpl.html + * + * - Mozilla Public License Version 1.1 or later (the "MPL") + * http://www.mozilla.org/MPL/MPL-1.1.html + * + * == END LICENSE == + * + * Compatibility code for Adobe AIR. + */ + +if ( FCKBrowserInfo.IsAIR ) +{ + var FCKAdobeAIR = (function() + { + /* + * ### Private functions. + */ + + var getDocumentHead = function( doc ) + { + var head ; + var heads = doc.getElementsByTagName( 'head' ) ; + + if( heads && heads[0] ) + head = heads[0] ; + else + { + head = doc.createElement( 'head' ) ; + doc.documentElement.insertBefore( head, doc.documentElement.firstChild ) ; + } + + return head ; + } ; + + /* + * ### Public interface. + */ + return { + FCKeditorAPI_Evaluate : function( parentWindow, script ) + { + // TODO : This one doesn't work always. The parent window will + // point to an anonymous function in this window. If this + // window is destroyied the parent window will be pointing to + // an invalid reference. + + // Evaluate the script in this window. + eval( script ) ; + + // Point the FCKeditorAPI property of the parent window to the + // local reference. + parentWindow.FCKeditorAPI = window.FCKeditorAPI ; + }, + + EditingArea_Start : function( doc, html ) + { + // Get the HTML for the . + var headInnerHtml = html.match( /([\s\S]*)<\/head>/i )[1] ; + + if ( headInnerHtml && headInnerHtml.length > 0 ) + { + // Inject the HTML inside a
. + // Do that before getDocumentHead because WebKit moves + // elements to the at this point. + var div = doc.createElement( 'div' ) ; + div.innerHTML = headInnerHtml ; + + // Move the
nodes to . + FCKDomTools.MoveChildren( div, getDocumentHead( doc ) ) ; + } + + doc.body.innerHTML = html.match( /([\s\S]*)<\/body>/i )[1] ; + + //prevent clicking on hyperlinks and navigating away + doc.addEventListener('click', function( ev ) + { + ev.preventDefault() ; + ev.stopPropagation() ; + }, true ) ; + }, + + Panel_Contructor : function( doc, baseLocation ) + { + var head = getDocumentHead( doc ) ; + + // Set the href. + head.appendChild( doc.createElement('base') ).href = baseLocation ; + + doc.body.style.margin = '0px' ; + doc.body.style.padding = '0px' ; + }, + + ToolbarSet_GetOutElement : function( win, outMatch ) + { + var toolbarTarget = win.parent ; + + var targetWindowParts = outMatch[1].split( '.' ) ; + while ( targetWindowParts.length > 0 ) + { + var part = targetWindowParts.shift() ; + if ( part.length > 0 ) + toolbarTarget = toolbarTarget[ part ] ; + } + + toolbarTarget = toolbarTarget.document.getElementById( outMatch[2] ) ; + }, + + ToolbarSet_InitOutFrame : function( doc ) + { + var head = getDocumentHead( doc ) ; + + head.appendChild( doc.createElement('base') ).href = window.document.location ; + + var targetWindow = doc.defaultView; + + targetWindow.adjust = function() + { + targetWindow.frameElement.height = doc.body.scrollHeight; + } ; + + targetWindow.onresize = targetWindow.adjust ; + targetWindow.setTimeout( targetWindow.adjust, 0 ) ; + + doc.body.style.overflow = 'hidden'; + doc.body.innerHTML = document.getElementById( 'xToolbarSpace' ).innerHTML ; + } + } ; + })(); + + /* + * ### Overrides + */ + ( function() + { + // Save references for override reuse. + var _Original_FCKPanel_Window_OnFocus = FCKPanel_Window_OnFocus ; + var _Original_FCKPanel_Window_OnBlur = FCKPanel_Window_OnBlur ; + var _Original_FCK_StartEditor = FCK.StartEditor ; + + FCKPanel_Window_OnFocus = function( e, panel ) + { + // Call the original implementation. + _Original_FCKPanel_Window_OnFocus.call( this, e, panel ) ; + + if ( panel._focusTimer ) + clearTimeout( panel._focusTimer ) ; + } + + FCKPanel_Window_OnBlur = function( e, panel ) + { + // Delay the execution of the original function. + panel._focusTimer = FCKTools.SetTimeout( _Original_FCKPanel_Window_OnBlur, 100, this, [ e, panel ] ) ; + } + + FCK.StartEditor = function() + { + // Force pointing to the CSS files instead of using the inline CSS cached styles. + window.FCK_InternalCSS = FCKConfig.BasePath + 'css/fck_internal.css' ; + window.FCK_ShowTableBordersCSS = FCKConfig.BasePath + 'css/fck_showtableborders_gecko.css' ; + + _Original_FCK_StartEditor.apply( this, arguments ) ; + } + })(); +} diff --git a/includes/fckeditor/editor/js/fckeditorcode_gecko.js b/includes/fckeditor/editor/js/fckeditorcode_gecko.js new file mode 100755 index 0000000..2e90236 --- /dev/null +++ b/includes/fckeditor/editor/js/fckeditorcode_gecko.js @@ -0,0 +1,108 @@ +/* + * FCKeditor - The text editor for Internet - http://www.fckeditor.net + * Copyright (C) 2003-2008 Frederico Caldeira Knabben + * + * == BEGIN LICENSE == + * + * Licensed under the terms of any of the following licenses at your + * choice: + * + * - GNU General Public License Version 2 or later (the "GPL") + * http://www.gnu.org/licenses/gpl.html + * + * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") + * http://www.gnu.org/licenses/lgpl.html + * + * - Mozilla Public License Version 1.1 or later (the "MPL") + * http://www.mozilla.org/MPL/MPL-1.1.html + * + * == END LICENSE == + * + * This file has been compressed for better performance. The original source + * can be found at "editor/_source". + */ + +var FCK_STATUS_NOTLOADED=window.parent.FCK_STATUS_NOTLOADED=0;var FCK_STATUS_ACTIVE=window.parent.FCK_STATUS_ACTIVE=1;var FCK_STATUS_COMPLETE=window.parent.FCK_STATUS_COMPLETE=2;var FCK_TRISTATE_OFF=window.parent.FCK_TRISTATE_OFF=0;var FCK_TRISTATE_ON=window.parent.FCK_TRISTATE_ON=1;var FCK_TRISTATE_DISABLED=window.parent.FCK_TRISTATE_DISABLED=-1;var FCK_UNKNOWN=window.parent.FCK_UNKNOWN=-9;var FCK_TOOLBARITEM_ONLYICON=window.parent.FCK_TOOLBARITEM_ONLYICON=0;var FCK_TOOLBARITEM_ONLYTEXT=window.parent.FCK_TOOLBARITEM_ONLYTEXT=1;var FCK_TOOLBARITEM_ICONTEXT=window.parent.FCK_TOOLBARITEM_ICONTEXT=2;var FCK_EDITMODE_WYSIWYG=window.parent.FCK_EDITMODE_WYSIWYG=0;var FCK_EDITMODE_SOURCE=window.parent.FCK_EDITMODE_SOURCE=1;var FCK_IMAGES_PATH='images/';var FCK_SPACER_PATH='images/spacer.gif';var CTRL=1000;var SHIFT=2000;var ALT=4000;var FCK_STYLE_BLOCK=0;var FCK_STYLE_INLINE=1;var FCK_STYLE_OBJECT=2; +String.prototype.Contains=function(A){return (this.indexOf(A)>-1);};String.prototype.Equals=function(){var A=arguments;if (A.length==1&&A[0].pop) A=A[0];for (var i=0;iC) return false;if (B){var E=new RegExp(A+'$','i');return E.test(this);}else return (D==0||this.substr(C-D,D)==A);};String.prototype.Remove=function(A,B){var s='';if (A>0) s=this.substring(0,A);if (A+B=7),IsIE6:/*@cc_on!@*/false&&(parseInt(s.match(/msie (\d+)/)[1],10)>=6),IsSafari:s.Contains(' applewebkit/'),IsOpera:!!window.opera,IsAIR:s.Contains(' adobeair/'),IsMac:s.Contains('macintosh')};(function(A){A.IsGecko=(navigator.product=='Gecko')&&!A.IsSafari&&!A.IsOpera;A.IsGeckoLike=(A.IsGecko||A.IsSafari||A.IsOpera);if (A.IsGecko){var B=s.match(/rv:(\d+\.\d+)/);var C=B&&parseFloat(B[1]);if (C){A.IsGecko10=(C<1.8);A.IsGecko19=(C>1.8);}}})(FCKBrowserInfo); +var FCKURLParams={};(function(){var A=document.location.search.substr(1).split('&');for (var i=0;i';if (!FCKRegexLib.HtmlOpener.test(A)) A=''+A+'';if (!FCKRegexLib.HeadOpener.test(A)) A=A.replace(FCKRegexLib.HtmlOpener,'$&');return A;}else{var B=FCKConfig.DocType+'0&&!FCKRegexLib.Html4DocType.test(FCKConfig.DocType)) B+=' style="overflow-y: scroll"';B+='>'+A+'';return B;}},ConvertToDataFormat:function(A,B,C,D){var E=FCKXHtml.GetXHTML(A,!B,D);if (C&&FCKRegexLib.EmptyOutParagraph.test(E)) return '';return E;},FixHtml:function(A){return A;}}; +var FCK={Name:FCKURLParams['InstanceName'],Status:0,EditMode:0,Toolbar:null,HasFocus:false,DataProcessor:new FCKDataProcessor(),GetInstanceObject:(function(){var w=window;return function(name){return w[name];}})(),AttachToOnSelectionChange:function(A){this.Events.AttachEvent('OnSelectionChange',A);},GetLinkedFieldValue:function(){return this.LinkedField.value;},GetParentForm:function(){return this.LinkedField.form;},StartupValue:'',IsDirty:function(){if (this.EditMode==1) return (this.StartupValue!=this.EditingArea.Textarea.value);else{if (!this.EditorDocument) return false;return (this.StartupValue!=this.EditorDocument.body.innerHTML);}},ResetIsDirty:function(){if (this.EditMode==1) this.StartupValue=this.EditingArea.Textarea.value;else if (this.EditorDocument.body) this.StartupValue=this.EditorDocument.body.innerHTML;},StartEditor:function(){this.TempBaseTag=FCKConfig.BaseHref.length>0?'':'';var A=FCK.KeystrokeHandler=new FCKKeystrokeHandler();A.OnKeystroke=_FCK_KeystrokeHandler_OnKeystroke;A.SetKeystrokes(FCKConfig.Keystrokes);if (FCKBrowserInfo.IsIE7){if ((CTRL+86) in A.Keystrokes) A.SetKeystrokes([CTRL+86,true]);if ((SHIFT+45) in A.Keystrokes) A.SetKeystrokes([SHIFT+45,true]);};A.SetKeystrokes([CTRL+8,true]);this.EditingArea=new FCKEditingArea(document.getElementById('xEditingArea'));this.EditingArea.FFSpellChecker=FCKConfig.FirefoxSpellChecker;this.SetData(this.GetLinkedFieldValue(),true);FCKTools.AddEventListener(document,"keydown",this._TabKeyHandler);this.AttachToOnSelectionChange(_FCK_PaddingNodeListener);if (FCKBrowserInfo.IsGecko) this.AttachToOnSelectionChange(this._ExecCheckEmptyBlock);},Focus:function(){FCK.EditingArea.Focus();},SetStatus:function(A){this.Status=A;if (A==1){FCKFocusManager.AddWindow(window,true);if (FCKBrowserInfo.IsIE) FCKFocusManager.AddWindow(window.frameElement,true);if (FCKConfig.StartupFocus) FCK.Focus();};this.Events.FireEvent('OnStatusChange',A);},FixBody:function(){var A=FCKConfig.EnterMode;if (A!='p'&&A!='div') return;var B=this.EditorDocument;if (!B) return;var C=B.body;if (!C) return;FCKDomTools.TrimNode(C);var D=C.firstChild;var E;while (D){var F=false;switch (D.nodeType){case 1:var G=D.nodeName.toLowerCase();if (!FCKListsLib.BlockElements[G]&&G!='li'&&!D.getAttribute('_fckfakelement')&&D.getAttribute('_moz_dirty')==null) F=true;break;case 3:if (E||D.nodeValue.Trim().length>0) F=true;break;case 8:if (E) F=true;break;};if (F){var H=D.parentNode;if (!E) E=H.insertBefore(B.createElement(A),D);E.appendChild(H.removeChild(D));D=E.nextSibling;}else{if (E){FCKDomTools.TrimNode(E);E=null;};D=D.nextSibling;}};if (E) FCKDomTools.TrimNode(E);},GetData:function(A){if (FCK.EditMode==1) return FCK.EditingArea.Textarea.value;this.FixBody();var B=FCK.EditorDocument;if (!B) return null;var C=FCKConfig.FullPage;var D=FCK.DataProcessor.ConvertToDataFormat(C?B.documentElement:B.body,!C,FCKConfig.IgnoreEmptyParagraphValue,A);D=FCK.ProtectEventsRestore(D);if (FCKBrowserInfo.IsIE) D=D.replace(FCKRegexLib.ToReplace,'$1');if (C){if (FCK.DocTypeDeclaration&&FCK.DocTypeDeclaration.length>0) D=FCK.DocTypeDeclaration+'\n'+D;if (FCK.XmlDeclaration&&FCK.XmlDeclaration.length>0) D=FCK.XmlDeclaration+'\n'+D;};return FCKConfig.ProtectedSource.Revert(D);},UpdateLinkedField:function(){var A=FCK.GetXHTML(FCKConfig.FormatOutput);if (FCKConfig.HtmlEncodeOutput) A=FCKTools.HTMLEncode(A);FCK.LinkedField.value=A;FCK.Events.FireEvent('OnAfterLinkedFieldUpdate');},RegisteredDoubleClickHandlers:{},OnDoubleClick:function(A){var B=FCK.RegisteredDoubleClickHandlers[A.tagName.toUpperCase()];if (B){for (var i=0;i0?'|ABBR|XML|EMBED|OBJECT':'ABBR|XML|EMBED|OBJECT';var C;if (B.length>0){C=new RegExp('<('+B+')(?!\w|:)','gi');A=A.replace(C,'','gi');A=A.replace(C,'<\/FCK:$1>');};B='META';if (FCKBrowserInfo.IsIE) B+='|HR';C=new RegExp('<(('+B+')(?=\\s|>|/)[\\s\\S]*?)/?>','gi');A=A.replace(C,'');return A;},SetData:function(A,B){this.EditingArea.Mode=FCK.EditMode;if (FCKBrowserInfo.IsIE&&FCK.EditorDocument){FCK.EditorDocument.detachEvent("onselectionchange",Doc_OnSelectionChange);};FCKTempBin.Reset();if (FCK.EditMode==0){this._ForceResetIsDirty=(B===true);A=FCKConfig.ProtectedSource.Protect(A);A=FCK.DataProcessor.ConvertToHtml(A);A=A.replace(FCKRegexLib.InvalidSelfCloseTags,'$1>');A=FCK.ProtectEvents(A);A=FCK.ProtectUrls(A);A=FCK.ProtectTags(A);if (FCK.TempBaseTag.length>0&&!FCKRegexLib.HasBaseTag.test(A)) A=A.replace(FCKRegexLib.HeadOpener,'$&'+FCK.TempBaseTag);var C='';if (!FCKConfig.FullPage) C+=_FCK_GetEditorAreaStyleTags();if (FCKBrowserInfo.IsIE) C+=FCK._GetBehaviorsStyle();else if (FCKConfig.ShowBorders) C+=FCKTools.GetStyleHtml(FCK_ShowTableBordersCSS,true);C+=FCKTools.GetStyleHtml(FCK_InternalCSS,true);A=A.replace(FCKRegexLib.HeadCloser,C+'$&');this.EditingArea.OnLoad=_FCK_EditingArea_OnLoad;this.EditingArea.Start(A);}else{FCK.EditorWindow=null;FCK.EditorDocument=null;FCKDomTools.PaddingNode=null;this.EditingArea.OnLoad=null;this.EditingArea.Start(A);this.EditingArea.Textarea._FCKShowContextMenu=true;FCK.EnterKeyHandler=null;if (B) this.ResetIsDirty();FCK.KeystrokeHandler.AttachToElement(this.EditingArea.Textarea);this.EditingArea.Textarea.focus();FCK.Events.FireEvent('OnAfterSetHTML');};if (FCKBrowserInfo.IsGecko) window.onresize();},RedirectNamedCommands:{},ExecuteNamedCommand:function(A,B,C,D){if (!D) FCKUndo.SaveUndoStep();if (!C&&FCK.RedirectNamedCommands[A]!=null) FCK.ExecuteRedirectedNamedCommand(A,B);else{FCK.Focus();FCK.EditorDocument.execCommand(A,false,B);FCK.Events.FireEvent('OnSelectionChange');};if (!D) FCKUndo.SaveUndoStep();},GetNamedCommandState:function(A){try{if (FCKBrowserInfo.IsSafari&&FCK.EditorWindow&&A.IEquals('Paste')) return 0;if (!FCK.EditorDocument.queryCommandEnabled(A)) return -1;else{return FCK.EditorDocument.queryCommandState(A)?1:0;}}catch (e){return 0;}},GetNamedCommandValue:function(A){var B='';var C=FCK.GetNamedCommandState(A);if (C==-1) return null;try{B=this.EditorDocument.queryCommandValue(A);}catch(e) {};return B?B:'';},Paste:function(A){if (FCK.Status!=2||!FCK.Events.FireEvent('OnPaste')) return false;return A||FCK._ExecPaste();},PasteFromWord:function(){FCKDialog.OpenDialog('FCKDialog_Paste',FCKLang.PasteFromWord,'dialog/fck_paste.html',400,330,'Word');},Preview:function(){var A;if (FCKConfig.FullPage){if (FCK.TempBaseTag.length>0) A=FCK.TempBaseTag+FCK.GetXHTML();else A=FCK.GetXHTML();}else{A=FCKConfig.DocType+''+FCK.TempBaseTag+''+FCKLang.Preview+''+_FCK_GetEditorAreaStyleTags()+''+FCK.GetXHTML()+'';};var B=FCKConfig.ScreenWidth*0.8;var C=FCKConfig.ScreenHeight*0.7;var D=(FCKConfig.ScreenWidth-B)/2;var E='';if (FCK_IS_CUSTOM_DOMAIN&&FCKBrowserInfo.IsIE){window._FCKHtmlToLoad=A;E='javascript:void( (function(){document.open() ;document.domain="'+document.domain+'" ;document.write( window.opener._FCKHtmlToLoad );document.close() ;window.opener._FCKHtmlToLoad = null ;})() )';};var F=window.open(E,null,'toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width='+B+',height='+C+',left='+D);if (!FCK_IS_CUSTOM_DOMAIN||!FCKBrowserInfo.IsIE){F.document.write(A);F.document.close();}},SwitchEditMode:function(A){var B=(FCK.EditMode==0);var C=FCK.IsDirty();var D;if (B){FCKCommands.GetCommand('ShowBlocks').SaveState();if (!A&&FCKBrowserInfo.IsIE) FCKUndo.SaveUndoStep();D=FCK.GetXHTML(FCKConfig.FormatSource);if (FCKBrowserInfo.IsIE) FCKTempBin.ToHtml();if (D==null) return false;}else D=this.EditingArea.Textarea.value;FCK.EditMode=B?1:0;FCK.SetData(D,!C);FCK.Focus();FCKTools.RunFunction(FCK.ToolbarSet.RefreshModeState,FCK.ToolbarSet);return true;},InsertElement:function(A){if (typeof A=='string') A=this.EditorDocument.createElement(A);var B=A.nodeName.toLowerCase();FCKSelection.Restore();var C=new FCKDomRange(this.EditorWindow);C.MoveToSelection();C.DeleteContents();if (FCKListsLib.BlockElements[B]!=null){if (C.StartBlock){if (C.CheckStartOfBlock()) C.MoveToPosition(C.StartBlock,3);else if (C.CheckEndOfBlock()) C.MoveToPosition(C.StartBlock,4);else C.SplitBlock();};C.InsertNode(A);var D=FCKDomTools.GetNextSourceElement(A,false,null,['hr','br','param','img','area','input'],true);if (!D&&FCKConfig.EnterMode!='br'){D=this.EditorDocument.body.appendChild(this.EditorDocument.createElement(FCKConfig.EnterMode));if (FCKBrowserInfo.IsGeckoLike) FCKTools.AppendBogusBr(D);};if (FCKListsLib.EmptyElements[B]==null) C.MoveToElementEditStart(A);else if (D) C.MoveToElementEditStart(D);else C.MoveToPosition(A,4);if (FCKBrowserInfo.IsGeckoLike){if (D) FCKDomTools.ScrollIntoView(D,false);FCKDomTools.ScrollIntoView(A,false);}}else{C.InsertNode(A);C.SetStart(A,4);C.SetEnd(A,4);};C.Select();C.Release();this.Focus();return A;},_InsertBlockElement:function(A){},_IsFunctionKey:function(A){if (A>=16&&A<=20) return true;if (A==27||(A>=33&&A<=40)) return true;if (A==45) return true;return false;},_KeyDownListener:function(A){if (!A) A=FCK.EditorWindow.event;if (FCK.EditorWindow){if (!FCK._IsFunctionKey(A.keyCode)&&!(A.ctrlKey||A.metaKey)&&!(A.keyCode==46)) FCK._KeyDownUndo();};return true;},_KeyDownUndo:function(){if (!FCKUndo.Typing){FCKUndo.SaveUndoStep();FCKUndo.Typing=true;FCK.Events.FireEvent("OnSelectionChange");};FCKUndo.TypesCount++;FCKUndo.Changed=1;if (FCKUndo.TypesCount>FCKUndo.MaxTypes){FCKUndo.TypesCount=0;FCKUndo.SaveUndoStep();}},_TabKeyHandler:function(A){if (!A) A=window.event;var B=A.keyCode;if (B==9&&FCK.EditMode!=0){if (FCKBrowserInfo.IsIE){var C=document.selection.createRange();if (C.parentElement()!=FCK.EditingArea.Textarea) return true;C.text='\t';C.select();}else{var a=[];var D=FCK.EditingArea.Textarea;var E=D.selectionStart;var F=D.selectionEnd;a.push(D.value.substr(0,E));a.push('\t');a.push(D.value.substr(F));D.value=a.join('');D.setSelectionRange(E+1,E+1);};if (A.preventDefault) return A.preventDefault();return A.returnValue=false;};return true;}};FCK.Events=new FCKEvents(FCK);FCK.GetHTML=FCK.GetXHTML=FCK.GetData;FCK.SetHTML=FCK.SetData;FCK.InsertElementAndGetIt=FCK.CreateElement=FCK.InsertElement;function _FCK_ProtectEvents_ReplaceTags(A){return A.replace(FCKRegexLib.EventAttributes,_FCK_ProtectEvents_ReplaceEvents);};function _FCK_ProtectEvents_ReplaceEvents(A,B){return ' '+B+'_fckprotectedatt="'+encodeURIComponent(A)+'"';};function _FCK_ProtectEvents_RestoreEvents(A,B){return decodeURIComponent(B);};function _FCK_MouseEventsListener(A){if (!A) A=window.event;if (A.type=='mousedown') FCK.MouseDownFlag=true;else if (A.type=='mouseup') FCK.MouseDownFlag=false;else if (A.type=='mousemove') FCK.Events.FireEvent('OnMouseMove',A);};function _FCK_PaddingNodeListener(){if (FCKConfig.EnterMode.IEquals('br')) return;FCKDomTools.EnforcePaddingNode(FCK.EditorDocument,FCKConfig.EnterMode);if (!FCKBrowserInfo.IsIE&&FCKDomTools.PaddingNode){var A=FCKSelection.GetSelection();if (A&&A.rangeCount==1){var B=A.getRangeAt(0);if (B.collapsed&&B.startContainer==FCK.EditorDocument.body&&B.startOffset==0){B.selectNodeContents(FCKDomTools.PaddingNode);B.collapse(true);A.removeAllRanges();A.addRange(B);}}}else if (FCKDomTools.PaddingNode){var C=FCKSelection.GetParentElement();var D=FCKDomTools.PaddingNode;if (C&&C.nodeName.IEquals('body')){if (FCK.EditorDocument.body.childNodes.length==1&&FCK.EditorDocument.body.firstChild==D){if (FCKSelection._GetSelectionDocument(FCK.EditorDocument.selection)!=FCK.EditorDocument) return;var B=FCK.EditorDocument.body.createTextRange();var F=false;if (!D.childNodes.firstChild){D.appendChild(FCKTools.GetElementDocument(D).createTextNode('\ufeff'));F=true;};B.moveToElementText(D);B.select();if (F) B.pasteHTML('');}}}};function _FCK_EditingArea_OnLoad(){FCK.EditorWindow=FCK.EditingArea.Window;FCK.EditorDocument=FCK.EditingArea.Document;if (FCKBrowserInfo.IsIE) FCKTempBin.ToElements();FCK.InitializeBehaviors();FCK.MouseDownFlag=false;FCKTools.AddEventListener(FCK.EditorDocument,'mousemove',_FCK_MouseEventsListener);FCKTools.AddEventListener(FCK.EditorDocument,'mousedown',_FCK_MouseEventsListener);FCKTools.AddEventListener(FCK.EditorDocument,'mouseup',_FCK_MouseEventsListener);if (FCKBrowserInfo.IsSafari){var A=function(evt){if (!(evt.ctrlKey||evt.metaKey)) return;if (FCK.EditMode!=0) return;switch (evt.keyCode){case 89:FCKUndo.Redo();break;case 90:FCKUndo.Undo();break;}};FCKTools.AddEventListener(FCK.EditorDocument,'keyup',A);};FCK.EnterKeyHandler=new FCKEnterKey(FCK.EditorWindow,FCKConfig.EnterMode,FCKConfig.ShiftEnterMode,FCKConfig.TabSpaces);FCK.KeystrokeHandler.AttachToElement(FCK.EditorDocument);if (FCK._ForceResetIsDirty) FCK.ResetIsDirty();if (FCKBrowserInfo.IsIE&&FCK.HasFocus) FCK.EditorDocument.body.setActive();FCK.OnAfterSetHTML();FCKCommands.GetCommand('ShowBlocks').RestoreState();if (FCK.Status!=0) return;FCK.SetStatus(1);};function _FCK_GetEditorAreaStyleTags(){return FCKTools.GetStyleHtml(FCKConfig.EditorAreaCSS)+FCKTools.GetStyleHtml(FCKConfig.EditorAreaStyles);};function _FCK_KeystrokeHandler_OnKeystroke(A,B){if (FCK.Status!=2) return false;if (FCK.EditMode==0){switch (B){case 'Paste':return!FCK.Paste();case 'Cut':FCKUndo.SaveUndoStep();return false;}}else{if (B.Equals('Paste','Undo','Redo','SelectAll','Cut')) return false;};var C=FCK.Commands.GetCommand(B);if (C.GetState()==-1) return false;return (C.Execute.apply(C,FCKTools.ArgumentsToArray(arguments,2))!==false);};(function(){var A=window.parent.document;var B=A.getElementById(FCK.Name);var i=0;while (B||i==0){if (B&&B.tagName.toLowerCase().Equals('input','textarea')){FCK.LinkedField=B;break;};B=A.getElementsByName(FCK.Name)[i++];}})();var FCKTempBin={Elements:[],AddElement:function(A){var B=this.Elements.length;this.Elements[B]=A;return B;},RemoveElement:function(A){var e=this.Elements[A];this.Elements[A]=null;return e;},Reset:function(){var i=0;while (i '+this.Elements[i].outerHTML+'
';this.Elements[i].isHtml=true;}},ToElements:function(){var A=FCK.EditorDocument.createElement('div');for (var i=0;i40) return;};var C=function(H){if (H.nodeType!=1) return false;var D=H.tagName.toLowerCase();return (FCKListsLib.BlockElements[D]||FCKListsLib.EmptyElements[D]);};var E=function(){var F=FCKSelection.GetSelection();var G=F.getRangeAt(0);if (!G||!G.collapsed) return;var H=G.endContainer;if (H.nodeType!=3) return;if (H.nodeValue.length!=G.endOffset) return;var I=H.parentNode.tagName.toLowerCase();if (!(I=='a'||(!FCKBrowserInfo.IsOpera&&String(H.parentNode.contentEditable)=='false')||(!(FCKListsLib.BlockElements[I]||FCKListsLib.NonEmptyBlockElements[I])&&B==35))) return;var J=FCKTools.GetNextTextNode(H,H.parentNode,C);if (J) return;G=FCK.EditorDocument.createRange();J=FCKTools.GetNextTextNode(H,H.parentNode.parentNode,C);if (J){if (FCKBrowserInfo.IsOpera&&B==37) return;G.setStart(J,0);G.setEnd(J,0);}else{while (H.parentNode&&H.parentNode!=FCK.EditorDocument.body&&H.parentNode!=FCK.EditorDocument.documentElement&&H==H.parentNode.lastChild&&(!FCKListsLib.BlockElements[H.parentNode.tagName.toLowerCase()]&&!FCKListsLib.NonEmptyBlockElements[H.parentNode.tagName.toLowerCase()])) H=H.parentNode;if (FCKListsLib.BlockElements[I]||FCKListsLib.EmptyElements[I]||H==FCK.EditorDocument.body){G.setStart(H,H.childNodes.length);G.setEnd(H,H.childNodes.length);}else{var K=H.nextSibling;while (K){if (K.nodeType!=1){K=K.nextSibling;continue;};var L=K.tagName.toLowerCase();if (FCKListsLib.BlockElements[L]||FCKListsLib.EmptyElements[L]||FCKListsLib.NonEmptyBlockElements[L]) break;K=K.nextSibling;};var M=FCK.EditorDocument.createTextNode('');if (K) H.parentNode.insertBefore(M,K);else H.parentNode.appendChild(M);G.setStart(M,0);G.setEnd(M,0);}};F.removeAllRanges();F.addRange(G);FCK.Events.FireEvent("OnSelectionChange");};setTimeout(E,1);};this.ExecOnSelectionChangeTimer=function(){if (FCK.LastOnChangeTimer) window.clearTimeout(FCK.LastOnChangeTimer);FCK.LastOnChangeTimer=window.setTimeout(FCK.ExecOnSelectionChange,100);};this.EditorDocument.addEventListener('mouseup',this.ExecOnSelectionChange,false);this.EditorDocument.addEventListener('keyup',this.ExecOnSelectionChangeTimer,false);this._DblClickListener=function(e){FCK.OnDoubleClick(e.target);e.stopPropagation();};this.EditorDocument.addEventListener('dblclick',this._DblClickListener,true);this.EditorDocument.addEventListener('keydown',this._KeyDownListener,false);if (FCKBrowserInfo.IsGecko){this.EditorWindow.addEventListener('dragdrop',this._ExecDrop,true);}else if (FCKBrowserInfo.IsSafari){var N=function(evt){ if (!FCK.MouseDownFlag) evt.returnValue=false;};this.EditorDocument.addEventListener('dragenter',N,true);this.EditorDocument.addEventListener('dragover',N,true);this.EditorDocument.addEventListener('drop',this._ExecDrop,true);this.EditorDocument.addEventListener('mousedown',function(ev){var O=ev.srcElement;if (O.nodeName.IEquals('IMG','HR','INPUT','TEXTAREA','SELECT')){FCKSelection.SelectNode(O);}},true);this.EditorDocument.addEventListener('mouseup',function(ev){if (ev.srcElement.nodeName.IEquals('INPUT','TEXTAREA','SELECT')) ev.preventDefault()},true);this.EditorDocument.addEventListener('click',function(ev){if (ev.srcElement.nodeName.IEquals('INPUT','TEXTAREA','SELECT')) ev.preventDefault()},true);};if (FCKBrowserInfo.IsGecko||FCKBrowserInfo.IsOpera){this.EditorDocument.addEventListener('keypress',this._ExecCheckCaret,false);this.EditorDocument.addEventListener('click',this._ExecCheckCaret,false);};FCK.ContextMenu._InnerContextMenu.SetMouseClickWindow(FCK.EditorWindow);FCK.ContextMenu._InnerContextMenu.AttachToElement(FCK.EditorDocument);};FCK.MakeEditable=function(){this.EditingArea.MakeEditable();};function Document_OnContextMenu(e){if (!e.target._FCKShowContextMenu) e.preventDefault();};document.oncontextmenu=Document_OnContextMenu;FCK._BaseGetNamedCommandState=FCK.GetNamedCommandState;FCK.GetNamedCommandState=function(A){switch (A){case 'Unlink':return FCKSelection.HasAncestorNode('A')?0:-1;default:return FCK._BaseGetNamedCommandState(A);}};FCK.RedirectNamedCommands={Print:true,Paste:true};FCK.ExecuteRedirectedNamedCommand=function(A,B){switch (A){case 'Print':FCK.EditorWindow.print();break;case 'Paste':try{if (FCKBrowserInfo.IsSafari) throw '';if (FCK.Paste()) FCK.ExecuteNamedCommand('Paste',null,true);}catch (e) { FCKDialog.OpenDialog('FCKDialog_Paste',FCKLang.Paste,'dialog/fck_paste.html',400,330,'Security');};break;default:FCK.ExecuteNamedCommand(A,B);}};FCK._ExecPaste=function(){FCKUndo.SaveUndoStep();if (FCKConfig.ForcePasteAsPlainText){FCK.PasteAsPlainText();return false;};return true;};FCK.InsertHtml=function(A){var B=FCK.EditorDocument,range;A=FCKConfig.ProtectedSource.Protect(A);A=FCK.ProtectEvents(A);A=FCK.ProtectUrls(A);A=FCK.ProtectTags(A);FCKUndo.SaveUndoStep();if (FCKBrowserInfo.IsGecko){A=A.replace(/ $/,'$&');var C=new FCKDocumentFragment(this.EditorDocument);C.AppendHtml(A);var D=C.RootNode.lastChild;range=new FCKDomRange(this.EditorWindow);range.MoveToSelection();range.DeleteContents();range.InsertNode(C.RootNode);range.MoveToPosition(D,4);}else B.execCommand('inserthtml',false,A);this.Focus();if (!range){range=new FCKDomRange(this.EditorWindow);range.MoveToSelection();};var E=range.CreateBookmark();FCKDocumentProcessor.Process(B);try{range.MoveToBookmark(E);range.Select();}catch (e) {};this.Events.FireEvent("OnSelectionChange");};FCK.PasteAsPlainText=function(){FCKTools.RunFunction(FCKDialog.OpenDialog,FCKDialog,['FCKDialog_Paste',FCKLang.PasteAsText,'dialog/fck_paste.html',400,330,'PlainText']);};FCK.GetClipboardHTML=function(){return '';};FCK.CreateLink=function(A,B){var C=[];if (FCKSelection.GetSelection().isCollapsed) return C;FCK.ExecuteNamedCommand('Unlink',null,false,!!B);if (A.length>0){var D='javascript:void(0);/*'+(new Date().getTime())+'*/';FCK.ExecuteNamedCommand('CreateLink',D,false,!!B);var E=this.EditorDocument.evaluate("//a[@href='"+D+"']",this.EditorDocument.body,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);for (var i=0;i0&&!isNaN(E)) this.PageConfig[D]=parseInt(E,10);else this.PageConfig[D]=E;}};function FCKConfig_LoadPageConfig(){var A=FCKConfig.PageConfig;for (var B in A) FCKConfig[B]=A[B];};function FCKConfig_PreProcess(){var A=FCKConfig;if (A.AllowQueryStringDebug){try{if ((/fckdebug=true/i).test(window.top.location.search)) A.Debug=true;}catch (e) { }};if (!A.PluginsPath.EndsWith('/')) A.PluginsPath+='/';var B=A.ToolbarComboPreviewCSS;if (!B||B.length==0) A.ToolbarComboPreviewCSS=A.EditorAreaCSS;A.RemoveAttributesArray=(A.RemoveAttributes||'').split(',');if (!FCKConfig.SkinEditorCSS||FCKConfig.SkinEditorCSS.length==0) FCKConfig.SkinEditorCSS=FCKConfig.SkinPath+'fck_editor.css';if (!FCKConfig.SkinDialogCSS||FCKConfig.SkinDialogCSS.length==0) FCKConfig.SkinDialogCSS=FCKConfig.SkinPath+'fck_dialog.css';};FCKConfig.ToolbarSets={};FCKConfig.Plugins={};FCKConfig.Plugins.Items=[];FCKConfig.Plugins.Add=function(A,B,C){FCKConfig.Plugins.Items.AddItem([A,B,C]);};FCKConfig.ProtectedSource={};FCKConfig.ProtectedSource._CodeTag=(new Date()).valueOf();FCKConfig.ProtectedSource.RegexEntries=[//g,//gi,//gi];FCKConfig.ProtectedSource.Add=function(A){this.RegexEntries.AddItem(A);};FCKConfig.ProtectedSource.Protect=function(A){var B=this._CodeTag;function _Replace(protectedSource){var C=FCKTempBin.AddElement(protectedSource);return '';};for (var i=0;i|>)","g");return A.replace(D,_Replace);};FCKConfig.GetBodyAttributes=function(){var A='';if (this.BodyId&&this.BodyId.length>0) A+=' id="'+this.BodyId+'"';if (this.BodyClass&&this.BodyClass.length>0) A+=' class="'+this.BodyClass+'"';return A;};FCKConfig.ApplyBodyAttributes=function(A){if (this.BodyId&&this.BodyId.length>0) A.id=FCKConfig.BodyId;if (this.BodyClass&&this.BodyClass.length>0) A.className+=' '+FCKConfig.BodyClass;}; +var FCKDebug={Output:function(){},OutputObject:function(){}}; +var FCKDomTools={MoveChildren:function(A,B,C){if (A==B) return;var D;if (C){while ((D=A.lastChild)) B.insertBefore(A.removeChild(D),B.firstChild);}else{while ((D=A.firstChild)) B.appendChild(A.removeChild(D));}},MoveNode:function(A,B,C){if (C) B.insertBefore(FCKDomTools.RemoveNode(A),B.firstChild);else B.appendChild(FCKDomTools.RemoveNode(A));},TrimNode:function(A){this.LTrimNode(A);this.RTrimNode(A);},LTrimNode:function(A){var B;while ((B=A.firstChild)){if (B.nodeType==3){var C=B.nodeValue.LTrim();var D=B.nodeValue.length;if (C.length==0){A.removeChild(B);continue;}else if (C.length0) break;if (A.lastChild) A=A.lastChild;else return this.GetPreviousSourceElement(A,B,C,D);};return null;},GetNextSourceElement:function(A,B,C,D,E){while((A=this.GetNextSourceNode(A,E))){if (A.nodeType==1){if (C&&A.nodeName.IEquals(C)) break;if (D&&A.nodeName.IEquals(D)) return this.GetNextSourceElement(A,B,C,D);return A;}else if (B&&A.nodeType==3&&A.nodeValue.RTrim().length>0) break;};return null;},GetNextSourceNode:function(A,B,C,D){if (!A) return null;var E;if (!B&&A.firstChild) E=A.firstChild;else{if (D&&A==D) return null;E=A.nextSibling;if (!E&&(!D||D!=A.parentNode)) return this.GetNextSourceNode(A.parentNode,true,C,D);};if (C&&E&&E.nodeType!=C) return this.GetNextSourceNode(E,false,C,D);return E;},GetPreviousSourceNode:function(A,B,C,D){if (!A) return null;var E;if (!B&&A.lastChild) E=A.lastChild;else{if (D&&A==D) return null;E=A.previousSibling;if (!E&&(!D||D!=A.parentNode)) return this.GetPreviousSourceNode(A.parentNode,true,C,D);};if (C&&E&&E.nodeType!=C) return this.GetPreviousSourceNode(E,false,C,D);return E;},InsertAfterNode:function(A,B){return A.parentNode.insertBefore(B,A.nextSibling);},GetParents:function(A){var B=[];while (A){B.unshift(A);A=A.parentNode;};return B;},GetCommonParents:function(A,B){var C=this.GetParents(A);var D=this.GetParents(B);var E=[];for (var i=0;i0) D[C.pop().toLowerCase()]=1;var E=this.GetCommonParents(A,B);var F=null;while ((F=E.pop())){if (D[F.nodeName.toLowerCase()]) return F;};return null;},GetIndexOf:function(A){var B=A.parentNode?A.parentNode.firstChild:null;var C=-1;while (B){C++;if (B==A) return C;B=B.nextSibling;};return-1;},PaddingNode:null,EnforcePaddingNode:function(A,B){try{if (!A||!A.body) return;}catch (e){return;};this.CheckAndRemovePaddingNode(A,B,true);try{if (A.body.lastChild&&(A.body.lastChild.nodeType!=1||A.body.lastChild.tagName.toLowerCase()==B.toLowerCase())) return;}catch (e){return;};var C=A.createElement(B);if (FCKBrowserInfo.IsGecko&&FCKListsLib.NonEmptyBlockElements[B]) FCKTools.AppendBogusBr(C);this.PaddingNode=C;if (A.body.childNodes.length==1&&A.body.firstChild.nodeType==1&&A.body.firstChild.tagName.toLowerCase()=='br'&&(A.body.firstChild.getAttribute('_moz_dirty')!=null||A.body.firstChild.getAttribute('type')=='_moz')) A.body.replaceChild(C,A.body.firstChild);else A.body.appendChild(C);},CheckAndRemovePaddingNode:function(A,B,C){var D=this.PaddingNode;if (!D) return;try{if (D.parentNode!=A.body||D.tagName.toLowerCase()!=B||(D.childNodes.length>1)||(D.firstChild&&D.firstChild.nodeValue!='\xa0'&&String(D.firstChild.tagName).toLowerCase()!='br')){this.PaddingNode=null;return;}}catch (e){this.PaddingNode=null;return;};if (!C){if (D.parentNode.childNodes.length>1) D.parentNode.removeChild(D);this.PaddingNode=null;}},HasAttribute:function(A,B){if (A.hasAttribute) return A.hasAttribute(B);else{var C=A.attributes[B];return (C!=undefined&&C.specified);}},HasAttributes:function(A){var B=A.attributes;for (var i=0;i0) return true;}else if (B[i].specified) return true;};return false;},RemoveAttribute:function(A,B){if (FCKBrowserInfo.IsIE&&B.toLowerCase()=='class') B='className';return A.removeAttribute(B,0);},RemoveAttributes:function (A,B){for (var i=0;i0) return false;C=C.nextSibling;};return D?this.CheckIsEmptyElement(D,B):true;},SetElementStyles:function(A,B){var C=A.style;for (var D in B) C[D]=B[D];},SetOpacity:function(A,B){if (FCKBrowserInfo.IsIE){B=Math.round(B*100);A.style.filter=(B>100?'':'progid:DXImageTransform.Microsoft.Alpha(opacity='+B+')');}else A.style.opacity=B;},GetCurrentElementStyle:function(A,B){if (FCKBrowserInfo.IsIE) return A.currentStyle[B];else return A.ownerDocument.defaultView.getComputedStyle(A,'').getPropertyValue(B);},GetPositionedAncestor:function(A){var B=A;while (B!=FCKTools.GetElementDocument(B).documentElement){if (this.GetCurrentElementStyle(B,'position')!='static') return B;if (B==FCKTools.GetElementDocument(B).documentElement&¤tWindow!=w) B=currentWindow.frameElement;else B=B.parentNode;};return null;},ScrollIntoView:function(A,B){var C=FCKTools.GetElementWindow(A);var D=FCKTools.GetViewPaneSize(C).Height;var E=D*-1;if (B===false){E+=A.offsetHeight||0;E+=parseInt(this.GetCurrentElementStyle(A,'marginBottom')||0,10)||0;};var F=FCKTools.GetDocumentPosition(C,A);E+=F.y;var G=FCKTools.GetScrollPosition(C).Y;if (E>0&&(E>G||E'+styleDef+'';};var C=function(cssFileUrl,markTemp){if (cssFileUrl.length==0) return '';var B=markTemp?' _fcktemp="true"':'';return '';};return function(cssFileOrArrayOrDef,markTemp){if (!cssFileOrArrayOrDef) return '';if (typeof(cssFileOrArrayOrDef)=='string'){if (/[\\\/\.][^{}]*$/.test(cssFileOrArrayOrDef)){return this.GetStyleHtml(cssFileOrArrayOrDef.split(','),markTemp);}else return A(this._GetUrlFixedCss(cssFileOrArrayOrDef),markTemp);}else{var E='';for (var i=0;i/g,'>');return A;};FCKTools.HTMLDecode=function(A){if (!A) return '';A=A.replace(/>/g,'>');A=A.replace(/</g,'<');A=A.replace(/&/g,'&');return A;};FCKTools._ProcessLineBreaksForPMode=function(A,B,C,D,E){var F=0;var G="

";var H="

";var I="
";if (C){G="
  • ";H="
  • ";F=1;}while (D&&D!=A.FCK.EditorDocument.body){if (D.tagName.toLowerCase()=='p'){F=1;break;};D=D.parentNode;};for (var i=0;i0) return A[A.length-1];return null;};FCKTools.GetDocumentPosition=function(w,A){var x=0;var y=0;var B=A;var C=null;var D=FCKTools.GetElementWindow(B);while (B&&!(D==w&&(B==w.document.body||B==w.document.documentElement))){x+=B.offsetLeft-B.scrollLeft;y+=B.offsetTop-B.scrollTop;if (!FCKBrowserInfo.IsOpera){var E=C;while (E&&E!=B){x-=E.scrollLeft;y-=E.scrollTop;E=E.parentNode;}};C=B;if (B.offsetParent) B=B.offsetParent;else{if (D!=w){B=D.frameElement;C=null;if (B) D=B.contentWindow.parent;}else B=null;}};if (FCKDomTools.GetCurrentElementStyle(w.document.body,'position')!='static'||(FCKBrowserInfo.IsIE&&FCKDomTools.GetPositionedAncestor(A)==null)){x+=w.document.body.offsetLeft;y+=w.document.body.offsetTop;};return { "x":x,"y":y };};FCKTools.GetWindowPosition=function(w,A){var B=this.GetDocumentPosition(w,A);var C=FCKTools.GetScrollPosition(w);B.x-=C.X;B.y-=C.Y;return B;};FCKTools.ProtectFormStyles=function(A){if (!A||A.nodeType!=1||A.tagName.toLowerCase()!='form') return [];var B=[];var C=['style','className'];for (var i=0;i0){for (var i=B.length-1;i>=0;i--){var C=B[i][0];var D=B[i][1];if (D) A.insertBefore(C,D);else A.appendChild(C);}}};FCKTools.GetNextNode=function(A,B){if (A.firstChild) return A.firstChild;else if (A.nextSibling) return A.nextSibling;else{var C=A.parentNode;while (C){if (C==B) return null;if (C.nextSibling) return C.nextSibling;else C=C.parentNode;}};return null;};FCKTools.GetNextTextNode=function(A,B,C){node=this.GetNextNode(A,B);if (C&&node&&C(node)) return null;while (node&&node.nodeType!=3){node=this.GetNextNode(node,B);if (C&&node&&C(node)) return null;};return node;};FCKTools.Merge=function(){var A=arguments;var o=A[0];for (var i=1;i');document.domain = '"+FCK_RUNTIME_DOMAIN+"';document.close();}() ) ;";if (FCKBrowserInfo.IsIE){if (FCKBrowserInfo.IsIE7||!FCKBrowserInfo.IsIE6) return "";else return "javascript: '';";};return "javascript: void(0);";};FCKTools.ResetStyles=function(A){A.style.cssText='margin:0;padding:0;border:0;background-color:transparent;background-image:none;';}; +FCKTools.CancelEvent=function(e){if (e) e.preventDefault();};FCKTools.DisableSelection=function(A){if (FCKBrowserInfo.IsGecko) A.style.MozUserSelect='none';else if (FCKBrowserInfo.IsSafari) A.style.KhtmlUserSelect='none';else A.style.userSelect='none';};FCKTools._AppendStyleSheet=function(A,B){var e=A.createElement('LINK');e.rel='stylesheet';e.type='text/css';e.href=B;A.getElementsByTagName("HEAD")[0].appendChild(e);return e;};FCKTools.AppendStyleString=function(A,B){if (!B) return null;var e=A.createElement("STYLE");e.appendChild(A.createTextNode(B));A.getElementsByTagName("HEAD")[0].appendChild(e);return e;};FCKTools.ClearElementAttributes=function(A){for (var i=0;i0) B[B.length]=D;C(parent.childNodes[i]);}};C(A);return B;};FCKTools.RemoveOuterTags=function(e){var A=e.ownerDocument.createDocumentFragment();for (var i=0;i','text/xml');FCKDomTools.RemoveNode(B.firstChild);return B;};return null;};FCKTools.GetScrollPosition=function(A){return { X:A.pageXOffset,Y:A.pageYOffset };};FCKTools.AddEventListener=function(A,B,C){A.addEventListener(B,C,false);};FCKTools.RemoveEventListener=function(A,B,C){A.removeEventListener(B,C,false);};FCKTools.AddEventListenerEx=function(A,B,C,D){A.addEventListener(B,function(e){C.apply(A,[e].concat(D||[]));},false);};FCKTools.GetViewPaneSize=function(A){return { Width:A.innerWidth,Height:A.innerHeight };};FCKTools.SaveStyles=function(A){var B=FCKTools.ProtectFormStyles(A);var C={};if (A.className.length>0){C.Class=A.className;A.className='';};var D=A.getAttribute('style');if (D&&D.length>0){C.Inline=D;A.setAttribute('style','',0);};FCKTools.RestoreFormStyles(A,B);return C;};FCKTools.RestoreStyles=function(A,B){var C=FCKTools.ProtectFormStyles(A);A.className=B.Class||'';if (B.Inline) A.setAttribute('style',B.Inline,0);else A.removeAttribute('style',0);FCKTools.RestoreFormStyles(A,C);};FCKTools.RegisterDollarFunction=function(A){A.$=function(id){return A.document.getElementById(id);};};FCKTools.AppendElement=function(A,B){return A.appendChild(A.ownerDocument.createElement(B));};FCKTools.GetElementPosition=function(A,B){var c={ X:0,Y:0 };var C=B||window;var D=FCKTools.GetElementWindow(A);var E=null;while (A){var F=D.getComputedStyle(A,'').position;if (F&&F!='static'&&A.style.zIndex!=FCKConfig.FloatingPanelsZIndex) break;c.X+=A.offsetLeft-A.scrollLeft;c.Y+=A.offsetTop-A.scrollTop;if (!FCKBrowserInfo.IsOpera){var G=E;while (G&&G!=A){c.X-=G.scrollLeft;c.Y-=G.scrollTop;G=G.parentNode;}};E=A;if (A.offsetParent) A=A.offsetParent;else{if (D!=C){A=D.frameElement;E=null;if (A) D=FCKTools.GetElementWindow(A);}else{c.X+=A.scrollLeft;c.Y+=A.scrollTop;break;}}};return c;}; +var FCKeditorAPI;function InitializeAPI(){var A=window.parent;if (!(FCKeditorAPI=A.FCKeditorAPI)){var B='window.FCKeditorAPI = {Version : "2.6.3",VersionBuild : "19836",Instances : new Object(),GetInstance : function( name ){return this.Instances[ name ];},_FormSubmit : function(){for ( var name in FCKeditorAPI.Instances ){var oEditor = FCKeditorAPI.Instances[ name ] ;if ( oEditor.GetParentForm && oEditor.GetParentForm() == this )oEditor.UpdateLinkedField() ;}this._FCKOriginalSubmit() ;},_FunctionQueue : {Functions : new Array(),IsRunning : false,Add : function( f ){this.Functions.push( f );if ( !this.IsRunning )this.StartNext();},StartNext : function(){var aQueue = this.Functions ;if ( aQueue.length > 0 ){this.IsRunning = true;aQueue[0].call();}else this.IsRunning = false;},Remove : function( f ){var aQueue = this.Functions;var i = 0, fFunc;while( (fFunc = aQueue[ i ]) ){if ( fFunc == f )aQueue.splice( i,1 );i++ ;}this.StartNext();}}}';if (A.execScript) A.execScript(B,'JavaScript');else{if (FCKBrowserInfo.IsGecko10){eval.call(A,B);}else if(FCKBrowserInfo.IsAIR){FCKAdobeAIR.FCKeditorAPI_Evaluate(A,B);}else if (FCKBrowserInfo.IsSafari){var C=A.document;var D=C.createElement('script');D.appendChild(C.createTextNode(B));C.documentElement.appendChild(D);}else A.eval(B);};FCKeditorAPI=A.FCKeditorAPI;FCKeditorAPI.__Instances=FCKeditorAPI.Instances;};FCKeditorAPI.Instances[FCK.Name]=FCK;};function _AttachFormSubmitToAPI(){var A=FCK.GetParentForm();if (A){FCKTools.AddEventListener(A,'submit',FCK.UpdateLinkedField);if (!A._FCKOriginalSubmit&&(typeof(A.submit)=='function'||(!A.submit.tagName&&!A.submit.length))){A._FCKOriginalSubmit=A.submit;A.submit=FCKeditorAPI._FormSubmit;}}};function FCKeditorAPI_Cleanup(){if (window.FCKConfig&&FCKConfig.MsWebBrowserControlCompat&&!window.FCKUnloadFlag) return;delete FCKeditorAPI.Instances[FCK.Name];};function FCKeditorAPI_ConfirmCleanup(){if (window.FCKConfig&&FCKConfig.MsWebBrowserControlCompat) window.FCKUnloadFlag=true;};FCKTools.AddEventListener(window,'unload',FCKeditorAPI_Cleanup);FCKTools.AddEventListener(window,'beforeunload',FCKeditorAPI_ConfirmCleanup); +var FCKImagePreloader=function(){this._Images=[];};FCKImagePreloader.prototype={AddImages:function(A){if (typeof(A)=='string') A=A.split(';');this._Images=this._Images.concat(A);},Start:function(){var A=this._Images;this._PreloadCount=A.length;for (var i=0;i]*\>)/i,AfterBody:/(\<\/body\>[\s\S]*$)/i,ToReplace:/___fcktoreplace:([\w]+)/ig,MetaHttpEquiv:/http-equiv\s*=\s*["']?([^"' ]+)/i,HasBaseTag:/]/i,HtmlOpener:/]*>/i,HeadOpener:/]*>/i,HeadCloser:/<\/head\s*>/i,FCK_Class:/\s*FCK__[^ ]*(?=\s+|$)/,ElementName:/(^[a-z_:][\w.\-:]*\w$)|(^[a-z_]$)/,ForceSimpleAmpersand:/___FCKAmp___/g,SpaceNoClose:/\/>/g,EmptyParagraph:/^<(p|div|address|h\d|center)(?=[ >])[^>]*>\s*(<\/\1>)?$/,EmptyOutParagraph:/^<(p|div|address|h\d|center)(?=[ >])[^>]*>(?:\s*| )(<\/\1>)?$/,TagBody:/>]+))/gi,ProtectUrlsA:/]+))/gi,ProtectUrlsArea:/]+))/gi,Html4DocType:/HTML 4\.0 Transitional/i,DocTypeTag:/]*>/i,HtmlDocType:/DTD HTML/,TagsWithEvent:/<[^\>]+ on\w+[\s\r\n]*=[\s\r\n]*?('|")[\s\S]+?\>/g,EventAttributes:/\s(on\w+)[\s\r\n]*=[\s\r\n]*?('|")([\s\S]*?)\2/g,ProtectedEvents:/\s\w+_fckprotectedatt="([^"]+)"/g,StyleProperties:/\S+\s*:/g,InvalidSelfCloseTags:/(<(?!base|meta|link|hr|br|param|img|area|input)([a-zA-Z0-9:]+)[^>]*)\/>/gi,StyleVariableAttName:/#\(\s*("|')(.+?)\1[^\)]*\s*\)/g,RegExp:/^\/(.*)\/([gim]*)$/,HtmlTag:/<[^\s<>](?:"[^"]*"|'[^']*'|[^<])*>/}; +var FCKListsLib={BlockElements:{ address:1,blockquote:1,center:1,div:1,dl:1,fieldset:1,form:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,hr:1,marquee:1,noscript:1,ol:1,p:1,pre:1,script:1,table:1,ul:1 },NonEmptyBlockElements:{ p:1,div:1,form:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,address:1,pre:1,ol:1,ul:1,li:1,td:1,th:1 },InlineChildReqElements:{ abbr:1,acronym:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,'var':1 },InlineNonEmptyElements:{ a:1,abbr:1,acronym:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,'var':1 },EmptyElements:{ base:1,col:1,meta:1,link:1,hr:1,br:1,param:1,img:1,area:1,input:1 },PathBlockElements:{ address:1,blockquote:1,dl:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1,li:1,dt:1,de:1 },PathBlockLimitElements:{ body:1,div:1,td:1,th:1,caption:1,form:1 },StyleBlockElements:{ address:1,div:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1 },StyleObjectElements:{ img:1,hr:1,li:1,table:1,tr:1,td:1,embed:1,object:1,ol:1,ul:1 },NonEditableElements:{ button:1,option:1,script:1,iframe:1,textarea:1,object:1,embed:1,map:1,applet:1 },BlockBoundaries:{ p:1,div:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,hr:1,address:1,pre:1,ol:1,ul:1,li:1,dt:1,de:1,table:1,thead:1,tbody:1,tfoot:1,tr:1,th:1,td:1,caption:1,col:1,colgroup:1,blockquote:1,body:1 },ListBoundaries:{ p:1,div:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,hr:1,address:1,pre:1,ol:1,ul:1,li:1,dt:1,de:1,table:1,thead:1,tbody:1,tfoot:1,tr:1,th:1,td:1,caption:1,col:1,colgroup:1,blockquote:1,body:1,br:1 }}; +var FCKLanguageManager=FCK.Language={AvailableLanguages:{af:'Afrikaans',ar:'Arabic',bg:'Bulgarian',bn:'Bengali/Bangla',bs:'Bosnian',ca:'Catalan',cs:'Czech',da:'Danish',de:'German',el:'Greek',en:'English','en-au':'English (Australia)','en-ca':'English (Canadian)','en-uk':'English (United Kingdom)',eo:'Esperanto',es:'Spanish',et:'Estonian',eu:'Basque',fa:'Persian',fi:'Finnish',fo:'Faroese',fr:'French','fr-ca':'French (Canada)',gl:'Galician',gu:'Gujarati',he:'Hebrew',hi:'Hindi',hr:'Croatian',hu:'Hungarian',it:'Italian',ja:'Japanese',km:'Khmer',ko:'Korean',lt:'Lithuanian',lv:'Latvian',mn:'Mongolian',ms:'Malay',nb:'Norwegian Bokmal',nl:'Dutch',no:'Norwegian',pl:'Polish',pt:'Portuguese (Portugal)','pt-br':'Portuguese (Brazil)',ro:'Romanian',ru:'Russian',sk:'Slovak',sl:'Slovenian',sr:'Serbian (Cyrillic)','sr-latn':'Serbian (Latin)',sv:'Swedish',th:'Thai',tr:'Turkish',uk:'Ukrainian',vi:'Vietnamese',zh:'Chinese Traditional','zh-cn':'Chinese Simplified'},GetActiveLanguage:function(){if (FCKConfig.AutoDetectLanguage){var A;if (navigator.userLanguage) A=navigator.userLanguage.toLowerCase();else if (navigator.language) A=navigator.language.toLowerCase();else{return FCKConfig.DefaultLanguage;};if (A.length>=5){A=A.substr(0,5);if (this.AvailableLanguages[A]) return A;};if (A.length>=2){A=A.substr(0,2);if (this.AvailableLanguages[A]) return A;}};return this.DefaultLanguage;},TranslateElements:function(A,B,C,D){var e=A.getElementsByTagName(B);var E,s;for (var i=0;i0) C+='|'+FCKConfig.AdditionalNumericEntities;FCKXHtmlEntities.EntitiesRegex=new RegExp(C,'g');}; +var FCKXHtml={};FCKXHtml.CurrentJobNum=0;FCKXHtml.GetXHTML=function(A,B,C){FCKDomTools.CheckAndRemovePaddingNode(FCKTools.GetElementDocument(A),FCKConfig.EnterMode);FCKXHtmlEntities.Initialize();this._NbspEntity=(FCKConfig.ProcessHTMLEntities?'nbsp':'#160');var D=FCK.IsDirty();FCKXHtml.SpecialBlocks=[];this.XML=FCKTools.CreateXmlObject('DOMDocument');this.MainNode=this.XML.appendChild(this.XML.createElement('xhtml'));FCKXHtml.CurrentJobNum++;if (B) this._AppendNode(this.MainNode,A);else this._AppendChildNodes(this.MainNode,A,false);var E=this._GetMainXmlString();this.XML=null;if (FCKBrowserInfo.IsSafari) E=E.replace(/^/,'');E=E.substr(7,E.length-15).Trim();if (FCKConfig.DocType.length>0&&FCKRegexLib.HtmlDocType.test(FCKConfig.DocType)) E=E.replace(FCKRegexLib.SpaceNoClose,'>');else E=E.replace(FCKRegexLib.SpaceNoClose,' />');if (FCKConfig.ForceSimpleAmpersand) E=E.replace(FCKRegexLib.ForceSimpleAmpersand,'&');if (C) E=FCKCodeFormatter.Format(E);for (var i=0;i0;if (C) A.appendChild(this.XML.createTextNode(B.replace(FCKXHtmlEntities.EntitiesRegex,FCKXHtml_GetEntity)));return C;};function FCKXHtml_GetEntity(A){var B=FCKXHtmlEntities.Entities[A]||('#'+A.charCodeAt(0));return '#?-:'+B+';';};FCKXHtml.TagProcessors={a:function(A,B){if (B.innerHTML.Trim().length==0&&!B.name) return false;var C=B.getAttribute('_fcksavedurl');if (C!=null) FCKXHtml._AppendAttribute(A,'href',C);if (FCKBrowserInfo.IsIE){if (B.name) FCKXHtml._AppendAttribute(A,'name',B.name);};A=FCKXHtml._AppendChildNodes(A,B,false);return A;},area:function(A,B){var C=B.getAttribute('_fcksavedurl');if (C!=null) FCKXHtml._AppendAttribute(A,'href',C);if (FCKBrowserInfo.IsIE){if (!A.attributes.getNamedItem('coords')){var D=B.getAttribute('coords',2);if (D&&D!='0,0,0') FCKXHtml._AppendAttribute(A,'coords',D);};if (!A.attributes.getNamedItem('shape')){var E=B.getAttribute('shape',2);if (E&&E.length>0) FCKXHtml._AppendAttribute(A,'shape',E.toLowerCase());}};return A;},body:function(A,B){A=FCKXHtml._AppendChildNodes(A,B,false);A.removeAttribute('spellcheck');return A;},iframe:function(A,B){var C=B.innerHTML;if (FCKBrowserInfo.IsGecko) C=FCKTools.HTMLDecode(C);C=C.replace(/\s_fcksavedurl="[^"]*"/g,'');A.appendChild(FCKXHtml.XML.createTextNode(FCKXHtml._AppendSpecialItem(C)));return A;},img:function(A,B){if (!A.attributes.getNamedItem('alt')) FCKXHtml._AppendAttribute(A,'alt','');var C=B.getAttribute('_fcksavedurl');if (C!=null) FCKXHtml._AppendAttribute(A,'src',C);if (B.style.width) A.removeAttribute('width');if (B.style.height) A.removeAttribute('height');return A;},li:function(A,B,C){if (C.nodeName.IEquals(['ul','ol'])) return FCKXHtml._AppendChildNodes(A,B,true);var D=FCKXHtml.XML.createElement('ul');B._fckxhtmljob=null;do{FCKXHtml._AppendNode(D,B);do{B=FCKDomTools.GetNextSibling(B);} while (B&&B.nodeType==3&&B.nodeValue.Trim().length==0)} while (B&&B.nodeName.toLowerCase()=='li') return D;},ol:function(A,B,C){if (B.innerHTML.Trim().length==0) return false;var D=C.lastChild;if (D&&D.nodeType==3) D=D.previousSibling;if (D&&D.nodeName.toUpperCase()=='LI'){B._fckxhtmljob=null;FCKXHtml._AppendNode(D,B);return false;};A=FCKXHtml._AppendChildNodes(A,B);return A;},pre:function (A,B){var C=B.firstChild;if (C&&C.nodeType==3) A.appendChild(FCKXHtml.XML.createTextNode(FCKXHtml._AppendSpecialItem('\r\n')));FCKXHtml._AppendChildNodes(A,B,true);return A;},script:function(A,B){if (!A.attributes.getNamedItem('type')) FCKXHtml._AppendAttribute(A,'type','text/javascript');A.appendChild(FCKXHtml.XML.createTextNode(FCKXHtml._AppendSpecialItem(B.text)));return A;},span:function(A,B){if (B.innerHTML.length==0) return false;A=FCKXHtml._AppendChildNodes(A,B,false);return A;},style:function(A,B){if (!A.attributes.getNamedItem('type')) FCKXHtml._AppendAttribute(A,'type','text/css');var C=B.innerHTML;if (FCKBrowserInfo.IsIE) C=C.replace(/^(\r\n|\n|\r)/,'');A.appendChild(FCKXHtml.XML.createTextNode(FCKXHtml._AppendSpecialItem(C)));return A;},title:function(A,B){A.appendChild(FCKXHtml.XML.createTextNode(FCK.EditorDocument.title));return A;}};FCKXHtml.TagProcessors.ul=FCKXHtml.TagProcessors.ol; +FCKXHtml._GetMainXmlString=function(){return (new XMLSerializer()).serializeToString(this.MainNode);};FCKXHtml._AppendAttributes=function(A,B,C){var D=B.attributes;for (var n=0;n]*\>/gi;A.BlocksCloser=/\<\/(P|DIV|H1|H2|H3|H4|H5|H6|ADDRESS|PRE|OL|UL|LI|TITLE|META|LINK|BASE|SCRIPT|LINK|TD|TH|AREA|OPTION)[^\>]*\>/gi;A.NewLineTags=/\<(BR|HR)[^\>]*\>/gi;A.MainTags=/\<\/?(HTML|HEAD|BODY|FORM|TABLE|TBODY|THEAD|TR)[^\>]*\>/gi;A.LineSplitter=/\s*\n+\s*/g;A.IncreaseIndent=/^\<(HTML|HEAD|BODY|FORM|TABLE|TBODY|THEAD|TR|UL|OL)[ \/\>]/i;A.DecreaseIndent=/^\<\/(HTML|HEAD|BODY|FORM|TABLE|TBODY|THEAD|TR|UL|OL)[ \>]/i;A.FormatIndentatorRemove=new RegExp('^'+FCKConfig.FormatIndentator);A.ProtectedTags=/(]*>)([\s\S]*?)(<\/PRE>)/gi;};FCKCodeFormatter._ProtectData=function(A,B,C,D){return B+'___FCKpd___'+FCKCodeFormatter.ProtectedData.AddItem(C)+D;};FCKCodeFormatter.Format=function(A){if (!this.Regex) this.Init();FCKCodeFormatter.ProtectedData=[];var B=A.replace(this.Regex.ProtectedTags,FCKCodeFormatter._ProtectData);B=B.replace(this.Regex.BlocksOpener,'\n$&');B=B.replace(this.Regex.BlocksCloser,'$&\n');B=B.replace(this.Regex.NewLineTags,'$&\n');B=B.replace(this.Regex.MainTags,'\n$&\n');var C='';var D=B.split(this.Regex.LineSplitter);B='';for (var i=0;iB[i]) return 1;};if (A.lengthB.length) return 1;return 0;};FCKUndo._CheckIsBookmarksEqual=function(A,B){if (!(A&&B)) return false;if (FCKBrowserInfo.IsIE){var C=A[1].search(A[0].StartId);var D=B[1].search(B[0].StartId);var E=A[1].search(A[0].EndId);var F=B[1].search(B[0].EndId);return C==D&&E==F;}else{return this._CompareCursors(A.Start,B.Start)==0&&this._CompareCursors(A.End,B.End)==0;}};FCKUndo.SaveUndoStep=function(){if (FCK.EditMode!=0||this.SaveLocked) return;if (this.SavedData.length) this.Changed=true;var A=FCK.EditorDocument.body.innerHTML;var B=this._GetBookmark();this.SavedData=this.SavedData.slice(0,this.CurrentIndex+1);if (this.CurrentIndex>0&&A==this.SavedData[this.CurrentIndex][0]&&this._CheckIsBookmarksEqual(B,this.SavedData[this.CurrentIndex][1])) return;else if (this.CurrentIndex==0&&this.SavedData.length&&A==this.SavedData[0][0]){this.SavedData[0][1]=B;return;};if (this.CurrentIndex+1>=FCKConfig.MaxUndoLevels) this.SavedData.shift();else this.CurrentIndex++;this.SavedData[this.CurrentIndex]=[A,B];FCK.Events.FireEvent("OnSelectionChange");};FCKUndo.CheckUndoState=function(){return (this.Changed||this.CurrentIndex>0);};FCKUndo.CheckRedoState=function(){return (this.CurrentIndex<(this.SavedData.length-1));};FCKUndo.Undo=function(){if (this.CheckUndoState()){if (this.CurrentIndex==(this.SavedData.length-1)){this.SaveUndoStep();};this._ApplyUndoLevel(--this.CurrentIndex);FCK.Events.FireEvent("OnSelectionChange");}};FCKUndo.Redo=function(){if (this.CheckRedoState()){this._ApplyUndoLevel(++this.CurrentIndex);FCK.Events.FireEvent("OnSelectionChange");}};FCKUndo._ApplyUndoLevel=function(A){var B=this.SavedData[A];if (!B) return;if (FCKBrowserInfo.IsIE){if (B[1]&&B[1][1]) FCK.SetInnerHtml(B[1][1]);else FCK.SetInnerHtml(B[0]);}else FCK.EditorDocument.body.innerHTML=B[0];this._SelectBookmark(B[1]);this.TypesCount=0;this.Changed=false;this.Typing=false;}; +var FCKEditingArea=function(A){this.TargetElement=A;this.Mode=0;if (FCK.IECleanup) FCK.IECleanup.AddItem(this,FCKEditingArea_Cleanup);};FCKEditingArea.prototype.Start=function(A,B){var C=this.TargetElement;var D=FCKTools.GetElementDocument(C);while(C.firstChild) C.removeChild(C.firstChild);if (this.Mode==0){if (FCK_IS_CUSTOM_DOMAIN) A=''+A;if (FCKBrowserInfo.IsIE) A=A.replace(/(]*?)\s*\/?>(?!\s*<\/base>)/gi,'$1>');else if (!B){var E=A.match(FCKRegexLib.BeforeBody);var F=A.match(FCKRegexLib.AfterBody);if (E&&F){var G=A.substr(E[1].length,A.length-E[1].length-F[1].length);A=E[1]+' '+F[1];if (FCKBrowserInfo.IsGecko&&(G.length==0||FCKRegexLib.EmptyParagraph.test(G))) G='
    ';this._BodyHTML=G;}else this._BodyHTML=A;};var H=this.IFrame=D.createElement('iframe');var I='';H.frameBorder=0;H.style.width=H.style.height='100%';if (FCK_IS_CUSTOM_DOMAIN&&FCKBrowserInfo.IsIE){window._FCKHtmlToLoad=A.replace(//i,''+I);H.src='javascript:void( (function(){document.open() ;document.domain="'+document.domain+'" ;document.write( window.parent._FCKHtmlToLoad );document.close() ;window.parent._FCKHtmlToLoad = null ;})() )';}else if (!FCKBrowserInfo.IsGecko){H.src='javascript:void(0)';};C.appendChild(H);this.Window=H.contentWindow;if (!FCK_IS_CUSTOM_DOMAIN||!FCKBrowserInfo.IsIE){var J=this.Window.document;J.open();J.write(A.replace(//i,''+I));J.close();};if (FCKBrowserInfo.IsAIR) FCKAdobeAIR.EditingArea_Start(J,A);if (FCKBrowserInfo.IsGecko10&&!B){this.Start(A,true);return;};if (H.readyState&&H.readyState!='completed'){var K=this;setTimeout(function(){try{K.Window.document.documentElement.doScroll("left");}catch(e){setTimeout(arguments.callee,0);return;};K.Window._FCKEditingArea=K;FCKEditingArea_CompleteStart.call(K.Window);},0);}else{this.Window._FCKEditingArea=this;if (FCKBrowserInfo.IsGecko10) this.Window.setTimeout(FCKEditingArea_CompleteStart,500);else FCKEditingArea_CompleteStart.call(this.Window);}}else{var L=this.Textarea=D.createElement('textarea');L.className='SourceField';L.dir='ltr';FCKDomTools.SetElementStyles(L,{width:'100%',height:'100%',border:'none',resize:'none',outline:'none'});C.appendChild(L);L.value=A;FCKTools.RunFunction(this.OnLoad);}};function FCKEditingArea_CompleteStart(){if (!this.document.body){this.setTimeout(FCKEditingArea_CompleteStart,50);return;};var A=this._FCKEditingArea;A.Document=A.Window.document;A.MakeEditable();FCKTools.RunFunction(A.OnLoad);};FCKEditingArea.prototype.MakeEditable=function(){var A=this.Document;if (FCKBrowserInfo.IsIE){A.body.disabled=true;A.body.contentEditable=true;A.body.removeAttribute("disabled");}else{try{A.body.spellcheck=(this.FFSpellChecker!==false);if (this._BodyHTML){A.body.innerHTML=this._BodyHTML;A.body.offsetLeft;this._BodyHTML=null;};A.designMode='on';A.execCommand('enableObjectResizing',false,!FCKConfig.DisableObjectResizing);A.execCommand('enableInlineTableEditing',false,!FCKConfig.DisableFFTableHandles);}catch (e){FCKTools.AddEventListener(this.Window.frameElement,'DOMAttrModified',FCKEditingArea_Document_AttributeNodeModified);}}};function FCKEditingArea_Document_AttributeNodeModified(A){var B=A.currentTarget.contentWindow._FCKEditingArea;if (B._timer) window.clearTimeout(B._timer);B._timer=FCKTools.SetTimeout(FCKEditingArea_MakeEditableByMutation,1000,B);};function FCKEditingArea_MakeEditableByMutation(){delete this._timer;FCKTools.RemoveEventListener(this.Window.frameElement,'DOMAttrModified',FCKEditingArea_Document_AttributeNodeModified);this.MakeEditable();};FCKEditingArea.prototype.Focus=function(){try{if (this.Mode==0){if (FCKBrowserInfo.IsIE) this._FocusIE();else this.Window.focus();}else{var A=FCKTools.GetElementDocument(this.Textarea);if ((!A.hasFocus||A.hasFocus())&&A.activeElement==this.Textarea) return;this.Textarea.focus();}}catch(e) {}};FCKEditingArea.prototype._FocusIE=function(){this.Document.body.setActive();this.Window.focus();var A=this.Document.selection.createRange();var B=A.parentElement();var C=B.nodeName.toLowerCase();if (B.childNodes.length>0||!(FCKListsLib.BlockElements[C]||FCKListsLib.NonEmptyBlockElements[C])){return;};A=new FCKDomRange(this.Window);A.MoveToElementEditStart(B);A.Select();};function FCKEditingArea_Cleanup(){if (this.Document) this.Document.body.innerHTML="";this.TargetElement=null;this.IFrame=null;this.Document=null;this.Textarea=null;if (this.Window){this.Window._FCKEditingArea=null;this.Window=null;}}; +var FCKKeystrokeHandler=function(A){this.Keystrokes={};this.CancelCtrlDefaults=(A!==false);};FCKKeystrokeHandler.prototype.AttachToElement=function(A){FCKTools.AddEventListenerEx(A,'keydown',_FCKKeystrokeHandler_OnKeyDown,this);if (FCKBrowserInfo.IsGecko10||FCKBrowserInfo.IsOpera||(FCKBrowserInfo.IsGecko&&FCKBrowserInfo.IsMac)) FCKTools.AddEventListenerEx(A,'keypress',_FCKKeystrokeHandler_OnKeyPress,this);};FCKKeystrokeHandler.prototype.SetKeystrokes=function(){for (var i=0;i40))){B._CancelIt=true;if (A.preventDefault) return A.preventDefault();A.returnValue=false;A.cancelBubble=true;return false;};return true;};function _FCKKeystrokeHandler_OnKeyPress(A,B){if (B._CancelIt){if (A.preventDefault) return A.preventDefault();return false;};return true;}; +FCK.DTD=(function(){var X=FCKTools.Merge;var A,L,J,M,N,O,D,H,P,K,Q,F,G,C,B,E,I;A={isindex:1,fieldset:1};B={input:1,button:1,select:1,textarea:1,label:1};C=X({a:1},B);D=X({iframe:1},C);E={hr:1,ul:1,menu:1,div:1,blockquote:1,noscript:1,table:1,center:1,address:1,dir:1,pre:1,h5:1,dl:1,h4:1,noframes:1,h6:1,ol:1,h1:1,h3:1,h2:1};F={ins:1,del:1,script:1};G=X({b:1,acronym:1,bdo:1,'var':1,'#':1,abbr:1,code:1,br:1,i:1,cite:1,kbd:1,u:1,strike:1,s:1,tt:1,strong:1,q:1,samp:1,em:1,dfn:1,span:1},F);H=X({sub:1,img:1,object:1,sup:1,basefont:1,map:1,applet:1,font:1,big:1,small:1},G);I=X({p:1},H);J=X({iframe:1},H,B);K={img:1,noscript:1,br:1,kbd:1,center:1,button:1,basefont:1,h5:1,h4:1,samp:1,h6:1,ol:1,h1:1,h3:1,h2:1,form:1,font:1,'#':1,select:1,menu:1,ins:1,abbr:1,label:1,code:1,table:1,script:1,cite:1,input:1,iframe:1,strong:1,textarea:1,noframes:1,big:1,small:1,span:1,hr:1,sub:1,bdo:1,'var':1,div:1,object:1,sup:1,strike:1,dir:1,map:1,dl:1,applet:1,del:1,isindex:1,fieldset:1,ul:1,b:1,acronym:1,a:1,blockquote:1,i:1,u:1,s:1,tt:1,address:1,q:1,pre:1,p:1,em:1,dfn:1};L=X({a:1},J);M={tr:1};N={'#':1};O=X({param:1},K);P=X({form:1},A,D,E,I);Q={li:1};return {col:{},tr:{td:1,th:1},img:{},colgroup:{col:1},noscript:P,td:P,br:{},th:P,center:P,kbd:L,button:X(I,E),basefont:{},h5:L,h4:L,samp:L,h6:L,ol:Q,h1:L,h3:L,option:N,h2:L,form:X(A,D,E,I),select:{optgroup:1,option:1},font:J,ins:P,menu:Q,abbr:L,label:L,table:{thead:1,col:1,tbody:1,tr:1,colgroup:1,caption:1,tfoot:1},code:L,script:N,tfoot:M,cite:L,li:P,input:{},iframe:P,strong:J,textarea:N,noframes:P,big:J,small:J,span:J,hr:{},dt:L,sub:J,optgroup:{option:1},param:{},bdo:L,'var':J,div:P,object:O,sup:J,dd:P,strike:J,area:{},dir:Q,map:X({area:1,form:1,p:1},A,F,E),applet:O,dl:{dt:1,dd:1},del:P,isindex:{},fieldset:X({legend:1},K),thead:M,ul:Q,acronym:L,b:J,a:J,blockquote:P,caption:L,i:J,u:J,tbody:M,s:L,address:X(D,I),tt:J,legend:L,q:L,pre:X(G,C),p:L,em:J,dfn:L};})(); +var FCKStyle=function(A){this.Element=(A.Element||'span').toLowerCase();this._StyleDesc=A;};FCKStyle.prototype={GetType:function(){var A=this.GetType_$;if (A!=undefined) return A;var B=this.Element;if (B=='#'||FCKListsLib.StyleBlockElements[B]) A=0;else if (FCKListsLib.StyleObjectElements[B]) A=2;else A=1;return (this.GetType_$=A);},ApplyToSelection:function(A){var B=new FCKDomRange(A);B.MoveToSelection();this.ApplyToRange(B,true);},ApplyToRange:function(A,B,C){switch (this.GetType()){case 0:this.ApplyToRange=this._ApplyBlockStyle;break;case 1:this.ApplyToRange=this._ApplyInlineStyle;break;default:return;};this.ApplyToRange(A,B,C);},ApplyToObject:function(A){if (!A) return;this.BuildElement(null,A);},RemoveFromSelection:function(A){var B=new FCKDomRange(A);B.MoveToSelection();this.RemoveFromRange(B,true);},RemoveFromRange:function(A,B,C){var D;var E=this._GetAttribsForComparison();var F=this._GetOverridesForComparison();if (A.CheckIsCollapsed()){var D=A.CreateBookmark(true);var H=A.GetBookmarkNode(D,true);var I=new FCKElementPath(H.parentNode);var J=[];var K=!FCKDomTools.GetNextSibling(H);var L=K||!FCKDomTools.GetPreviousSibling(H);var M;var N=-1;for (var i=0;i=0;i--){var E=D[i];for (var F in B){if (FCKDomTools.HasAttribute(E,F)){switch (F){case 'style':this._RemoveStylesFromElement(E);break;case 'class':if (FCKDomTools.GetAttributeValue(E,F)!=this.GetFinalAttributeValue(F)) continue;default:FCKDomTools.RemoveAttribute(E,F);}}};this._RemoveOverrides(E,C[this.Element]);this._RemoveNoAttribElement(E);};for (var G in C){if (G!=this.Element){D=A.getElementsByTagName(G);for (var i=D.length-1;i>=0;i--){var E=D[i];this._RemoveOverrides(E,C[G]);this._RemoveNoAttribElement(E);}}}},_RemoveStylesFromElement:function(A){var B=A.style.cssText;var C=this.GetFinalStyleValue();if (B.length>0&&C.length==0) return;C='(^|;)\\s*('+C.replace(/\s*([^ ]+):.*?(;|$)/g,'$1|').replace(/\|$/,'')+'):[^;]+';var D=new RegExp(C,'gi');B=B.replace(D,'').Trim();if (B.length==0||B==';') FCKDomTools.RemoveAttribute(A,'style');else A.style.cssText=B.replace(D,'');},_RemoveOverrides:function(A,B){var C=B&&B.Attributes;if (C){for (var i=0;i0) C.style.cssText=this.GetFinalStyleValue();return C;},_CompareAttributeValues:function(A,B,C){if (A=='style'&&B&&C){B=B.replace(/;$/,'').toLowerCase();C=C.replace(/;$/,'').toLowerCase();};return (B==C||((B===null||B==='')&&(C===null||C==='')))},GetFinalAttributeValue:function(A){var B=this._StyleDesc.Attributes;var B=B?B[A]:null;if (!B&&A=='style') return this.GetFinalStyleValue();if (B&&this._Variables) B=B.Replace(FCKRegexLib.StyleVariableAttName,this._GetVariableReplace,this);return B;},GetFinalStyleValue:function(){var A=this._GetStyleText();if (A.length>0&&this._Variables){A=A.Replace(FCKRegexLib.StyleVariableAttName,this._GetVariableReplace,this);A=FCKTools.NormalizeCssText(A);};return A;},_GetVariableReplace:function(){return this._Variables[arguments[2]]||arguments[0];},SetVariable:function(A,B){var C=this._Variables;if (!C) C=this._Variables={};this._Variables[A]=B;},_FromPre:function(A,B,C){var D=B.innerHTML;D=D.replace(/(\r\n|\r)/g,'\n');D=D.replace(/^[ \t]*\n/,'');D=D.replace(/\n$/,'');D=D.replace(/^[ \t]+|[ \t]+$/g,function(match,offset,s){if (match.length==1) return ' ';else if (offset==0) return new Array(match.length).join(' ')+' ';else return ' '+new Array(match.length).join(' ');});var E=new FCKHtmlIterator(D);var F=[];E.Each(function(isTag,value){if (!isTag){value=value.replace(/\n/g,'
    ');value=value.replace(/[ \t]{2,}/g,function (match){return new Array(match.length).join(' ')+' ';});};F.push(value);});C.innerHTML=F.join('');return C;},_ToPre:function(A,B,C){var D=B.innerHTML.Trim();D=D.replace(/[ \t\r\n]*(]*>)[ \t\r\n]*/gi,'
    ');var E=new FCKHtmlIterator(D);var F=[];E.Each(function(isTag,value){if (!isTag) value=value.replace(/([ \t\n\r]+| )/g,' ');else if (isTag&&value=='
    ') value='\n';F.push(value);});if (FCKBrowserInfo.IsIE){var G=A.createElement('div');G.appendChild(C);C.outerHTML='
    \n'+F.join('')+'
    ';C=G.removeChild(G.firstChild);}else C.innerHTML=F.join('');return C;},_CheckAndMergePre:function(A,B){if (A!=FCKDomTools.GetPreviousSourceElement(B,true)) return;var C=A.innerHTML.replace(/\n$/,'')+'\n\n'+B.innerHTML.replace(/^\n/,'');if (FCKBrowserInfo.IsIE) B.outerHTML='
    '+C+'
    ';else B.innerHTML=C;FCKDomTools.RemoveNode(A);},_CheckAndSplitPre:function(A){var B;var C=A.firstChild;C=C&&C.nextSibling;while (C){var D=C.nextSibling;if (D&&D.nextSibling&&C.nodeName.IEquals('br')&&D.nodeName.IEquals('br')){FCKDomTools.RemoveNode(C);C=D.nextSibling;FCKDomTools.RemoveNode(D);B=FCKDomTools.InsertAfterNode(B||A,FCKDomTools.CloneElement(A));continue;};if (B){C=C.previousSibling;FCKDomTools.MoveNode(C.nextSibling,B);};C=C.nextSibling;}},_ApplyBlockStyle:function(A,B,C){var D;if (B) D=A.CreateBookmark();var E=new FCKDomRangeIterator(A);E.EnforceRealBlocks=true;var F;var G=A.Window.document;var H;while((F=E.GetNextParagraph())){var I=this.BuildElement(G);var J=I.nodeName.IEquals('pre');var K=F.nodeName.IEquals('pre');var L=J&&!K;var M=!J&&K;if (L) I=this._ToPre(G,F,I);else if (M) I=this._FromPre(G,F,I);else FCKDomTools.MoveChildren(F,I);F.parentNode.insertBefore(I,F);FCKDomTools.RemoveNode(F);if (J){if (H) this._CheckAndMergePre(H,I);H=I;}else if (M) this._CheckAndSplitPre(I);};if (B) A.SelectBookmark(D);if (C) A.MoveToBookmark(D);},_ApplyInlineStyle:function(A,B,C){var D=A.Window.document;if (A.CheckIsCollapsed()){var E=this.BuildElement(D);A.InsertNode(E);A.MoveToPosition(E,2);A.Select();return;};var F=this.Element;var G=FCK.DTD[F]||FCK.DTD.span;var H=this._GetAttribsForComparison();var I;A.Expand('inline_elements');var J=A.CreateBookmark(true);var K=A.GetBookmarkNode(J,true);var L=A.GetBookmarkNode(J,false);A.Release(true);var M=FCKDomTools.GetNextSourceNode(K,true);while (M){var N=false;var O=M.nodeType;var P=O==1?M.nodeName.toLowerCase():null;if (!P||G[P]){if ((FCK.DTD[M.parentNode.nodeName.toLowerCase()]||FCK.DTD.span)[F]||!FCK.DTD[F]){if (!A.CheckHasRange()) A.SetStart(M,3);if (O!=1||M.childNodes.length==0){var Q=M;var R=Q.parentNode;while (Q==R.lastChild&&G[R.nodeName.toLowerCase()]){Q=R;};A.SetEnd(Q,4);if (Q==Q.parentNode.lastChild&&!G[Q.parentNode.nodeName.toLowerCase()]) N=true;}else{A.SetEnd(M,3);}}else N=true;}else N=true;M=FCKDomTools.GetNextSourceNode(M);if (M==L){M=null;N=true;};if (N&&A.CheckHasRange()&&!A.CheckIsCollapsed()){I=this.BuildElement(D);A.ExtractContents().AppendTo(I);if (I.innerHTML.RTrim().length>0){A.InsertNode(I);this.RemoveFromElement(I);this._MergeSiblings(I,this._GetAttribsForComparison());if (!FCKBrowserInfo.IsIE) I.normalize();};A.Release(true);}};this._FixBookmarkStart(K);if (B) A.SelectBookmark(J);if (C) A.MoveToBookmark(J);},_FixBookmarkStart:function(A){var B;while ((B=A.nextSibling)){if (B.nodeType==1&&FCKListsLib.InlineNonEmptyElements[B.nodeName.toLowerCase()]){if (!B.firstChild) FCKDomTools.RemoveNode(B);else FCKDomTools.MoveNode(A,B,true);continue;};if (B.nodeType==3&&B.length==0){FCKDomTools.RemoveNode(B);continue;};break;}},_MergeSiblings:function(A,B){if (!A||A.nodeType!=1||!FCKListsLib.InlineNonEmptyElements[A.nodeName.toLowerCase()]) return;this._MergeNextSibling(A,B);this._MergePreviousSibling(A,B);},_MergeNextSibling:function(A,B){var C=A.nextSibling;var D=(C&&C.nodeType==1&&C.getAttribute('_fck_bookmark'));if (D) C=C.nextSibling;if (C&&C.nodeType==1&&C.nodeName==A.nodeName){if (!B) B=this._CreateElementAttribsForComparison(A);if (this._CheckAttributesMatch(C,B)){var E=A.lastChild;if (D) FCKDomTools.MoveNode(A.nextSibling,A);FCKDomTools.MoveChildren(C,A);FCKDomTools.RemoveNode(C);if (E) this._MergeNextSibling(E);}}},_MergePreviousSibling:function(A,B){var C=A.previousSibling;var D=(C&&C.nodeType==1&&C.getAttribute('_fck_bookmark'));if (D) C=C.previousSibling;if (C&&C.nodeType==1&&C.nodeName==A.nodeName){if (!B) B=this._CreateElementAttribsForComparison(A);if (this._CheckAttributesMatch(C,B)){var E=A.firstChild;if (D) FCKDomTools.MoveNode(A.previousSibling,A,true);FCKDomTools.MoveChildren(C,A,true);FCKDomTools.RemoveNode(C);if (E) this._MergePreviousSibling(E);}}},_GetStyleText:function(){var A=this._StyleDesc.Styles;var B=(this._StyleDesc.Attributes?this._StyleDesc.Attributes['style']||'':'');if (B.length>0) B+=';';for (var C in A) B+=C+':'+A[C]+';';if (B.length>0&&!(/#\(/.test(B))){B=FCKTools.NormalizeCssText(B);};return (this._GetStyleText=function() { return B;})();},_GetAttribsForComparison:function(){var A=this._GetAttribsForComparison_$;if (A) return A;A={};var B=this._StyleDesc.Attributes;if (B){for (var C in B){A[C.toLowerCase()]=B[C].toLowerCase();}};if (this._GetStyleText().length>0){A['style']=this._GetStyleText().toLowerCase();};FCKTools.AppendLengthProperty(A,'_length');return (this._GetAttribsForComparison_$=A);},_GetOverridesForComparison:function(){var A=this._GetOverridesForComparison_$;if (A) return A;A={};var B=this._StyleDesc.Overrides;if (B){if (!FCKTools.IsArray(B)) B=[B];for (var i=0;i0) return true;};B=B.nextSibling;};return false;}}; +var FCKElementPath=function(A){var B=null;var C=null;var D=[];var e=A;while (e){if (e.nodeType==1){if (!this.LastElement) this.LastElement=e;var E=e.nodeName.toLowerCase();if (FCKBrowserInfo.IsIE&&e.scopeName!='HTML') E=e.scopeName.toLowerCase()+':'+E;if (!C){if (!B&&FCKListsLib.PathBlockElements[E]!=null) B=e;if (FCKListsLib.PathBlockLimitElements[E]!=null){if (!B&&E=='div'&&!FCKElementPath._CheckHasBlock(e)) B=e;else C=e;}};D.push(e);if (E=='body') break;};e=e.parentNode;};this.Block=B;this.BlockLimit=C;this.Elements=D;};FCKElementPath._CheckHasBlock=function(A){var B=A.childNodes;for (var i=0,count=B.length;i0){if (D.nodeType==3){var G=D.nodeValue.substr(0,E).Trim();if (G.length!=0) return A.IsStartOfBlock=false;}else F=D.childNodes[E-1];};if (!F) F=FCKDomTools.GetPreviousSourceNode(D,true,null,C);while (F){switch (F.nodeType){case 1:if (!FCKListsLib.InlineChildReqElements[F.nodeName.toLowerCase()]) return A.IsStartOfBlock=false;break;case 3:if (F.nodeValue.Trim().length>0) return A.IsStartOfBlock=false;};F=FCKDomTools.GetPreviousSourceNode(F,false,null,C);};return A.IsStartOfBlock=true;},CheckEndOfBlock:function(A){var B=this._Cache.IsEndOfBlock;if (B!=undefined) return B;var C=this.EndBlock||this.EndBlockLimit;var D=this._Range.endContainer;var E=this._Range.endOffset;var F;if (D.nodeType==3){var G=D.nodeValue;if (E0) return this._Cache.IsEndOfBlock=false;};F=FCKDomTools.GetNextSourceNode(F,false,null,C);};if (A) this.Select();return this._Cache.IsEndOfBlock=true;},CreateBookmark:function(A){var B={StartId:(new Date()).valueOf()+Math.floor(Math.random()*1000)+'S',EndId:(new Date()).valueOf()+Math.floor(Math.random()*1000)+'E'};var C=this.Window.document;var D;var E;var F;if (!this.CheckIsCollapsed()){E=C.createElement('span');E.style.display='none';E.id=B.EndId;E.setAttribute('_fck_bookmark',true);E.innerHTML=' ';F=this.Clone();F.Collapse(false);F.InsertNode(E);};D=C.createElement('span');D.style.display='none';D.id=B.StartId;D.setAttribute('_fck_bookmark',true);D.innerHTML=' ';F=this.Clone();F.Collapse(true);F.InsertNode(D);if (A){B.StartNode=D;B.EndNode=E;};if (E){this.SetStart(D,4);this.SetEnd(E,3);}else this.MoveToPosition(D,4);return B;},GetBookmarkNode:function(A,B){var C=this.Window.document;if (B) return A.StartNode||C.getElementById(A.StartId);else return A.EndNode||C.getElementById(A.EndId);},MoveToBookmark:function(A,B){var C=this.GetBookmarkNode(A,true);var D=this.GetBookmarkNode(A,false);this.SetStart(C,3);if (!B) FCKDomTools.RemoveNode(C);if (D){this.SetEnd(D,3);if (!B) FCKDomTools.RemoveNode(D);}else this.Collapse(true);this._UpdateElementInfo();},CreateBookmark2:function(){if (!this._Range) return { "Start":0,"End":0 };var A={"Start":[this._Range.startOffset],"End":[this._Range.endOffset]};var B=this._Range.startContainer.previousSibling;var C=this._Range.endContainer.previousSibling;var D=this._Range.startContainer;var E=this._Range.endContainer;while (B&&D.nodeType==3){A.Start[0]+=B.length;D=B;B=B.previousSibling;}while (C&&E.nodeType==3){A.End[0]+=C.length;E=C;C=C.previousSibling;};if (D.nodeType==1&&D.childNodes[A.Start[0]]&&D.childNodes[A.Start[0]].nodeType==3){var F=D.childNodes[A.Start[0]];var G=0;while (F.previousSibling&&F.previousSibling.nodeType==3){F=F.previousSibling;G+=F.length;};D=F;A.Start[0]=G;};if (E.nodeType==1&&E.childNodes[A.End[0]]&&E.childNodes[A.End[0]].nodeType==3){var F=E.childNodes[A.End[0]];var G=0;while (F.previousSibling&&F.previousSibling.nodeType==3){F=F.previousSibling;G+=F.length;};E=F;A.End[0]=G;};A.Start=FCKDomTools.GetNodeAddress(D,true).concat(A.Start);A.End=FCKDomTools.GetNodeAddress(E,true).concat(A.End);return A;},MoveToBookmark2:function(A){var B=FCKDomTools.GetNodeFromAddress(this.Window.document,A.Start.slice(0,-1),true);var C=FCKDomTools.GetNodeFromAddress(this.Window.document,A.End.slice(0,-1),true);this.Release(true);this._Range=new FCKW3CRange(this.Window.document);var D=A.Start[A.Start.length-1];var E=A.End[A.End.length-1];while (B.nodeType==3&&D>B.length){if (!B.nextSibling||B.nextSibling.nodeType!=3) break;D-=B.length;B=B.nextSibling;}while (C.nodeType==3&&E>C.length){if (!C.nextSibling||C.nextSibling.nodeType!=3) break;E-=C.length;C=C.nextSibling;};this._Range.setStart(B,D);this._Range.setEnd(C,E);this._UpdateElementInfo();},MoveToPosition:function(A,B){this.SetStart(A,B);this.Collapse(true);},SetStart:function(A,B,C){var D=this._Range;if (!D) D=this._Range=this.CreateRange();switch(B){case 1:D.setStart(A,0);break;case 2:D.setStart(A,A.childNodes.length);break;case 3:D.setStartBefore(A);break;case 4:D.setStartAfter(A);};if (!C) this._UpdateElementInfo();},SetEnd:function(A,B,C){var D=this._Range;if (!D) D=this._Range=this.CreateRange();switch(B){case 1:D.setEnd(A,0);break;case 2:D.setEnd(A,A.childNodes.length);break;case 3:D.setEndBefore(A);break;case 4:D.setEndAfter(A);};if (!C) this._UpdateElementInfo();},Expand:function(A){var B,oSibling;switch (A){case 'inline_elements':if (this._Range.startOffset==0){B=this._Range.startContainer;if (B.nodeType!=1) B=B.previousSibling?null:B.parentNode;if (B){while (FCKListsLib.InlineNonEmptyElements[B.nodeName.toLowerCase()]){this._Range.setStartBefore(B);if (B!=B.parentNode.firstChild) break;B=B.parentNode;}}};B=this._Range.endContainer;var C=this._Range.endOffset;if ((B.nodeType==3&&C>=B.nodeValue.length)||(B.nodeType==1&&C>=B.childNodes.length)||(B.nodeType!=1&&B.nodeType!=3)){if (B.nodeType!=1) B=B.nextSibling?null:B.parentNode;if (B){while (FCKListsLib.InlineNonEmptyElements[B.nodeName.toLowerCase()]){this._Range.setEndAfter(B);if (B!=B.parentNode.lastChild) break;B=B.parentNode;}}};break;case 'block_contents':case 'list_contents':var D=FCKListsLib.BlockBoundaries;if (A=='list_contents'||FCKConfig.EnterMode=='br') D=FCKListsLib.ListBoundaries;if (this.StartBlock&&FCKConfig.EnterMode!='br'&&A=='block_contents') this.SetStart(this.StartBlock,1);else{B=this._Range.startContainer;if (B.nodeType==1){var E=B.childNodes[this._Range.startOffset];if (E) B=FCKDomTools.GetPreviousSourceNode(E,true);else B=B.lastChild||B;}while (B&&(B.nodeType!=1||(B!=this.StartBlockLimit&&!D[B.nodeName.toLowerCase()]))){this._Range.setStartBefore(B);B=B.previousSibling||B.parentNode;}};if (this.EndBlock&&FCKConfig.EnterMode!='br'&&A=='block_contents'&&this.EndBlock.nodeName.toLowerCase()!='li') this.SetEnd(this.EndBlock,2);else{B=this._Range.endContainer;if (B.nodeType==1) B=B.childNodes[this._Range.endOffset]||B.lastChild;while (B&&(B.nodeType!=1||(B!=this.StartBlockLimit&&!D[B.nodeName.toLowerCase()]))){this._Range.setEndAfter(B);B=B.nextSibling||B.parentNode;};if (B&&B.nodeName.toLowerCase()=='br') this._Range.setEndAfter(B);};this._UpdateElementInfo();}},SplitBlock:function(A){var B=A||FCKConfig.EnterMode;if (!this._Range) this.MoveToSelection();if (this.StartBlockLimit==this.EndBlockLimit){var C=this.StartBlock;var D=this.EndBlock;var E=null;if (B!='br'){if (!C){C=this.FixBlock(true,B);D=this.EndBlock;};if (!D) D=this.FixBlock(false,B);};var F=(C!=null&&this.CheckStartOfBlock());var G=(D!=null&&this.CheckEndOfBlock());if (!this.CheckIsEmpty()) this.DeleteContents();if (C&&D&&C==D){if (G){E=new FCKElementPath(this.StartContainer);this.MoveToPosition(D,4);D=null;}else if (F){E=new FCKElementPath(this.StartContainer);this.MoveToPosition(C,3);C=null;}else{this.SetEnd(C,2);var H=this.ExtractContents();D=C.cloneNode(false);D.removeAttribute('id',false);H.AppendTo(D);FCKDomTools.InsertAfterNode(C,D);this.MoveToPosition(C,4);if (FCKBrowserInfo.IsGecko&&!C.nodeName.IEquals(['ul','ol'])) FCKTools.AppendBogusBr(C);}};return {PreviousBlock:C,NextBlock:D,WasStartOfBlock:F,WasEndOfBlock:G,ElementPath:E};};return null;},FixBlock:function(A,B){var C=this.CreateBookmark();this.Collapse(A);this.Expand('block_contents');var D=this.Window.document.createElement(B);this.ExtractContents().AppendTo(D);FCKDomTools.TrimNode(D);if (FCKDomTools.CheckIsEmptyElement(D,function(element) { return element.getAttribute('_fck_bookmark')!='true';})&&FCKBrowserInfo.IsGeckoLike) FCKTools.AppendBogusBr(D);this.InsertNode(D);this.MoveToBookmark(C);return D;},Release:function(A){if (!A) this.Window=null;this.StartNode=null;this.StartContainer=null;this.StartBlock=null;this.StartBlockLimit=null;this.EndNode=null;this.EndContainer=null;this.EndBlock=null;this.EndBlockLimit=null;this._Range=null;this._Cache=null;},CheckHasRange:function(){return!!this._Range;},GetTouchedStartNode:function(){var A=this._Range;var B=A.startContainer;if (A.collapsed||B.nodeType!=1) return B;return B.childNodes[A.startOffset]||B;},GetTouchedEndNode:function(){var A=this._Range;var B=A.endContainer;if (A.collapsed||B.nodeType!=1) return B;return B.childNodes[A.endOffset-1]||B;}}; +FCKDomRange.prototype.MoveToSelection=function(){this.Release(true);var A=this.Window.getSelection();if (A&&A.rangeCount>0){this._Range=FCKW3CRange.CreateFromRange(this.Window.document,A.getRangeAt(0));this._UpdateElementInfo();}else if (this.Window.document) this.MoveToElementStart(this.Window.document.body);};FCKDomRange.prototype.Select=function(){var A=this._Range;if (A){var B=A.startContainer;if (A.collapsed&&B.nodeType==1&&B.childNodes.length==0) B.appendChild(A._Document.createTextNode(''));var C=this.Window.document.createRange();C.setStart(B,A.startOffset);try{C.setEnd(A.endContainer,A.endOffset);}catch (e){if (e.toString().Contains('NS_ERROR_ILLEGAL_VALUE')){A.collapse(true);C.setEnd(A.endContainer,A.endOffset);}else throw(e);};var D=this.Window.getSelection();D.removeAllRanges();D.addRange(C);}};FCKDomRange.prototype.SelectBookmark=function(A){var B=this.Window.document.createRange();var C=this.GetBookmarkNode(A,true);var D=this.GetBookmarkNode(A,false);B.setStart(C.parentNode,FCKDomTools.GetIndexOf(C));FCKDomTools.RemoveNode(C);if (D){B.setEnd(D.parentNode,FCKDomTools.GetIndexOf(D));FCKDomTools.RemoveNode(D);};var E=this.Window.getSelection();E.removeAllRanges();E.addRange(B);}; +var FCKDomRangeIterator=function(A){this.Range=A;this.ForceBrBreak=false;this.EnforceRealBlocks=false;};FCKDomRangeIterator.CreateFromSelection=function(A){var B=new FCKDomRange(A);B.MoveToSelection();return new FCKDomRangeIterator(B);};FCKDomRangeIterator.prototype={GetNextParagraph:function(){var A;var B;var C;var D;var E;var F=this.ForceBrBreak?FCKListsLib.ListBoundaries:FCKListsLib.BlockBoundaries;if (!this._LastNode){var B=this.Range.Clone();B.Expand(this.ForceBrBreak?'list_contents':'block_contents');this._NextNode=B.GetTouchedStartNode();this._LastNode=B.GetTouchedEndNode();B=null;};var H=this._NextNode;var I=this._LastNode;this._NextNode=null;while (H){var J=false;var K=(H.nodeType!=1);var L=false;if (!K){var M=H.nodeName.toLowerCase();if (F[M]&&(!FCKBrowserInfo.IsIE||H.scopeName=='HTML')){if (M=='br') K=true;else if (!B&&H.childNodes.length==0&&M!='hr'){A=H;C=H==I;break;};if (B){B.SetEnd(H,3,true);if (M!='br') this._NextNode=FCKDomTools.GetNextSourceNode(H,true,null,I);};J=true;}else{if (H.firstChild){if (!B){B=new FCKDomRange(this.Range.Window);B.SetStart(H,3,true);};H=H.firstChild;continue;};K=true;}}else if (H.nodeType==3){if (/^[\r\n\t ]+$/.test(H.nodeValue)) K=false;};if (K&&!B){B=new FCKDomRange(this.Range.Window);B.SetStart(H,3,true);};C=((!J||K)&&H==I);if (B&&!J){while (!H.nextSibling&&!C){var N=H.parentNode;if (F[N.nodeName.toLowerCase()]){J=true;C=C||(N==I);break;};H=N;K=true;C=(H==I);L=true;}};if (K) B.SetEnd(H,4,true);if ((J||C)&&B){B._UpdateElementInfo();if (B.StartNode==B.EndNode&&B.StartNode.parentNode==B.StartBlockLimit&&B.StartNode.getAttribute&&B.StartNode.getAttribute('_fck_bookmark')) B=null;else break;};if (C) break;H=FCKDomTools.GetNextSourceNode(H,L,null,I);};if (!A){if (!B){this._NextNode=null;return null;};A=B.StartBlock;if (!A&&!this.EnforceRealBlocks&&B.StartBlockLimit.nodeName.IEquals('DIV','TH','TD')&&B.CheckStartOfBlock()&&B.CheckEndOfBlock()){A=B.StartBlockLimit;}else if (!A||(this.EnforceRealBlocks&&A.nodeName.toLowerCase()=='li')){A=this.Range.Window.document.createElement(FCKConfig.EnterMode=='p'?'p':'div');B.ExtractContents().AppendTo(A);FCKDomTools.TrimNode(A);B.InsertNode(A);D=true;E=true;}else if (A.nodeName.toLowerCase()!='li'){if (!B.CheckStartOfBlock()||!B.CheckEndOfBlock()){A=A.cloneNode(false);B.ExtractContents().AppendTo(A);FCKDomTools.TrimNode(A);var O=B.SplitBlock();D=!O.WasStartOfBlock;E=!O.WasEndOfBlock;B.InsertNode(A);}}else if (!C){this._NextNode=A==I?null:FCKDomTools.GetNextSourceNode(B.EndNode,true,null,I);return A;}};if (D){var P=A.previousSibling;if (P&&P.nodeType==1){if (P.nodeName.toLowerCase()=='br') P.parentNode.removeChild(P);else if (P.lastChild&&P.lastChild.nodeName.IEquals('br')) P.removeChild(P.lastChild);}};if (E){var Q=A.lastChild;if (Q&&Q.nodeType==1&&Q.nodeName.toLowerCase()=='br') A.removeChild(Q);};if (!this._NextNode) this._NextNode=(C||A==I)?null:FCKDomTools.GetNextSourceNode(A,true,null,I);return A;}}; +var FCKDocumentFragment=function(A,B){this.RootNode=B||A.createDocumentFragment();};FCKDocumentFragment.prototype={AppendTo:function(A){A.appendChild(this.RootNode);},AppendHtml:function(A){var B=this.RootNode.ownerDocument.createElement('div');B.innerHTML=A;FCKDomTools.MoveChildren(B,this.RootNode);},InsertAfterNode:function(A){FCKDomTools.InsertAfterNode(A,this.RootNode);}}; +var FCKW3CRange=function(A){this._Document=A;this.startContainer=null;this.startOffset=null;this.endContainer=null;this.endOffset=null;this.collapsed=true;};FCKW3CRange.CreateRange=function(A){return new FCKW3CRange(A);};FCKW3CRange.CreateFromRange=function(A,B){var C=FCKW3CRange.CreateRange(A);C.setStart(B.startContainer,B.startOffset);C.setEnd(B.endContainer,B.endOffset);return C;};FCKW3CRange.prototype={_UpdateCollapsed:function(){this.collapsed=(this.startContainer==this.endContainer&&this.startOffset==this.endOffset);},setStart:function(A,B){this.startContainer=A;this.startOffset=B;if (!this.endContainer){this.endContainer=A;this.endOffset=B;};this._UpdateCollapsed();},setEnd:function(A,B){this.endContainer=A;this.endOffset=B;if (!this.startContainer){this.startContainer=A;this.startOffset=B;};this._UpdateCollapsed();},setStartAfter:function(A){this.setStart(A.parentNode,FCKDomTools.GetIndexOf(A)+1);},setStartBefore:function(A){this.setStart(A.parentNode,FCKDomTools.GetIndexOf(A));},setEndAfter:function(A){this.setEnd(A.parentNode,FCKDomTools.GetIndexOf(A)+1);},setEndBefore:function(A){this.setEnd(A.parentNode,FCKDomTools.GetIndexOf(A));},collapse:function(A){if (A){this.endContainer=this.startContainer;this.endOffset=this.startOffset;}else{this.startContainer=this.endContainer;this.startOffset=this.endOffset;};this.collapsed=true;},selectNodeContents:function(A){this.setStart(A,0);this.setEnd(A,A.nodeType==3?A.data.length:A.childNodes.length);},insertNode:function(A){var B=this.startContainer;var C=this.startOffset;if (B.nodeType==3){B.splitText(C);if (B==this.endContainer) this.setEnd(B.nextSibling,this.endOffset-this.startOffset);FCKDomTools.InsertAfterNode(B,A);return;}else{B.insertBefore(A,B.childNodes[C]||null);if (B==this.endContainer){this.endOffset++;this.collapsed=false;}}},deleteContents:function(){if (this.collapsed) return;this._ExecContentsAction(0);},extractContents:function(){var A=new FCKDocumentFragment(this._Document);if (!this.collapsed) this._ExecContentsAction(1,A);return A;},cloneContents:function(){var A=new FCKDocumentFragment(this._Document);if (!this.collapsed) this._ExecContentsAction(2,A);return A;},_ExecContentsAction:function(A,B){var C=this.startContainer;var D=this.endContainer;var E=this.startOffset;var F=this.endOffset;var G=false;var H=false;if (D.nodeType==3) D=D.splitText(F);else{if (D.childNodes.length>0){if (F>D.childNodes.length-1){D=FCKDomTools.InsertAfterNode(D.lastChild,this._Document.createTextNode(''));H=true;}else D=D.childNodes[F];}};if (C.nodeType==3){C.splitText(E);if (C==D) D=C.nextSibling;}else{if (E==0){C=C.insertBefore(this._Document.createTextNode(''),C.firstChild);G=true;}else if (E>C.childNodes.length-1){C=C.appendChild(this._Document.createTextNode(''));G=true;}else C=C.childNodes[E].previousSibling;};var I=FCKDomTools.GetParents(C);var J=FCKDomTools.GetParents(D);var i,topStart,topEnd;for (i=0;i0&&levelStartNode!=D) levelClone=K.appendChild(levelStartNode.cloneNode(levelStartNode==D));if (!I[k]||levelStartNode.parentNode!=I[k].parentNode){currentNode=levelStartNode.previousSibling;while(currentNode){if (currentNode==I[k]||currentNode==C) break;currentSibling=currentNode.previousSibling;if (A==2) K.insertBefore(currentNode.cloneNode(true),K.firstChild);else{currentNode.parentNode.removeChild(currentNode);if (A==1) K.insertBefore(currentNode,K.firstChild);};currentNode=currentSibling;}};if (K) K=levelClone;};if (A==2){var L=this.startContainer;if (L.nodeType==3){L.data+=L.nextSibling.data;L.parentNode.removeChild(L.nextSibling);};var M=this.endContainer;if (M.nodeType==3&&M.nextSibling){M.data+=M.nextSibling.data;M.parentNode.removeChild(M.nextSibling);}}else{if (topStart&&topEnd&&(C.parentNode!=topStart.parentNode||D.parentNode!=topEnd.parentNode)){var N=FCKDomTools.GetIndexOf(topEnd);if (G&&topEnd.parentNode==C.parentNode) N--;this.setStart(topEnd.parentNode,N);};this.collapse(true);};if(G) C.parentNode.removeChild(C);if(H&&D.parentNode) D.parentNode.removeChild(D);},cloneRange:function(){return FCKW3CRange.CreateFromRange(this._Document,this);}}; +var FCKEnterKey=function(A,B,C,D){this.Window=A;this.EnterMode=B||'p';this.ShiftEnterMode=C||'br';var E=new FCKKeystrokeHandler(false);E._EnterKey=this;E.OnKeystroke=FCKEnterKey_OnKeystroke;E.SetKeystrokes([[13,'Enter'],[SHIFT+13,'ShiftEnter'],[8,'Backspace'],[CTRL+8,'CtrlBackspace'],[46,'Delete']]);this.TabText='';if (D>0||FCKBrowserInfo.IsSafari){while (D--) this.TabText+='\xa0';E.SetKeystrokes([9,'Tab']);};E.AttachToElement(A.document);};function FCKEnterKey_OnKeystroke(A,B){var C=this._EnterKey;try{switch (B){case 'Enter':return C.DoEnter();break;case 'ShiftEnter':return C.DoShiftEnter();break;case 'Backspace':return C.DoBackspace();break;case 'Delete':return C.DoDelete();break;case 'Tab':return C.DoTab();break;case 'CtrlBackspace':return C.DoCtrlBackspace();break;}}catch (e){};return false;};FCKEnterKey.prototype.DoEnter=function(A,B){FCKUndo.SaveUndoStep();this._HasShift=(B===true);var C=FCKSelection.GetParentElement();var D=new FCKElementPath(C);var E=A||this.EnterMode;if (E=='br'||D.Block&&D.Block.tagName.toLowerCase()=='pre') return this._ExecuteEnterBr();else return this._ExecuteEnterBlock(E);};FCKEnterKey.prototype.DoShiftEnter=function(){return this.DoEnter(this.ShiftEnterMode,true);};FCKEnterKey.prototype.DoBackspace=function(){var A=false;var B=new FCKDomRange(this.Window);B.MoveToSelection();if (FCKBrowserInfo.IsIE&&this._CheckIsAllContentsIncluded(B,this.Window.document.body)){this._FixIESelectAllBug(B);return true;};var C=B.CheckIsCollapsed();if (!C){if (FCKBrowserInfo.IsIE&&this.Window.document.selection.type.toLowerCase()=="control"){var D=this.Window.document.selection.createRange();for (var i=D.length-1;i>=0;i--){var E=D.item(i);E.parentNode.removeChild(E);};return true;};return false;};if (FCKBrowserInfo.IsIE){var F=FCKDomTools.GetPreviousSourceElement(B.StartNode,true);if (F&&F.nodeName.toLowerCase()=='br'){var G=B.Clone();G.SetStart(F,4);if (G.CheckIsEmpty()){F.parentNode.removeChild(F);return true;}}};var H=B.StartBlock;var I=B.EndBlock;if (B.StartBlockLimit==B.EndBlockLimit&&H&&I){if (!C){var J=B.CheckEndOfBlock();B.DeleteContents();if (H!=I){B.SetStart(I,1);B.SetEnd(I,1);};B.Select();A=(H==I);};if (B.CheckStartOfBlock()){var K=B.StartBlock;var L=FCKDomTools.GetPreviousSourceElement(K,true,['BODY',B.StartBlockLimit.nodeName],['UL','OL']);A=this._ExecuteBackspace(B,L,K);}else if (FCKBrowserInfo.IsGeckoLike){B.Select();}};B.Release();return A;};FCKEnterKey.prototype.DoCtrlBackspace=function(){FCKUndo.SaveUndoStep();var A=new FCKDomRange(this.Window);A.MoveToSelection();if (FCKBrowserInfo.IsIE&&this._CheckIsAllContentsIncluded(A,this.Window.document.body)){this._FixIESelectAllBug(A);return true;};return false;};FCKEnterKey.prototype._ExecuteBackspace=function(A,B,C){var D=false;if (!B&&C&&C.nodeName.IEquals('LI')&&C.parentNode.parentNode.nodeName.IEquals('LI')){this._OutdentWithSelection(C,A);return true;};if (B&&B.nodeName.IEquals('LI')){var E=FCKDomTools.GetLastChild(B,['UL','OL']);while (E){B=FCKDomTools.GetLastChild(E,'LI');E=FCKDomTools.GetLastChild(B,['UL','OL']);}};if (B&&C){if (C.nodeName.IEquals('LI')&&!B.nodeName.IEquals('LI')){this._OutdentWithSelection(C,A);return true;};var F=C.parentNode;var G=B.nodeName.toLowerCase();if (FCKListsLib.EmptyElements[G]!=null||G=='table'){FCKDomTools.RemoveNode(B);D=true;}else{FCKDomTools.RemoveNode(C);while (F.innerHTML.Trim().length==0){var H=F.parentNode;H.removeChild(F);F=H;};FCKDomTools.LTrimNode(C);FCKDomTools.RTrimNode(B);A.SetStart(B,2,true);A.Collapse(true);var I=A.CreateBookmark(true);if (!C.tagName.IEquals(['TABLE'])) FCKDomTools.MoveChildren(C,B);A.SelectBookmark(I);D=true;}};return D;};FCKEnterKey.prototype.DoDelete=function(){FCKUndo.SaveUndoStep();var A=false;var B=new FCKDomRange(this.Window);B.MoveToSelection();if (FCKBrowserInfo.IsIE&&this._CheckIsAllContentsIncluded(B,this.Window.document.body)){this._FixIESelectAllBug(B);return true;};if (B.CheckIsCollapsed()&&B.CheckEndOfBlock(FCKBrowserInfo.IsGeckoLike)){var C=B.StartBlock;var D=FCKTools.GetElementAscensor(C,'td');var E=FCKDomTools.GetNextSourceElement(C,true,[B.StartBlockLimit.nodeName],['UL','OL','TR'],true);if (D){var F=FCKTools.GetElementAscensor(E,'td');if (F!=D) return true;};A=this._ExecuteBackspace(B,C,E);};B.Release();return A;};FCKEnterKey.prototype.DoTab=function(){var A=new FCKDomRange(this.Window);A.MoveToSelection();var B=A._Range.startContainer;while (B){if (B.nodeType==1){var C=B.tagName.toLowerCase();if (C=="tr"||C=="td"||C=="th"||C=="tbody"||C=="table") return false;else break;};B=B.parentNode;};if (this.TabText){A.DeleteContents();A.InsertNode(this.Window.document.createTextNode(this.TabText));A.Collapse(false);A.Select();};return true;};FCKEnterKey.prototype._ExecuteEnterBlock=function(A,B){var C=B||new FCKDomRange(this.Window);var D=C.SplitBlock(A);if (D){var E=D.PreviousBlock;var F=D.NextBlock;var G=D.WasStartOfBlock;var H=D.WasEndOfBlock;if (F){if (F.parentNode.nodeName.IEquals('li')){FCKDomTools.BreakParent(F,F.parentNode);FCKDomTools.MoveNode(F,F.nextSibling,true);}}else if (E&&E.parentNode.nodeName.IEquals('li')){FCKDomTools.BreakParent(E,E.parentNode);C.MoveToElementEditStart(E.nextSibling);FCKDomTools.MoveNode(E,E.previousSibling);};if (!G&&!H){if (F.nodeName.IEquals('li')&&F.firstChild&&F.firstChild.nodeName.IEquals(['ul','ol'])) F.insertBefore(FCKTools.GetElementDocument(F).createTextNode('\xa0'),F.firstChild);if (F) C.MoveToElementEditStart(F);}else{if (G&&H&&E.tagName.toUpperCase()=='LI'){C.MoveToElementStart(E);this._OutdentWithSelection(E,C);C.Release();return true;};var I;if (E){var J=E.tagName.toUpperCase();if (!this._HasShift&&!(/^H[1-6]$/).test(J)){I=FCKDomTools.CloneElement(E);}}else if (F) I=FCKDomTools.CloneElement(F);if (!I) I=this.Window.document.createElement(A);var K=D.ElementPath;if (K){for (var i=0,len=K.Elements.length;i=0&&(C=B[i--])){if (C.name.length>0){if (C.innerHTML!==''){if (FCKBrowserInfo.IsIE) C.className+=' FCK__AnchorC';}else{var D=FCKDocumentProcessor_CreateFakeImage('FCK__Anchor',C.cloneNode(true));D.setAttribute('_fckanchor','true',0);C.parentNode.insertBefore(D,C);C.parentNode.removeChild(C);}}}}};var FCKPageBreaksProcessor=FCKDocumentProcessor.AppendNew();FCKPageBreaksProcessor.ProcessDocument=function(A){var B=A.getElementsByTagName('DIV');var C;var i=B.length-1;while (i>=0&&(C=B[i--])){if (C.style.pageBreakAfter=='always'&&C.childNodes.length==1&&C.childNodes[0].style&&C.childNodes[0].style.display=='none'){var D=FCKDocumentProcessor_CreateFakeImage('FCK__PageBreak',C.cloneNode(true));C.parentNode.insertBefore(D,C);C.parentNode.removeChild(C);}}};FCKEmbedAndObjectProcessor=(function(){var A=[];var B=function(el){var C=el.cloneNode(true);var D;var E=D=FCKDocumentProcessor_CreateFakeImage('FCK__UnknownObject',C);FCKEmbedAndObjectProcessor.RefreshView(E,el);for (var i=0;i=0;i--) B(G[i]);};var H=function(doc){F('object',doc);F('embed',doc);};return FCKTools.Merge(FCKDocumentProcessor.AppendNew(),{ProcessDocument:function(doc){if (FCKBrowserInfo.IsGecko) FCKTools.RunFunction(H,this,[doc]);else H(doc);},RefreshView:function(placeHolder,original){if (original.getAttribute('width')>0) placeHolder.style.width=FCKTools.ConvertHtmlSizeToStyle(original.getAttribute('width'));if (original.getAttribute('height')>0) placeHolder.style.height=FCKTools.ConvertHtmlSizeToStyle(original.getAttribute('height'));},AddCustomHandler:function(func){A.push(func);}});})();FCK.GetRealElement=function(A){var e=FCKTempBin.Elements[A.getAttribute('_fckrealelement')];if (A.getAttribute('_fckflash')){if (A.style.width.length>0) e.width=FCKTools.ConvertStyleSizeToHtml(A.style.width);if (A.style.height.length>0) e.height=FCKTools.ConvertStyleSizeToHtml(A.style.height);};return e;};if (FCKBrowserInfo.IsIE){FCKDocumentProcessor.AppendNew().ProcessDocument=function(A){var B=A.getElementsByTagName('HR');var C;var i=B.length-1;while (i>=0&&(C=B[i--])){var D=A.createElement('hr');D.mergeAttributes(C,true);FCKDomTools.InsertAfterNode(C,D);C.parentNode.removeChild(C);}}};FCKDocumentProcessor.AppendNew().ProcessDocument=function(A){var B=A.getElementsByTagName('INPUT');var C;var i=B.length-1;while (i>=0&&(C=B[i--])){if (C.type=='hidden'){var D=FCKDocumentProcessor_CreateFakeImage('FCK__InputHidden',C.cloneNode(true));D.setAttribute('_fckinputhidden','true',0);C.parentNode.insertBefore(D,C);C.parentNode.removeChild(C);}}};FCKEmbedAndObjectProcessor.AddCustomHandler(function(A,B){if (!(A.nodeName.IEquals('embed')&&(A.type=='application/x-shockwave-flash'||/\.swf($|#|\?)/i.test(A.src)))) return;B.className='FCK__Flash';B.setAttribute('_fckflash','true',0);});if (FCKBrowserInfo.IsSafari){FCKDocumentProcessor.AppendNew().ProcessDocument=function(A){var B=A.getElementsByClassName?A.getElementsByClassName('Apple-style-span'):Array.prototype.filter.call(A.getElementsByTagName('span'),function(item){ return item.className=='Apple-style-span';});for (var i=B.length-1;i>=0;i--) FCKDomTools.RemoveNode(B[i],true);}}; +var FCKSelection=FCK.Selection={GetParentBlock:function(){var A=this.GetParentElement();while (A){if (FCKListsLib.BlockBoundaries[A.nodeName.toLowerCase()]) break;A=A.parentNode;};return A;},ApplyStyle:function(A){FCKStyles.ApplyStyle(new FCKStyle(A));}}; +FCKSelection.GetType=function(){var A='Text';var B;try { B=this.GetSelection();} catch (e) {};if (B&&B.rangeCount==1){var C=B.getRangeAt(0);if (C.startContainer==C.endContainer&&(C.endOffset-C.startOffset)==1&&C.startContainer.nodeType==1&&FCKListsLib.StyleObjectElements[C.startContainer.childNodes[C.startOffset].nodeName.toLowerCase()]){A='Control';}};return A;};FCKSelection.GetSelectedElement=function(){var A=!!FCK.EditorWindow&&this.GetSelection();if (!A||A.rangeCount<1) return null;var B=A.getRangeAt(0);if (B.startContainer!=B.endContainer||B.startContainer.nodeType!=1||B.startOffset!=B.endOffset-1) return null;var C=B.startContainer.childNodes[B.startOffset];if (C.nodeType!=1) return null;return C;};FCKSelection.GetParentElement=function(){if (this.GetType()=='Control') return FCKSelection.GetSelectedElement().parentNode;else{var A=this.GetSelection();if (A){if (A.anchorNode&&A.anchorNode==A.focusNode){var B=A.getRangeAt(0);if (B.collapsed||B.startContainer.nodeType==3) return A.anchorNode.parentNode;else return A.anchorNode;};var C=new FCKElementPath(A.anchorNode);var D=new FCKElementPath(A.focusNode);var E=null;var F=null;if (C.Elements.length>D.Elements.length){E=C.Elements;F=D.Elements;}else{E=D.Elements;F=C.Elements;};var G=E.length-F.length;for(var i=0;i0){var C=B.getRangeAt(A?0:(B.rangeCount-1));var D=A?C.startContainer:C.endContainer;return (D.nodeType==1?D:D.parentNode);}};return null;};FCKSelection.SelectNode=function(A){var B=FCK.EditorDocument.createRange();B.selectNode(A);var C=this.GetSelection();C.removeAllRanges();C.addRange(B);};FCKSelection.Collapse=function(A){var B=this.GetSelection();if (A==null||A===true) B.collapseToStart();else B.collapseToEnd();};FCKSelection.HasAncestorNode=function(A){var B=this.GetSelectedElement();if (!B&&FCK.EditorWindow){try { B=this.GetSelection().getRangeAt(0).startContainer;}catch(e){}}while (B){if (B.nodeType==1&&B.nodeName.IEquals(A)) return true;B=B.parentNode;};return false;};FCKSelection.MoveToAncestorNode=function(A){var B;var C=this.GetSelectedElement();if (!C) C=this.GetSelection().getRangeAt(0).startContainer;while (C){if (C.nodeName.IEquals(A)) return C;C=C.parentNode;};return null;};FCKSelection.Delete=function(){var A=this.GetSelection();for (var i=0;i=0;i--){if (C[i]) FCKTableHandler.DeleteRows(C[i]);};return;};var E=FCKTools.GetElementAscensor(A,'TABLE');if (E.rows.length==1){FCKTableHandler.DeleteTable(E);return;};A.parentNode.removeChild(A);};FCKTableHandler.DeleteTable=function(A){if (!A){A=FCKSelection.GetSelectedElement();if (!A||A.tagName!='TABLE') A=FCKSelection.MoveToAncestorNode('TABLE');};if (!A) return;FCKSelection.SelectNode(A);FCKSelection.Collapse();if (A.parentNode.childNodes.length==1) A.parentNode.parentNode.removeChild(A.parentNode);else A.parentNode.removeChild(A);};FCKTableHandler.InsertColumn=function(A){var B=null;var C=this.GetSelectedCells();if (C&&C.length) B=C[A?0:(C.length-1)];if (!B) return;var D=FCKTools.GetElementAscensor(B,'TABLE');var E=B.cellIndex;for (var i=0;i=0;i--){if (B[i]) FCKTableHandler.DeleteColumns(B[i]);};return;};if (!A) return;var C=FCKTools.GetElementAscensor(A,'TABLE');var D=A.cellIndex;for (var i=C.rows.length-1;i>=0;i--){var E=C.rows[i];if (D==0&&E.cells.length==1){FCKTableHandler.DeleteRows(E);continue;};if (E.cells[D]) E.removeChild(E.cells[D]);}};FCKTableHandler.InsertCell=function(A,B){var C=null;var D=this.GetSelectedCells();if (D&&D.length) C=D[B?0:(D.length-1)];if (!C) return null;var E=FCK.EditorDocument.createElement('TD');if (FCKBrowserInfo.IsGeckoLike) FCKTools.AppendBogusBr(E);if (!B&&C.cellIndex==C.parentNode.cells.length-1) C.parentNode.appendChild(E);else C.parentNode.insertBefore(E,B?C:C.nextSibling);return E;};FCKTableHandler.DeleteCell=function(A){if (A.parentNode.cells.length==1){FCKTableHandler.DeleteRows(FCKTools.GetElementAscensor(A,'TR'));return;};A.parentNode.removeChild(A);};FCKTableHandler.DeleteCells=function(){var A=FCKTableHandler.GetSelectedCells();for (var i=A.length-1;i>=0;i--){FCKTableHandler.DeleteCell(A[i]);}};FCKTableHandler._MarkCells=function(A,B){for (var i=0;i=E.height){for (D=F;D0){var L=K.removeChild(K.firstChild);if (L.nodeType!=1||(L.getAttribute('type',2)!='_moz'&&L.getAttribute('_moz_dirty')!=null)){I.appendChild(L);J++;}}};if (J>0) I.appendChild(FCKTools.GetElementDocument(B).createElement('br'));};this._ReplaceCellsByMarker(C,'_SelectedCells',B);this._UnmarkCells(A,'_SelectedCells');this._InstallTableMap(C,B.parentNode.parentNode);B.appendChild(I);if (FCKBrowserInfo.IsGeckoLike&&(!B.firstChild)) FCKTools.AppendBogusBr(B);this._MoveCaretToCell(B,false);};FCKTableHandler.MergeRight=function(){var A=this.GetMergeRightTarget();if (A==null) return;var B=A.refCell;var C=A.tableMap;var D=A.nextCell;var E=FCK.EditorDocument.createDocumentFragment();while (D&&D.childNodes&&D.childNodes.length>0) E.appendChild(D.removeChild(D.firstChild));D.parentNode.removeChild(D);B.appendChild(E);this._MarkCells([D],'_Replace');this._ReplaceCellsByMarker(C,'_Replace',B);this._InstallTableMap(C,B.parentNode.parentNode);this._MoveCaretToCell(B,false);};FCKTableHandler.MergeDown=function(){var A=this.GetMergeDownTarget();if (A==null) return;var B=A.refCell;var C=A.tableMap;var D=A.nextCell;var E=FCKTools.GetElementDocument(B).createDocumentFragment();while (D&&D.childNodes&&D.childNodes.length>0) E.appendChild(D.removeChild(D.firstChild));if (E.firstChild) E.insertBefore(FCKTools.GetElementDocument(D).createElement('br'),E.firstChild);B.appendChild(E);this._MarkCells([D],'_Replace');this._ReplaceCellsByMarker(C,'_Replace',B);this._InstallTableMap(C,B.parentNode.parentNode);this._MoveCaretToCell(B,false);};FCKTableHandler.HorizontalSplitCell=function(){var A=FCKTableHandler.GetSelectedCells();if (A.length!=1) return;var B=A[0];var C=this._CreateTableMap(B.parentNode.parentNode);var D=B.parentNode.rowIndex;var E=FCKTableHandler._GetCellIndexSpan(C,D,B);var F=isNaN(B.colSpan)?1:B.colSpan;if (F>1){var G=Math.ceil(F/2);var H=FCKTools.GetElementDocument(B).createElement('td');if (FCKBrowserInfo.IsGeckoLike) FCKTools.AppendBogusBr(H);var I=E+G;var J=E+F;var K=isNaN(B.rowSpan)?1:B.rowSpan;for (var r=D;r1){B.rowSpan=Math.ceil(E/2);var G=F+Math.ceil(E/2);var H=null;for (var i=D+1;iG) L.insertBefore(K,L.rows[G]);else L.appendChild(K);for (var i=0;i0){var D=B.rows[0];D.parentNode.removeChild(D);};for (var i=0;iF) F=j;if (E._colScanned===true) continue;if (A[i][j-1]==E) E.colSpan++;if (A[i][j+1]!=E) E._colScanned=true;}};for (var i=0;i<=F;i++){for (var j=0;j 
    ';var A=FCKDocumentProcessor_CreateFakeImage('FCK__PageBreak',e);var B=new FCKDomRange(FCK.EditorWindow);B.MoveToSelection();var C=B.SplitBlock();B.InsertNode(A);FCK.Events.FireEvent('OnSelectionChange');};FCKPageBreakCommand.prototype.GetState=function(){if (FCK.EditMode!=0) return -1;return 0;};var FCKUnlinkCommand=function(){this.Name='Unlink';};FCKUnlinkCommand.prototype.Execute=function(){FCKUndo.SaveUndoStep();if (FCKBrowserInfo.IsGeckoLike){var A=FCK.Selection.MoveToAncestorNode('A');if (A) FCKTools.RemoveOuterTags(A);return;};FCK.ExecuteNamedCommand(this.Name);};FCKUnlinkCommand.prototype.GetState=function(){if (FCK.EditMode!=0) return -1;var A=FCK.GetNamedCommandState(this.Name);if (A==0&&FCK.EditMode==0){var B=FCKSelection.MoveToAncestorNode('A');var C=(B&&B.name.length>0&&B.href.length==0);if (C) A=-1;};return A;};FCKVisitLinkCommand=function(){this.Name='VisitLink';};FCKVisitLinkCommand.prototype={GetState:function(){if (FCK.EditMode!=0) return -1;var A=FCK.GetNamedCommandState('Unlink');if (A==0){var B=FCKSelection.MoveToAncestorNode('A');if (!B.href) A=-1;};return A;},Execute:function(){var A=FCKSelection.MoveToAncestorNode('A');var B=A.getAttribute('_fcksavedurl')||A.getAttribute('href',2);if (!/:\/\//.test(B)){var C=FCKConfig.BaseHref;var D=FCK.GetInstanceObject('parent');if (!C){C=D.document.location.href;C=C.substring(0,C.lastIndexOf('/')+1);};if (/^\//.test(B)){try{C=C.match(/^.*:\/\/+[^\/]+/)[0];}catch (e){C=D.document.location.protocol+'://'+D.parent.document.location.host;}};B=C+B;};if (!window.open(B,'_blank')) alert(FCKLang.VisitLinkBlocked);}};var FCKSelectAllCommand=function(){this.Name='SelectAll';};FCKSelectAllCommand.prototype.Execute=function(){if (FCK.EditMode==0){FCK.ExecuteNamedCommand('SelectAll');}else{var A=FCK.EditingArea.Textarea;if (FCKBrowserInfo.IsIE){A.createTextRange().execCommand('SelectAll');}else{A.selectionStart=0;A.selectionEnd=A.value.length;};A.focus();}};FCKSelectAllCommand.prototype.GetState=function(){if (FCK.EditMode!=0) return -1;return 0;};var FCKPasteCommand=function(){this.Name='Paste';};FCKPasteCommand.prototype={Execute:function(){if (FCKBrowserInfo.IsIE) FCK.Paste();else FCK.ExecuteNamedCommand('Paste');},GetState:function(){if (FCK.EditMode!=0) return -1;return FCK.GetNamedCommandState('Paste');}};var FCKRuleCommand=function(){this.Name='Rule';};FCKRuleCommand.prototype={Execute:function(){FCKUndo.SaveUndoStep();FCK.InsertElement('hr');},GetState:function(){if (FCK.EditMode!=0) return -1;return FCK.GetNamedCommandState('InsertHorizontalRule');}};var FCKCutCopyCommand=function(A){this.Name=A?'Cut':'Copy';};FCKCutCopyCommand.prototype={Execute:function(){var A=false;if (FCKBrowserInfo.IsIE){var B=function(){A=true;};var C='on'+this.Name.toLowerCase();FCK.EditorDocument.body.attachEvent(C,B);FCK.ExecuteNamedCommand(this.Name);FCK.EditorDocument.body.detachEvent(C,B);}else{try{FCK.ExecuteNamedCommand(this.Name);A=true;}catch(e){}};if (!A) alert(FCKLang['PasteError'+this.Name]);},GetState:function(){return FCK.EditMode!=0?-1:FCK.GetNamedCommandState('Cut');}};var FCKAnchorDeleteCommand=function(){this.Name='AnchorDelete';};FCKAnchorDeleteCommand.prototype={Execute:function(){if (FCK.Selection.GetType()=='Control'){FCK.Selection.Delete();}else{var A=FCK.Selection.GetSelectedElement();if (A){if (A.tagName=='IMG'&&A.getAttribute('_fckanchor')) oAnchor=FCK.GetRealElement(A);else A=null;};if (!A){oAnchor=FCK.Selection.MoveToAncestorNode('A');if (oAnchor) FCK.Selection.SelectNode(oAnchor);};if (oAnchor.href.length!=0){oAnchor.removeAttribute('name');if (FCKBrowserInfo.IsIE) oAnchor.className=oAnchor.className.replace(FCKRegexLib.FCK_Class,'');return;};if (A){A.parentNode.removeChild(A);return;};if (oAnchor.innerHTML.length==0){oAnchor.parentNode.removeChild(oAnchor);return;};FCKTools.RemoveOuterTags(oAnchor);};if (FCKBrowserInfo.IsGecko) FCK.Selection.Collapse(true);},GetState:function(){if (FCK.EditMode!=0) return -1;return FCK.GetNamedCommandState('Unlink');}};var FCKDeleteDivCommand=function(){};FCKDeleteDivCommand.prototype={GetState:function(){if (FCK.EditMode!=0) return -1;var A=FCKSelection.GetParentElement();var B=new FCKElementPath(A);return B.BlockLimit&&B.BlockLimit.nodeName.IEquals('div')?0:-1;},Execute:function(){FCKUndo.SaveUndoStep();var A=FCKDomTools.GetSelectedDivContainers();var B=new FCKDomRange(FCK.EditorWindow);B.MoveToSelection();var C=B.CreateBookmark();for (var i=0;i\n