Example #1
0
 /**
  * 获取用户真实手机
  * GET /user/1/email
  * @method GET_infoAction
  * @param  integer        $id [description]
  * @author NewFuture
  */
 public function GET_emailAction($id = 0)
 {
     $pid = $this->authPrinter();
     if (TaskModel::where('use_id', $id)->where('pri_id', $pid)->get('id')) {
         $email = UserModel::where('id', '=', $id)->get('email');
         $email = $email ? Encrypt::decryptEmail($email) : null;
         $this->response(1, $email);
     } else {
         $this->response(0, '此同学未在此打印过');
     }
 }
Example #2
0
 /**
  * @param int $userId task owner's id
  * @param int $listId list
  * @param bool $asArrays whether function should return data as array of arrays of array of objects 
  *    
  * @return TaskModel[]|array[] user's tasks sorted by id desc
  * @author Karol
  */
 public function getTasks(ListModel $list, $asArrays = false)
 {
     $tasks = $list->getTasks();
     if (!count($tasks)) {
         return array();
     }
     $tasksT = array_flip($tasks);
     $this->dump($tasks);
     $sql = sprintf("SELECT * FROM task WHERE id IN (%s)", implode(',', $tasks));
     $db = FLite::getInstance()->getDB();
     $res = $db->getResults($sql);
     if (!is_array($res)) {
         return null;
     }
     foreach ($res as $row) {
         $task = new TaskModel($row);
         $tasksT[$task->getId()] = $asArrays ? $task->toArray() : $task;
     }
     return $tasksT;
 }
Example #3
0
 /**
  * 打印书籍
  * @method POST_printAction
  * @todo 计价
  * @param  integer          $id [description]
  * @author NewFuture
  */
 public function POST_printAction($id = 0)
 {
     $uid = $this->auth();
     $response['status'] = 0;
     if (!($Book = BookModel::find($id))) {
         $response['info'] = '无效书籍';
     } else {
         $task = ['use_id' => $uid, 'url' => 'book/' . $id];
         $task['pri_id'] = $Book['pri_id'];
         $task['name'] = $Book['name'];
         if ($tid = TaskModel::insert($task)) {
             $Book->inc('count');
             $response['info'] = ['id' => $tid, 'msg' => '保存成功'];
         } else {
             $response['info'] = '保存出错';
         }
     }
     $this->response = $response;
 }
Example #4
0
 public function set_task_type($id, $new_type)
 {
     return parent::Update("task_task", array("id_type" => $new_type), " id_task LIKE {$id}");
 }
Example #5
0
<?php

require_once 'permisson.php';
require_once '../common/common.php';
$openid = param("openid", null);
$r = AccountExtra::getInfo($openid);
$account = Account::getAccount($openid);
if ($r == null) {
    $r = array();
}
if ($account['phone'] != null) {
    $r['contact_phone'] = $account['phone'];
}
$r["nickname"] = $account["nickname"];
$publishTaskCount = TaskModel::getPublishTaskCountById($openid);
$acceptTaskCount = TaskModel::getAcceptTaskCountById($openid);
$r["publishTaskCount"] = $publishTaskCount;
$r["acceptTaskCount"] = $acceptTaskCount;
json_put("result", $r);
json_output();
Example #6
0
 /**
  * 获取单个任务列表
  *
  * @author boxcore
  * @date   2014-09-17
  * @return array     [description]
  */
 protected function _getTaskList()
 {
     $mark = 'qsbk';
     $task_list = array();
     if (!empty($mark)) {
         $taskModel = new TaskModel();
         $task_id = $taskModel->getIdByMark($mark);
         if ($task_id > 0) {
             $task_list = $taskModel->getList(array('task_id' => $task_id));
             if (!empty($task_list)) {
                 return $task_list[0];
             }
         }
     }
     return false;
 }
Example #7
0
 public function loadExpandList()
 {
     $this->select('task.*, start, stop, CEIL(spent/60) as spent');
     $this->from('task');
     $this->leftJoin('timer', 'task.id=timer.task_id');
     return parent::loadList(false);
 }
Example #8
0
<?php

require_once 'permisson.php';
require_once '../common/common.php';
$pageIndex = param("page", 1);
$taskName = param("taskName", null);
// 跟据创建时间分页展示
$tasks = TaskModel::getAllTasks($taskName, $pageIndex);
json_put("result", $tasks);
json_output();
Example #9
0
<?php

