Example #1
0
<?php

/**
 * 发送成功列表
 * @author 潘洪学 panliu888@gmail.com
 * @create_date	2011-10
 */
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.php';
Passport::RequireLogin();
$task = new Task();
switch (strtolower($_GET['action'])) {
    case 'del':
        $task->UpdateStatus(Task::DELETE_OK, intval($_GET['id']), '已取消');
        break;
    case 'clear':
        $task->update(array('status' => Task::DELETE_OK, 'msg' => '被清空'), array('uid' => Passport::GetLoginUid(), 'status' => Task::OK));
        redirect('?');
        break;
}
$pager = new Pager($task->GetCount(Task::OK), 20);
$TEMPLATE['list'] = $task->GetList(Task::OK, $pager->offset());
$TEMPLATE['pager'] = $pager->render();
$TEMPLATE['title'] = '已发送';
$TEMPLATE['login_name'] = Passport::GetLoginName();
$TEMPLATE['nav']['list_ok'] = 'current';
$smarty = new Template();
echo $smarty->r('list_ok');
Example #2
0
            $watch->Stop();
            $TEMPLATE['report']['watch'] = array('status' => true, 'msg' => "总耗时:{$watch->getElapsedSeconds()} 秒");
        }
    }
}
$TEMPLATE['title'] = '发博客';
$TEMPLATE['login_name'] = Passport::GetLoginName();
$TEMPLATE['nav']['blog'] = 'current';
$TEMPLATE['target_list'] = $wt_open->getBlogList();
$TEMPLATE['platform_list'] = $wt_open->getPlatformList();
foreach ($TEMPLATE['platform_list'] as &$item) {
    $item['list'] = $wt_open->getBlogList($item['id']);
    unset($item);
}
$smarty = new Template();
echo $smarty->r('blog');
function validate()
{
    global $TEMPLATE;
    $check = true;
    if (strlen($_POST['title']) == 0 || strlen($_POST['content']) == 0) {
        $TEMPLATE['report']['check_cont'] = array('status' => false, 'msg' => '标题和内容均不能为空!');
        $check = false;
    }
    if ($_POST['time'] == 'on' && strtotime($_POST['send_time']) < time()) {
        $TEMPLATE['report']['check_time'] = array('status' => false, 'msg' => '定时发送时间比当前时间早,可能输入了一个错误的时间!');
        $check = false;
    }
    if ($_POST['target'] == NULL) {
        $TEMPLATE['report']['check_select'] = array('status' => false, 'msg' => '没有选择任何博客平台!');
        $check = false;
Example #3
0
        break;
}
if (!Request::IsPost()) {
    $TEMPLATE['data']['return_url'] = str_replace('action=', '', Request::Referer());
    if ($data['status'] == Task::TASK) {
        $task->UpdateStatus(Task::TASK_EDIT, $id);
        $TEMPLATE['data']['time'] = 'on';
    }
}
if (preg_match('/^\\d+$/', $TEMPLATE['data']['send_time'])) {
    $TEMPLATE['data']['send_time'] = date('Y-m-d H:i', $TEMPLATE['data']['send_time']);
}
$TEMPLATE['title'] = '修改' . ($data['cat'] == 'weibo' ? '微博' : '博客');
$TEMPLATE['login_name'] = Passport::GetLoginName();
$smarty = new Template();
echo $smarty->r('edit');
/**
 * 验证发送表单
 */
function validate()
{
    global $TEMPLATE;
    global $data;
    $check = true;
    if ($data['cat'] == 'weibo') {
        if (strlen($_POST['content']) == 0) {
            $TEMPLATE['report']['check_cont'] = array('status' => false, 'msg' => '没有输入内容!');
            $check = false;
        }
    } else {
        if (strlen($_POST['title']) == 0 || strlen($_POST['content']) == 0) {
Example #4
0
                $TEMPLATE['data'] = $fields;
            }
        }
        $wt_open = new WTOpen();
        $TEMPLATE['simula']['weibo_list'] = $wt_open->getWeiboList(0, false);
        $TEMPLATE['simula']['blog_list'] = $wt_open->getBlogList(0, false);
        $TEMPLATE['platform_list'] = $wt_open->getPlatformList(false);
        foreach ($TEMPLATE['platform_list'] as &$item) {
            $item['weibo_list'] = $wt_open->getWeiboList($item['id'], false);
            $item['blog_list'] = $wt_open->getBlogList($item['id'], false);
            unset($item);
        }
        if (!is_array($TEMPLATE['data']['perms'])) {
            $TEMPLATE['data']['perms'] = array();
        }
        exit($smarty->r('users_edit'));
        break;
}
$TEMPLATE['list'] = $user->getsAll();
foreach ($TEMPLATE['list'] as &$item) {
    $item['perms'] = unserialize($item['perms']);
    unset($item);
}
echo $smarty->r('users');
function validate(&$fields)
{
    global $TEMPLATE;
    $ret = true;
    if ($fields['password'] == '') {
        unset($fields['password']);
        //		$TEMPLATE['error']['password'] = '******';
Example #5
0
</script>
HTML;
                exit;
                redirect(get_returnurl('index.php'));
            } else {
                $TEMPLATE['error']['username'] = '******';
            }
        }
    }
    // 保持填写的数据
    $TEMPLATE['data'] = $fields;
}
$TEMPLATE['title'] = '注册';
$TEMPLATE['nav']['register'] = 'current';
$smarty = new Template();
echo $smarty->r('register');
function validate($fields)
{
    global $TEMPLATE;
    $ret = true;
    if ($fields['username'] == '') {
        $TEMPLATE['error']['username'] = '******';
        $ret = false;
    }
    if ($fields['password'] == '') {
        $TEMPLATE['error']['password'] = '******';
        $ret = false;
    }
    if ($fields['re_password'] == '') {
        $TEMPLATE['error']['re_password'] = '******';
        $ret = false;
Example #6
0
foreach ($TEMPLATE['blog_list'] as $key => &$value) {
    $value = array('name' => $value, 'third' => get_status($key));
    unset($value);
}
/* debug cookie start */
if ($_REQUEST['debug_cookie'] == 1) {
    $TEMPLATE['debug_cookie'] = true;
    $cookie_path = LOG_PATH . "{$pid}.cookie";
    if (Request::IsPost()) {
        file_put_contents($cookie_path, $_POST['p_cookie']);
    }
    $TEMPLATE['p_cookie'] = file_get_contents($cookie_path);
}
/* debug cookie end*/
$smarty = new Template();
echo $smarty->r('bind');
/**
 * 获取账号绑定状态,smarty 模板用
 * @param string $type
 */
function get_status($type)
{
    global $thirdAccount, $pid;
    $third = $thirdAccount->getByType($type, $pid);
    if (!$third) {
        return array('status' => 0);
        // 未绑定
    }
    if (!$third['valid']) {
        $third['status'] = -1;
        return $third;
Example #7
0
            $type = $item['type'];
            $arr = explode('|', $type);
            $third = $thirdAccount->getByType($arr[0], $arr[1], $item['uid']);
            $api = Factory::CreateAPI2($arr[0], $arr[1], $third);
            if ($item['cat'] == 'weibo') {
                $ret = $api->upload($item['content'], $item['pic']);
            } else {
                $ret = $api->publish($item['title'], $item['content']);
            }
            $TEMPLATE['report'] = array();
            $TEMPLATE['report'][$type] = array('id' => $id, 'status' => $ret === true, 'msg' => $ret === true ? '发送成功!<a href="' . $third['url'] . '" target="_blank">查看</a>' : '发送失败:' . $ret);
            $task->UpdateStatus($ret === true ? Task::OK : Task::ERROR, $id, $ret);
        }
        break;
    case 'del':
        $task->UpdateStatus(Task::DELETE_ERR, intval($_GET['id']), '已取消');
        break;
    case 'clear':
        $task->update(array('status' => Task::DELETE_ERR, 'msg' => '被清空'), array('uid' => Passport::GetLoginUid(), 'status' => Task::ERROR));
        redirect('?');
        break;
}
$pager = new Pager($task->GetCount(Task::ERROR), 20);
$TEMPLATE['list'] = $task->GetList(Task::ERROR, $pager->offset());
$TEMPLATE['pager'] = $pager->render();
$TEMPLATE['title'] = '失败列表';
$TEMPLATE['login_name'] = Passport::GetLoginName();
$TEMPLATE['nav']['list_err'] = 'current';
$smarty = new Template();
echo $smarty->r('list_err');
Example #8
0
switch ($_GET['action']) {
    case 'send':
        $thirdAccount = new ThirdAccount();
        $id = intval($_GET['id']);
        $item = $task->get($id);
        if ($item) {
            $type = $item['type'];
            $arr = explode('|', $type);
            $third = $thirdAccount->getByType($arr[0], $arr[1], $item['uid']);
            $api = Factory::CreateAPI2($arr[0], $arr[1], $third);
            if ($item['cat'] == 'weibo') {
                $ret = $api->upload($item['content'], $item['pic']);
            } else {
                $ret = $api->publish($item['title'], $item['content']);
            }
            $TEMPLATE['report'] = array();
            $TEMPLATE['report'][$type] = array('id' => $id, 'status' => $ret === true, 'msg' => $ret === true ? '发送成功!<a href="' . $third['url'] . '" target="_blank">查看</a>' : '发送失败:' . $ret);
            $task->UpdateStatus($ret === true ? Task::OK : Task::ERROR, $id, $ret, time());
        }
        break;
    case 'del':
        $task->UpdateStatus(Task::DELETE_TASK, intval($_GET['id']), '已取消');
        break;
}
$TEMPLATE['list'] = $task->GetList(Task::TASK);
$TEMPLATE['title'] = '定时发送任务';
$TEMPLATE['login_name'] = Passport::GetLoginName();
$TEMPLATE['nav']['task'] = 'current';
$smarty = new Template();
echo $smarty->r('task');
Example #9
0
            $wt_open->delete(array('pid' => $pid));
            foreach ($app as $key => $value) {
                $tableInfo = array('pid' => $pid, 'name' => $key, 'app_key' => trim($value['key']), 'app_secret' => trim($value['secret']), 'callback' => trim($value['callback']), 'status' => $value['key'] && $value['secret'], 'user' => Passport::GetLoginName());
                $wt_open->replace($tableInfo);
            }
            $TEMPLATE['error']['app'] = '<span style="color:#090">保存成功!</span>';
        }
        break;
    case 'delete':
        $wt_open->update(array('status' => -1), array('id' => $pid));
        $wt_open->update(array('status' => -1), array('pid' => $pid));
        redirect('?');
        break;
}
$TEMPLATE['title'] = '平台设定';
$TEMPLATE['login_name'] = Passport::GetLoginName();
$TEMPLATE['nav']['platform'] = 'current';
$TEMPLATE['platform_list'] = $wt_open->getPlatformList(false);
$TEMPLATE['open_list'] = Config::open_list();
if ($pid > 0) {
    $TEMPLATE['pid'] = $pid;
    $TEMPLATE['open_data'] = $wt_open->findBy(array('pid' => $pid), 'name');
    //var_dump($TEMPLATE['open_data']);
    foreach ($TEMPLATE['open_list'] as $key => &$value) {
        $value = array_merge(array('weibo_name' => $value), (array) $TEMPLATE['open_data'][$key]);
        unset($value);
    }
}
$smarty = new Template();
echo $smarty->r('platform');
Example #10
0
    case Task::DELETE_OK:
        $TEMPLATE['data']['status_text'] = '从发送成功列表删除';
        break;
    case Task::DELETE_ERR:
        $TEMPLATE['data']['status_text'] = '从失败列表删除';
        break;
    case Task::DELETE_TASK:
        $TEMPLATE['data']['status_text'] = '从定时任务列表删除';
        break;
    case Task::TASK:
        $TEMPLATE['data']['status_text'] = '定时任务';
        break;
    case Task::EXECING:
        $TEMPLATE['data']['status_text'] = '正在执行的定时任务';
        break;
    case Task::TASK_EDIT:
        $TEMPLATE['data']['status_text'] = '修改中';
        break;
    case Task::ERROR:
        $TEMPLATE['data']['status_text'] = '发送失败:' . $TEMPLATE['data']['msg'];
        break;
    default:
        $TEMPLATE['data']['status_text'] = '未知状态:' . $TEMPLATE['data']['status'];
        break;
}
$TEMPLATE['title'] = '详细信息';
$TEMPLATE['login_name'] = Passport::GetLoginName();
$TEMPLATE['nav']['list_ok'] = 'current';
$smarty = new Template();
echo $smarty->r('details');
Example #11
0
            redirect(get_returnurl('index.php'));
        } else {
            $TEMPLATE['error'] = array();
            if (strpos($ret, '密码') !== false) {
                $TEMPLATE['error']['password'] = $ret;
            } else {
                $TEMPLATE['error']['username'] = $ret;
            }
        }
    }
    // 保持填写的数据
    $TEMPLATE['data'] = $fields;
}
$TEMPLATE['title'] = '登录';
$TEMPLATE['nav']['login'] = '******';
$smarty = new Template();
echo $smarty->r('login');
function validate($fields)
{
    global $TEMPLATE;
    $ret = true;
    if ($fields['username'] == '') {
        $TEMPLATE['error']['username'] = '******';
        $ret = false;
    }
    if ($fields['password'] == '') {
        $TEMPLATE['error']['password'] = '******';
        $ret = false;
    }
    return $ret;
}
Example #12
0
        echo '发送成功';
    } else {
        echo "<font color=red>发送失败:{$error}</font>";
    }
}
$TEMPLATE['title'] = '发微博';
$TEMPLATE['login_name'] = Passport::GetLoginName();
$TEMPLATE['nav']['index'] = 'current';
$TEMPLATE['target_list'] = $wt_open->getWeiboList();
$TEMPLATE['platform_list'] = $wt_open->getPlatformList();
foreach ($TEMPLATE['platform_list'] as &$item) {
    $item['list'] = $wt_open->getWeiboList($item['id']);
    unset($item);
}
$smarty = new Template();
echo $smarty->r('index');
/**
 * 验证发送表单
 */
