Browse Source

fix wrong data file path

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

22
themes/tajian/controller/FrontapiController.php

@ -156,20 +156,20 @@ Class FrontApiController extends SiteController { @@ -156,20 +156,20 @@ Class FrontApiController extends SiteController {
}
$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;
}
//保存分享视频到tag分类
//TODO: 如果高并发,需要避免数据被覆盖的问题
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)) {
mkdir($tag_dir, 0755, true);
}
$video_id = $this->getVideoId($url);
$filepath = "{$tag_dir}/{$tagName}.txt";
$filepath = realpath($tag_dir) . "/{$tagName}.txt";
if (file_exists($filepath)) {
$content = file_get_contents($filepath);
$videos = explode("\n", $content);
@ -220,7 +220,7 @@ Class FrontApiController extends SiteController { @@ -220,7 +220,7 @@ Class FrontApiController extends SiteController {
//保存快捷方式
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)) {
mkdir($data_dir, 0755, true);
}
@ -230,17 +230,13 @@ Class FrontApiController extends SiteController { @@ -230,17 +230,13 @@ Class FrontApiController extends SiteController {
URL={$task_url}
eof;
try {
$filepath = "{$data_dir}/{$video_id}.url";
return file_put_contents($filepath, $shortUrlContent);
}catch(Exception $err) {
return false;
}
$filepath = realpath($data_dir) . "/{$video_id}.url";
return file_put_contents($filepath, $shortUrlContent) !== false;
}
//保存描述文件:标题和图片
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)) {
mkdir($data_dir, 0755, true);
}
@ -248,8 +244,10 @@ eof; @@ -248,8 +244,10 @@ eof;
$done = true;
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']);
//保存图片文件

Loading…
Cancel
Save