set template path may be dynamic later $tpl_path = "templates/default/"; if ( isset($_REQUEST['mode']) ) $mode = $_REQUEST['mode']; if ( isset($_REQUEST['pcid']) ) $pcid = (int)$_REQUEST['pcid']; if ( isset($_REQUEST['series_id']) ) $series_id = (int)$_REQUEST['series_id']; $referer = $_SERVER['HTTP_REFERER']; session_start(); // change login button $_SESSION['logged_in'] ? $logged_in = 1 : $logged_in = 0; // show admin menu button $_SESSION['boss'] ? $boss = 1 : $boss = 0; $series = get_series(null,$series_id,0,10000); $nl_feedback = ""; switch ($mode) { default: $tpl_content = $tpl_path . "pclist.tpl"; $podcasts = get_pcl(null,null,null,0,5); $view_pagination = 0; $view_welcome = 1; $message = $lang['new_podcast']; $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('podcasts',$podcasts) ; $TBS->MergeBlock('series',$series) ; $TBS->Show() ; break; case "open_podcast": $tpl_content = $tpl_path . "pcdetail.tpl"; $podcasts = get_pcl(null,null,$pcid); $message = ""; $comments = get_comments($pcid,null); $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('podcasts',$podcasts) ; $TBS->MergeBlock('comments',$comments) ; $TBS->MergeBlock('series',$series) ; $TBS->Show() ; break; case "add_edit_comment": if ( $logged_in==0 ) { loadpage("index.php?mode=login_page"); } else { if ( isset($_REQUEST['save']) && $_REQUEST['save']==1 && isset($_REQUEST['id']) && isset($_REQUEST['pid']) ){ $id = (int)$_REQUEST['id']; $pid = (int)$_REQUEST['pid']; save_comment($id); loadpage("index.php?mode=open_podcast&pcid=$pid"); } else { isset($_REQUEST['id']) ? $id = $_REQUEST['id'] : exit("invalid parameters"); isset($_REQUEST['pid']) ? $pid = $_REQUEST['pid'] : exit("invalid parameters"); if ($id == "new"){ $comments = array(); $new = 1; } else { $comments = get_comments($id); $new = 0; }} $uid = $_SESSION['uid']; $tpl_content = $tpl_path . "comment_add_edit.tpl"; $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('comments',$comments) ; $TBS->MergeBlock('series',$series) ; $TBS->Show() ; } break; case "search": $tpl_content = $tpl_path . "pclist.tpl"; $search = $_REQUEST['searchstring']; $pagination = ""; $view_pagination = 0; $view_welcome = 0; $podcasts = get_pcl($search); empty($podcasts) ? $message = $lang['no_result'] : $message = $lang['your_results_for']." \"$search\"" ; $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('podcasts',$podcasts) ; $TBS->MergeBlock('series',$series) ; $TBS->Show() ; break; case "show_series": $tpl_content = $tpl_path . "pclist.tpl"; $page = (int)$_GET['page']-1; $page > 0 ? $offset = $page*5 : $offset=0; $podcasts = get_pcl(null,$series_id,null,$offset,5,null); $series_info = get_series($series_id); $pcs_count = get_count(null,$series_id); $pcs_count < 5 ? $view_pagination=0 : $view_pagination=0; $view_welcome = 0; $view_pagination = 1; $pagination = paginate($pcs_count,"show_series&series_id=$series_id",(int)$_GET['page'],5); empty($podcasts) ? $message = $lang['no_result'] : $message = $series_info[0]['name'] ; $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('podcasts',$podcasts) ; $TBS->MergeBlock('series',$series) ; $TBS->Show() ; break; case "player": $pcpath = $config['url']."mp3/"; $pcurl = $pcpath . $_REQUEST['file']; $autoplay = "true"; $pctitle = $_REQUEST['title']; $playerpath = $config['url']."swf/xspf_player_slim.swf?song_url=$pcurl&autoplay=$autoplay&song_title=$pctitle"; $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'player.tpl') ; $TBS->Show() ; break; case "noplayer": $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'noplayer.tpl') ; $TBS->Show() ; break; case "howto": $tpl_content = $tpl_path . "how_to.tpl"; $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('series',$series) ; $TBS->Show() ; break; case "terms": $tpl_content = $tpl_path . "terms.tpl"; $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('series',$series) ; $TBS->Show() ; break; case "privacy": $tpl_content = $tpl_path . "privacy.tpl"; $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('series',$series) ; $TBS->Show() ; break; case "imprint": $tpl_content = $tpl_path . "imprint.tpl"; $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('series',$series) ; $TBS->Show() ; break; case "admin": if ( !$_SESSION['boss'] ) { loadpage("index.php?mode=login_page"); } else { $tpl_content = $tpl_path . "admin.tpl"; $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('series',$series) ; $TBS->Show() ; } break; case "series": if ( !$_SESSION['boss'] ) { loadpage("index.php?mode=login_page"); } else { $page = (int)$_GET['page']-1; $page > 0 ? $offset = $page*20 : $offset=0; $series_edit = get_series(null,null,$offset,20); $series_count = get_count("series"); $pagination = paginate($series_count,"series",(int)$_GET['page'],20); $tpl_content = $tpl_path . "series.tpl"; $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('series',$series) ; $TBS->MergeBlock('series_edit',$series_edit) ; $TBS->Show() ; } break; case "add_edit_series": if ( !$_SESSION['boss'] ) { loadpage("index.php?mode=login_page"); } else { if ( isset($_REQUEST['save']) && $_REQUEST['save']==1 && isset($_REQUEST['id']) && isset($_REQUEST['name']) ){ $id = $_REQUEST['id']; $name = $_REQUEST['name']; save_series($id,$name); loadpage("index.php?mode=series"); } else { isset($_REQUEST['id']) ? $id = $_REQUEST['id'] : exit("invalid parameters"); $series = get_series(); if ($id == "new"){ $series_edit = array( array("id" => "new", "name" => "") ); $show_delete_button = 0; } else { $series_edit = get_series($id); $show_delete_button = 1; } $tpl_content = $tpl_path . "series_add_edit.tpl"; $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('series',$series) ; $TBS->MergeBlock('series_edit',$series_edit) ; $TBS->Show() ; } } break; case "delete_series": if ( !$_SESSION['boss'] ) { loadpage("index.php?mode=login_page"); } else { if ( isset($_REQUEST['id'])){ $id = $_REQUEST['id']; delete_series($id); loadpage("index.php?mode=series"); } } break; case "delete_podcast": if ( !$_SESSION['boss'] ) { loadpage("index.php?mode=login_page"); } else { if ( isset($_REQUEST['id'])){ $id = $_REQUEST['id']; delete_podcast($id); loadpage("index.php?mode=pcmgmt"); } } break; case "pcmgmt": if ( !$_SESSION['boss'] ) { loadpage("index.php?mode=login_page"); } else { $tpl_content = $tpl_path . "pcmgmt.tpl"; $page = (int)$_GET['page']-1; $page > 0 ? $offset = $page*10 : $offset=0; $pcs_edit = get_pcl(null,null,null,$offset,10,1); $pcs_count = get_count("podcasts"); $pagination = paginate($pcs_count,"pcmgmt",(int)$_GET['page'],10); $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('series',$series) ; $TBS->MergeBlock('pcs_edit',$pcs_edit) ; $TBS->Show() ; } break; case "add_edit_podcast": if ( !$_SESSION['boss'] ) { loadpage("index.php?mode=login_page"); } else { if ( isset($_REQUEST['save']) && $_REQUEST['save']==1 && isset($_REQUEST['id']) ){ $pid = (int)$_REQUEST['id']; save_podcast($pid); loadpage("index.php?mode=pcmgmt"); } else { isset($_REQUEST['id']) ? $pid = $_REQUEST['id'] : exit("invalid parameters"); if ($pid == "new"){ $podcast_edit = array(); $new = 1; $pcseries = get_series(); } else { $podcast_edit = get_pcl(null,null,$pid); $pcseries = get_series(null,$podcast_edit[0]['series']); $new = 0; } $tpl_content = $tpl_path . "podcast_add_edit.tpl"; $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('series',$series) ; $TBS->MergeBlock('pcseries',$pcseries) ; $TBS->MergeBlock('podcast_edit',$podcast_edit) ; $TBS->Show() ; } } break; case "show_calendar": if ( !$_SESSION['boss'] ) { loadpage("index.php?mode=login_page"); } else { $form = $_REQUEST['form']; $control = $_REQUEST['control']; $month=(int)$_GET['month']; $year=(int)$_GET['year']; if ( empty($month) ) $month = date(m,time()); if ( empty($year) ) $year = date(Y,time()); if ($month<0 || $month>12) exit("illegal parameter"); if ($year<1970 || $year>2037) exit("illegal parameter"); $time = mktime(0, 0, 0, $month, 1, $year); $time_next = mktime(0, 0, 0, $month+1, 1, $year); $month_next = date(n,$time_next); $year_next = date(Y,$time_next); $time_before = mktime(0, 0, 0, $month-1, 1, $year); $month_before = date(n,$time_before); $year_before = date(Y,$time_before); $days_of_month = date(t,$time); $days=array("Mon","Tue","Wed","Thu","Fri","Sat","Sun"); $empty_days = array_search( date(D,$time),$days ); $monthnr = date("n",$time)-1; $month_name= $lang['month_arr'][$monthnr]; for($i=1;$i<=$empty_days;$i++) $calendar[] = array("day" => "", "month" => "", "year" => ""); for($i=1;$i<=$days_of_month;$i++) $calendar[] = array("day" => $i, "month" => $month, "year" => $year); $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'calendar.tpl'); $TBS->Mergeblock('calendar',$calendar); $TBS->MergeField('lang',$lang); $TBS->Show() ; } break; case "publish": if ( !$_SESSION['boss'] ) { loadpage("index.php?mode=login_page"); } else { $TBS =& new clsTinyButStrong ; $build_date = date( "D, d M Y H:i:s",time() ); $pub_date = date( "D, d M Y H:i:s",time() ); $year = date( "Y", time() ); $podcasts = get_pcl($search=null,$series=null,$id=null,$offset=0,$limit=1000,$admin=null); $TBS->LoadTemplate($tpl_path . 'rss.tpl') ; $TBS->MergeBlock('podcasts',$podcasts); $TBS->Show(TBS_NOTHING); $rss = $TBS->Source; $rss = utf8_encode($rss); $success = write_rss($rss); if ($success){ $status = "ok"; $pingpath = $config['ping_path']; } else { $status = "failure"; $pingpath = ""; } $TBS->LoadTemplate($tpl_path . 'publish.tpl'); $TBS->MergeField('lang',$lang); $TBS->Show() ; } break; case "newsletter": if ( !$_SESSION['boss'] ) { loadpage("index.php?mode=login_page"); } else { $subject = $lang['newsletter_subject']; $pc = get_pcl(null,null,null,0,1); $mailtext = str_replace("[podcast]",$pc[0]['title'],$lang['newsletter_mailtext']); $pcurl = $config['url']."index.php?mode=open_podcast&pcid=".$pc[0]['id']."\n"; $mailtext = str_replace("[url]",$pcurl,$mailtext)."\n\n\n"; $newsletters = get_newsletters(); $tpl_content = $tpl_path . "newsletter.tpl"; $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('newsletters',$newsletters) ; $TBS->Show() ; } break; case "show_newsletter": if ( !$_SESSION['boss'] ) { loadpage("index.php?mode=login_page"); } else { $id = (int)$_GET['id']; if ($id==0) exit("wrong parameters."); $newsletter = get_newsletters($id); $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'show_newsletter.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('newsletter',$newsletter) ; $TBS->Show() ; } break; case "send_newsletter": if ( !$_SESSION['boss'] ) { loadpage("index.php?mode=login_page"); } else { $send = send_newsletter(); $message = $lang['sent_newsletters']; $backbtn = 1; $backlink = "index.php?mode=newsletter"; $tpl_content = $tpl_path . "message.tpl"; $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->Show() ; } break; case "assign_newsletter": $backbtn = 1; $backlink = "index.php"; $email = $_REQUEST['email']; $check = add_subscriber($email); $check ? $message = $lang['verification_send'] : $message = $error[5]; $tpl_content = $tpl_path . "message.tpl"; $TBS = new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('series',$series) ; $TBS->Show() ; break; case "verify_newsletter": $backbtn = 1; $backlink = "index.php"; $vc = $_REQUEST['vc']; $check = verify_subscriber($vc); $check ? $message = $lang['verification_completed'] : $message = $error[6]; $tpl_content = $tpl_path . "message.tpl"; $TBS = new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeBlock('series',$series) ; $TBS->MergeField('lang',$lang); $TBS->Show() ; break; case "block_newsletter": $backbtn = 1; $backlink = "index.php"; $vc = $_REQUEST['vc']; $check = block_subscriber($vc); $check ? $message = $lang['block_completed'] : $message = $error[6]; $tpl_content = $tpl_path . "message.tpl"; $TBS = new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeBlock('series',$series) ; $TBS->MergeField('lang',$lang); $TBS->Show() ; break; case "play_tutorial": $tid = (int)$_REQUEST['tid']; $tutorial = "swf/tutorial".$tid; $tutorial_swf = "swf/tutorial".$tid.".swf"; $tutorial_width = (int)$_REQUEST['width']; $tutorial_height = (int)$_REQUEST['height']; $TBS =& new clsTinyButStrong; $TBS->LoadTemplate($tpl_path . 'tutorial.tpl'); $TBS->MergeField('lang',$lang); $TBS->Show() ; break; case "new_account": $tpl_content = $tpl_path . "new_account.tpl"; $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('series',$series) ; $TBS->Show() ; break; case "create_account": $backbtn = 1; $backlink = "index.php?mode=new_account"; $check = create_account(); $check ? $message = $lang['account_created_msg'] : $message = $error[7]; $tpl_content = $tpl_path . "message.tpl"; $TBS = new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('series',$series) ; $TBS->Show() ;; break; case "verify_account": $backbtn = 1; $backlink = "index.php"; $ac = $_REQUEST['ac']; $check = verify_account($ac); $check ? $message = $lang['verification_completed'] : $message = $error[6]; $tpl_content = $tpl_path . "message.tpl"; $TBS = new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('series',$series) ; $TBS->Show() ;; break; case "usermgmt": if ( !$_SESSION['boss'] ) { loadpage("index.php?mode=login_page"); } else { $page = (int)$_GET['page']-1; $page > 0 ? $offset = $page*50 : $offset=0; $users = get_users(null,$offset,50); $users_count = get_count("users"); $pagination = paginate($users_count,"usermgmt",(int)$_GET['page'],50); $tpl_content = $tpl_path . "users.tpl"; $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('series',$series) ; $TBS->MergeBlock('users',$users) ; $TBS->Show() ; } break; case "add_edit_user": if ( !$_SESSION['boss'] ) { loadpage("index.php?mode=login_page"); } else { if ( $_REQUEST['save']==1 && isset($_REQUEST['id']) ){ $id = (int)$_REQUEST['id']; save_user($id); loadpage("index.php?mode=usermgmt"); } else { isset($_REQUEST['id']) ? $id = $_REQUEST['id'] : exit("invalid parameters"); if ($id == "new"){ $userinfo = array(); $show_delete_button = 0; } else { $userinfo = get_users($id); $show_delete_button = 1; } $tpl_content = $tpl_path . "user_add_edit.tpl"; $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('series',$series) ; $TBS->MergeBlock('userinfo',$userinfo) ; $TBS->Show() ; } } break; case "delete_user": if ( !$_SESSION['boss'] ) { loadpage("index.php?mode=login_page"); } else { if ( isset($_REQUEST['id'])){ $id = $_REQUEST['id']; delete_user($id); loadpage("index.php?mode=usermgmt"); } } break; case "login_page": $tpl_content = $tpl_path . "login.tpl"; $TBS =& new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('series',$series) ; $TBS->Show() ; break; case "error": isset($_GET['no']) ? $no = (int)$_GET['no'] : $no=0; $message = $error[$no]; $backbtn = (int)$_GET['backbtn']; $backlink = "index.php?mode=".$_REQUEST['backlink']; $tpl_content = $tpl_path . "message.tpl"; $TBS = new clsTinyButStrong ; $TBS->LoadTemplate($tpl_path . 'podcast.tpl') ; $TBS->MergeField('lang',$lang); $TBS->MergeBlock('series',$series) ; $TBS->Show() ; break; case "login": $user = check_login(); if ($user['boss']==1) { $_SESSION['logged_in'] = 1; $_SESSION['boss'] = 1; $_SESSION['uid'] = $user['id']; loadpage('index.php?mode=admin'); } else if ($user){ $_SESSION['logged_in'] = 1; $_SESSION['uid'] = $user['id']; loadpage('index.php'); } else { loadpage('index.php?mode=error&no=1'); } break; case "logout": session_unset(); unset($_SESSION); loadpage('index.php'); break; } /* // generate blank users case "generate_podcasts": $query = "INSERT INTO podcasts (title,link,copyright,pubdate,author,category,". "image,subtitle,duration,keywords,summary,active,series,uploaddate)" . "VALUES ('test','test','bla','0','1','music',". "'bla.jpg','world of bla','000010','bla','bla','$1','1','0')"; $Connection = new mysqlconnection(); for ($i=1;$i<=100;$i++) $Connection->query($query); break; */ ?>