Example #1
0
 private function connect($listen_events)
 {
     if ($this->fp) {
         return;
     }
     $this->fp = @fsockopen($this->ip, $this->port, $errno, $errstr, 25);
     if (!$this->fp) {
         custom_error("Unable to connect to the master backend at {$this->ip}:{$this->port}" . ($this->host == $this->ip ? '' : " (hostname: {$this->host})") . ".\nIs it running?");
     }
     socket_set_timeout($this->fp, 30);
     $this->checkProtocolVersion();
     $this->announce($listen_events);
 }
Example #2
0
 * look for videos.
 *
 * @global  string   $GLOBALS['mythvideo_dir']
 * @name    $mythvideo_dir
 **/
//// dont need this...
//    global $mythvideo_dir;
//    $mythvideo_dir = setting('VideoStartupDir', hostname);
// Load the video storage directories
$video_dirs = $db->query_list('
        SELECT  dirname
        FROM    storagegroup
        WHERE   groupname="Videos"
        ');
if (empty($video_dirs)) {
    custom_error('MythWeb now requires use of the Videos Storage Group.');
}
// a extra function
function makeImdbWebUrl($num)
{
    $imdbwebtype = setting('web_video_imdb_type', hostname);
    switch ($imdbwebtype) {
        case 'ALLOCINE':
            return "http://www.allocine.fr/film/fichefilm_gen_cfilm=" . $num . ".html";
        default:
            return "http://www.imdb.com/Title?" . $num;
    }
}
/** nor any of this...
// Make sure the video directory exists
    if (file_exists('data/video')) {
Example #3
0
<?php

/**
 * This file is part of MythWeb, a php-based interface for MythTV.
 * See http://www.mythtv.org/ for details.
 *
 * @license     GPL
 *
 * @package     MythWeb
 *
/**/
// Make sure the data directory exists and is writable
if (!is_dir('data') && !mkdir('data', 0755)) {
    custom_error('Error creating the data directory. Please check permissions.');
}
if (!is_writable('data')) {
    $process_user = posix_getpwuid(posix_geteuid());
    custom_error('data directory is not writable by ' . $process_user['name'] . '. Please check permissions.');
}
Example #4
0
        if (!isset($_SESSION['upnp_db'])) {
            for ($i = 0; $i < 10; $i++) {
                $info = UPnP_Client::discoverDatabase();
                if ($info) {
                    $_SESSION['upnp_db'] = $info;
                    break;
                }
            }
        }
        if (!isset($_SESSION['upnp_db'])) {
            custom_error("UPnP Database Discovery failed!");
        }
        $db = Database::connect($_SESSION['upnp_db']['name'], $_SESSION['upnp_db']['user'], $_SESSION['upnp_db']['pass'], $_SESSION['upnp_db']['host'], NULL, 'mysql');
    }
    if (!is_object($db)) {
        custom_error("Database connection is not valid!");
    }
    $db->register_global_name('db');
}
// Access denied -- probably means that there is no database
if ($db->errno == 1045) {
    tailored_error('db_access_denied');
}
// We don't need these security risks hanging around taking up memory.
unset($_SERVER['db_name'], $_SERVER['db_login'], $_SERVER['db_password'], $_SERVER['db_server']);
//
//  If there was a database connection error, this will send an email to
//    the administrator, and then present the user with a static page
//    informing them of the trouble.
//
if ($db->error) {
Example #5
0
<?php

/**
 * Handler for all MythWeb Settings routines
 *
 * @license     GPL
 *
 * @package     MythWeb
 * @subpackage  Settings
 *
 **/
// Make sure we at least have the mythweb settings defined
if (empty($Settings['mythweb'])) {
    custom_error('modules/mythweb/init.php is missing, please verify your install.');
}
// Restore the last used path?
if (empty($Path[1]) && is_array($_SESSION['settings']['last'])) {
    array_splice($Path, 1, count($Path), $_SESSION['settings']['last']);
}
// Empty or unknown module?
if (empty($Path[1]) || empty($Settings[$Path[1]])) {
    $Path[1] = 'mythweb';
}
// Empty or unknown subsection?
if (empty($Path[2]) || empty($Settings[$Path[1]]['choices'][$Path[2]])) {
    $Path[2] = $Settings[$Path[1]]['default'];
}
// Keep track of this path for the next visit
$_SESSION['settings']['last'] = array_slice($Path, 1);
// Define a constant for settings pages to use as their form action="" target
define('form_action', root_url . 'settings/' . $Path[1] . ($Path[2] == $Settings[$Path[1]]['default'] ? '' : '/' . $Path[2]));
Example #6
0
<?php

/**
 * This file is part of MythWeb, a php-based interface for MythTV.
 * See http://www.mythtv.org/ for details.
 *
 * @license     GPL
 *
 * @package     MythWeb
 *
/**/
// No MySQL libraries installed in PHP
if (!function_exists('mysql_connect')) {
    custom_error("Please install the MySQL libraries for PHP.\n" . 'The package is usually called something like php-mysql.');
}
// No database connection info defined?
if (empty($_SERVER['db_server']) || empty($_SERVER['db_name']) || empty($_SERVER['db_login'])) {
    tailored_error('db_vars_error');
}
// Load the database connection routines
require_once 'classes/Database.php';
require_once 'classes/Database/mysql.php';
require_once 'classes/Database/mysqlicompat.php';
require_once 'classes/Database/Query.php';
require_once 'classes/Database/Query/mysql.php';
require_once 'classes/Database/Query/mysqlicompat.php';
/**
 * All database connections should now go through this object.
 *
 * @global  Database    $GLOBALS['db']
 * @name    $db
Example #7
0
    // You can't symlink on windows
    if (strtoupper(substr(php_uname('s'), 0, 3)) == 'WIN') {
        custom_error('MythWeb would like to create a symlink at data/video_covers,' . ' but this host is running Windows, which does not work with' . ' symbolic links.  Please create this directory manually and' . ' reload this page.');
    } else {
        foreach ($artwork_dirs as $dir) {
            if (is_dir($dir) || is_link($dir)) {
                $artwork_dir = $dir;
                break;
            }
        }
        if (empty($artwork_dir)) {
            custom_error("Could not find any valid Coverart storage directories.  Please" . ' create a symlink to your Coverart storage directory at' . ' data/video_covers in order to use the video artwork portions' . ' of MythWeb.');
        }
        $ret = @symlink($artwork_dir, 'data/video_covers');
        if (!$ret) {
            custom_error("Could not create a symlink to {$dir}, the local MythVideo artwork" . ' directory for this hostname (' . hostname . ').  Please create a' . ' symlink to your MythVideo directory at data/video_covers in order to' . ' use the video artwork portions of MythWeb.');
        }
    }
}
define('video_img_height', _or(setting('web_video_thumbnail_height', hostname), 140));
define('video_img_width', _or(setting('web_video_thumbnail_width', hostname), 94));
// Load a custom page
switch ($Path[1]) {
    case 'edit':
        require_once 'modules/video/edit.php';
        exit;
    case 'imdb':
        require_once 'modules/video/imdb.php';
        exit;
    case 'scan':
        require_once 'modules/video/scan.php';
Example #8
0
function prepare_statement($sql, $data, $conn)
{
    global $sql_fields, $sql_types;
    $sql_fields = array();
    $sql_types = array();
    // turn query with named parameters into query with mysql placeholders and populate the sql_fields and sql_types arrays for the php bind_param statement
    $sql_with_question_marks = preg_replace_callback('/(:\\w+)\\[([sidb])\\]/', 'process_named_parameter', $sql);
    $values = array();
    foreach ($sql_fields as $f) {
        $values[] = $data[$f];
    }
    $types = join("", $sql_types);
    $bind_params = array_merge(array($types), $values);
    $statement = $conn->prepare($sql_with_question_marks);
    if ($statement == null) {
        $result = array();
        $result["error"] = $db_connection->error;
        $result["sql"] = $sql_with_question_marks;
        custom_error($result);
    }
    call_user_func_array(array($statement, 'bind_param'), $bind_params);
    return $statement;
}