Tuesday, December 31, 2013

openfire and jabberd2 and – setup log

with above openfire and jwchat support bosh – setup log

1.setup spack

downlaod spark_2_6_3_online.exe from http://www.igniterealtime.org/downloads/index.jsp

setup it

2.register and login for openfire

image

click "Account",

image

input user and password,then click "Create account"

image

account is created ok!

image

input your created user and password,then click "login".

image

login ok!

3.replace openfire with jabbed2

3.1 file list:

in jabberd2 files like bellow:

image

3.2 setup profile

i used my sql for my default db.

so i changed:

c2s.xml c2s–> authreg->module: <module>sqlite</module> => <module>mysql</module>

for support bosh, uncomment: <ssl-port>5223</ssl-port>

sm.xml –> sm->storage –> driver: <driver>sqlite</driver> –> <driver>mysql</driver>

import mysql db to mysql: jabberd2\tools\db-setup.mysql

create mysql account "jabberd2" password "secret" for db "jabberd2"

3.3 run

in jabberd2\win32\bin\debug

sure mysql is running,and first run route.exe then run sm.exe and c2s.exe.

 

image

4. thanks.

Monday, December 30, 2013

openfire and jwchat support bosh - setup log

1.setup openfire

1.1downlaod openfire setup program

http://www.igniterealtime.org/downloads/index.jsp

1.2extract openfire files

extract openfire_3_8_2.zip to c:\program files\

image

1.3 setup

C:\Program Files\openfire\bin\openfire.exe

image

click "Launch Admin", or open url : http://127.0.0.1:9090

image

click "continue"

image

change domain value:"localhost",click "continue"

image

click "Embedded Database",click "continue"

image

click "continue"

image

input "New Password:" and "Confirm Password:" with same value: "admin",click "continue",then wait some seconds.

image

ok.then click "Login to the admin console"

image

input username and password with:"admin","admin". click "Login"

image

it ok!

1.4 edit openfire to support BoshConnection.

image

click "security settings"

image

checked "Accept self-signed certificates. Server dialback over TLS is now available. " ,click "Save Setting".

1.5 restart openfire

image

click "Stop" then click "Start".

2. setup jwchat

2.1download

download from https://sourceforge.net/projects/jwchat/files/latest/download

2.2 extract

extract jwchat-1.0.zip to [your tomcat server]\webapps\ROOT\jwchat

image

then modify filenames from filename.locale to filename,for example, browsercheck.js.zh_CN => browsercheck.js

and your can used these java tool:(i forget who is author):


package replacejwtfilename;

import java.io.File;

public abstract class Replacejwtfilename {

public static void rename(String path, String type) {
File dir = new File(path);
File[] list = dir.listFiles();
for (File file : list) {
String name = file.getName();
String[] s = name.split("\\.");
if (s.length == 3 && type.equals(s[2])) {
System.out.println(s[0] + "--" + s[1] + "--" + s[2]);
file.renameTo(new File(path + "/" + s[0] + "." + s[1]));
}
}
}

public static void main(String[] args) {
rename("E:\\develop\\xampp\\tomcat\\webapps\\ROOT\\jwchat", "zh_CN");
}
}


2.3 install Jabber HTTP Binding Servlet

download these zip and extract it in webapps\ROOT\WEB-INF\lib\


image


my webapps\ROOT\WEB-INF\web.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"

version="3.0"
metadata-complete="true">

<servlet>
<servlet-name>Jabber HTTP Binding Servlet</servlet-name>
<servlet-class>org.jabber.JabberHTTPBind.JHBServlet</servlet-class>
<!--
<init-param>
<param-name>debug</param-name>
<param-value>1</param-value>
</init-param>
-->
</servlet>

<servlet-mapping>
<servlet-name>Jabber HTTP Binding Servlet</servlet-name>
<url-pattern>/JHB/</url-pattern>
</servlet-mapping>

<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>

</web-app>



2.4 start tomcat


my tomcat server port is 8080,so it address is http://localhost:8080/jwchat/


image


switch " Nativa Binding " => "Open delay", Server:"localhost" username and password your can random input,for example,i input username and password with same value "pkrss",then checked "register new account", click "Login"


image


ok!


3.last webim


3.1 introduction


these project is from where internet sample.it used Jabber HTTP Binding Servlet and JSJaC.js.


it it so simple.so i add these project to here.


3.1 downlaod


download this zip , it used netbeans and can used other java ide.


it run as:


image


4.thanks!

Saturday, December 28, 2013

yii 集成taobao php代码

1.下载php版taobao代码

下载地址:http://open.taobao.com/doc/detail.htm?id=112

2.程序目录结构

原始taobao结构:

image

修改后集成进yii的文件结构:

image

3.开始工作

1.把下载的程序结构解压,我放进了我的yii模块union中。

2.删除jushita、lotusphp_runtime目录

3.在top\目录下新建LtInflector.php、LtLogger.php两个文件

LtInflector.php 代码:

<?php
class LtInflector
{
public $conf = array("separator" => "_");

public function camelize($uncamelized_words)
{
$uncamelized_words = $this->conf["separator"] . str_replace($this->conf["separator"] , " ", strtolower($uncamelized_words));
return ltrim(str_replace(" ", "", ucwords($uncamelized_words)), $this->conf["separator"] );
}

public function uncamelize($camelCaps)
{
return strtolower(preg_replace('/([a-z])([A-Z])/', "$1" . $this->conf["separator"] . "$2", $camelCaps));
}
}

LtLogger.php 代码:

<?php
class LtLogger
{
public $conf = array(
"separator" => "\t"
);

public function log($logData)
{
if (is_array($logData))
{
$logData = implode($this->conf["separator"], $logData);
}
Yii::log($logData);
}
}




4.完成改造,调用示例:


protected\modules\union\controllers\TaobaoController.php代码:

<?php

if(!defined('TOP_SDK_WORK_DIR')){
define('TOP_SDK_WORK_DIR',dirname(__FILE__).'/../tmp/');
}

include 'taobao/TopSdk.php';

class TaobaoController extends CController
{
public $menuitems;
public $taobaoClient;

public function init(){
parent::init();
//$this->menuitems = Yii::app()->getModule('union')->menuitems;
return true;
}

public function actionIndex()
{
//将下载SDK解压后top里的TopClient.php第8行$gatewayUrl的值改为沙箱地址:http://gw.api.tbsandbox.com/router/rest,
//正式环境时需要将该地址设置为:http://gw.api.taobao.com/router/rest

$taobaoConfig = Yii::app()->getModule('union')->taobaoConfig;

//实例化TopClient类
$c = new TopClient;
if(defined('YII_DEBUG') && YII_DEBUG){
$c->appkey = $taobaoConfig['sandbox_appkey'];
$c->secretKey = $taobaoConfig['sandbox_secretKey'];
$c->sessionkey= $taobaoConfig['sandbox_sessionKey'];
$c->gatewayUrl = 'http://gw.api.tbsandbox.com/router/rest';
}else{
$c->appkey = $taobaoConfig['appkey'];
$c->secretKey = $taobaoConfig['secretKey'];
$c->sessionkey= $taobaoConfig['sessionKey'];
}

// $c->sessionkey= "test"; //如沙箱测试帐号sandbox_c_1授权后得到的sessionkey
$this->taobaoClient = $c;
$this->render('index',array(
'taobaoClient' => $c,
));
}
}

