This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CommonAction extends Action | |
{ | |
public function _initialize() | |
{ | |
if(isset($_COOKIE['auto']) && !isset($_SESSION['uid'])){ | |
$auto=explode('|',$_COOKIE['auto']); | |
$where=array('uid'=>$auto[0],'username'=>$auto[1]); | |
$user=M('user')->where($where)->find(); | |
if ($user) { | |
session('uid',$user['id']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function login() | |
{ | |
if(!IS_POST) $this->redirect('index',array('errormsg' => '非法请求')); | |
$email = I('email'); | |
$last_login = date(time(),"Y-m-d,H:i:s"); | |
$password = I('password','','md5'); | |
/////find只会找到一条记录 这个是和select不同的地方 这找到的是一个集合 | |
$user = M('user')->where(array('email' => $email))->find(); | |
if (!$user || $user['password']!= $password) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
*/ | |
class TopicViewModel extends ViewModel | |
{ | |
public $viewFields = array( | |
'topic' => array('id','title','content','last_replied_by','last_touched','created'), | |
'user' => array('username','nickname','avatar','uid','reputation', '_on' => 'topic.author_id=user.uid'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
*/ | |
class TopicViewModel extends ViewModel | |
{ | |
public $viewFields = array( | |
'topic' => array('id','title','content','last_replied_by','last_touched','created'), | |
'user' => array('username','nickname','avatar','uid','reputation', '_on' => 'topic.author_id=user.uid'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* wechat php test | |
*/ | |
//define your token | |
define("TOKEN", "iambus"); | |
$wechatObj = new wechatCallbackapiTest(); | |
if (isset($_GET['echostr'])) { | |
$wechatObj->valid(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def index(request): | |
data={} | |
#传递request参数有没有比这个更好的实现? | |
data['request'] = request | |
return render_to_response('index.html',data,context_instance=RequestContext(request)) | |
def signin(request): | |
data={} | |
if request.user.is_authenticated(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="nav-collapse collapse pull-right"> | |
<ul class="nav"> | |
{% if request.user.is_authenticated %} | |
<li> | |
<a href="/settings">{{ request.user.username }}</a> | |
</li> | |
<li> | |
<a href="/logout">退出</a> | |
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | |
import os | |
BASE_DIR = os.path.dirname(os.path.dirname(__file__)) | |
#celery setting | |
from datetime import timedelta | |
CELERYBEAT_SCHEDULE = { | |
'add-every-30-seconds': { | |
'task': 'tasks.add', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.management.base import BaseCommand,CommandError | |
from myapp.models import * | |
class Command(BaseCommand): | |
def handle(self, *args, **options): | |
result_list = results.objects.exclude(value='') | |
i = 1 | |
for item in result_list: | |
patt = re.compile(u'^\d+\.\d+$|^\d+$') | |
maxvalue = item.re_monitor_info.max_value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generated by CoffeeScript 1.8.0 | |
var Bitfinex, crypto, qs, request; | |
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; | |
request = require('request'); | |
crypto = require('crypto'); | |
qs = require('querystring'); |
OlderNewer