function ResetPoll($x = null) { global $db; if (!is_numeric($x) && !($x = GetID(true))) { return false; } $db->exec('UPDATE ' . PRE . 'answers SET num=0 WHERE IDP IN (' . $x . ')'); $db->exec('UPDATE ' . PRE . 'polls SET num=0 WHERE ID IN (' . $x . ')'); $db->exec('DELETE FROM ' . PRE . 'pollvotes WHERE ID IN (' . $x . ')'); RebuildPoll(); }
if (!$id) { $id = $db->lastInsertId(); } #Insert answers $q1 = $db->prepare('UPDATE ' . PRE . 'answers SET a=?, seq=?, color=? WHERE ID=? AND IDP=?'); $q2 = $db->prepare('INSERT INTO ' . PRE . 'answers (seq,IDP,a,color) VALUES (?,?,?,?)'); for ($i = 0; $i < $num; $i++) { if ($an[$i][0]) { $q1->execute(array($an[$i][1], $i, $an[$i][2], $an[$i][0], $id)); } elseif ($an[$i][1]) { $q2->execute(array($i, $id, $an[$i][1], $an[$i][2])); } } #Update cache of latest polls include './mod/polls/poll.php'; RebuildPoll(); #Apply changes $db->commit(); $view->info($lang['saved'], array(url('editPoll', '', 'admin') => $lang['addPoll'], url('editPoll/' . $id, '', 'admin') => $lang['editPoll'], url('poll/' . $id) => $poll['name'])); return 1; } catch (Exception $e) { $view->info($lang['error'] . $e); } } elseif ($id) { if (!($poll = $db->query('SELECT * FROM ' . PRE . 'polls WHERE ID=' . $id)->fetch(2))) { return; } $an = $db->query('SELECT ID,a,color FROM ' . PRE . 'answers WHERE IDP=' . $id . ' ORDER BY seq')->fetchAll(3); } else { $poll = array('name' => '', 'q' => '', 'type' => 1, 'ison' => 1, 'access' => LANG); $an = array(array(0, '', '#ed1c24'), array(0, '', '#22b14c'), array(0, '', '#3f48cc'));
function commit(&$data) { $cfg = array(); Installer::$urlMode = $this->urls; #Content options - category IDs foreach ($this->catid as $lang => $id) { $cfg['start'][$lang] = $id; } require './cfg/content.php'; $o = new Config('content'); $o->save($cfg); $cfg = array(); require './cfg/main.php'; #Get Sblam! key if (function_exists('fsockopen')) { $key = @file_get_contents('http://sblam.com/keygen.html'); $cfg['captcha'] = 1; $cfg['sbKey'] = $key ? $key : NULL; } else { $cfg['captcha'] = 0; $cfg['sbKey'] = NULL; } #Main options - page title and URL format $cfg['title'] = $this->title; $cfg['RSS'] = $this->rss; $o = new Config('main'); $o->add('cfg', $cfg); $o->save(); #Database access - db.php $this->buildConfig($data); #Rebuild polls if (file_exists('./mod/polls')) { include './mod/polls/poll.php'; RebuildPoll(null, $this->db); } #Sort categories include './lib/categories.php'; RebuildTree($this->db); RSS(null, $this->db); #Create menu cache include './lib/mcache.php'; RenderMenu($this->db); #Finish :) $this->db->commit(); }