protected\modules\union\UnionModule.php代码:


<?php

class UnionModule extends CWebModule {

public $taobaoConfig = array();

/**
* @var array
* @desc Behaviors for models
*/
public $componentBehaviors = array();

public function init() {
// this method is called when the module is being created
// you may place code here to customize the module or the application
// import the module-level models and components
$this->setImport(array(
'union.models.*',
'union.components.*',
'union.components.taobao.top.*',
'union.components.taobao.top.request.*',
'ext.bootstrap.widgets.*',
'ext.bootstrap.helpers.*',
'ext.bootstrap.behaviors.*',
));
}

public function getBehaviorsFor($componentName) {
if (isset($this->componentBehaviors[$componentName])) {
return $this->componentBehaviors[$componentName];
} else {
return array();
}
}

public function beforeControllerAction($controller, $action) {

if (parent::beforeControllerAction($controller, $action)) {
// this method is called before any module controller action is performed
// you may place customized code here
return true;
} else
return false;
}

/**
* @param $str
* @param $params
* @param $dic
* @return string
*/
public static function t($str = '', $params = array(), $dic = 'union') {
if (Yii::t("UnionModule", $str) == $str) {
return Yii::t("UnionModule." . $dic, $str, $params);
} else {
return Yii::t("UnionModule", $str, $params);
}
}

}
protected\modules\union\views\taobao\index.php代码:
<?php


//实例化具体API对应的Request类
$req = new UserSellerGetRequest;
$req->setFields("nick,user_id,type");
//$req->setNick("sandbox_c_1");

//执行API请求并打印结果
$resp = $taobaoClient->execute($req,$this->taobaoClient->sessionkey);
echo "result:";
print_r($resp);
echo "<br>";
//echo "nick:".$req->getNick();
?>



Monday, December 23, 2013

jabberd2 debug analyze – startup

1.c2s

1.1.entry point code

in jabberd2\c2s\main.c line:608

JABBER_MAIN("jabberd2c2s", "Jabber 2 C2S", "Jabber Open Source Server: Client to Server", "jabberd2router\0")

1.

2.profile file


in jabberd2\win32\bin\debug\c2s.xml


search keywords "sqlite" and "mysql",and change these value.


i changed: "authreg –> module" from "sqlite" to "mysql"


1.3. import mysql db data


import jabberd2\win32\db-setup.mysql to mysql.


add user:

CREATE USER 'jabberd2'@'localhost' IDENTIFIED BY  '***';

GRANT ALL PRIVILEGES ON * . * TO 'jabberd2'@'localhost' IDENTIFIED BY '***' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;



2.sm


2.1 profile file


in jabberd2\win32\bin\debug\sm.xml


search keywords "sqlite" and "mysql",and change these value.


i changed: "storage –> driver" from "sqlite" to "mysql"

jabberd2 debug analyze – startup

1.c2s

1.1.entry point code

in jabberd2\c2s\main.c line:608

JABBER_MAIN("jabberd2c2s", "Jabber 2 C2S", "Jabber Open Source Server: Client to Server", "jabberd2router\0")

1.

2.profile file


in jabberd2\win32\bin\debug\c2s.xml


search keywords "sqlite" and "mysql",and change these value.


i changed: "authreg –> module" from "sqlite" to "mysql"


1.3. import mysql db data


import jabberd2\win32\db-setup.mysql to mysql.


add user:

CREATE USER 'jabberd2'@'localhost' IDENTIFIED BY  '***';

GRANT ALL PRIVILEGES ON * . * TO 'jabberd2'@'localhost' IDENTIFIED BY '***' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;



2.sm


2.1 profile file


in jabberd2\win32\bin\debug\sm.xml


search keywords "sqlite" and "mysql",and change these value.


i changed: "storage –> driver" from "sqlite" to "mysql"

Tuesday, December 17, 2013

yii php develop log – bootstrap TbThumbnails widget

1.screenshots:

url:http://localhost/mw2/exam/exam/locale

image

2.code

mw2\protected\modules\exam\views\exam\locale.php:

<?php 
$this->widget('bootstrap.widgets.TbThumbnails', array(
'dataProvider'=>new CArrayDataProvider(Yii::app()->getModule('rss')->getLocaleList()),
'template'=>"{items}\n{pager}",
'itemView'=>'_localethumb',
));

?>



mw2\protected\modules\exam\views\exam\_localethumb.php:

<li class="span3">
<a href="#" class="thumbnail" rel="<?php echo $data['country'] ?>" data-title="<?php echo $data['country'] ?>">
<img src="/s/images/flags/<?php echo $data['locale'] ?>.png" alt="<?php echo $data['country'] ?>">
</a>
</li>




mw2\protected\modules\rss\RssModule.php:

<?php

class RssModule extends CWebModule
{
//... other code

public function getLocaleList($all = false){
$rows = RssLocaleModel::model()->findAll($all ? null : 'rssstatus=1');
$ret = array();
foreach($rows as $row)
$ret []= $row->getAttributes();
return $ret;
}

}




data table pkrss_rsslocale:

CREATE TABLE `pkrss_rsslocale` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`locale` varchar(32) NOT NULL,
`country` varchar(64) DEFAULT NULL,
`encoding` varchar(32) DEFAULT 'utf-8',
`defaultcatalogid` int(11) NOT NULL,
`ucatid` int(11) NOT NULL,
`rssstatus` int(11) NOT NULL DEFAULT '0',
`timezone` varchar(64) DEFAULT NULL,
`pid` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `locale` (`locale`),
KEY `defaultcatalogid` (`defaultcatalogid`)
)



3.end


thanks!

Monday, December 16, 2013

Inspirational - good saying

1、一杯清水因滴入一滴污水而变污浊,一杯污水却不会因一滴清水的存在而变清澈。
         A drop of  dirty water will contaminate a glass of clean water, whereas a drop of clean water will not purify a glass of dirty water.
2、这世上有三样东西是别人抢不走的:一是吃进胃里的食物,二是藏在心中的梦想,三是读进大脑的书。
        There are three things in the world that people can not take away from you: the food in your stomach, the dream in your bosom, and the knowledge in your mind.
3、马在松软的土地上易失蹄,人在甜言蜜语中易摔跤。
       Horses are liable to stumble over soft grounds, so are people over sweet talks.
4、世界没有悲剧和喜剧之分,如果你能从悲剧中走出来,那就是喜剧,如果你沉缅于喜剧之中,那它就是悲剧。

       There is no distinction between tragedy and comedy.  The tragedy you can get over from is a piece of comedy; the comedy you indulge yourself with is a piece of tragedy.

5、如果不读书,行万里路也不过是个邮差。
       Without reading, you are nothing but a mailman even you've trod thousands of miles.
6、当你的邻居在深夜两点弹钢琴时你别气恼,你可以在四点钟时叫醒他,并告诉他你很欣赏他的演奏。
       Don't get riled up when your neighbor plays piano at two o'clock in the morning; you can wake him up at four and tell him of your admiring his performance.
7、如果你只是等待,发生的事情只会是你变老了。
        If you do nothing but wait, you'll find the only thing would happen is your getting old.
8、真正的朋友不是在一起有聊不完的话,而是即使不说一句话也不觉得尴尬。
        Real friendship doesn't mean endless talks when people getting together; instead, it means no need of an ice-breaker even there is only silence between them.
