月度存档: 7 月 2015

给Ubuntu Server装中文环境

有需要给Ubuntu Server装中文环境的往这看,该加sudo的自己加去,俺是root…

1、安装中文语言包

apt-get install language-pack-zh
2、用vim配置语言环境变量

vim /etc/environment
在下面添加如下两行

LANG=”zh_CN.UTF-8″
LANGUAGE=”zh_CN:zh:en_US:en”
如果你想用英文环境了,改成这两行就OK

LANG=”en_US.UTF-8″
LANGUAGE=”en_US:en”
3、重启Ubuntu Server

reboot
4、可以用locale查看一下环境变量…

locale

转:SecureCRT中文乱码解决方案

原文地址:http://www.bootf.com/547.html
SecureCRT是一个商业终端连接工具。SecureCRT可以自定义界面颜色方案,可以连接SSH1与SSH2、Telnet等服务。默认设置下,通过SecureCRT连接SSH服务器可能出现中文乱码的情况。这是由于SecureCRT字符编码与服务器的字符编码不一致造成的。解决方法非常简单,进行设置即可。
中文乱码解决方法
一般来说
1、右键点击SecureCRT的连接标签

选择“会话选项”菜单。
2、在弹出的窗口中,左边栏选择“外观”选项卡;

3、在右边的窗口中选择UTF8,如图所示:

4、此时,SecureCRT中即可正常显示中文了:

如果此时依然无法正常显示中文,则可能是由于Linux系统中默认的字符编码非UTF8所致,解决方法如下:
修改Linux服务器的配置文件:
1
[root@www ~]# vi /etc/sysconfig/i18n
如果安装系统的时候选择了中文系统,则把LANG字段改为:
1
LANG=”zh_CN.UTF-8″
如果安装系统的时候选择的英文系统,则把LANG字段改为:
1
LANG=”en_US.UTF-8″
然后保存文件。
这时断开SSH连接并重新登录,会发现中文文件名、文件中的中文字符均已经可以正常显示,并可以通过输入法输入中文了。

解决Axure RP输出成html放到网站后,不能读取中文网址页面的办法

解决Axure RP输出成html放到网站后,不能读取中文网址页面的办法

Axure RP输出 html档案,如果左侧Page列表是用中文命名,在自己的计算机上可以正常点选连结,但是放到网站上会发生无法读取的情况: 点左侧选单,但右侧无法出现对应的数据。

这个状况的问题出在 「放」到网络上的方法以及网站操作系统是否支持中文文件名?

以网站操作系统来区分,把Axure RP输出的html prototype传到网站上的方法:

1. Web放在Windows OS(已经支持中文文件名)

以网络芳邻的方式 (在局域网络里头),直接把Axure RP输出的html档案,复制或搬移到web server可读取的目录之下,中文文件名的网址不会有问题。

2. Web放在Linux之类的OS (必须支持中文档名)

CentOS 终端命令行中文乱码的解决

安装CentOS的时候选择了中文,结果在终端不能显示中文,都是乱码,解决方法:
修改/etc/sysconfig/i18n,内容为(ubuntu:/usr/share/i18n/SUPPORTED)

LANG=”zh_CN.GB18030″
LANGUAGE=”zh_CN.GB18030:zh_CN.GB2312:zh_CN”
SUPPORTED=”zh_CN.UTF-8:zh_CN:zh:en_US.UTF-8:en_US:en”
SYSFONT=”lat0-sun16″

安装中文字体:

#yum install fonts-chinese.noarch

退出重新登录即可

然后采用 FTP上传Axure RP输出的html文件,必须将 FTP传输模式改成 『UTF8″,否则当FTP软件以ANSI或其它编码传输到 Linux的档案目录上,Apache是无法辨认出这种编码的中文文件名的。我们建议采用FileZilla,FileZilla支持传输编码的设定。

如果没有FTP,也可以使用sftp的方式上传,推荐一个工具 sftpDrive,可以将文件夹直接拷贝到Linux服务器上。

举例:
下面这个prototype使用了中文html,仍然可以顺利浏览。
http://userxper.com/samples/zh/Prototypes/demo_travelsite/index.html

SMB服务不存在这个问题,也是一个不错的替代方案

yii2_study10_关联数据库的下拉列表

1.修改backend\views\branches_form.php

use yii\helpers\ArrayHelper;
use backend\models\Companies;

    <?= $form->field($model, 'companies_company_id')->dropDownList(
    ArrayHelper::map(Companies::find()->all(),'company_name','company_id'),
    ['prompt'=>'Select Company']
    )?>

2.访问 http://https://https://amyflash.com/yii/advanced/backend/web/index.php?r=branches%2Fcreate ,发现下拉列表中自动关联了company_name

yii2_study9_Advanced_CRUD

