\n"; if ( !mysql_num_rows($res) ) { echo "No polls available.\n"; } while ( $poll_arr = mysql_fetch_array($res) ) { if ( $poll_arr['Active'] == 'on' ) $active = " "; else $active = " "; $poll_question = process_line_output( $poll_arr['Question'] ); echo " $active Edit | Delete  {$poll_question} \n"; } echo "\n"; } function MemberDeletePoll() { $res = db_res( "DELETE FROM `polls_q` WHERE ID = ". (int)$_GET['delete_id'] ); if ( $res ) $res = db_res( "DELETE FROM `polls_a` WHERE ID = ". (int)$_GET['delete_id'] ); return $res; } function MemberAddPoll() { global $def_new_polls; global $MySQL; $poll_question = process_db_input( $_POST['Question'] ); $res = db_res( "INSERT INTO `polls_q` SET `Question` = '$poll_question'" ); $poll_id = mysql_insert_id( $MySQL->link ); if ( $res ) { for ( $i=0 ; $i < $def_new_polls ; ++$i ) { $poll_answer = process_db_input( trim($_POST["Answer{$i}"]) ); if ( strlen($poll_answer) == 0 ) continue; $res = db_res( "INSERT INTO `polls_a` (`ID`, `Answer`) VALUES ($poll_id, '$poll_answer')" ); } } return $res; } function MemberEditPoll() { $poll_id = (int)$_POST['edit_id']; $poll_question = process_db_input( $_POST['Question'] ); $poll_active = ($_POST['Active'] ? "on" : "" ); $res = db_res( "UPDATE `polls_q` SET `Question` = '$poll_question', `Active` = '$poll_active' WHERE ID = $poll_id" ); $res = db_res( "SELECT `IDanswer` FROM `polls_a` WHERE `ID` = $poll_id" ); while ( $answ_arr = mysql_fetch_array($res) ) { $poll_answer = process_db_input( trim($_POST[$answ_arr['IDanswer']]) ); if ( strlen($poll_answer) > 0 ) db_res( "UPDATE `polls_a` SET `Answer` = '$poll_answer' WHERE `IDanswer` = {$answ_arr['IDanswer']} " ); else db_res( "DELETE FROM `polls_a` WHERE `IDanswer` = {$answ_arr['IDanswer']} " ); } $poll_answer = process_db_input( trim($_POST['NewAnswer']) ); if ( strlen($poll_answer) > 0 ) { $res = db_res( "INSERT INTO `polls_a` (`ID`, `Answer`) VALUES ($poll_id, '$poll_answer')" ); } return $res; } $action_result = ""; if ( !$demo_mode && $_POST['action'] == 'new' && strlen($_POST['Question']) ) { if ( MemberAddPoll() ) $action_result .= "Poll was added"; else $action_result .= "Poll adding failed"; } if ( !$demo_mode && $_POST['action'] == 'edit' && ((int)$_POST['edit_id'] != 0) && strlen($_POST['Question']) ) { if ( MemberEditPoll() ) $action_result .= ( "Poll was updated" ); else $action_result .= ( "Poll updating failed" ); } if ( !$demo_mode && (int)$_GET['delete_id'] != 0 && $_GET['action'] == "delete" ) { if ( MemberDeletePoll() ) $action_result .= ( "Poll was deleted" ); else $action_result .= ( "Poll deleting failed" ); } $_page['header'] = ( "Polls administration" ); $_page['header_text'] = ( "" ); TopCodeAdmin(); ContentBlockHead("Polls administration"); if ( strlen($action_result) ) echo "
$action_result

\n"; MemberPrintPolls(); $m_per_row = 1; if ( (int)$_GET['edit_id'] != 0 ) { $poll_arr = db_arr( "SELECT * FROM `polls_q` WHERE `ID` = ". (int)$_GET['edit_id'] ); $res_answers = db_res( "SELECT `IDanswer`, `ID`, `Answer`, `Votes` FROM `polls_a` WHERE `ID` = ". (int)$_GET['edit_id'] ." ORDER BY `IDanswer` ASC" ); } ContentBlockFoot(); ContentBlockHead("Polls"); ?>
\n"; } else { $checked = ($poll_arr['Active'] == 'on' ? 'checked' : ''); echo "Active Poll        \n"; echo "\n"; echo "\n"; echo "\n"; } ?>
>
 Question 
>
"; } } else { $i = 0; while ( $arr_answers = mysql_fetch_array($res_answers) ) { echo " "; ++$i; } echo " "; } ?>
Answer ". ($i + 1) ." :  
Answer ". ($i + 1) ." :  
New Answer :  

\n"; echo "