9、时间是治疗心灵创伤的大师,但绝不是解决问题的高手。

       Time is a master of curing trauma, but absolutely not an expert in solving problems.

10、宁愿做过了后悔,也不要错过了后悔。

       It'd better regret of doing something, rather than regret of missing something.

=B7=D6=B3=C9=D5=CB=B5=A5

------=_Part_1982_3663766.1387200585828
Content-Type: text/html;charset=GB2312
Content-Transfer-Encoding: quoted-printable




=B7=D6=B3=C9=D5=CB=B5=A5

body{font-size:12px;text-align:center;}
#wrap img{border:none;}
#wrap a{color:#094faa;text-decoration:none;}
#wrap *{padding:0;margin:0;}
#wrap i{font-style:normal;}
#wrap .left{float:left;width:402px;}
#wrap .right{float:left;width:185px;padding-top:93px;}
#wrap .right a{margin-bottom:21px;display: block;}
#wrap .left dl{padding:119px 0 0 41px;}
#wrap .left h3{background:url(http://u5.mm-img.com/rs/res/publish/settlemen=
t/images/h3bg.jpg) no-repeat;color:#0a4a85;font-size:12px;height:25px;paddi=
ng:22px 0 14px 43px;margin-top: 12px;}
#wrap .left dt{padding-bottom:13px;}
#wrap .left dt i{font-size:14px;font-weight:bold;color:#004395;}
#wrap .left dd{line-height:20px;width:305px;text-indent:24px;}
#wrap .left dd i{font-weight:bold;font-size:14px;color:#fe0000;}
#wrap{width:598px;border:1px solid #e0e0e0;background:url(http://u5.mm-img.=
com/rs/res/publish/settlement/images/topbg.jpg) top no-repeat;padding-botto=
m:22px;margin:0 auto;text-align:left;}

#wrap .list{text-align:center;width:309px;margin-left: 38px;border-bottom:1=
px solid #7ec0f6;padding-bottom:4px;}
#wrap .list th{color:#4f4f4f;font-weight:normal;margin-bottom:-1px;}
#wrap .list .title{background:#f2f7fb url(http://u5.mm-img.com/rs/res/publi=
sh/settlement/images/thbg.jpg) no-repeat top left;height:30px;line-height:3=
0px;}
#wrap .list td{height:30px;line-height:30px;border-top:1px solid #eee;}
#wrap .list td a{text-decoration: underline;}
#wrap .txt{background:url(http://u5.mm-img.com/rs/res/publish/settlement/im=
ages/bottombg.jpg) left bottom no-repeat;width:385px;margin:0 0 12px 8px;li=
ne-height:20px;}
#wrap .txt p{padding:15px 40px 20px 41px;}
#wrap .txt a{font-size:14px;font-weight:bold;text-decoration:underline;}
#wrap .clearboth{height:0;clear:both;display:block;}
#wrap .tip{padding:19px 0 0 18px;background:url(http://u5.mm-img.com/rs/res=
/publish/settlement/images/tipbg.jpg) no-repeat 387px -10px;}
#wrap .tip h2{color:#f00;font-size:14px;padding-bottom:9px;}
#wrap .tip .brief{text-indent:24px;width:360px;line-height:20px;padding-bot=
tom:12px;}
#wrap .tipdetail{border:1px solid #aec5e3;width:558px;background:url(http:/=
/u5.mm-img.com/rs/res/publish/settlement/images/line.jpg) repeat-x bottom;p=
adding:12px 1px 20px 9px;margin-bottom:12px;}
#wrap .tipdetail .bd{margin:0 15px;border-top:1px dashed #a9c2e3;}
#wrap .tipdetail dd{line-height:24px;}
#wrap .tipdetail dd a{ text-decoration:underline;}
#wrap .tipdetail i{color:#f00;font-weight:bold;}
#wrap .pl12{padding-left:12px;}
#wrap .link1{float:left;display:inline;margin:0 0 0 9px;}
#wrap .link2{float:right;display:inline;margin:22px 12px 0 0;}






=09

=09
=C1=AC=B5=C2=C1=C1 =A3=AC=C4=E3=BA=C3=A3=BA

=09

=C4=FA=D4=DA=D2=C6=B6=AF=D3=A6=D3=C3=C9=CC=B3=A1=A3=A8Mobile =
Market=A3=A9 2013=C4=EA11=D4=C2=B5=C4=B7=D6=B3=C9=BD=E1=CB=E3=CA=D5=
=C8=EB=BA=CF=BC=C6=CE=AA=A3=BA21 =D4=AA=A1=A3=C8=E7=C4=FA=B1=BE=
=C6=DA=BD=E1=CB=E3=CA=D5=C8=EB=B5=BD=B4=EF5000=D4=AA=BB=F2=D2=D4=C9=CF=A3=
=AC=C7=EB=C4=FA=B0=B4=D5=D5=BF=AA=B7=A2=D5=DF=C9=E7=C7=F8=C9=CF=B5=C4=BD=D3=
=CA=D5=B7=A2=C6=B1=B0=B2=C5=C5=B9=AB=B8=E6=A3=AC=CD=EA=B3=C9=B7=A2=C6=B1=B5=
=C4=CC=E1=BD=BB=A1=A3=D0=BB=D0=BB=A3=A1

=09

•=B7=D6=B3=C9=D5=CB=B5=A5=C3=F7=CF=B8•








=09=09=09
=D3=A6=D3=C3=C3=FB=B3=C6 =D2=B5=CE=F1=B4=FA=C2=EB =CA=D5=C8=EB
=D3=EF=D2=F4=C9=E8=D6=C3=BB=CA227=
1932701
23.1


=09

=C8=E7=D0=E8=B2=E9=D1=AF=C9=CF=D4=C2=BD=E1=CB=E3=CA=D5=C8=EB=
=A3=AC=C7=EB=B5=E3=BB=F7=B4=CB=B4=A6=B5=C7=C2=BD=BF=AA=B7=A2=D5=DF=C9=E7=C7=F8=
=D7=D4=B7=FE=CE=F1=C7=F8=B2=E9=D1=AF=A1=A3






=09
=09
=09
=09



=09

=CE=C2=DC=B0=CC=E1=CA=BE:


=C8=E7=D0=E8=CC=E1=B3=F6=B6=D4=D5=CB=C9=EA=C7=EB=
=A3=AC=C7=EB=D3=EB=BD=E1=CB=E3=B5=A5=B7=A2=B2=BC=B5=C430=B8=F6=D7=D4=C8=BB=
=C8=D5=C4=DA=A3=AC=B5=C7=C2=BD=BF=AA=B7=A2=D5=DF=C9=E7=C7=F8=D7=D4=B7=FE=CE=
=F1=C7=F8=B5=C4=BD=E1=CB=E3=B5=A5=B2=E9=D1=AF=BD=F8=D0=D0=C9=EA=C7=EB=A1=A3=



=09

=C8=E7=B9=FB=C4=FA=D3=D0=C8=CE=BA=CE=D2=C9=CE=CA,=C7=EB=
=C1=AA=CF=B5=BF=CD=B7=FE=D7=C9=D1=AF

=C1=AA=CF=B5=B7=BD=CA=BD=C8=E7=CF=C2=A3=BA

•=D6=D0=B9=FA=D2=C6=B6=AF=BF=AA=B7=A2=D5=DF=C9=E7=
=C7=F8=B7=FE=CE=F1=D3=CA=CF=E4=A3=BAapservice@chinamobile.com=A3=BB


