Browse Source

fix wrong data file path

master
filesite 8 months ago
parent
commit
791cd14a76
  1. 20
      themes/tajian/controller/FrontapiController.php

20
themes/tajian/controller/FrontapiController.php

@ -156,20 +156,20 @@ Class FrontApiController extends SiteController {
} }
$video_id = $this->getVideoId($url); $video_id = $this->getVideoId($url);
$filepath = "{$task_dir}/{$video_id}.task"; $filepath = realpath($task_dir) . "/{$video_id}.task";
return file_put_contents($filepath, $url) !== false; return file_put_contents($filepath, $url) !== false;
} }
//保存分享视频到tag分类 //保存分享视频到tag分类
//TODO: 如果高并发,需要避免数据被覆盖的问题 //TODO: 如果高并发,需要避免数据被覆盖的问题
protected function saveVideoToTag($url, $tagName) { protected function saveVideoToTag($url, $tagName) {
$tag_dir = __DIR__ . '/../../../www/' . FSC::$app['config']['content_directory'] . '/' . FSC::$app['config']['tajian']['tag_dir']; $tag_dir = __DIR__ . '/../../../www/' . FSC::$app['config']['content_directory'] . FSC::$app['config']['tajian']['tag_dir'];
if (!is_dir($tag_dir)) { if (!is_dir($tag_dir)) {
mkdir($tag_dir, 0755, true); mkdir($tag_dir, 0755, true);
} }
$video_id = $this->getVideoId($url); $video_id = $this->getVideoId($url);
$filepath = "{$tag_dir}/{$tagName}.txt"; $filepath = realpath($tag_dir) . "/{$tagName}.txt";
if (file_exists($filepath)) { if (file_exists($filepath)) {
$content = file_get_contents($filepath); $content = file_get_contents($filepath);
$videos = explode("\n", $content); $videos = explode("\n", $content);
@ -220,7 +220,7 @@ Class FrontApiController extends SiteController {
//保存快捷方式 //保存快捷方式
protected function saveUrlShortCut($video_id, $task_url) { protected function saveUrlShortCut($video_id, $task_url) {
$data_dir = __DIR__ . '/../../../www/' . FSC::$app['config']['content_directory'] . '/' . FSC::$app['config']['tajian']['data_dir']; $data_dir = __DIR__ . '/../../../www/' . FSC::$app['config']['content_directory'] . FSC::$app['config']['tajian']['data_dir'];
if (!is_dir($data_dir)) { if (!is_dir($data_dir)) {
mkdir($data_dir, 0755, true); mkdir($data_dir, 0755, true);
} }
@ -230,17 +230,13 @@ Class FrontApiController extends SiteController {
URL={$task_url} URL={$task_url}
eof; eof;
try { $filepath = realpath($data_dir) . "/{$video_id}.url";
$filepath = "{$data_dir}/{$video_id}.url"; return file_put_contents($filepath, $shortUrlContent) !== false;
return file_put_contents($filepath, $shortUrlContent);
}catch(Exception $err) {
return false;
}
} }
//保存描述文件:标题和图片 //保存描述文件:标题和图片
protected function saveDescriptionFiles($video_id, $task_data) { protected function saveDescriptionFiles($video_id, $task_data) {
$data_dir = __DIR__ . '/../../../www/' . FSC::$app['config']['content_directory'] . '/' . FSC::$app['config']['tajian']['data_dir']; $data_dir = __DIR__ . '/../../../www/' . FSC::$app['config']['content_directory'] . FSC::$app['config']['tajian']['data_dir'];
if (!is_dir($data_dir)) { if (!is_dir($data_dir)) {
mkdir($data_dir, 0755, true); mkdir($data_dir, 0755, true);
} }
@ -248,6 +244,8 @@ eof;
$done = true; $done = true;
try { try {
$data_dir = realpath($data_dir);
//保存标题 //保存标题
$filepath_title = "{$data_dir}/{$video_id}_title.txt"; $filepath_title = "{$data_dir}/{$video_id}_title.txt";
file_put_contents($filepath_title, $task_data['title']); file_put_contents($filepath_title, $task_data['title']);

Loading…
Cancel
Save