<?php include 'api_common.inc.php'; if (empty($_POST['username']) || empty($_POST['apikey'])) { ajaxReturn('', 'username,apikey can not be empty', 403); } //验证apikey,获取上传url $url = SVC_PPTVYUN . '/api/picurlwithtoken'; $params = array('username' => $_POST['username'], 'apitk' => md5($_POST['apikey'] . $url)); $arr = json_decode(send_get($url . '?' . http_build_query($params)), 1); if (empty($arr['data'])) { ajaxReturn('', 'apikey认证失败', 403); } //获取上传图片的url $newUrl = 'http://ppyun.ugc.upload.pptv.com/php/uploadPic.php'; $uploadPicUrl = str_replace('http://api.grocery.pptv.com/upload_file.php', $newUrl, $arr['data']); $uploadPicUrl = str_replace('http://api.grocery.ppqa.com/upload_file.php', $newUrl, $uploadPicUrl); if (empty($_POST['uploadpic'])) { $uploadPicUrl = ''; } //算出登录的token $session_data = array('username' => $_POST['username'], 'apikey' => $_POST['apikey'], 'expire_time' => time() + 86400); $token = urlencode(base64_encode(des_encrypt(http_build_query($session_data), $TRIPLEDES_KEY, $TRIPLEDES_IV))); $data = array('nextUrl' => "{$URL_PREFIX}/initUpload.php", 'uploadPicUrl' => $uploadPicUrl, 'token' => $token); ajaxReturn($data, 'success', 0);
<?php include 'api_common.inc.php'; $timestamp = time() * 1000; //debug if (!empty($_GET['fid'])) { exit(urlencode(base64_encode(des_encrypt("{$_GET['fid']}|{$timestamp}0|username", $TRIPLEDES_KEY, $TRIPLEDES_IV)))); } if (empty($_GET['encode_profile']) || empty($_GET['name']) || empty($_GET['username']) || empty($_GET['token'])) { exit('Missing encode_profile/name/username/token'); } $encode_profile = trim($_GET['encode_profile']); $name = trim($_GET['name']); $encodeArr = explode('|', des_decrypt(base64_decode($encode_profile), $TRIPLEDES_KEY, $TRIPLEDES_IV)); if (sizeof($encodeArr) != 3 || $encodeArr[2] != $_GET['username'] || $encodeArr[1] < $timestamp) { exit('Unauthorized or out-of-date'); } $url = API_CLOUDPLAY . "/private/2/file/{$encodeArr[0]}/download_url?download_inner=0&download_expire=864000"; $rs = json_decode(send_get($url), 1); if (!empty($rs['data'])) { $rs['data'] = str_replace('http://sw3.pplive.cn', '', $rs['data']); $rs['data'] = str_replace('http://swift.pplive.cn', '', $rs['data']); if (strpos($_SERVER["HTTP_USER_AGENT"], "MSIE") || strpos($_SERVER["HTTP_USER_AGENT"], 'rv:11')) { $name = urlencode(urlencode($name)); } else { $name = urlencode($name); } $rs['data'] = str_replace('.ppc?', ".ppc.{$name}.mp4?", $rs['data']); header("Location: {$rs['data']}"); }
parse_str(des_decrypt(base64_decode(urldecode($_POST['token'])), $TRIPLEDES_KEY, $TRIPLEDES_IV), $session); if (empty($session)) { ajaxReturn('', 'token error', 403); } //获取ppFeature $tmpArr = $_FILES['files']['tmp_name']; $ppFeature = ''; foreach ($tmpArr as $tmp) { $ppFeature .= file_get_contents($tmp); } $ppFeature = "{$_POST['size']}_" . sha1($ppFeature); //获取视频列表 $url = SVC_PPTVYUN . '/api/channelcategory/categorylist'; $params = array('username' => $session['username'], 'apitk' => md5($session['apikey'] . $url)); $arr = json_decode(send_get($url . '?' . http_build_query($params)), 1); if (empty($arr['data'])) { ajaxReturn('', 'apikey认证失败', 403); } $categoryId = $arr['data'][0]['id']; if (!empty($_POST['categoryid'])) { $categoryId = intval($_POST['categoryid']); } //创建视频 $url = SVC_PPTVYUN . '/api/channel/upload'; $postData = array('username' => $session['username'], 'apitk' => md5($session['apikey'] . $url), 'categoryid' => $categoryId, 'name' => isset($_POST['channelname']) ? trim($_POST['channelname']) : '', 'summary' => isset($_POST['summary']) ? trim($_POST['summary']) : '', 'coverimg' => isset($_POST['coverimg']) ? trim($_POST['coverimg']) : '', 'length' => isset($_POST['size']) ? intval($_POST['size']) : 0, 'ppfeature' => $ppFeature); $arr = json_decode(send_json_post($url, json_encode($postData)), 1); if (!empty($arr['data'])) { $fid = base64_encode(des_encrypt($arr['data']['fId'], $TRIPLEDES_KEY, $TRIPLEDES_IV)); $arr['data'] = array('nextUrl' => "{$URL_PREFIX}/getRange.php", 'channelWebId' => $arr['data']['channelWebId'], "coverImage" => "http://grocery.pptv.com/lpic/ea7/a31/013/de8660322896b27530d31d82a0aa7bd0.jpg", 'ppfeature' => $ppFeature, 'fid' => urlencode($fid)); } ajaxReturn($arr['data'], $arr['msg'], 0);