Ejemplo n.º 1
0
/**
 * Get or set a database setting.
 *
 * @param string $field     The field (settings.value) to retrieve/set.
 * @param string $hostname  Hostname (or null) associated with $field.
 * @param string $new_value New value (settings.data) to set.
 *
 * @return string The value (settings.data) associated with $field and $hostname.
/**/
function setting($field, $hostname = null, $new_value = "oldold", $clearSettingsCache = true)
{
    global $db;
    static $cache = array();
    // Best not to have an array index that's null
    $h = is_null($hostname) ? '-null-' : $hostname;
    if (!isset($cache[$h]) || !is_array($cache[$h])) {
        $cache[$h] = array();
    }
    if (!is_object($db)) {
        return null;
    }
    // Assigning a new value
    if ($new_value !== "oldold") {
        if (is_null($hostname)) {
            $db->query('DELETE FROM settings
                                  WHERE value=? AND hostname IS NULL', $field);
        } else {
            $db->query('DELETE FROM settings
                                  WHERE value=? AND hostname=?', $field, $hostname);
        }
        $db->query('INSERT INTO settings (value, data, hostname) VALUES (?,?,?)', $field, $new_value, $hostname);
        $cache[$h][$field] = $new_value;
        // Alert the rest of the MythTV network.  Though there are some
        // occasional times where setting() gets called before we're actually
        // connected to the backend, the only known instance is in db_update.php
        // and those settings don't affect anything but MythWeb.
        if ($clearSettingsCache) {
            MythBackend::find()->sendCommand(array('MESSAGE', 'CLEAR_SETTINGS_CACHE'));
        }
    } elseif (!array_key_exists($field, $cache[$h])) {
        if (is_null($hostname)) {
            $cache[$h][$field] = $db->query_col('SELECT data
                                                       FROM settings
                                                      WHERE value=? AND hostname IS NULL', $field);
        } else {
            $cache[$h][$field] = $db->query_col('SELECT data
                                                       FROM settings
                                                      WHERE value=? AND hostname LIKE ?', $field, $hostname);
        }
    }
    // Return the cached value
    return $cache[$h][$field];
}
Ejemplo n.º 2
0
<?php

/**
 * Does a query against the backend to look up metadata for a show
 * returns the result as JSON
 *
 * @license     GPL
 *
 * @package     MythWeb
 * @subpackage  TV
 *
/**/
header('Content-Type: application/json');
$url = "Video/LookupVideo";
$args = array('Title' => $_REQUEST['title'], 'Subtitle' => $_REQUEST['subtitle'], 'Inetref' => $_REQUEST['inetref'], 'Season' => $_REQUEST['season'], 'Episode' => $_REQUEST['episode'], 'GrabberType' => $_REQUEST['grabbertype'], 'AllowGeneric' => $_REQUEST['allowgeneric']);
echo MythBackend::find()->httpRequestAsJson($url, $args);
Ejemplo n.º 3
0
    if (setting("JobsRunOnRecordHost")) {
        $host = $program->hostname;
    }
    $db->query('INSERT INTO jobqueue
                       SET chanid       = ?,
                           starttime    = FROM_UNIXTIME(?),
                           inserttime   = NOW(),
                           type         = ?,
                           hostname     = ?,
                           args         = "",
                           status       = ?,
                           statustime   = NOW(),
                           schedruntime = NOW(),
                           comment      = "Queued via MythWeb",
                           flags        = ?', $program->chanid, $program->recstartts, $_REQUEST['job'], $host, JOB_QUEUED, JOB_USE_CUTLIST);
    MythBackend::find()->rescheduleRecording();
    // Redirect back to the page again, but without the query string, so the
    // user doesn't accidentally repost this request on a page reload.
    redirect_browser(root_url . 'tv/detail/' . $program->chanid . '/' . $program->recstartts);
}
// The user tried to update the recording settings - update the database and the variable in memory
if (isset($_POST['save'])) {
    if ($schedule) {
        // Which type of recording is this?  Make sure an illegal one isn't specified
        switch ($_POST['record']) {
            case rectype_once:
                $type = rectype_once;
                break;
            case rectype_daily:
                $type = rectype_daily;
                break;
Ejemplo n.º 4
0
// Check out the php version info
require_once 'includes/php_version_check.php';
// Load the error trapping and display routines
require_once 'includes/errors.php';
require_once 'includes/errordisplay.php';
// Setup the database
require_once 'includes/database.php';
// Make sure the database is up to date
require_once 'includes/db_update.php';
// Load the session handler routines
require_once 'includes/session.php';
// Define some common stuff
require_once 'includes/defines.php';
// Load the translation routines so the modules can translate their descriptions
require_once 'includes/translate.php';
// Protect the users!
require_once 'includes/lockdown.php';
// Include a few useful functions
require_once 'includes/css.php';
require_once 'includes/mouseovers.php';
// Detect mobile users
require_once 'includes/mobile.php';
// Setup the skins and themes
require_once 'includes/skin.php';
// Setup the data_dir
require_once 'includes/data_dir.php';
// Load the session defaults and other config info
require_once 'includes/config.php';
// And do some quick setup...
MythBackend::find()->setTimezone();
Ejemplo n.º 5
0
 /**
  * Stop recording the program is we are currently recording...
  *
  * @return bool did we actually stop recording?
  **/
 public function stopRecording()
 {
     if ($this->recstatus != 'Recording') {
         return false;
     }
     MythBackend::find()->sendCommand(array('STOP_RECORDING', $prog->backend_row(), '0'));
     return true;
 }
Ejemplo n.º 6
0
if (isset($_REQUEST['title'])) {
    $_SESSION['recorded_title'] = $_REQUEST['title'];
}
if (isset($_REQUEST['recgroup'])) {
    $_SESSION['recorded_recgroup'] = $_REQUEST['recgroup'];
}
// The default sorting choice isn't so good for recorded programs, so we'll set our own default
if (!is_array($_SESSION['recorded_sortby']) || !count($_SESSION['recorded_sortby'])) {
    $_SESSION['recorded_sortby'] = array(array('field' => 'airdate', 'reverse' => true), array('field' => 'title', 'reverse' => false));
}
// Sort the programs
if (count($All_Shows)) {
    sort_programs($All_Shows, 'recorded_sortby');
}
// How much free disk space on the backend machine?
list($size, $used) = MythBackend::find()->sendCommand('QUERY_FREE_SPACE_SUMMARY');
if (function_exists('gmp_mul')) {
    // GMP functions should work better with 64 bit numbers.
    $size = gmp_mul('1024', $size);
    define(disk_size, gmp_strval($size));
    $size = gmp_mul('1024', $used);
    define(disk_used, gmp_strval($size));
} else {
    // This is inaccurate, but it's the best we can get without GMP.
    define(disk_size, $size * 1024);
    define(disk_used, $used * 1024);
}
// Load the class for this page
require_once tmpl_dir . 'recorded.php';
// Exit
exit;
Ejemplo n.º 7
0
 function __construct($chanid)
 {
     // Are we loading up an invalid channel?
     if ($chanid == -1) {
         return;
     }
     global $db;
     $channel_data = $db->query_assoc('SELECT * FROM channel WHERE chanid = ?', $chanid);
     if (!isset($channel_data['chanid']) || $channel_data['chanid'] != $chanid) {
         return;
     }
     foreach ($channel_data as $key => $value) {
         $this->{$key} = $value;
     }
     $this->icon = 'data/tv_icons/' . basename($channel_data['icon']);
     // Try to copy over any missing channel icons
     if ($channel_data['icon'] && !file_exists($this->icon)) {
         // Local file?
         if (file_exists($channel_data['icon'])) {
             @copy($channel_data['icon'], $this->icon);
         } else {
             // Make the request and store the result
             $data = MythBackend::find()->httpRequest('Guide/GetChannelIcon', array('ChanId' => $this->chanid));
             if ($data) {
                 file_put_contents($this->icon, $data);
             }
             unset($data);
         }
     }
     // Wipe the icon path completely if it doesn't exist.
     if (!is_file($this->icon)) {
         $this->icon = null;
     }
 }
Ejemplo n.º 8
0
<?php

/**
 * Video scanner
 *
 *
 * @package     MythWeb
 * @subpackage  Video
 *
/**/
MythBackend::find()->sendCommand('SCAN_VIDEOS');
sleep(2);
Ejemplo n.º 9
0
 /**
  * Delete this schedule
 /**/
 public function delete()
 {
     global $db;
     // Delete this schedule from the database
     $sh = $db->query('DELETE FROM record WHERE recordid=?', $this->recordid);
     // Notify the backend of the changes
     if ($sh->affected_rows()) {
         MythBackend::find()->rescheduleRecording($this->recordid);
     }
     // Finish
     $sh->finish();
 }