1.数据库准备好3张表,注意表之间有外链关联
[code]
CREATE TABLE `companies` (
`company_id` int(11) NOT NULL ,
`company_name` varchar(100) NULL ,
`company_email` varchar(100) NULL ,
`company_address` varchar(255) NULL ,
`company_created_date` datetime NULL ,
`company_status` enum(‘inactive’,’active’) NULL ,
PRIMARY KEY (`company_id`)
);
CREATE TABLE `branches` (
`branch_id` int(11) NOT NULL ,
`companies_company_id` int(11) NOT NULL ,
`branch_name` varchar(100) NULL ,
`branch_address` varchar(255) NULL ,
`branch_created_date` datetime NULL ,
`branch_status` enum(‘inactive’,’active’) NULL ,
PRIMARY KEY (`branch_id`)
);
CREATE TABLE `departmentes` (
`department_id` int(11) NOT NULL ,
`branches_branch_id` int(11) NOT NULL ,
`department_name` varchar(100) NULL ,
`companies_company_id` int(11) NULL ,
`department_created_date` datetime NULL ,
`department_status` enum(‘inactive’,’active’) NULL ,
PRIMARY KEY (`department_id`)
);
[/code]

2.使用http://https://https://amyflash.com/yii/advanced/backend/web/index.php?r=gii,创建mvc,模型中的自增长id可以注释掉

3.修改backend/controllers里创建中关于日期的函数,取系统日期
[code]
public function actionCreate()
{
$model = new Companies();

if ($model->load(Yii::$app->request->post()) /*&& $model->save()*/) {
$model->company_created_date = date(‘y-m-d h:m:s’);
$model->save();
return $this->redirect([‘view’, ‘id’ => $model->company_id]);
} else {
return $this->render(‘create’, [
‘model’ => $model,
]);
}
}
[/code]

4.修改backend\views\companies\index.php _form.php等看页面效果
[code]
<?= $form->field($model, ‘company_status’)->dropDownList([ ‘inactive’ => ‘Inactive’, ‘active’ => ‘Active’, ” => ”, ], [‘prompt’ => ‘status’]) //添加一个默认状态
?>
[/code]

yii2_study8_Customizing_signup_form

1.在数据库advanced_yii2的user表的id后新加2个字段first_name,last_name
2.对应修改advanced/frontend/models/SignupForm.php,添加
public $first_name;
public $last_name;
return里面添加:
[‘first_name’, ‘required’,”message”=>’this is add by aha68.com!’],
[‘last_name’, ‘required’],
signupz函数里添加:
$user->first_name = $this->first_name;
$user->last_name = $this->last_name;
3.修改form视图 advanced/frontend/views/site/signup.php
field($model, ‘first_name’) ?>
field($model, ‘last_name’) ?>
4.访问: http://https://https://amyflash.com/yii/advanced/frontend/web/index.php?r=site%2Fsignup,注册个新用户玩玩

yii2_study7_install_advanced

1.yiiframework上下载advanced安装包,解压 tar zxvf xx.tgz
2.进入advanced 目录: 执行 php init
3.配置database , common/config/main-local.php
4.新建advanced_yii2数据库,执行 php yii migrate 自动会在新建的数据库里添加两张表,确保用户signup成功

yii2_study6_access_control

1.修改自动生成的basic\controllers\PostsController.php,前面引入use yii\filters\AccessControl;
[code]class PostsController extends Controller
{
public function behaviors()
{
return [

‘access’=>[
‘class’=>AccessControl::className(),
‘only’=>[‘create’,’update’],
‘rules’=>[
[‘allow’=>true,
‘roles’=>[‘@’]
],
]
]

,
‘verbs’ => [
‘class’ => VerbFilter::className(),
‘actions’ => [
‘delete’ => [‘post’],
],
],
];
}[/code]

2.访问http://https://https://amyflash.com/yii/basic/web/index.php?r=posts/
点击create posts按钮,出现登陆页面了

yii2_study5_CRUD

1.数据库里面创建posts表,表中author_id与users表中user_id关联
2.visit http://https://https://amyflash.com/yii/basic/web/index.php?r=gii create model: Post.php
3.visit http://myphp.com/yii/basic/web/index.php?r=posts/index

yii2_study4_db

1.yii\basic\config\db.php 修改数据库配置(dbname,username,password),新建数据库test
2.basic\models目录下新建Users.php
[code]
<?php
namespace app\models;
use yii\db\ActiveRecord;
class Users extends ActiveRecord
{

}
?>
[/code]
3.basic\controllers add UsersController.php
[code]
<?php

namespace app\controllers;
use yii\web\Controller;
use app\models\Users;

class UsersController extends Controller
{
public function actionIndex()
{
$users = Users::find()->all();
//print_r($users);
return $this->render(‘index’,[‘users’=>$users]);
}
}
?>
[/code]

4.basic\views\ 下增加一个文件夹Users,里面新建一个页面index.php,页面打印参数users
[code]<?php
foreach($users as $item){
echo $item->username."<br>";
}
?>[/code]