if (2 == $row['task_type']) { echo '<p class="no_vertical_margin">您关注了 ' . $row['owner_name'] . ' 的新浪微博,获得 ' . $user_income . ' 元。</p>'; } else { if (1 == $row['task_type']) { echo '<p class="no_vertical_margin">您转发了 ' . $row['owner_name'] . '的微博,收入 ' . $user_income . ' 元。</p>'; } } echo '<br /><span class="no_vertical_margin">on: ' . $row['time'] . '</span><hr />'; } } else { if ('ader' == $_SESSION['role']) { // 企业用户 foreach ($sql_res as $row) { $user_base_price = price_db_to_user($row['base_price']); $db_total_price = $row['base_price'] * $row['amount']; $user_total_price = price_db_to_user($db_total_price); if (2 == $row['type']) { $type_name = '新浪关注任务'; } else { if (1 == $row['type']) { $type_name = '新浪转发任务'; } } echo '<p class="no_vertical_margin">您发布了' . $type_name . ',基本佣金' . $user_base_price . '。预期点击量:' . $row['amount'] . '。预期总支出:' . $user_total_price . ' 元。</p>'; echo '<br /><span class="no_vertical_margin">on: ' . $row['create_at'] . '</span>'; echo '<br /><span class="no_vertical_margin">expire in ' . $row['expire_in'] . ' days</span><hr />'; } } } ?> <?php
$location = $dbo->real_escape_string($person['location']); $description = $dbo->real_escape_string($person['description']); $sql = "insert into task_info_sina_follow values(NULL, '{$last_task_id}', '{$pid}', '{$screen_name}', '{$person['friends_count']}', '{$person['followers_count']}', '{$person['statuses_count']}', '{$person['profile_image_url']}', '{$person['avatar_large']}', '{$location}', '{$description}')"; $num = $dbo->exeUpdate($sql); if (1 != $num) { $msg = '数据库插入数据出错。SQL:' . $sql; debug($msg, __FILE__, __LINE__); // 回滚金钱数据和task表数据 $sql1 = "delete from task where task_id = '{$last_task_id}' limit 1"; $num1 = $dbo->exeUpdate($sql1); $sql2 = "update user set realtime_money = realtime_money + {$db_total_price} where user_id = '{$_SESSION['uid']}' limit 1"; $num2 = $dbo->exeUpdate($sql2); if (1 != $num1) { $msg = "回滚金钱数据失败,这个比较糟糕。SQL:" . $sql1; debug($msg, __FILE__, __LINE__); } if (1 != $num2) { $msg = "回滚task数据失败,SQL:" . $sql2; debug($msg, __FILE__, __LINE__); } } // 任务插入完毕 $_SESSION['user_realtime_money'] -= price_db_to_user($db_total_price); $msg = "恭喜,任务创建成功"; $to_url = $siteRoot . 'task.php'; // 如何跳到指定的任务?设立‘我的任务页面’? delay_jump(3, $msg, $to_url, '任务列表'); break; default: $msg = '暂不支持该类型'; }
if (1 !== $sql_res) { // 更新token失败, // 此处并不影响微博登录的用户继续操作,因为该类用户使用的token不从数据库中获得 // 受影响的是使用微动力帐号登录的用户,和我们的检测程序(如果我们的帐号出错的话) debug('更新数据库中用户token时,updte操作出错,SQL[' . $sql . ']。', __FILE__, __LINE__, FALSE, 'fatal'); } } } // 写session $sql = "select user_id, role, realtime_money as rm, level, sina_level from user join user_info_sina using(user_id) where sina_uid = {$sid} limit 1"; $res = $dbo->getRow($sql); $_SESSION['uid'] = $res['user_id']; $_SESSION['role'] = user_role_switch($res['role'], FALSE); $_SESSION['sid'] = $sid; $_SESSION['name'] = $name; $_SESSION['user_realtime_money'] = price_db_to_user($res['rm']); $_SESSION['stoken'] = $token['access_token']; $_SESSION['level'] = $res['level']; $_SESSION['slevel'] = $res['sina_level']; $_SESSION['is_bind_weibo'] = TRUE; header("Location:my.php"); // 后台获取用户的已关注用户列表,写入SESSION $friends = $c->friends_by_id($_SESSION['sid']); if_weiboapi_fail($friends, __FILE__, __LINE__); foreach ($friends['users'] as $friend) { $followed_id[] = $friend['id']; } $_SESSION['followed_id'] = $followed_id; } else { $msg = '授权失败。请稍候重试' . '<a href="index.php">点此</a>返回主页'; debug($msg, __FILE__, __LINE__);
default: $msg = '暂不支持该类型'; } $config_base_price = intval($_POST['base_price']); // 基础价 $amount = intval($_POST['amount']); // 期望点击数 global $ader_normal_rate; // init in config.php $config_total_price = $config_base_price * $amount * ($ader_normal_rate + 1); $user_total_price = price_config_to_user($config_total_price); $expire_in = intval($_POST['expire_in']); // 当前企业用户的余额信息 $sql = "select realtime_money from user where user_id = '{$_SESSION['uid']}'"; $sql_res = $dbo->getRow($sql); $user_realtime_money = price_db_to_user($sql_res['realtime_money']); require_once "uiparts/docheader.php"; ?> <body> <?php include "uiparts/header.php"; ?> <div id="func_column"> <ul > <li><a href="create_task.php?type=sina_follow">创建新浪关注任务</a></li> <li><a href="create_task.php?type=sina_repost">创建新浪转发任务</a></li> <li><a alt="create_task.php?type=sina_review">创建新浪评论任务(暂不可用)</a></li> <li><a alt="create_task.php?type=sina_create">创建新浪原创任务(暂不可用)</a></li> </ul> </div> <!-- end of DIV func_column -->
</div><!-- end of DIV task_block --> <?php } ?> </div><!-- end of DIV task_show --> <?php break; ?> <?php case 'sina_repost': ?> <div id="task_show"> <?php foreach ($res as $row) { $user_level_price = price_db_to_user(price_base_to_level($row['base_price'], $_SESSION['slevel'])); $user_top_price = price_db_to_user(price_base_to_top($row['base_price'])); ?> <div class="task_block"> <p><?php echo '<p class="repost_task_text">' . $row['text'] . '</p>'; echo '<p class="repost_task_comment">by:<a href="http://weibo.com/u/' . $row['sina_uid'] . '" target="_blank">' . $row['screen_name'] . '</a>。<br />转发此微博,您可以获利' . $user_level_price . '元,最高可获利' . $user_top_price . '元<sup><a href="help.php#price">?</a></sup>。'; if (isset($_SESSION['is_bind_weibo']) && $_SESSION['is_bind_weibo']) { echo '<a href="action/repost.php?id=' . $row['task_id'] . '">转发</a>'; } else { echo '转发(不可用)<a href="help.php#task_invalid"><sup>?</sup></a>'; } ?> 。<a href="action/repost.php?id=<?php echo $row['task_id']; ?> &type=hide">屏蔽</a></p><hr />
exit; } // 做成功了,写数据库,写SESSION // 写do_task表 $db_level_price = price_base_to_level($base_price, $_SESSION['slevel']); // $sql = "insert do_task (task_id, user_id, status, repost_mid, time)values($task_id, {$_SESSION['uid']}, '11', {$task_res['retweeted_status']['mid']}, now())"; // 此处应注意,retweeted_status['mid']是原微博的mid,而非转发产生的mid $sql = "insert do_task (task_id, user_id, status, task_type, owner_name, income, repost_mid, time)values({$task_id}, {$_SESSION['uid']}, 11, 1, '{$task_owner_name}', '{$db_level_price}', '{$task_res['mid']}', now())"; $sql_num = $dbo->exeUpdate($sql); if (1 != $sql_num) { echo 'debug. 写数据库失败。file: ' . __FILE__ . '; line: ' . __LINE__; $dbo->close(); exit; } $sql = "update user set task_taken=task_taken+1, task_finished=task_finished+1," . " total_money=total_money+{$db_level_price}, realtime_money=realtime_money+{$db_level_price}" . " where user_id = {$_SESSION['uid']} limit 1"; // 写user表 $sql_num = $dbo->exeUpdate($sql); if (1 != $sql_num) { echo 'debug. 写数据库出现错误。file: ' . __FILE__ . '; line: ' . __LINE__ . '. sql:' . $sql; $dbo->close(); exit; } // 写数据成功,释放数据库连接 $dbo->close(); $_SESSION['user_realtime_money'] = $_SESSION['user_realtime_money'] + price_db_to_user($db_level_price); $sec = 3; $msg = '转发成功!'; $to_url = $_SERVER['HTTP_REFERER']; $to_name = '任务页面'; delay_jump($sec, $msg, $to_url, $to_name); }