mirror of
https://github.com/UnickSoft/graphonline.git
synced 2026-04-05 07:16:17 +00:00
Added vote to site
This commit is contained in:
48
src/vote_func.php
Normal file
48
src/vote_func.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
function getVoteTopics()
|
||||
{
|
||||
global $g_config, $g_lang;
|
||||
|
||||
$voteTopics = array();
|
||||
$voteTopicsFile = $g_config['voteTopics'] . $g_lang["current_language"];
|
||||
$csvTopicFile = fopen($voteTopicsFile, "r");
|
||||
if ($csvTopicFile)
|
||||
{
|
||||
while (($data = fgetcsv($csvTopicFile, 1000, "|")) !== FALSE)
|
||||
{
|
||||
$topic["title"] = $data[0];
|
||||
$topic["desc"] = $data[1];
|
||||
$voteTopics[] = $topic;
|
||||
}
|
||||
|
||||
fclose($csvTopicFile);
|
||||
}
|
||||
|
||||
return $voteTopics;
|
||||
}
|
||||
|
||||
function getVotes($voteTopics)
|
||||
{
|
||||
global $g_config;
|
||||
|
||||
$votes = array();
|
||||
for ($i = 0; $i < count($voteTopics); $i++)
|
||||
{
|
||||
$votes[] = 0;
|
||||
}
|
||||
|
||||
$voteFile = fopen($g_config['vote'], "r");
|
||||
if ($voteFile)
|
||||
{
|
||||
while (($line = fgets($voteFile)) !== false)
|
||||
{
|
||||
$votes[intval($line)] ++;
|
||||
}
|
||||
}
|
||||
|
||||
fclose($voteFile);
|
||||
|
||||
return $votes;
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user