/** * Show current voting */ function votingShowCurrent($page_content) { global $objDatabase, $_CONFIG, $_ARRAYLANG, $_COOKIE; $paging = ''; $objTpl = new \Cx\Core\Html\Sigma('.'); \Cx\Core\Csrf\Controller\Csrf::add_placeholder($objTpl); $objTpl->setErrorHandling(PEAR_ERROR_DIE); $objTpl->setTemplate($page_content); if (!isset($_GET['vid'])) { $_GET['vid'] = ''; } if (!isset($_POST['votingemail'])) { $_POST['votingemail'] = ''; } $votingId = intval($_GET['vid']); $msg = ''; $voted = false; if ($_POST["votingoption"]) { $voteId = intval($_POST["votingoption"]); $query = "SELECT voting_system_id from " . DBPREFIX . "voting_results WHERE id=" . $voteId; $objResult = $objDatabase->SelectLimit($query, 1); if (!$objResult->EOF) { $votingId = $objResult->fields["voting_system_id"]; } $objVoting = $objDatabase->SelectLimit("SELECT submit_check FROM `" . DBPREFIX . "voting_system` WHERE `id`=" . $votingId, 1); if ($objVoting !== false && $objVoting->RecordCount() == 1) { if ($objVoting->fields['submit_check'] == 'email') { $email = contrexx_addslashes($_POST['votingemail']); $objValidator = new \FWValidator(); if ($objValidator->isEmail($email)) { if (!_alreadyVotedWithEmail($votingId, $email)) { if (($msg = VotingSubmitEmail($votingId, $voteId, $email)) === true) { $msg = ''; $voted = true; } else { $msg = $_ARRAYLANG['TXT_VOTING_NONEXISTENT_EMAIL'] . '<br /><br />'; } } else { $msg = $_ARRAYLANG['TXT_VOTING_ALREADY_VOTED'] . '<br /><br />'; } } else { $msg = $_ARRAYLANG['TXT_VOTING_INVALID_EMAIL_ERROR'] . '<br /><br />'; } } else { VotingSubmit(); $voted = true; } } } if ($_GET['vid'] != '' && $_GET['act'] != 'delete') { $query = "SELECT\n\t\t\tid, status,\n\t\t\tdate as datesec, question,\n\t\t\tvotes, submit_check,\n\t\t\tadditional_nickname, additional_forename,\n\t\t\tadditional_surname, additional_phone,\n\t\t\tadditional_street, additional_zip,\n additional_city, additional_email,\n additional_comment\n\n\t\t\tFROM " . DBPREFIX . "voting_system where id=" . intval($_GET['vid']); } else { $query = "SELECT\n\t\t\tid, status,\n\t\t\tdate as datesec, question,\n\t\t\tvotes, submit_check,\n\t\t\tadditional_nickname, additional_forename,\n\t\t\tadditional_surname, additional_phone,\n\t\t\tadditional_street, additional_zip,\n\t\t \tadditional_city, additional_email,\n additional_comment\n\n\t\t\tFROM " . DBPREFIX . "voting_system where status=1"; } $objResult = $objDatabase->Execute($query); if ($objResult->RecordCount() == 0) { // Only show old records when no voting is set available $objTpl->setVariable(array('VOTING_TITLE' => $_ARRAYLANG['TXT_VOTING_NOT_AVAILABLE'], 'VOTING_DATE' => '', 'VOTING_OLDER_TEXT' => '', 'VOTING_OLDER_DATE' => '', 'VOTING_PAGING' => '', 'TXT_DATE' => '', 'TXT_TITLE' => '', 'VOTING_RESULTS_TEXT' => '', 'VOTING_RESULTS_TOTAL_VOTES' => '', 'VOTING_OLDER_TITLE' => $_ARRAYLANG['TXT_VOTING_OLDER'], 'TXT_SUBMIT' => '')); /** start paging **/ $query = "SELECT id, date as datesec, title, votes FROM " . DBPREFIX . "voting_system order by id desc"; $objResult = $objDatabase->SelectLimit($query, 5); $count = $objResult->RecordCount(); $pos = intval($_GET[pos]); if ($count > intval($_CONFIG['corePagingLimit'])) { $paging = getPaging($count, $pos, "§ion=Voting", "<b>" . $_ARRAYLANG['TXT_VOTING_ENTRIES'] . "</b>", true); } /** end paging **/ $query = "SELECT id, date as datesec, title, votes FROM " . DBPREFIX . "voting_system order by id desc "; $objResult = $objDatabase->SelectLimit($query, $_CONFIG['corePagingLimit'], $pos); while (!$objResult->EOF) { $votingid = $objResult->fields['id']; $votingTitle = stripslashes($objResult->fields['title']); $votingVotes = $objResult->fields['votes']; $votingDate = strtotime($objResult->fields['datesec']); if ($i % 2 == 0) { $class = "row2"; } else { $class = "row1"; } $objTpl->setVariable(array('VOTING_OLDER_TEXT' => '<a href="index.php?section=Voting&vid=' . $votingid . '" title="' . $votingTitle . '">' . $votingTitle . '</a>', 'VOTING_OLDER_DATE' => showFormattedDate($votingDate), 'VOTING_VOTING_ID' => $votingid, 'VOTING_LIST_CLASS' => $class, 'VOTING_PAGING' => $paging)); $objTpl->parse("votingRow"); $i++; $objResult->MoveNext(); } } else { if (!$objResult->EOF) { $votingId = $objResult->fields['id']; $votingTitle = stripslashes($objResult->fields['question']); $votingVotes = $objResult->fields['votes']; $votingDate = strtotime($objResult->fields['datesec']); $votingStatus = $objResult->fields['status']; $votingMethod = $objResult->fields['submit_check']; $additional_fields = _create_additional_input_fields($objResult); $objResult->MoveNext(); } else { errorHandling(); return false; } $images = 1; $query = "SELECT id, question, votes FROM " . DBPREFIX . "voting_results WHERE voting_system_id='{$votingId}' ORDER BY id"; $objResult = $objDatabase->Execute($query); while (!$objResult->EOF) { if ($votingStatus == 1 && ($votingMethod == 'email' && !$voted || $votingMethod == 'cookie' && $_COOKIE['votingcookie'] != '1')) { $votingOptionText .= "<div><input type='radio' id='votingoption_" . $objResult->fields['id'] . "' name='votingoption' value='" . $objResult->fields['id'] . "' " . ($_POST["votingoption"] == $objResult->fields['id'] ? 'checked="checked"' : '') . " /> "; $votingOptionText .= "<label for='votingoption_" . $objResult->fields['id'] . "'>" . stripslashes($objResult->fields['question']) . "</label></div>"; } $objResult->MoveNext(); } $votingResultText = _vote_result_html($votingId); if ($votingStatus == 1 && ($votingMethod == 'email' && !$voted || $votingMethod == 'cookie' && $_COOKIE['votingcookie'] != '1')) { $votingVotes = ''; if ($votingMethod == 'email') { $objTpl->setVariable('VOTING_EMAIL', !empty($_POST['votingemail']) ? htmlentities($_POST['votingemail'], ENT_QUOTES) : ''); $objTpl->parse('voting_email_input'); } else { if ($objTpl->blockExists('voting_email_input')) { $objTpl->hideBlock('voting_email_input'); } } $submitbutton = '<input type="submit" value="' . $_ARRAYLANG['TXT_SUBMIT'] . '" name="Submit" />'; } else { if ($objTpl->blockExists('voting_email_input')) { $objTpl->hideBlock('voting_email_input'); } if ($objTpl->blockExists('additional_fields')) { $objTpl->hideBlock('additional_fields'); } $votingVotes = $_ARRAYLANG['TXT_VOTING_TOTAL'] . ":\t" . $votingVotes; $submitbutton = ''; } if (sizeof($additional_fields)) { $objTpl->parse('additional_fields'); foreach ($additional_fields as $field) { list($name, $label, $tag) = $field; $objTpl->setVariable(array('VOTING_ADDITIONAL_INPUT_LABEL' => $label, 'VOTING_ADDITIONAL_INPUT' => $tag, 'VOTING_ADDITIONAL_NAME' => $name)); $objTpl->parse('additional_elements'); } } else { $objTpl->hideBlock('additional_fields'); } $objTpl->setVariable(array('VOTING_MSG' => $msg, 'VOTING_TITLE' => $votingTitle, 'VOTING_DATE' => showFormattedDate($votingDate), 'VOTING_OPTIONS_TEXT' => $votingOptionText, 'VOTING_RESULTS_TEXT' => $votingResultText, 'VOTING_RESULTS_TOTAL_VOTES' => $votingVotes, 'VOTING_OLDER_TITLE' => $_ARRAYLANG['TXT_VOTING_OLDER'], 'TXT_DATE' => $_ARRAYLANG['TXT_DATE'], 'TXT_TITLE' => $_ARRAYLANG['TXT_TITLE'], 'TXT_VOTES' => $_ARRAYLANG['TXT_VOTES'], 'TXT_SUBMIT' => $submitbutton)); // show other Poll entries /** start paging **/ $query = "SELECT id, date as datesec, title, votes FROM " . DBPREFIX . "voting_system WHERE id<>{$votingId} order by id desc"; $objResult = $objDatabase->SelectLimit($query, 5); $count = $objResult->RecordCount(); $pos = intval($_GET[pos]); if ($count > intval($_CONFIG['corePagingLimit'])) { $paging = getPaging($count, $pos, "§ion=Voting", "<b>" . $_ARRAYLANG['TXT_VOTING_ENTRIES'] . "</b>", true); } /** end paging **/ $query = "SELECT id, date as datesec, title, votes FROM " . DBPREFIX . "voting_system WHERE id<>{$votingId} order by id desc "; $objResult = $objDatabase->SelectLimit($query, $_CONFIG['corePagingLimit'], $pos); $objTpl->setVariable(array('VOTING_OLDER_TEXT' => '', 'VOTING_OLDER_DATE' => '', 'VOTING_VOTING_ID' => '', 'VOTING_PAGING' => '', 'TXT_DATE' => '', 'TXT_TITLE' => '')); while (!$objResult->EOF) { $votingid = $objResult->fields['id']; $votingTitle = stripslashes($objResult->fields['title']); $votingVotes = $objResult->fields['votes']; $votingDate = strtotime($objResult->fields['datesec']); if ($i % 2 == 0) { $class = "row2"; } else { $class = "row1"; } $objTpl->setVariable(array('VOTING_OLDER_TEXT' => '<a href="index.php?section=Voting&vid=' . $votingid . '" title="' . $votingTitle . '">' . $votingTitle . '</a>', 'VOTING_OLDER_DATE' => showFormattedDate($votingDate), 'VOTING_VOTING_ID' => $votingid, 'VOTING_LIST_CLASS' => $class, 'VOTING_PAGING' => $paging)); $objTpl->parse("votingRow"); $i++; $objResult->MoveNext(); } } return $objTpl->get(); }
<?php /** * Created by PhpStorm. * User: Mazhar * Date: 10/25/2014 * Time: 5:59 PM */ if (isset($_REQUEST['error'])) { $error = $_REQUEST['error']; $user_name = isset($_REQUEST['user_ame']) ? $_REQUEST['user_ame'] : ""; $user_id = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : ""; errorHandling($error, $user_name, $user_id); } function errorHandling($e, $user_name = "", $user_id = "") { $content = "Message: {$user_name} has faced this error and his User ID is {$user_id} on " . date("l jS \\of F Y h:i:s A") . " {$e} \n"; $myFile = "log/error/errorLog.txt"; $fh = fopen($myFile, 'a+') or die("can't open file"); fwrite($fh, $content); fclose($fh); } /* * */