manage_program_end.php
资源名称:p2p_vod.rar [点击查看]
上传用户:liguizhu
上传日期:2015-11-01
资源大小:2422k
文件大小:6k
源码类别:
P2P编程
开发平台:
Visual C++
- <?PHP
- include_once 'common.php';
- include_once '../classes/template.inc';
- $act = getParameter('act', 'letter', PP_GET);
- $t = new Template();
- switch ($act){
- case 'add':
- $title = getParameter('title', 'common', PP_POST);
- if(!empty($title)){
- $sql_new = "SELECT count(title) FROM programe WHERE title = '$title'";
- $query_new = db_query($sql_new);
- list($count) = db_fetch_row($query_new);
- if($count == 0){
- $t -> set_file('main', '../html/manage_program_in.html');
- $t -> set_block('main', 'option', 'options');
- $t -> set_var('tvname', $title);
- $sql_i = "INSERT INTO programe (title) VALUES ('$title')";
- $query_i = db_query($sql_i);
- $pid = db_insert_id($query_i);
- $t -> set_var('pid', $pid);
- $sql_s = "SELECT sort_name, sid FROM sort";
- $query_s = db_query($sql_s);
- while ($rs_s = db_fetch_array($query_s)){
- $t -> set_var('sid', $rs_s['sid']);
- $t -> set_var('sort_name', $rs_s['sort_name']);
- $t -> parse('options', 'option', true);
- }
- $t -> parse('out', 'main');
- $t -> p('out');
- }else {
- $t -> set_file('main', '../html/manage_success.html');
- $t -> set_var('img', 'error.gif');
- $t -> set_var('talk', '此节目已存在,请重新填写节目名称!');
- $t -> set_var('ahref', 'manage_program.php');
- $t -> parse('out', 'main');
- $t -> p('out');
- }
- }else {
- $t -> set_file('main', '../html/manage_success.html');
- $t -> set_var('img', 'error.gif');
- $t -> set_var('talk', '请填写节目名称');
- $t -> set_var('ahref', 'manage_program.php');
- $t -> parse('out', 'main');
- $t -> p('out');
- }
- break;
- case 'addend':
- $pid = getParameter('pid', 'numbers', PP_GET);
- $tvname = getParameter('tvname', 'common', PP_POST);
- $sid = getParameter('sort', 'numbers', PP_POST);
- $addr = getParameter('addr', 'url', PP_POST);
- $live = getParameter('live', 'numbers', PP_POST);
- $sql_n = "SELECT count(title) FROM programe WHERE title = '$tvname' AND pid != $pid";
- $query_n = db_query($sql_n);
- list($count) = db_fetch_row($query_n);
- if($count==0){
- $sql_f = "SELECT count(*) FROM flags WHERE pid = '$pid' AND sid = '$sid'";
- $query_f = db_query($sql_f);
- list($count_f) = db_fetch_row($query_f);
- if ($count_f != 0){
- $t -> set_file('main', '../html/manage_success.html');
- $t -> set_var('img', 'error.gif');
- $t -> set_var('talk', '节目已经在此分类中!');
- $t -> set_var('ahref', 'manage_program.php');
- $t -> parse('out', 'main');
- $t -> p('out');
- }else {
- if(empty($live)){
- $live = 0;
- }else {
- $live = 1;
- }
- $sql_p = "UPDATE programe SET title = '$tvname', addr = '$addr', live = '$live' WHERE pid = $pid";
- $query_p = db_query($sql_p);
- if(!empty($sid)){
- $sql_uf = "INSERT INTO flags (pid, sid) VALUES ('$pid', '$sid')";
- $query_uf = db_query($sql_uf);
- }
- $t -> set_file('main', '../html/manage_success.html');
- $t -> set_var('img', 'success.gif');
- $t -> set_var('talk', '节目更新成功');
- $t -> set_var('ahref', 'manage_program.php');
- $t -> parse('out', 'main');
- $t -> p('out');
- }
- }else {
- $t -> set_file('main', '../html/manage_success.html');
- $t -> set_var('img', 'success.gif');
- $t -> set_var('talk', '此节目已经存在!');
- $t -> set_var('ahref', 'manage_program.php');
- $t -> parse('out', 'main');
- $t -> p('out');
- }
- break;
- case 'ename':
- $t -> set_file('main', '../html/manage_program_in.html');
- $t -> set_block('main', 'option', 'options');
- $sql_s = "SELECT * FROM sort";
- $query_s = db_query($sql_s);
- while ($rs_s = db_fetch_array($query_s)){
- $t -> set_var('sid', $rs_s['sid']);
- $t -> set_var('sort_name', $rs_s['sort_name']);
- $t -> parse('options', 'option', true);
- }
- $pid = getParameter('pid', 'numbers', PP_GET);
- $sql = "SELECT * FROM programe WHERE pid = $pid";
- $query = db_query($sql);
- $rs = db_fetch_array($query);
- if ($rs['live']==0){
- $t -> set_var('check', '');
- }else {
- $t -> set_var('check', 'checked');
- }
- $t -> set_var('pid', $pid);
- $t -> set_var('tvname', $rs['title']);
- $t -> set_var('addr', $rs['addr']);
- $t -> parse('out', 'main');
- $t -> p('out');
- break;
- case 'del':
- $pid = getParameter('pid', 'numbers', PP_GET);
- $t -> set_file('main', '../html/manage_success.html');
- $sql_p = "DELETE FROM programe WHERE pid = $pid";
- $query_p = db_query($sql_p);
- $sql_s = "DELETE FROM flags WHERE pid = $pid";
- $query_s = db_query($sql_s);
- $t -> set_var('img', 'success.gif');
- $t -> set_var('talk', '删除节目成功');
- $t -> set_var('ahref', 'manage_program.php');
- $t -> parse('out', 'main');
- $t -> p('out');
- break;
- case 'esort':
- $fid = getParameter('fid', 'numbers', PP_GET);
- $t -> set_file('main', '../html/manage_sort_del.html');
- $sql = "SELECT * FROM flags WHERE fid = $fid";
- $query = db_query($sql);
- $rs = db_fetch_array($query);
- $pid = $rs['pid'];
- $sid = $rs['sid'];
- $sql_p = "SELECT title FROM programe WHERE pid = $pid";
- $query_p = db_query($sql_p);
- $rs_p = db_fetch_array($query_p);
- $t -> set_var('tvname', $rs_p['title']);
- $sql_s = "SELECT sort_name FROM sort WHERE sid = $sid";
- $query_s = db_query($sql_s);
- $rs_s = db_fetch_array($query_s);
- $t -> set_var('sortname', $rs_s['sort_name']);
- $t -> set_var('fid', $fid);
- $t -> parse('out', 'main');
- $t -> p('out');
- break;
- case 'fdel':
- $fid = getParameter('fid', 'numbers', PP_GET);
- $t -> set_file('main', '../html/manage_success.html');
- $sql = "delete from flags where fid = $fid";
- $query = db_query($sql);
- $t -> set_var('img', 'success.gif');
- $t -> set_var('talk', '节目已从此分类中删除');
- $t -> set_var('ahref', 'manage_program.php');
- $t -> parse('out', 'main');
- $t -> p('out');
- break;
- case 'estate':
- $pid = getParameter('pid', 'numbers', PP_GET);
- $sql = "SELECT live FROM programe WHERE pid = '$pid'";
- $query = db_query($sql);
- $rs = db_fetch_array($query);
- if($rs['live'] == 1){
- $live = 0;
- }else {
- $live = 1;
- }
- $sql_up = "UPDATE programe SET live = $live WHERE pid = $pid";
- $query_up = db_query($sql_up);
- header('location: manage_program.php');
- break;
- }
- ?>