•=B7=C9=D0=C5=BF=CD=B7=FE=BA=C5=A3=BA855552270=A3=BB


•139=CB=B5=BF=CD=B7=FE=CE=F1=A3=BA

1=A1=A2=B1=E0=BC=AD=B6=CC=D0=C5=A3=AC=B7=
=A2=CB=CD=A1=B0T=A1=B1=D6=C1106581039952228058=BC=B4=BF=C9=A1=A3

2=A1=A2=B5=C7=C2=BC139=CB=B5=BF=CD=A3=AC=
=D4=DA=D3=D2=B2=E0=B5=C4=A1=B0=B2=E9=D5=D2=CB=B5=BF=CD=A1=B1=D6=D0=CA=E4=C8=
=EB =A1=B0=BF=AA=B7=A2=D5=DF=BF=CD=B7=FE=A1=B1=BD=F8=D0=D0=B2=E9=D5=D2=A3=
=AC=C8=BB=BA=F3=B5=E3=BB=F7=A1=B0=CC=FDTA=CB=B5=A1=B1=BC=B4=BF=C9=A1=A3

3=A1=A2=B5=C7=C2=BC139=CB=B5=BF=CD=A3=AC=
=D4=DA=D3=D2=B2=E0=B5=C4=A1=B0=B2=E9=D5=D2=CB=B5=BF=CD=A1=B1=D6=D0=CA=E4=C8=
=EB =A1=B0=BF=AA=B7=A2=D5=DF=BF=CD=B7=FE=A1=B1=BD=F8=D0=D0=B2=E9=D5=D2=A3=
=AC=C8=BB=BA=F3=B5=E3=BB=F7=A1=B0=CC=FDTA=CB=B5=A1=B1=BC=B4=BF=C9=A1=A3



=B8=D0=D0=BB=C4=FA=
=B6=D4=D2=C6=B6=AF=D3=A6=D3=C3=C9=CC=B3=A1(Mobile Market)=B9=D8=D7=A2=D3=EB=
=D6=A7=B3=D6=A3=A1

=D6=D0=B9=FA=D2=C6=
=B6=AF=BF=AA=B7=A2=D5=DF=C9=E7=C7=F8







------=_Part_1982_3663766.1387200585828--

Saturday, December 14, 2013

php develop log–yii yiic mirgate

1.error

Error: The migration directory does not exist: user.migrations

 




or

Yii Migration Tool v1.0 (based on Yii v1.1.14)

Creating migration history table "tbl_migration"...done.
Total 2 new migrations to be applied:
m110805_153437_installYiiUser
m110810_162301_userTimestampFix

Apply the above migrations? (yes|no) [no]:y
*** applying m110805_153437_installYiiUser
Exception: Alias "user.UserModule" is invalid. Make sure it points to an existin
g PHP file and the file is readable. (D:\doc\webserver\wwwroot\third\yii\YiiBase
.php:322)
#0 D:\doc\webserver\wwwroot\third\yii\YiiBase.php(196): YiiBase::import('user.Us
erModule'
, true)
#1 D:\doc\webserver\wwwroot\third\yii\base\CModule.php(282): YiiBase::createComp
onent('user.UserModule', 'user', NULL, Array)
#2 D:\doc\webserver\wwwroot\mw2\protected\migrations\m110805_153437_installYiiUs
er.php(10): CModule->getModule('user')
#3 D:\doc\webserver\wwwroot\third\yii\db\CDbMigration.php(53): m110805_153437_in
stallYiiUser->safeUp()
#4 D:\doc\webserver\wwwroot\third\yii\cli\commands\MigrateCommand.php(386): CDbM
igration->up()
#5 D:\doc\webserver\wwwroot\third\yii\cli\commands\MigrateCommand.php(110): Migr
ateCommand->migrateUp('m110805_153437_...')
#6 [internal function]: MigrateCommand->actionUp(Array)
#7 D:\doc\webserver\wwwroot\third\yii\console\CConsoleCommand.php(172): Reflecti
onMethod->invokeArgs(Object(MigrateCommand), Array)
#8 D:\doc\webserver\wwwroot\third\yii\console\CConsoleCommandRunner.php(71): CCo
nsoleCommand->run(Array)
#9 D:\doc\webserver\wwwroot\third\yii\console\CConsoleApplication.php(92): CCons
oleCommandRunner->run(Array)
#10 D:\doc\webserver\wwwroot\third\yii\base\CApplication.php(180): CConsoleAppli
cation->processRequest()
#11 D:\doc\webserver\wwwroot\third\yii\yiic.php(33): CApplication->run()
#12 D:\doc\webserver\wwwroot\mw2\protected\yiic.php(7): require_once('D:\doc\web
serve...'
)
#13 {main}
*** failed to apply m110805_153437_installYiiUser (time: 0.008s)


Migration failed. All later migrations are canceled.
or
Add to console.php :
'modules'=>array(
...
'user'=>array(
... # copy settings from main config
),
...
),

*** failed to apply m110805_153437_installYiiUser (time: 0.005s)

 




2.why


i want to add this plugin: http://www.yiiframework.com/extension/yii-user/ ,


my yii worked path is D:\doc\webserver\wwwroot\mw2\


and mw2 is not generated by cmd: yii webapp D:\doc\webserver\wwwroot\mw2\,it created by manual.


3.fixed


3.1 regenerate it


now i rename mw2,and cmd:

yii webapp D:\doc\webserver\wwwroot\mw2\

 




it generate some files,and override old mw2 files in it.


3.2 unpack


unpack yii-user-0.3-61-gfc69518.zip,and extract all files to D:\doc\webserver\wwwroot\mw2\protected\modules\user\


like it:


image


3.3 modify config file


D:\doc\webserver\wwwroot\mw2\protected\config\ main.php and config.php


main.php:

<?php

include dirname(__FILE__).'/../../config.inc.php';

// This is the main Web application configuration. Any writable
// application properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'pkrss v2',

'theme'=>'bootstrap',

// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',

'application.modules.user.models.*',
'application.modules.user.models.user.*',
'application.modules.user.components.*',

'ext.bootstrap-theme.widgets.*',
'ext.bootstrap-theme.helpers.*',
'ext.bootstrap-theme.behaviors.*',
),

'modules'=>array(
'user'=>array(
# encrypting method (php hash function)
'hash' => 'md5',

# send activation email
'sendActivationMail' => true,

# allow access for non-activated users
'loginNotActiv' => false,

# activate user on registration (only sendActivationMail = false)
'activeAfterRegister' => false,

# automatically login from registration
'autoLogin' => true,

# registration path
'registrationUrl' => array('/user/registration'),

# recovery password path
'recoveryUrl' => array('/user/recovery'),

# login form path
'loginUrl' => array('/user/login'),

# page after login
'returnUrl' => array('/user/profile'),

# page after logout
'returnLogoutUrl' => array('/user/login'),
),

'gii' => array(
'generatorPaths'=>array(
'ext.bootstrap-theme.gii',
),
),
),