require_once '../common/common.php';
$openId = $_SESSION['openid'];
$pageIndex = param("page", 1);
$phone = param("phone");
// 获取任务类型1:发布的任务,其它值是接受的任务
$type = param("type");
if ($phone == null) {
    //	operation_fail("手机号不能为空");
}
if ($pageIndex <= 0) {
    $pageIndex = 1;
}
if ($type == 1) {
    $result = TaskModel::getMyPublishTask($openId, $pageIndex);
} else {
    $result = TaskModel::getMyAcceptTask($openId, $pageIndex);
}
json_put("result", $result);
json_output();
Example #10
0
<?php

// 默认超时
set_time_limit(0);
// 定义应用目录
define('APP', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR);
// 载入框架引导文件
require APP . 'system/_shell.php';
require APP . 'funcs/spider.fn.php';
require APP . 'models/TaskModel.php';
system('echo -e "\\033[32m开始获取队列... \\033[0m"');
$taskModel = new TaskModel();
$task_list = $taskModel->getList();
$task_count = count($task_list);
system('echo -e "获取到\\033[32m[' . $task_count . ']\\033[0m个任务队列, 开始抓取链接列表..."');
foreach ($task_list as $v) {
    $task_list_id = $v['id'];
    $task_status = $v['status'];
    $chatset = $v['charset'];
    $rules = array();
    if ($task_status == 'yes') {
        system("echo -e '开始抓取\\033[34m[" . $v['node_name'] . "]\\033[0m...'");
        $rules = json_decode($v['link_rules'], true);
        // 获取内容的链接
        $link_list = array();
        $link_list = get_link_list($rules['list_rule']);
        $link_list_count = count($link_list);
        system("echo -e '获取到\\033[32m[" . $link_list_count . "]\\033[0m个列表列表链接,准备获取文章链接...'");
        foreach ($link_list as $vo) {
            system("echo -e '获取列表内容链接: \\033[32m" . $vo . "\\033[0m'");
            $content = '';
Example #11
0
 /**
  * 删除
  * POST /share/123/print
  * @method 添加打印任务
  * @author NewFuture
  */
 public function POST_printAction($id = 0)
 {
     $userid = $this->auth();
     $response['status'] = 0;
     if (!($share = ShareModel::where('status', '>', 0)->field('name,url')->find())) {
         $response['info'] = '此分享已经删除!';
     } elseif (!Input::post('pid', $pid, 'int')) {
         $response['info'] = '请选择打印店!';
     } else {
         $task = TaskModel::create('post');
         $task['use_id'] = $userid;
         $task['pid'] = $pid;
         $task['url'] = File::addTask($share['url']);
         $task['name'] = $share['name'];
         if (!($tid = TaskModel::insert($task))) {
             $response['info'] = '任务添加失败';
         } else {
             $response['status'] = 1;
             $response['info'] = ['msg' => '任务添加成功', 'id' => $tid];
         }
     }
     $this->response = $response;
 }
Example #12
0
<?php

require_once '../common/common.php';
$openId = $_SESSION['openid'];
$taskId = param('taskId');
if ($taskId == null) {
    operation_fail('任务ID不能为空');
}
$task = TaskModel::getTaskById($taskId);
if ($task == null) {
    operation_fail("任务不存在");
}
if ($task['publisher_openid'] != $openId) {
    operation_fail("只有任务发布者才能结束任务");
}
if ($task['status'] != TaskModel::STATUS_ACCEPTED) {
    operation_fail("当前任务状态不对,不能结束");
}
$r = TaskModel::finishTask($taskId, $openId);
if ($r) {
    json_put("result", "结束成功");
} else {
    json_put("result", '结束任务失败');
}
json_output();
?>

Example #13
0
<?php

require_once 'permisson.php';
require_once '../common/common.php';
$taskId = param('taskId');
$r = TaskModel::deleteTask($taskId);
if ($r) {
    json_put("result", "删除成功");
} else {
    json_put("result", '删除任务失败');
}
json_output();
?>


Example #14
0
 /**
  * 获取源文件
  * 在转码出问题可用此接口
  * @param [type] $id [description]
  */
 public function GET_fileAction($id)
 {
     $pid = $this->authPrinter();
     if ($url = TaskModel::where('id', intval($id))->where('pri_id', '=', $pid)->get('url')) {
         $this->response(1, File::source($url));
     } else {
         $this->response(0, '无此文件');
     }
 }
Example #15
0
<?php

require_once '../common/common.php';
$openId = $_SESSION['openid'];
$taskId = param('taskId');
if ($taskId == null) {
    operation_fail('任务ID不能为空');
}
$publisher = param('user');
$phone = param('phone');
//$title = param('title');
$desc = param('desc');
$endTime = param('endTime');
$reward = param('tip');
$address = param('address');
//$fromAddress = param('fromAddress');
$lng = param('lng');
//经度
$lat = param('lat');
//续度
$reward = intval(100 * $reward);
$r = TaskModel::updateTask($taskId, $publisher, $openId, $phone, $desc, $reward, $endTime, $address, $lng, $lat);
if ($r) {
    json_put("result", $r);
} else {
    json_put("result", '更新任务失败');
}
json_output();
?>

Example #16
0
<?php

require_once '../common/__html__.php';
require_once '../common/common.php';
require_once '../common/page.php';
$id = param('id');
if ($id == null) {
    echo "<span><strong><b>任务不存在</b></strong></span>";
    exit;
} else {
    $r = TaskModel::getTaskById($id);
    $now = date("Y-m-d H:i:s", time());
    if ($r == null || $r['status'] != 1 || strtotime($now) >= strtotime($r['end_time'])) {
        echo "<span><strong><b>任务不存在或者已失效</b></strong></span>";
        exit;
    }
}
?>
<div class="container">
    <form class="form-horizontal" role="form" name="myform" method="post" action="">
        <div id="legend" class="col-sm-12">
            <legend class="">接受任务</legend>
        </div>
        <input type="hidden" name="taskId" value="<?php 
echo $id;
?>
">

        <div class="form-group">
            <!-- Text input-->
            <label class="col-sm-2 control-label">任务标题</label>
Example #17
0
<?php

require_once 'permisson.php';
require_once '../common/common.php';
$openid = param("openid", null);
$publishTasks = TaskModel::getMyPublishTask($openid);
$acceptTasks = TaskModel::getMyAcceptTask($openid);
$tasks = array_merge($publishTasks, $acceptTasks);
json_put("result", $tasks);
json_output();
Example #18
0
 public function createReaction()
 {
     $this->result = array();
     $data = explode("\n", $this->fc->getReqVar('data'));
     ArrayHelper::arrayTrim($data);
     $t = count($data);
     // total to parse
     $i = 0;
     // successfully parsed counter
     $defDate = '';
     // date of previous created task
     $defValue = '';
     // default value for multiple tasks creation (set by *)
     foreach ($data as $val) {
         if ($objTask = TaskModel::parse($val, $defValue, $defDate)) {
             // really creating a task
             $objTask->connectDb();
             if ($objTask->check($this->switch_id)) {
                 $objTask->insert();
                 $i++;
             }
         }
     }
     $this->fc->redirect($this->fc->getUrl('task', 'main'), 'created');
     // -TODO- show $i
 }
Example #19
0
}
$now = date("Y-m-d H:i:s", time());
//date_default_timezone_set('PRC');
if ($endTime != null && strtotime($now) > strtotime($endTime)) {
    operation_fail("任务的送达时间" . $endTime . "不能小于当前时间" . $now);
} else {
    if ($endTime == null) {
        $endTime = $now;
    }
}
//if ($verifyCode == null) {
//	operation_fail("验证码不能为空");
//}
//$r = VerifyCodeModel::getCodeByPhone($phone);
//if ($r == null || $r['status'] != 0 || strtotime($r['time']) + VERIFY_CODE_VALID_TIME*60 < time() || $verifyCode != $r['code']) {
//	operation_fail('验证码不正确或者已失效');
//}
if ($reward < 0) {
    operation_fail('任务奖励不能为负数');
}
// 转成分
$reward = intval(100 * $reward);
//$r = TaskModel::publishTask($openId, $phone, $title, $desc, $reward, $now, $endTime, $address, $fromAddress, $lng, $lat);
$r = TaskModel::publishTask($publisher, $openId, $phone, $title, $desc, $reward, $now, $endTime, $address, '', $lng, $lat);
//VerifyCodeModel::deleteVerifyCode($phone);
if ($r) {
    json_put("result", $r);
} else {
    json_put("result", '发布任务失败');
}
json_output();
Example #20
0
<?php

require_once '../common/common.php';
$lng = param('lng');
// 传入用户的经度
$lat = param('lat');
// 纬度
if ($lng == null || $lat == null) {
    operation_fail("经纬度错误");
}
$distance = param("distance", 50);
$page = param("page", 1);
$tasks = TaskModel::getValidTasks($lng, $lat, $distance, $page);
$tasksTotalCount = TaskModel::getValidTasksCount();
json_put("tasks", $tasks);
json_put("total", $tasksTotalCount);
json_output();
?>


Example #21
0
 /**
  * 打印文件
  * POST /file/:id/print
  * @method
  */
 public function POST_printAction($id)
 {
     $userid = $this->auth();
     $response['status'] = 0;
     if (!($id = intval($id))) {
         $response['info'] = '未选择文件';
     } elseif (!Input::post('pid', $pid, 'int')) {
         $response['info'] = '未选择打印店';
     } elseif (!($file = FileModel::where('use_id', $userid)->where('status', '>', 0)->field('url,name,status')->find($id))) {
         $response['info'] = '没有该文件或者此文件已经删除';
     } else {
         $task = TaskModel::create('post');
         $task['name'] = $file['name'];
         $task['use_id'] = $userid;
         $task['pri_id'] = $pid;
         if (!($task['url'] = File::addTask($file['url']))) {
             $response['info'] = '文件转换出错';
         } elseif (!($tid = TaskModel::insert($task))) {
             $response['info'] = '任务添加失败';
         } else {
             $response['status'] = 1;
             $response['info'] = ['msg' => '打印任务添加成功', 'id' => $tid, 'name' => $file['name']];
         }
     }
     $this->response = $response;
 }
 /**
  * Returns the next pending task.
  *
  * @param string|null $type
  *
  * @return TaskModel|null|false
  */
 public function getNextPendingTask($type = null)
 {
     // If a type was passed, we don't need to actually save it, as it's probably not an actual task-running request.
     if ($type) {
         $pendingTasks = $this->getPendingTasks($type, 1);
         if ($pendingTasks) {
             return $pendingTasks[0];
         }
     } else {
         if (!isset($this->_nextPendingTask)) {
             $taskRecord = TaskRecord::model()->roots()->ordered()->findByAttributes(array('status' => TaskStatus::Pending));
             if ($taskRecord) {
                 $this->_taskRecordsById[$taskRecord->id] = $taskRecord;
                 $this->_nextPendingTask = TaskModel::populateModel($taskRecord);
             } else {
                 $this->_nextPendingTask = false;
             }
         }
         if ($this->_nextPendingTask) {
             return $this->_nextPendingTask;
         }
     }
 }
Example #23
0
<?php

require_once '../common/common.php';
$openId = $_SESSION['openid'];
$taskId = param('taskId');
if ($taskId == null) {
    operation_fail('任务ID不能为空');
}
$task = TaskModel::getTaskById($taskId);
if ($task == null) {
    operation_fail("任务不存在");
}
if ($task['publisher_openid'] != $openId) {
    operation_fail("只有任务发布者才能取消任务");
}
if ($task['status'] != TaskModel::STATUS_PUBLISHING) {
    operation_fail("当前任务状态不对,不能取消");
}
$r = TaskModel::closeTask($taskId, $openId);
if ($r) {
    json_put("result", "关闭成功");
} else {
    json_put("result", '关闭任务失败');
}
json_output();
?>

Example #24
0
    operation_fail("任务不存在");
}
if ($task['status'] != TaskModel::STATUS_PUBLISHING) {
    operation_fail("任务不是发布中,不能接单");
}
if ($task['publisher_openid'] == $openId) {
    operation_fail("不能接自己发布的单");
}
//if ($verifyCode == null) {
//	operation_fail("验证码不能为空");
//}
/*$r = VerifyCodeModel::getCodeByPhone($acceptPhone);
if ($r == null || 
	$r['status'] != 0 || 
	strtotime($r['time']) + VERIFY_CODE_VALID_TIME*60 < time() ||
	$verifyCode != $r['code']) {
	operation_fail('验证码不正确或者已失效');
}

VerifyCodeModel::deleteVerifyCode($acceptPhone);
*/
$r = TaskModel::acceptTask($taskId, $openId, $acceptPhone);
if ($r) {
    json_put("result", "接单成功");
} else {
    json_put("result", '发布任务失败');
}
json_output();
?>

Example #25
0
 /**
  *  获取下载url   
  * @method GET_urlAction
  * @param     $id [description]
  * @author NewFuture
  */
 public function GET_urlAction($id = 0)
 {
     $userid = $this->auth();
     $url = TaskModel::where('id', '=', $id)->where('use_id', '=', $userid)->get($url);
     Input::get('alias', $alias, 'title');
     if ($url && ($url = File::get($url, $alias))) {
         $this->response(1, $url);
     } else {
         $this->response(0, '你没有设定此任务');
     }
 }