Handling External URLs in Umbraco 6 页面重定向到外部URL

发布于:
Microsoft.Net

copy from: http://www.theoutfield.net/blog/2013/10/handling-external-urls-in-umbraco-6

Umbraco 有一些特殊的别名,如:umbracoUrlName,能让你在当前网站中的页面间重定向。然而,他没有一个内置的方法将一个页面重定向到外部URL。我认为我想出了一个相当不错的办法,下面讲解如何做到:

创建一个属性(Property)

我们在文档类型中创建一个名为“umbracoExternalUrl”的文本字符串属性。

创建 IUrlProvider

  我已经设立我们需要的属性,现在我们要让umbraco知道,当这个属性值被设置的时候,就使用他的值来作为节点的URL而不是使用默认生的URL。我们将使用Umbraco一个很酷的新功能实现它,它是一个UrlProvider,该IUrlProvider接口能在生成一个节点的URL的时候定义我们自己的逻辑。继续,我们建立一个接口如下

单网卡Debian服务器打造 PPTP VPN服务器

发布于:
服务器技术

  搭建 VPN 服务器的方法非常多,比较著名的有 PPTP, L2TP/IPSec 和OpenVPN。

  这三种方式中后两者的安全性比较好,但配置较麻烦。其中 OpenVPN 在 Windows/Mac 平台上还需要额外的客户端。

  而L2TP/IPSec 方式虽然比较好,但我配置后,虽然 Windows 和 Linux 用户没有问题,但 Mac/iPhone却始终无法连上,所以暂时删掉了,日后搞清楚是什么问题再换到这种方式。

  只剩下 PPTP 了。事实上 PPTP 是这三者中配置最容易的方式,而且由于 Windows/Mac 系统中都内建相应的客户端,使用起来非常方便。

环境:Debian (服务器)单网卡,Win7(客户机)
服务器ip地址:192.168.1.250  ,客户机ip地址:192.168.1.2

VPN-SERVER:~# apt-get pptpd
系统会自动解决依赖关系,安装好后,需要进行一番设置。

编辑 /etc/pptpd.conf

VPN-SERVER:~# nano /etc/pptpd.conf

localip 192.168.15.1
remoteip 10.100.15.2-100

编辑 /etc/ppp/pptpd-options 文件

VPN-SERVER:~# nano etc/ppp/pptpd-options

ms-dns 8.8.8.8
ms-dns 114.114.114.114

修改 /etc/ppp/chap-secrets 文件
这里面存放着 VPN的用户名和密码,根据你的实际情况填写即可。如文件中注释所示,第一列是用户名,第二列是服务器名(默认写 pptpd 即可,如果在
pptpd-options 文件中更改过的话,注意这里保持一致),第三列是密码,第四列是 IP 限制(不做限制写 * 即可)

VPN-SERVER:~# nano /etc/ppp/chap-secrets

# Secrets for authentication using CHAP
# client        server  secret                  IP addresses
username        pptpd   123456                  *

重启 pptpd 服务使新配置生效

VPN-SERVER:~# /etc/init.d/pptpd restart

首先修改内核设置,使其支持转发功能
修改 /etc/sysctl.conf

VPN-SERVER:~# nano /etc/sysctl.conf

net.ipv4.ip_forward = 1

使设置永久生效

VPN-SERVER:~# cat /proc/sys/net/ipv4/ip_forward

做snat,使vpn拨号进来后可以访问Internet(外网);

VPN-SERVER:~# nano /root/snat.sh

#/bin/bash

#加载需要的模块
modeprobe iptable_nat
modeprobe ip_conntrack
modeprobe ip_conntrack_ftp
modeprobe ip_nat_ftp

#清除所有用户已经定义的规,自定义链,将所有chain的计数和流量统计为0

iptables -F
iptables -X
iptables -Z

#修改SNAT,用于上外网
iptables -t nat -A POSTROUTING -s 192.168.15.0/24 -j SNAT -- to 192.168.15.1

执行此脚本
VPN-SERVER:~# sh /root/snat.sh

如果服务器采用了shorewall防火墙,需要开放端口1723,47和gre协议
略…

至此,可以设置VPN客户端连接了。

Umbraco 7 编辑器tinymce配置

发布于:
Microsoft.Net

Umbraco 发布了新的版本,Umbraco 7,全新的后台。看上去非常不错。

但的他有编辑器默认配置还是有点满足不了需要,查了一下文档,有些配置可以在 <InstallPath>ConfigtinyMceConfig.config 中修改

