Esempio n. 1
0
    $SELECT = 'SELECT ' . TBL_DATA . '.id, ' . TBL_DATA . '.owner_id, ' . TBL_USERS . '.name AS owner, 
                      !ISNULL(' . TBL_USERSEEN . '.video_id) AS seen, ' . $SELECT . '
                 FROM ' . TBL_DATA . '
            LEFT JOIN ' . TBL_USERS . ' ON ' . TBL_DATA . '.owner_id = ' . TBL_USERS . '.id
            LEFT JOIN ' . TBL_USERSEEN . ' 
                   ON ' . TBL_DATA . '.id = ' . TBL_USERSEEN . '.video_id AND ' . TBL_USERSEEN . '.user_id = ' . get_current_user_id() . '
                WHERE ' . TBL_DATA . '.id = ' . $id;
    $video = runSQL($SELECT);
    // diskid to global scope:
    $diskid = $video[0]['diskid'];
} else {
    $video[0]['language'] = $config['langdefault'];
}
// assign automatic disk id
if ($config['autoid'] && (empty($diskid) || $add_flag) && $mediatype != MEDIA_WISHLIST) {
    $video[0]['diskid'] = getDiskId();
    // Fix for Bugreport [1122052] Automatic DiskID generation problem
    $smarty->assign('autoid', $result[0]['max']);
}
if (empty($video[0]['owner_id']) && !empty($owner_id)) {
    $video[0]['owner_id'] = $owner_id;
}
// prepare templates
tpl_page();
tpl_edit($video[0]);
$smarty->assign('lookup_id', $lookup);
$smarty->assign('http_error', $CLIENTERROR);
// allow XML import
if ($config['xml'] && empty($id)) {
    $smarty->assign('xmlimport', true);
}
Esempio n. 2
0
/**
 * Prepare update SQL
 *
 * @param   array $data key/value pairs of data
 * @returns string      result SQL, suitable for INSERT/UPDATE
 */
function prepareSQL($data, $setonly = false)
{
    global $config, $imdb_set_fields, $db_null_fields, $db_zero_fields;
    // get global variables into local scope
    extract($data);
    // Fix for Bugreport [1122052] Automatic DiskID generation problem
    if ($config['autoid'] && !empty($diskid) && $diskid == $autoid) {
        // in case DiskID is already used in meanwhile
        // -> update to new DiskId
        $diskid = getDiskId();
    }
    // set default mediatype
    if (empty($mediatype)) {
        $mediatype = $config['mediadefault'];
    }
    // set owner
    if (is_numeric($owner_id)) {
        $SQL = 'owner_id = ' . $owner_id;
    }
    // rating up to 10
    $rating = min($rating, 10);
    // update all fields according to list
    foreach ($imdb_set_fields as $name) {
        if ($setonly && !isset(${$name})) {
            continue;
        }
        // sanitize input
        ${$name} = removeEvilTags(${$name});
        ${$name} = html_entity_decode(${$name});
        // make sure no formatting contained in basic data
        if (in_array($name, array('title', 'subtitle'))) {
            ${$name} = trim(strip_tags(${$name}));
            // string leading articles?
            if ($config['removearticles']) {
                ${$name} = removeArticles(${$name});
            }
        }
        $SET = "{$name} = '" . addslashes(${$name}) . "'";
        // special null/zero handling
        if (empty(${$name})) {
            if (in_array($name, $db_null_fields)) {
                $SET = "{$name} = NULL";
            } elseif (in_array($name, $db_zero_fields)) {
                $SET = "{$name} = 0";
            }
        }
        if ($SQL) {
            $SQL .= ', ';
        }
        $SQL .= $SET;
    }
    return $SQL;
}