// application components
'components'=>array(
'cache'=>array(
'class'=>'system.caching.CDbCache',
'autoCreateCacheTable'=>false,
'cacheTableName'=>PKRSS_DB_TABLEPREFIX . 'yiicache',
'connectionID'=>'db',
),
'db'=>array(
'class'=>'CDbConnection',
'connectionString'=>PKRSS_DB_CONNECTIONSTRING,
'username'=>PKRSS_DB_USERNAME,
'password'=>PKRSS_DB_PASSWORD,
'tablePrefix' => PKRSS_DB_TABLEPREFIX,
'charset' => 'utf8',
'emulatePrepare'=>true, // needed by some MySQL installations
),
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'user/<controller:\w+>/'=>'user/<controller>',
'<subdir:\w+>/<controller:\w+>/<action:\w+>'=>'<subdir>/<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
'user'=>array(
// enable cookie-based authentication
'class' => 'WebUser',
'allowAutoLogin'=>true,
'loginUrl' => array('/user/login'),
),
'bootstrap'=>array(
'class'=>'bootstrap.components.Bootstrap',
),
),

// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=> PKRSS_ADMINEMAIL,
),
);

 




console.php:

<?php

include dirname(__FILE__).'/../../config.inc.php';

// This is the configuration for yiic console application.
// Any writable CConsoleApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Console Application',

// preloading 'log' component
'preload'=>array('log'),


// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',

'application.modules.user.models.*',
'application.modules.user.components.*',

'ext.bootstrap-theme.widgets.*',
'ext.bootstrap-theme.helpers.*',
'ext.bootstrap-theme.behaviors.*',
),

'modules'=>array(
'user'=>array(
# encrypting method (php hash function)
'hash' => 'md5',

# send activation email
'sendActivationMail' => true,

# allow access for non-activated users
'loginNotActiv' => false,

# activate user on registration (only sendActivationMail = false)
'activeAfterRegister' => false,

# automatically login from registration
'autoLogin' => true,

# registration path
'registrationUrl' => array('/user/registration'),

# recovery password path
'recoveryUrl' => array('/user/recovery'),

# login form path
'loginUrl' => array('/user/login'),

# page after login
'returnUrl' => array('/user/profile'),

# page after logout
'returnLogoutUrl' => array('/user/login'),
),

'gii' => array(
'generatorPaths'=>array(
'ext.bootstrap-theme.gii',
),
),
),
// application components
'components'=>array(
'db'=>array(
'class'=>'CDbConnection',
'connectionString'=>PKRSS_DB_CONNECTIONSTRING,
'username'=>PKRSS_DB_USERNAME,
'password'=>PKRSS_DB_PASSWORD,
'tablePrefix' => PKRSS_DB_TABLEPREFIX,
'charset' => 'utf8',
'emulatePrepare'=>true, // needed by some MySQL installations
),
'user'=>array(
// enable cookie-based authentication
'class' => 'WebUser',
'allowAutoLogin'=>true,
'loginUrl' => array('/user/login'),
),
// uncomment the following to use a MySQL database
/*
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=testdrive',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
),
*/
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
),
),
),
);
config.inc.php
<?php

defined('YII_DEBUG') or define('YII_DEBUG',true);
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);

define('PKRSS_DB_CONNECTIONSTRING','mysql:host=localhost;dbname=sp500ccbd11028f');
define('PKRSS_DB_USERNAME','root');
define('PKRSS_DB_PASSWORD','');

define('PKRSS_DB_TABLEPREFIX','pkrss_');
define('PKRSS_ADMINEMAIL','liandeliang@gmail.com');


define('PKRSS_DB_LOCALE_CACHE_SECONDS',30);

define('PKRSS_CACHE_ENABLED',true);

 






3.3 migrate


then cmd:

D:\doc\webserver\wwwroot\mw2\protected>yiic migrate --migrationPath=application.modules.user.migrations

 




 


4.result


success.


then i called:http://localhost/mw2/user/ , if i logined it, may called index.php is 404,but the error not relative above. tks.


screen shots:


image

Inspirational: Opportunity die in seven words in!

转: 机会,就死在这7句话里!

Forwarding : Opportunity to die in seven words in!

大多数的机会,都死在别人的嘴里:

Most opportunities are dead in someone else's mouth:

1:认为骗人。不去认真了解,直接下定论。一锤子砸死,导致丧失机会。要仔细想一下,别人能骗你什么呢?骗财还是骗色呢?最坏的是怎么样。

1: that the lie. Do not really understand, direct conclusion. A hammer killed, resulting in lost opportunities. To carefully think about what people can lie to you? Defraud or Pianse it? The worst is how.

2:迟疑。思想斗争时间过长,迟迟不下决定,把新闻熬成了历史。这和我们买衣服一样,今天看了一件衣服感觉很漂亮,想要买,但是嫌贵迟疑了,过几天衣服却不再了,或者已经失去了购买的欲望。趁热打铁是非常重要的。

2: hesitation. Ideological struggle for too long, less than delay the decision, the news revolve history. That and we buy clothes, today saw a dress I feel very beautiful, you want to buy, but too expensive hesitated a few days of clothes but no longer, or have lost the desire to buy. While the iron is very important.

3:研究。很有兴趣的从学术方面研究其理论,阐述其观点,放弃实践。研究会把自己搞复杂,成功者都是简单的人。选择都是看第一感觉的。

3: Research. Very interested in research from academic theory to explain their point of view, to abandon the practice. Research will engage in their own complicated winners are simple people. Select all look at the first feeling.

4:问错人。询问不懂行的人,想做服装却去问开宠物店的人,他会叫你开宠物店好了。询问在同行没做成功的人,开服装店去问曾经倒闭过的人,你应问做成功赚了钱的人。

4: asking the wrong person. Ask people do not understand the line, wants to open a clothing store but ask people who open pet store , he will tell you to open a pet store better. Asked people in the peer did not do successful, to ask the person have closed down over clothing stores , you should ask people to do successfully make money.

5:别人说。别人说的真那么重要吗?某某人结婚两天就离婚了,我看你就别结婚了!

5: others said. Others say really important? Certain people get married divorced two days, I see you do not get married!

6:有难度。所有商业机会都是早期比较赚钱,因为很多人不知道。等很多人知道了,你已经出人头地了!做都没做,想就把自己想死了,穷。

6: difficult. All business opportunities are relatively early money, because many people do not know. And many people know, you have to get ahead of the! Do not do anything, wanted to put his wish to die, and the poor.

7:这个和那个差不多。类似的东西很多,但你要看到本质的不同!说实话的,死人跟活人也差不多,就差一口气。能差不多吗?差不多的东西都差很多。

7: this and that about the same. Something like that a lot, but you need to see a different nature! To tell the truth, dead samed with the living, but sent a deep breath. Can the same? Almost everything a lot worse.

点评:与其说是死在别人的嘴里,不如说是死在自己的思维方式和心态里。

Comments: not so much dead in someone else's mouth, as it is dead in his way of thinking and mentality in.

原文

Friday, December 13, 2013

应用发布进展通知(2013年12月13日)

------=_Part_3201_18352639.1386896404164
Content-Type: text/html;charset=GB2312
Content-Transfer-Encoding: quoted-printable