<commands> 中增加一个按钮(文字颜色选择器),如下

<command>
            <umbracoAlias>forecolor</umbracoAlias>
            <icon>images/editor/forecolor.gif</icon>
            <tinyMceCommand value="" userInterface="false" frontendCommand="forecolor">forecolor</tinyMceCommand>
            <priority>1001</priority>
 </command>

 

当然增加了这个不会有任何效果的,好像他依赖 textcolor 插件,所以在 <plugins> 中启用这个插件

<plugin loadOnFrontend="true">textcolor</plugin>

 

依次类推,就这么简单。

但是,我遇到一个难题,想在 Formats 中分组显示各种样式,默认可以在后台配置 启用编辑器CSS样式解析,但是不分组显示,不是很方便啊。不想动他源码,不然升级麻烦。

SQLEXPRESS 自动备份

发布于:
服务器技术

在你Master数据库内执行该段存储过程,该存储过程被Windows计划调用

-- ============================================= 
-- Description: 备份数据库
-- Parameter1: 数据库名
-- Parameter2: 备份类型 F=全部, D=差异, L=日志
-- ============================================= 
CREATE PROCEDURE [dbo].[sp_BackupDatabase]  
       @databaseName sysname, @backupType CHAR(1) 
AS 
BEGIN 
       SET NOCOUNT ON; 

       DECLARE @sqlCommand NVARCHAR(1000) 
       DECLARE @dateTime NVARCHAR(20) 

       SELECT @dateTime = REPLACE(CONVERT(VARCHAR, GETDATE(),111),'/','') + 
       REPLACE(CONVERT(VARCHAR, GETDATE(),108),':','')  

       IF @backupType = 'F' 
               SET @sqlCommand = 'BACKUP DATABASE ' + @databaseName + 
               ' TO DISK = ''C:Backup' + @databaseName + '_Full_' + @dateTime + '.BAK''' 
        
       IF @backupType = 'D' 
               SET @sqlCommand = 'BACKUP DATABASE ' + @databaseName + 
               ' TO DISK = ''C:Backup' + @databaseName + '_Diff_' + @dateTime + '.BAK'' WITH DIFFERENTIAL' 
        
       IF @backupType = 'L' 
               SET @sqlCommand = 'BACKUP LOG ' + @databaseName + 
               ' TO DISK = ''C:Backup' + @databaseName + '_Log_' + @dateTime + '.TRN''' 
        
       EXECUTE sp_executesql @sqlCommand 
END
go

建立一个windows任务计划,打开任务计划向导,选择指定的的exe文件,该文件名为SQLCMD.EXE,位于ToolsBinn 目录下。

修改运行命令参数为:sqlcmd -S .SQLEXPRESS -E -i c:Backup.sql

注:.SQLEXPRESS 是你的数据库实例, c:Backup.sql 磁盘位置可任意更改。Backup.sql 文件内容为:

exec [sp_BackupDatabase] '需要备份的数据库名','F';
go

 

Orchard CMS Taxonomy Term Autoroute Token Slug v2.0

发布于:
Orchard CMS

From :http://sheltonial.blogspot.com.au/2013/11/orchard-cms-taxonomy-term-autoroute.html

This is a new and improved solution to my original post http://sheltonial.blogspot.com.au/2013/10/orchard-cms-taxonomy-term-autoroute.html.

The purpose of this post is to provide a method of returning a full taxonomy term path slug as a token in Orchard CMS. I am currently using this solution in Orchard 1.7.1 as of changeset 91d0048f2796f093a8cefe2111ff013818d220fb.

 

The problem with the previous solution was that it only rendered the 1 selected taxonomy term into the token result, which was great if you were working with the root terms, but as soon as you went deeper it did not render the full taxonomy term path into the token result.

The following solution allows a full taxonomy term path to be slugified and rendered into a token result.

使用jQuery插件pngFix让所有的浏览器都支持PNG

发布于:
Script
<script type="text/javascript" src="Js/jQuery/jquery.js"></script>
<script type="text/javascript" src="Js/jQuery/plugs/pngFix/jquery.pngFix.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $(document).pngFix();
});
</script>
<script type="text/javascript" src="Js/jQuery/jquery.js"></script>
<script type="text/javascript" src="Js/jQuery/plugs/pngFix/jquery.pngFix.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $(document).pngFix();
});
</script>

 

pngFix下载地址:http://jquery.andreaseberhard.de/download/pngFix.zip

最佳ASP.NET内容管理系统(cms)TOP7快速回顾

发布于:
Microsoft.Net

