<?php

# return array(video, journal_buy) 1为可以、2为不可以
function checkVersion()
{
	$video = 1;
	$journal_buy = 1;
    $mobile = 1;
	$config = Dever::db('main/config')->one();
    $source_type = Dever::input('source_type');

    #小程序去掉视频
    $app = false;
    if ($source_type == 'ios' || $source_type == 'android') {
        $app = true;
    }
    $app = true;
    if ((isset($config['video']) && $config['video'] == 2) || !$app) {
        $video = 2;
    } elseif (isset($config['version']) && Dever::input('version') && $config['version'] == Dever::input('version')) {
        $video = 2;
        $journal_buy = 2;
        $mobile = 2;
    }

    return (object) array('video' => $video, 'journal_buy' => $journal_buy, 'mobile' => $mobile);
}

/**
 * 音视频转换
 */
function convert($url, $ext = 'mp4', $table = false, $id = false, $col = '')
{
    if ($url && !strstr($url, '_c.' . $ext)) {
        $file = $url . '_c.' . $ext;
        if (Dever::is_file($file)) {
            $url = $file;

            if ($table) {
                Dever::db($table)->update(array('where_id' => $id, $col => $file));
            }
        }
    }

    return $url;
}