function validate()
{
    global $TEMPLATE;
    $check = true;
    if (strlen($_POST['content']) == 0) {
        $TEMPLATE['report']['check_cont'] = array('status' => false, 'msg' => '没有输入内容!');
        $check = false;
    }
    if ($_POST['time'] == 'on' && strtotime($_POST['send_time']) < time()) {
        $TEMPLATE['report']['check_time'] = array('status' => false, 'msg' => '定时发送时间比当前时间早,可能输入了一个错误的时间!');
        $check = false;
    }
Example #13
0
        if ($user->update($tableInfo, array('id' => Passport::GetLoginUid()))) {
            $TEMPLATE['error']['username'] = '******';
        } else {
            $TEMPLATE['error']['username'] = '******';
            $TEMPLATE['data'] = $fields;
        }
    } else {
        // 保持填写的数据
        $TEMPLATE['data'] = $fields;
    }
}
$TEMPLATE['title'] = '修改密码';
$TEMPLATE['login_name'] = Passport::GetLoginName();
$TEMPLATE['nav']['profile'] = 'current';
$smarty = new Template();
echo $smarty->r('profile');
function validate($fields)
{
    global $TEMPLATE;
    $ret = true;
    if ($fields['password'] == '') {
        $TEMPLATE['error']['password'] = '******';
        $ret = false;
    }
    if ($fields['re_password'] == '') {
        $TEMPLATE['error']['re_password'] = '******';
        $ret = false;
    } elseif ($fields['re_password'] != $fields['password']) {
        $TEMPLATE['error']['re_password'] = '******';
        $ret = false;
    }