.maintable {
=09background-color:#EBF7F8;
=09bordercolor:#9FCCEC;
=09border-top:1px solid #9FCCEC;
=09border-left:1px solid #9FCCEC;
=09width: 60%;
}
.yi_hang_4 {
=09float:left;
=09text-indent: 15px;
=09padding-left: 5px;
=09font-family: "=CB=CE=CC=E5";
=09font-size: 12px;
=09color: black;
=09line-height: 1.7em;
=09padding-top: 2px;
=09padding-bottom: 2px;
=09background-color: #EBF7F8;
=09text-align: right;
}
.titletd {
=09font-family: "=CB=CE=CC=E5";
=09font-size: 12px;
=09color: black;
=09line-height: 1.7em;
=09padding-top: 2px;
=09padding-bottom: 2px;
=09text-align: center;
}
.yi_hang_9 {
=09font-family: "=CB=CE=CC=E5";
=09font-size: 12px;
=09line-height: 1.7em;
=09background-color: #FFFFFF;
}
td {
=09font-family: "=CB=CE=CC=E5";
=09font-size: 12px;
=09line-height: 1.7em;
}
.noWarp{
=09width:60%;
=09white-space:normal;
=09word-break:break-all;
}
a:visited {
=09color: #000000;
=09text-decoration: none;
}
a:active {
=09color: #FF0000;
=09text-decoration: none;
}
a:link {
=09color: #000000;
=09text-decoration: none;
}
.whitefont {
=09font-family: "=CB=CE=CC=E5";
=09color: #FFFFFF;
}
.menuborder {
=09background-color: #A9D8FC;
=09border: 1px solid #65B8F7;
}
.maintable a:link{
=09color:#0000ff;
=09}

.tablePager a:active{
=09color:#00008B;
}
.maintable a:hovor{
=09color:#0000ff;
}

.maintable a:visited{
=09color:#00008B;
}
.maintable td{
=09=09border-bottom:1px solid #9FCCEC;
=09=09border-right:1px solid #9FCCEC;
=09=09height:25px;
}

=20
=20


=09

=09=09 =D7=F0=BE=B4=B5=C4=BF=AA=B7=A2=D5=DF=A3=A8=C1=AC=B5=C2=C1=C1=A3=
=A9=A3=AC=C4=FA=BA=C3=A3=A1
=09=09
=09=09=09     =CE=C2=DC=B0=CC=E1=CA=
=BE=A3=BA=D6=D0=B9=FA=D2=C6=B6=AF=CE=AA=C4=FA=CC=E1=B9=A9=D5=E6=BB=FA=B2=E2=
=CA=D4=B7=FE=CE=F1=A1=A3=CC=E1=BD=BB=D3=A6=D3=C3=C7=B0=C4=E3=BF=C9=CF=C8=CA=
=B9=D3=C3=B4=CB=B7=FE=CE=F1=D7=F7=D7=D4=BC=EC=A1=A3
=BD=F8=C8=
=EB=D5=E6=BB=FA=B2=E2=CA=D4>>>>

=09=09=09
=09=09=09     =C4=FA=D4=DA=D6=D0=B9=FA=D2=C6=B6=AF=BF=
=AA=B7=A2=D5=DF=C9=E7=C7=F8=B7=A2=B2=BC=B5=C4=D3=A6=D3=C3=D7=EE=BD=FC24=D0=
=A1=CA=B1=C4=DA=D7=B4=CC=AC=B1=E4=BB=AF=C7=E9=BF=F6=C8=E7=CF=C2=A3=BA
=09


=09=09

=09=09

    =09=09 =09=09
    =09=09=09=09=20
    =09=09=09=09=20
    =09=09=09=09=20
    =09=09=09=09
    =09=09=09=09=20
    =09=09=09=09 =09=09=09=09
  • =D2=D4=CF=C2=D3=A6=D3=C3=
    =CE=B4=C4=DC=CD=A8=B9=FD=D4=A4=B2=E2=CA=D4=A3=AC=BE=DF=CC=E5=D4=AD=D2=F2=C7=
    =EB=B5=C7=C2=BC=BF=AA=B7=A2=D5=DF=C9=E7=C7=F8=BA=F3=D4=DA=A1=B0=D3=A6=D3=C3=
    =B2=E9=D1=AF=BC=B0=D0=DE=B8=C4=A1=B1=D6=D0=B5=C4=CF=E0=B9=D8=D2=B3=C3=E6=B2=
    =E9=D4=C4=A3=BA
  • =09
    =09=09=09=09=20
    =09=09=09=09 =09
    =09=09=09=09
    =09=09=09=09=09
    =09=09=09=09=09=09
    =09=09=09=09=09=09
    =09=09=09=09=09
    =09=09=09=09=09=20
    =09=09=09=09=09 =09=09=09=09=09
    =09=09=09
    =09=09=09=09=09=09
    =09=09=09=09=09=09
    =09=09=09=09=09
    =09=09=09=09=09 =09=09=09=09=09
    =09=09=09=09=09 =09=09=09=09=09=20
    =09=09=09=09=09
    =09=09=09=09
    =D3=A6=D3=C3=C3=FB=
    =B3=C6
    =D3=A6=D3=C3=B4=FA=
    =C2=EB
    =D3=A6=D3=C3=B7=D6=
    =C0=E0

    =09=09=09=09 =BB=FA=B9=D8=CD=F5
    =09=09=09=09=09=09

    =09=09=09=09 =B4=FD=B7=D6=C5=E4
    =09=09=09=09=09=09

    =09=09=09=09 =D3=A6=D3=C3=D3=CE=CF=B7
    =09=09=09=09=09=09

    =09=09=09=09
    =09=09=09=09=09=09 =A3=A8=D7=EE=B6=E0=C1=D015=D0=D0=A3=A9=B8=FC=B6=E0=
    =C7=EB=B5=C7=C2=BD=BF=AA=B7=A2=D5=DF=C9=E7=C7=F8=B2=E9=BF=B4
    =09=09=09=09=09=09=09
    =09=09
    =09=09=09=09=09=09
    =09=09=09=09=20
    =09=09=09=09=20
    =09=09=09=09
    =09=09=09=09=20
    =09=09=09=09=20
    =09=09=09=09=20
    =09=09=09=09 =09=09=09
=09
=09



=09=09

=09=09           &nbs=
p; 
=09=09=09 =B4=CB=CE=AA=CF=B5=CD=B3=D7=D4=B6=AF=CD=A8=D6=AA=D3=CA=BC=FE=A3=
=AC=C7=EB=CE=F0=D6=B1=BD=D3=BB=D8=B8=B4=A1=A3=B8=D0=D0=BB=D6=A7=B3=D6=A3=A1
=09=09

=09=09=20
=09=09

=09=09 =D6=D0=B9=FA=D2=C6=B6=AF=BF=AA=B7=A2=D5=DF=C9=E7=C7=F8 &nbs=
p;      
=09=09=09 2013=C4=EA12=D4=C213=C8=D5      &nb=
sp; 
=09=09=09
=09=09=09 =C1=AA=CF=B5=CE=D2=C3=C7      &=
nbsp; 
=09=09=09

=09=09

=09



------=_Part_3201_18352639.1386896404164--

Wednesday, December 11, 2013

应用发布进展通知(2013年12月11日)

------=_Part_2429_17299309.1386723615660
Content-Type: text/html;charset=GB2312
Content-Transfer-Encoding: quoted-printable





