if ($db->foundRows < 1) { system_messages(0, 'Invalid story requested'); return; } $data = $db->fetch_assoc(); ?> <h3 class='arena-match-title'>Title:: <?php echo ucfirst($data['title']); ?> </h3> <hr class='h3-bottom-line' /> <div id="showstories"> <?php echo stripslashes(preg_replace("/<rmore>/", "", $data['content'])); //Remove the read more tag and strip any splashes echo "<p class='article_details'><span class='light1'>" . time_stamp_to_readable($data['create_time']) . "</span> .::. Author: <span class='admin_orange'>{$data['nick_name']}</span></p>"; //Get next and previous stories if any $query = "SELECT * FROM {$_pre}stories WHERE id<{$story_id} AND published=1"; $db->setQuery($query); $prev_stories = "<span class=\"dark1\"><< prev</span>"; if ($db->foundRows > 0) { $tmp = $db->fetch_assoc(); $prev_stories = "<a class=\"bold\" href=\"index.php?a=showstory&s_id={$tmp['id']}\"><< prev</a>"; } $query = "SELECT * FROM {$_pre}stories WHERE id>{$story_id} AND published=1"; $db->setQuery($query); $next_stories = "<span class=\"dark1\">next >></span>"; if ($db->foundRows > 0) { $tmp = $db->fetch_assoc(); $next_stories = "<a class=\"bold\" href=\"index.php?a=showstory&s_id={$tmp['id']}\">next >></a>"; }
return; } $query = "SELECT * FROM {$_pre}{$match_data['match_table_name']} WHERE registration_no='{$registration_no}'"; $db->setQuery($query); //Is this user already registered? if ($db->foundRows > 0) { system_messages(0, 'You are already registered for this match!'); return; } //Now we can safely register this user (fun..) $query = "INSERT INTO {$_pre}{$match_data['match_table_name']} (registration_no,nick_name) VALUES ('{$registration_no}','{$nick_name}')"; $db->setQuery($query); //Update profile table that is, match_count column and add the user to user_match_log table $query = "SELECT match_count FROM " . $_pre . "profile WHERE registration_no='{$registration_no}'"; $db->setQuery($query); $data = $db->fetch_assoc(); $new_match_count = $data['match_count'] + 1; //$matches_participated=(strlen($data['matches_participated'])==0)?$match_data['id'].'---'.$match_data['title']:$data['matches_participated'].'*****'.$match_data['id'].'---'.$match_data['title']; $query = "UPDATE " . $_pre . "profile SET match_count={$new_match_count} WHERE registration_no='{$registration_no}'"; $db->setQuery($query); $query = "INSERT INTO {$_pre}user_match_log (registration_no,match_id,title,match_date,register_date) VALUES ('{$registration_no}',{$match_data['id']},'{$match_data['title']}',{$match_data['start_time']}," . time() . ")"; $db->setQuery($query); //Mail confirmation to user require_once 'lib' . DS . 'mail' . DS . 'mail.php'; $subject = 'Match Registration Confirmation'; $message = "{$_SESSION['user_row_data']['nick_name']},\nYou have been successfuly registered to participate in the CodeZone match {$match_data['title']} scheduled to take place on the " . time_stamp_to_readable($match_data['start_time']) . ".\nMore details on this match can be found here http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}?a=schedule .\nWishing you all the best!\n\nCodeZone Admin"; mailSend(array($_SESSION['user_row_data']['email']), $subject, $message); //Echo success message echo "<p><span class='notify_success'>You have been successfully registered. A confirmation email will be sent to your account shortly</span></p>"; echo "<a href='index.php'>Go to home page</a>"; }
/** * Render news stories in the administration panel */ function renderNewsStories() { global $db, $_pre; $page_limit = isset($_GET['page_limit']) ? (int) $_GET['page_limit'] : 10; //Default is 10 $page_num = isset($_GET['page_num']) ? (int) $_GET['page_num'] : 1; //Default page is 1 if ($page_limit < 0 || $page_limit > 50) { $page_limit = 0; } $filter_string = isset($_GET['filter']) && $_GET['a1'] == 'stories' ? $_GET['filter'] : ""; $filter_query = strlen($filter_string) > 0 ? "WHERE {$_pre}stories.title LIKE '%{$filter_string}%'" : ""; $query = "SELECT * FROM {$_pre}stories {$filter_query} ORDER BY create_time"; $db->setQuery($query); $num_rows = $db->foundRows; if ($num_rows == 0) { //Avoid division by zero here below $num_rows = 1; } $last_page = $page_limit != 0 ? ceil($num_rows / $page_limit) : 1; if ($page_num < 1) { $page_num = 1; } if ($page_num > $last_page) { $page_num = $last_page; } if ($page_limit != 0) { $maximum = 'LIMIT ' . ($page_num - 1) * $page_limit . ',' . $page_limit; } else { $maximum = ''; } $query = "SELECT {$_pre}stories.*,{$_pre}users.nick_name FROM {$_pre}stories LEFT JOIN {$_pre}users ON {$_pre}stories.registration_no = {$_pre}users.registration_no {$filter_query} ORDER BY create_time DESC {$maximum}"; $db->setQuery($query); $found_rows = $db->foundRows; ?> <div id="user_admin_panel"> <div id="loading-bar"><img src="images/progress.gif" /></div><!--Progress bar --> <!--User details are loaded here for editing--> <div id='edit_story_form'></div> <div><!--Story toolbar --> <p> <button class="admin-panel-button" onclick="newStory()">New story</button> <button class="admin-panel-button" onclick="editStoryCb('sbox',<?php echo $found_rows; ?> )">Edit story</button> <button class="admin-panel-button" onclick="storyModify('delete')">Delete story</button> <button class="admin-panel-button" onclick="storyModify('publish')">Publish</button> <button class="admin-panel-button" onclick="storyModify('unpublish')">Unpublish</button> </p> </div> Filter: <input id="story_filter_input" onchange="submitFilter('story_filter_input','index.php?a=su&a1=stories&page_limit=<?php echo $page_limit; ?> &page_num=<?php echo $page_num; ?> ');" type="text" class="admin-panel-text-input" style="width:70px;" value="<?php echo $filter_string; ?> " /> <button class="admin-panel-button" onclick="submitFilter('story_filter_input','index.php?a=su&a1=stories&page_limit=<?php echo $page_limit; ?> &page_num=<?php echo $page_num; ?> ');">go</button> <button class="admin-panel-button" onclick="submitFilterReset('index.php?a=su&a1=stories&page_limit=<?php echo $page_limit; ?> &page_num=<?php echo $page_num; ?> ');">reset</button> <form id="modify_news_story" name="modify_news_story" method="POST" action="index.php?a=su&a1=stories&do=modify_news_story" > <table class='user_row_details' border="0" cellpadding="3" cellspacing="0"> <tr class="header"> <td>#</td><td><input type="checkbox" name="check_all" onclick="checkAll('sbox',<?php echo $found_rows; ?> ,this.checked)" /></td><td>Title</td><td>Published</td><td>Author</td><td>Created on</td><td>ID</td> </tr> <?php $i = ($page_num - 1) * $page_limit + 1; $u = 1; while ($row = $db->fetch_assoc()) { $article_state = $row['published']; if ($article_state == 1) { $article_state_icon = "<img src='theme/images/story_active.png' alt='published' title='published' />"; } else { $article_state_icon = "<img src='theme/images/story_inactive.png' alt='unpublished' title='unpublished' />"; } echo "<tr class='story_row_data'>"; echo "<td>{$i}</td><td><input type='checkbox' name='sbox[]' id='sbox{$u}' value='" . base64_encode($row['id']) . "' /></td><td><a href='javascript:void(0);' class='edit_story' onclick=\"editStory('" . base64_encode($row['id']) . "')\" title='click to edit'>{$row['title']}</a></td><td>{$article_state_icon}</td><td><span class='admin_orange'>{$row['nick_name']}</span></td><td class='greyish'>" . time_stamp_to_readable($row['create_time']) . "</td><td class='greyish'>{$row['id']}</td>"; echo "</tr>"; $i++; $u++; } echo "</table>"; ?> <input type="hidden" name="adm" value="<?php echo base64_encode('su'); ?> " /><input type="hidden" name="f" value="<?php echo base64_encode('modify_news_story'); ?> " /> <input type="hidden" name="story_modify_action" id="story_modify_action" value="" /> </form> <div align="center" class="limit"> <p class="pagination_links"> <?php if ($page_num == 1) { echo "<span class='dead'>back </span>"; } else { echo "<a href='index.php?a=su&a1=stories&page_limit={$page_limit}&page_num=" . ($page_num - 1) . "&filter_story={$filter_string}' class='active'>back </a>"; } for ($i = 1; $i <= $last_page; $i++) { if ($page_num == $i) { echo "<span class='dead'>{$i} </span>"; } else { echo "<a href='index.php?a=su&a1=stories&page_limit={$page_limit}&page_num={$i}&filter_story={$filter_string}' class='active'>{$i} </a>"; } } if ($page_num == $last_page) { echo "<span class='dead'>next </span>"; } else { echo "<a href='index.php?a=su&a1=stories&page_limit={$page_limit}&page_num=" . ($page_num + 1) . "&filter_story={$filter_string}' class='active'>next </a>"; } ?> </p> Display #<select name="limit" class="admin-panel-select" id="" onchange="submitForm('index.php?a=su&a1=stories',this.value);"><option value="5" <?php echo $page_limit == 5 ? "selected='selected'" : ''; ?> >5</option><option value="10" <?php echo $page_limit == 10 ? "selected='selected'" : ''; ?> >10</option><option value="15" <?php echo $page_limit == 15 ? "selected='selected'" : ''; ?> >15</option><option value="20" <?php echo $page_limit == 20 ? "selected='selected'" : ''; ?> >20</option><option value="25" <?php echo $page_limit == 25 ? "selected='selected'" : ''; ?> >25</option><option value="30" <?php echo $page_limit == 30 ? "selected='selected'" : ''; ?> >30</option><option value="50" <?php echo $page_limit == 50 ? "selected='selected'" : ''; ?> >50</option><option value="0" <?php echo $page_limit == 0 ? "selected='selected'" : ''; ?> >all</option></select> </div> </div> <?php }