1. DotNetNuke

Of all the ASP .NET CMSes out there, DotNetNuke is probably the most well known and popular. One of the reasons for the popularity of this CMS is due to its multiple versions which allow for the flexibility to accommodate a beginning web developer, a small to medium sized business, or even a large enterprise. It has enjoyed a busy development since before 2003 that continues to this day.

For those that don’t need much support other than what the open source community can provide, there’s the DotNetNuke Community Edition offered under the BSD License. It contains most of the features which comprise the other editions, but the support is left up to the community. The Professional Edition gives you support from the DotNetNuke Corporation along with a few more features, and for a (much) increased price, the Enterprise Edition gives you a few more features along with phone support.

This CMS has been around for a while, so it’s very stable and there’s a plethora of add-ons in the community, so it’s definitely the first stop if you’re looking for something that’s proven.

HTML字符实体(Character Entities),转义字符串(Escape Sequence)

发布于:
Script

HTML中<,>,&等有特殊含义(<,>,用于链接签,&用于转义),不能直接使用。这些符号是不显示在我们最终看到的网页里的,那如果我们希望在网页中显示这些符号,该怎么办呢?

这就要说到HTML转义字符串(Escape Sequence)了。

  转义字符串(Escape Sequence)也称字符实体(Character Entity)。在HTML中,定义转义字符串的原因有两个:第一个原因是像“<”和“>”这类符号已经用来表示HTML标签,因此就不能直接当作文本中的符号来使用。为了在HTML文档中使用这些符号,就需要定义它的转义字符串。当解释程序遇到这类字符串时就把它解释为真实的字符。在输入转义字符串时,要严格遵守字母大小写的规则。第二个原因是,有些字符在ASCII字符集中没有定义,因此需要使用转义字符串来表示。

转义字符串的组成

  转义字符串(Escape Sequence),即字符实体(Character Entity)分成三部分:第一部分是一个&符号,英文叫ampersand;第二部分是实体(Entity)名字或者是#加上实体(Entity)编号;第三部分是一个分号。

比如,要显示小于号(<),就可以写 &lt; 或者 &#60; 。

用实体(Entity)名字的好处是比较好理解,一看lt,大概就猜出是less than的意思,但是其劣势在于并不是所有的浏览器都支持最新的Entity名字。而实体(Entity)编号,各种浏览器都能处理。

提示:实体名称(Entity)是区分大小写的。

备注:同一个符号,可以用“实体名称”和“实体编号”两种方式引用,“实体名称”的优势在于便于记忆,但不能保证所有的浏览器都能顺利识别它,而“实体编号”则没有这种担忧,但它实在不方便记忆。

为BlogEngine的分类增加了自定义Url别名功能

发布于:
Microsoft.Net
//修改代码xxxxx:
//BlogEngine.Core.Category.cs

private string _Title;
/// <summary>
/// Gets or sets the Title or the object.
/// </summary>
public string Title
{
    get { return _Title; }
    set
    {
        if (_Title != value) MarkChanged("Title");
        _Title = value;
    }
}
//后添加:
private string _Slug;
/// <summary>
/// Gets or sets the Slug or the object.
/// </summary>
public string Slug
{
    get { return _Slug; }
    set
    {
        if (_Slug != value) MarkChanged("Slug");
        _Slug = value;
    }
}
public Category(string title, string description,string slug)
{
    this.Id = Guid.NewGuid();
    this._Title = title;
    this._Description = description;
    this._Slug = slug;
    this.Parent = null;
}

微软补丁造成MYSQL经常连接失败解决方法

发布于:
服务器技术

微软补丁KB967723造成MYSQL经常连接失败解决方法

有以下两种方法:

1,卸载微软补丁KB967723 (不建议
步骤:在 添加和删除程序 中(勾选上方的“显示更新”)在里面可以看到更新的KB967723这个补丁,然后就想卸载普通软件一样卸载,卸载中会提示你,如果卸载可能导致程序运行出错,没关系,选择“是”,继续卸载。卸载完成后重启数据库服务器。

2,修改注册表(推荐此方法
本方法是微软给出的修改注册表修复该Bug的的方法,
原因是TCP 端口的默认值 是 5000 。建议调整TCP端口值为65533。
步骤:找到注册表路径 HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesTcpipParameters
新增 MaxUserPort
值名称: MaxUserPort 
值类型: DWORD
建议值为 65533  {有效范围: 5000 65534 (十进制)}
退出注册表,重启服务器即可。

微软原文地址 :http://support.microsoft.com/kb/q196271