.maintable {
=09background-color:#EBF7F8;
=09bordercolor:#9FCCEC;
=09border-top:1px solid #9FCCEC;
=09border-left:1px solid #9FCCEC;
=09width: 60%;
}
.yi_hang_4 {
=09float:left;
=09text-indent: 15px;
=09padding-left: 5px;
=09font-family: "=CB=CE=CC=E5";
=09font-size: 12px;
=09color: black;
=09line-height: 1.7em;
=09padding-top: 2px;
=09padding-bottom: 2px;
=09background-color: #EBF7F8;
=09text-align: right;
}
.titletd {
=09font-family: "=CB=CE=CC=E5";
=09font-size: 12px;
=09color: black;
=09line-height: 1.7em;
=09padding-top: 2px;
=09padding-bottom: 2px;
=09text-align: center;
}
.yi_hang_9 {
=09font-family: "=CB=CE=CC=E5";
=09font-size: 12px;
=09line-height: 1.7em;
=09background-color: #FFFFFF;
}
td {
=09font-family: "=CB=CE=CC=E5";
=09font-size: 12px;
=09line-height: 1.7em;
}
.noWarp{
=09width:60%;
=09white-space:normal;
=09word-break:break-all;
}
a:visited {
=09color: #000000;
=09text-decoration: none;
}
a:active {
=09color: #FF0000;
=09text-decoration: none;
}
a:link {
=09color: #000000;
=09text-decoration: none;
}
.whitefont {
=09font-family: "=CB=CE=CC=E5";
=09color: #FFFFFF;
}
.menuborder {
=09background-color: #A9D8FC;
=09border: 1px solid #65B8F7;
}
.maintable a:link{
=09color:#0000ff;
=09}

.tablePager a:active{
=09color:#00008B;
}
.maintable a:hovor{
=09color:#0000ff;
}

.maintable a:visited{
=09color:#00008B;
}
.maintable td{
=09=09border-bottom:1px solid #9FCCEC;
=09=09border-right:1px solid #9FCCEC;
=09=09height:25px;
}

=20
=20


=09

=09=09 =D7=F0=BE=B4=B5=C4=BF=AA=B7=A2=D5=DF=A3=A8=C1=AC=B5=C2=C1=C1=A3=
=A9=A3=AC=C4=FA=BA=C3=A3=A1
=09=09
=09=09=09     =CE=C2=DC=B0=CC=E1=CA=
=BE=A3=BA=D6=D0=B9=FA=D2=C6=B6=AF=CE=AA=C4=FA=CC=E1=B9=A9=D5=E6=BB=FA=B2=E2=
=CA=D4=B7=FE=CE=F1=A1=A3=CC=E1=BD=BB=D3=A6=D3=C3=C7=B0=C4=E3=BF=C9=CF=C8=CA=
=B9=D3=C3=B4=CB=B7=FE=CE=F1=D7=F7=D7=D4=BC=EC=A1=A3
=BD=F8=C8=
=EB=D5=E6=BB=FA=B2=E2=CA=D4>>>>

=09=09=09
=09=09=09     =C4=FA=D4=DA=D6=D0=B9=FA=D2=C6=B6=AF=BF=
=AA=B7=A2=D5=DF=C9=E7=C7=F8=B7=A2=B2=BC=B5=C4=D3=A6=D3=C3=D7=EE=BD=FC24=D0=
=A1=CA=B1=C4=DA=D7=B4=CC=AC=B1=E4=BB=AF=C7=E9=BF=F6=C8=E7=CF=C2=A3=BA
=09


=09=09

=09=09

    =09=09 =09=09=09=09
  • =D2=D4=CF=C2=D3=A6=D3=C3=D2=D1=B3=C9=B9=A6=
    =B7=A2=B2=BC=A3=AC=CF=D6=B4=A6=D3=DA=A1=B0=D4=A4=B2=E2=CA=D4=A1=B1=BD=D7=B6=
    =CE=A3=AC=BE=B4=C7=EB=C1=F4=D2=E2=D4=A4=B2=E2=CA=D4=BD=E1=B9=FB=A3=BA
  • =
    =09
    =09=09=09=09=20
    =09=09=09=09 =09
    =09=09=09=09
    =09=09=09=09=09
    =09=09=09=09=09=09
    =09=09=09=09=09=09
    =09=09=09=09=09
    =09=09=09=09=09=20
    =09=09=09=09=09 =09=09=09=09=09 =09=09=09=09=09=09
    =09=09=09
    =09=09=09=09=09=09
    =09=09=09=09=09=09
    =09=09=09=09=09
    =09=09=09=09=09 =09=09=09=09=09=20
    =09=09=09=09=09
    =09=09=09=09=09 =09=09=09=09=09=09=20
    =09=09=09=09=09 =09=09=09=09=09=20
    =09=09=09=09
    =D3=A6=D3=C3=C3=FB=
    =B3=C6
    =D3=A6=D3=C3=B4=FA=
    =C2=EB
    =D3=A6=D3=C3=B7=D6=
    =C0=E0

    =09=09=09=09 =BB=FA=B9=D8=CD=F5
    =09=09=09=09=09=09

    =09=09=09=09 =B4=FD=B7=D6=C5=E4
    =09=09=09=09=09=09

    =09=09=09=09 =D3=A6=D3=C3=D3=CE=CF=B7
    =09=09=09=09=09=09

    =09=09=09=09
    =09=09=09=09=09=09 =A3=A8=D7=EE=B6=E0=C1=D015=D0=D0=A3=A9=B8=FC=B6=E0=
    =C7=EB=B5=C7=C2=BD=BF=AA=B7=A2=D5=DF=C9=E7=C7=F8=B2=E9=BF=B4
    =09=09=09=09=09=09=09
    =09=09
    =09=09=09=09=09=09
    =09=09=09=09=20
    =09=09=09=09=20
    =09=09=09=09
    =09=09=09=09 =09=09
    =09=09=09=09=20
    =09=09=09=09=20
    =09=09=09=09=20
    =09=09=09=09
    =09=09=09=09=20
    =09=09=09=09=20
    =09=09=09=09=20
    =09=09=09=09=20
    =09=09=09=09 =09=09=09
=09
=09



=09=09

=09=09           &nbs=
p; 
=09=09=09 =B4=CB=CE=AA=CF=B5=CD=B3=D7=D4=B6=AF=CD=A8=D6=AA=D3=CA=BC=FE=A3=
=AC=C7=EB=CE=F0=D6=B1=BD=D3=BB=D8=B8=B4=A1=A3=B8=D0=D0=BB=D6=A7=B3=D6=A3=A1
=09=09

=09=09=20
=09=09

=09=09 =D6=D0=B9=FA=D2=C6=B6=AF=BF=AA=B7=A2=D5=DF=C9=E7=C7=F8 &nbs=
p;      
=09=09=09 2013=C4=EA12=D4=C211=C8=D5      &nb=
sp; 
=09=09=09
=09=09=09 =C1=AA=CF=B5=CE=D2=C3=C7      &=
nbsp; 
=09=09=09

=09=09

=09



------=_Part_2429_17299309.1386723615660--

Saturday, December 7, 2013

yii develop log - test CActiveRecord

1.data tables

1.1 pkrss_test data table

CREATE TABLE IF NOT EXISTS `pkrss_test` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `k` varchar(255) NOT NULL,
  `v` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `k` (`k`)
) AUTO_INCREMENT=3 ;

INSERT INTO `pkrss_test` (`id`, `k`, `v`) VALUES
(1, 'k1', 'v1'),
(2, 'k2', 'v2');

1.2 pkrss_test2 data table

