69 lines
1.6 KiB
PHP
69 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace app\admin\model\config;
|
|
|
|
use think\Model;
|
|
use think\Session;
|
|
use think\Config;
|
|
class Vod extends Model
|
|
{
|
|
|
|
// 开启自动写入时间戳字段
|
|
protected $autoWriteTimestamp = 'int';
|
|
// 定义时间戳字段名
|
|
protected $createTime = 'createtime';
|
|
protected $updateTime = 'updatetime';
|
|
|
|
public function getList(){
|
|
return Config::get('vod');
|
|
}
|
|
|
|
/**
|
|
* 设置状态
|
|
* @param $name
|
|
* @param $status
|
|
* @return void
|
|
*/
|
|
public function setStatus($name,$status = true){
|
|
$config = $this->getList();
|
|
|
|
foreach ($config as &$item){
|
|
if($status == true){
|
|
if($item['status']== 1){
|
|
//禁用
|
|
// \app\admin\controller\Addon::selfstate($item['type'],'disable');
|
|
$item['status'] = 0;
|
|
}
|
|
}
|
|
|
|
if($item['type'] == $name){
|
|
$item['status'] = $status ? 1 : 0;
|
|
|
|
if($item['status'] == 1){
|
|
// \app\admin\controller\Addon::selfstate($item['type'],'enable');
|
|
}
|
|
}
|
|
}
|
|
$configFile = CONF_PATH . 'extra' . DS . 'vod.php';
|
|
|
|
file_put_contents($configFile, '<?php' . "\n\nreturn " . var_export_short($config) . ";\n");
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取选中的平台
|
|
* @return false|mixed
|
|
*/
|
|
public static function getChecked(){
|
|
$config = Config::get('vod');
|
|
|
|
foreach ($config as $item){
|
|
if($item['status']){
|
|
return $item['type'];
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
}
|