CREATE TABLE IF NOT EXISTS `pkrss_test2` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `k` varchar(255) NOT NULL,
  `v2` varchar(255) DEFAULT NULL,
  `pid` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `pid` (`pid`)
) AUTO_INCREMENT=3 ;

INSERT INTO `pkrss_test2` (`id`, `k`, `v2`, `pid`) VALUES
(1, 'k1', 'k1', 1),
(2, 'k2', 'v2', 2);

ALTER TABLE `pkrss_test2`
  ADD CONSTRAINT `pkrss_test2_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `pkrss_test` (`id`);

2.php code and test result

2.1 TestModel.php

<?php

/*
CREATE TABLE IF NOT EXISTS `pkrss_test` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`k` varchar(255) NOT NULL,
`v` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `k` (`k`)
) AUTO_INCREMENT=3 ;

INSERT INTO `pkrss_test` (`id`, `k`, `v`) VALUES
(1, 'k1', 'v1'),
(2, 'k2', 'v2');
*/
class TestModel extends CActiveRecord {

public static function model($className=__CLASS__)
{
return parent::model($className);
}

public function tableName()
{
return '{{test}}';
}

public $k='';
public $v='';

public function primaryKey()
{
return 'id';
}

public function relations()
{
return array(
'key'=>array(self::HAS_MANY, 'Test2Model', 'pid'),
);
}

public static function testFind(){

$model = self::model();

// return db object
$result = $model->find('k=:k',array(':k'=>'k1'));

// return data array
$result = $result->getAttributes();

// return null object
$result = $model->find('k=:k',array(':k'=>'none'));
if($result)
$result = $result->getAttributes();
}

public static function testFindAll(){

$model = self::model();

// return db object array
$result = $model->findAll('k=:k',array(':k'=>'k1'));
foreach($result as $row){
// return data array
$v = $row->getAttributes();
}

// return: array()
$result = $model->findAll('k=:k',array(':k'=>'null'));
// count($result) == 0
}

public static function testFindByPk(){

$model = self::model();

// return db object
$result = $model->findByPk(1);

// return: array(3) { ["id"]=> string(1) "1" ["k"]=> string(2) "k1" ["v"]=> string(2) "v1" }
$result = $result->getAttributes();

// return: NULL
$result = $model->findByPk(-1);

var_dump($result);
}

public static function testFindByAttributes(){

$model = self::model();

// return db object
$result = $model->findByAttributes(array('id'=>1),'k=:k',array(':k'=>'k1'));


// return: array(3) { ["id"]=> string(1) "1" ["k"]=> string(2) "k1" ["v"]=> string(2) "v1" }
$result = $result->getAttributes();

// return: NULL
$result = $model->findByAttributes(array('id'=>-1));
}

public static function testWithFindAll(){

$model = self::model();

// return db object
$result = $model->with('key')->findAll();
foreach($result as $row){
// return: array(3) { ["id"]=> string(1) "1" ["k"]=> string(2) "k1" ["v"]=> string(2) "v1" }
$v = $row->getAttributes();

// return null
$testmodel2row = $row->key->getAttributes();
}
}
}

?>



2.2 Test2Mode.php

<?php

/*
CREATE TABLE IF NOT EXISTS `pkrss_test2` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`k` varchar(255) NOT NULL,
`v2` varchar(255) DEFAULT NULL,
`pid` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `pid` (`pid`)
) AUTO_INCREMENT=3 ;

INSERT INTO `pkrss_test2` (`id`, `k`, `v2`, `pid`) VALUES
(1, 'k1', 'k1', 1),
(2, 'k2', 'v2', 2);

ALTER TABLE `pkrss_test2`
ADD CONSTRAINT `pkrss_test2_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `pkrss_test` (`id`);
*/
class Test2Model extends CActiveRecord {

public static function model($className=__CLASS__)
{
return parent::model($className);
}

public function tableName()
{
return '{{test2}}';
}

public $k='';
public $v2='';
public $pid=0;

public function primaryKey()
{
return 'id';
}

public function relations()
{
return array(
'key'=>array(self::BELONGS_TO, 'TestModel', 'pid'),
);
}

public static function testWithFindAll(){

$model = self::model();

// return db obj
$result = $model->with('key')->findAll();
foreach($result as $row){
// return: array(4) { ["id"]=> string(1) "1" ["pid"]=> string(1) "1" ["k"]=> string(2) "k1" ["v2"]=> string(2) "k1" }
$v = $row->getAttributes();

// return array(3) { ["id"]=> string(1) "1" ["k"]=> string(2) "k1" ["v"]=> string(2) "v1" }
$testmodelrow = $row->key->getAttributes();
}
}
}

?>

3. more to later


Monday, December 2, 2013

Windows 8 App Award

Congratulations!

Your apps (PKMAP, PKBOOK) has been tested and rated by the BestWindows8Apps.net. Feel free to use Editor's pick award on your web page to show your visitors how highly we value your apps.

Award:
http://bestwindows8apps.net/wp-content/uploads/2013/11/editors_pick.png

Your apps:
http://bestwindows8apps.net/pkmap/
http://bestwindows8apps.net/pkbook/


Best Regards,
Eric Manco
BestWindows8Apps.net

Thursday, November 28, 2013

cocos2d-x c++ implement auto object point release

1.why

because some class liked "cs::CSJsonDictionary" is not derive from CCObject,so when i new it,need manual release it later.

2. todo

implement one plan.that can auto release those class who are not derive from CCObject.

3. code

Single ton and Memory pool class


template<class _Ty>
class pkSingleTon{
public:
pkSingleTon(){}
public:
static _Ty* Instance(){
static _Ty s_val;
return &s_val;
}
};

#include <string>
#include <set>
#include <map>
#include <list>
#include <vector>

template<class _Ty>
class pkObserver : public std::set<_Ty>{
};

template<class _Ty>
class pkMemoryPool : private pkSingleTon<pkMemoryPool<_Ty> >{
private:
typedef pkObserver<_Ty*> CON;
CON mdatas;
private:
void _add(_Ty* v){
mdatas.insert(v);
}
void _remove(_Ty* v){
typename CON::iterator b = mdatas.find(v);
if(b == mdatas.end())
return;
delete (*b);
mdatas.erase(b);
}
public:
static _Ty* create(){
_Ty* ret = new _Ty();
add(ret);
return ret;
}
static void add(_Ty* v){
pkMemoryPool<_Ty>::Instance()->_add(v);
}
static void remove(_Ty* v){
pkMemoryPool<_Ty>::Instance()->_remove(v);
}
};




Auto memory pool code:


#include "cocos2d.h"

template<class _Ty>
class pkAutoMemoryPool{
private:
class pkObjectMemoryPool_Helper : public cocos2d::CCObject{
private:
_Ty* m_value;
public:
static void create(_Ty* v){
pkObjectMemoryPool_Helper* ret = new pkObjectMemoryPool_Helper();
ret->m_value = v;
ret->autorelease();
}
virtual ~pkObjectMemoryPool_Helper(){
pkAutoMemoryPool<_Ty>::remove(m_value);
}
};
public:
static _Ty* create(){
_Ty* ret = pkMemoryPool<_Ty>::create();
pkObjectMemoryPool_Helper::create(ret);
return ret;
}
static void remove(_Ty* v){
pkMemoryPool<_Ty>::remove(v);
}
};




4 used

cs::CSJsonDictionary* ret = pkAutoMemoryPool<cs::CSJsonDictionary>::create();