function __construct($options = null) { // clear cache $cache_time = 30; //minutes $dir = dirname($_SERVER['SCRIPT_FILENAME']) . '/files'; $dir_contents = scandir($dir); foreach ($dir_contents as $entry) { if (is_dir($dir . '/' . $entry) && $entry != "." && $entry != "..") { $time = filemtime($dir . '/' . $entry); if (@strtotime('now') - $time > 60 * $cache_time) { rrmdir($dir . '/' . $entry); } } } // clear thumbnails $cache_time = 30; //minutes $dir = dirname($_SERVER['SCRIPT_FILENAME']) . '/thumbnails'; $dir_contents = scandir($dir); foreach ($dir_contents as $entry) { if (is_dir($dir . '/' . $entry) && $entry != "." && $entry != "..") { $time = filemtime($dir . '/' . $entry); if (@strtotime('now') - $time > 60 * $cache_time) { rrmdir($dir . '/' . $entry); } } } empty($_REQUEST['param_name']) ? $param_name = 'files' : ($param_name = $_REQUEST['param_name']); $rand = randomAlphaNum(5); while (is_dir(dirname($_SERVER['SCRIPT_FILENAME']) . '/files/' . $rand . '/')) { $rand = randomAlphaNum(5); } mkdir(dirname($_SERVER['SCRIPT_FILENAME']) . '/files/' . $rand . '/', 0777); $this->options = array('rand' => $rand, 'script_url' => $this->getFullUrl() . '/', 'upload_dir' => dirname($_SERVER['SCRIPT_FILENAME']) . '/files/' . $rand . '/', 'upload_url' => $this->getFullUrl() . '/files/' . $rand . '/', 'param_name' => $param_name, 'delete_type' => 'DELETE', 'max_file_size' => null, 'min_file_size' => 1, 'accept_file_types' => '/.+$/i', 'max_number_of_files' => null, 'discard_aborted_uploads' => true, 'orient_image' => false, 'image_versions' => array('thumbnail' => array('upload_dir' => dirname($_SERVER['SCRIPT_FILENAME']) . '/thumbnails/', 'upload_url' => $this->getFullUrl() . '/thumbnails/' . $rand . '/', 'max_width' => 80, 'max_height' => 80))); if ($options) { $this->options = array_replace_recursive($this->options, $options); } }
include 'functions.php'; connectdb(); if ($_POST['action'] == 'email') { // change the email id of the user if (trim($_POST['email']) == "") { header("Location: account.php?derror=1"); } else { mysqli_query("UPDATE users SET email='" . mysql_real_escape_string($_POST['email']) . "' WHERE username='******'username'] . "'"); header("Location: account.php?changed=1"); } } else { if ($_POST['action'] == 'password') { // change the password of the user if (trim($_POST['oldpass']) == "" or trim($_POST['newpass']) == "") { header("Location: account.php?derror=1"); } else { $query = "SELECT salt,hash FROM users WHERE username='******'username'] . "'"; $result = mysql_query($query); $fields = mysql_fetch_array($result); $currhash = crypt($_POST['oldpass'], $fields['salt']); if ($currhash == $fields['hash']) { $salt = randomAlphaNum(5); $newhash = crypt($_POST['newpass'], $salt); mysqli_query("UPDATE users SET hash='{$newhash}', salt='{$salt}' WHERE username='******'username'] . "'"); header("Location: account.php?changed=1"); } else { header("Location: account.php?passerror=1"); } } } }
$calc2014plzen = array(array('name' => 'Volební kalkulačka Plzeň 2014', 'friendly_url' => 'plzen-2014', 'custom' => true)); $calc2014ostrava = array(array('name' => 'Volební kalkulačka Ostrava 2014', 'friendly_url' => 'ostrava-2014', 'custom' => true)); $calc2014praha = array(array('name' => 'Volební kalkulačka Praha 2014', 'friendly_url' => 'praha-2014', 'custom' => true)); $calc2014brno = array(array('name' => 'Volební kalkulačka Brno 2014', 'friendly_url' => 'brno-2014', 'selected' => true, 'custom' => true)); $calc2014senat = array(array('name' => 'Volební kalkulačka Senát 2014', 'friendly_url' => 'senat-2014', 'selected' => true, 'custom' => true)); $calc2014senat1 = array(array('name' => 'Volební kalkulačka Senát 2014 - Praha 10', 'friendly_url' => 'senat-2014-1', 'selected' => false, 'custom' => true)); $calc2014ep = array(array('name' => 'Volební kalkulačka EP 2014', 'friendly_url' => 'evropsky-parlament-2014/', 'selected' => false, 'custom' => true)); $inventory2014ep = array(array('name' => 'Inventura hlasování EP 2009-2014', 'friendly_url' => 'inventura-hlasovani-evropsky-parlament-2009-2014/', 'selected' => false, 'custom' => true)); $calc2013 = array(array('name' => 'Volební kalkulačka 2013', 'friendly_url' => 'poslanecka-snemovna-2013/')); $inventory2013 = array(array('name' => 'Inventura hlasování 2010-2013', 'friendly_url' => 'poslanecka-snemovna-2013-inventura-hlasovani/')); $president2 = array(array('name' => 'Prezidentská kalkulačka 2. kolo', 'friendly_url' => 'volba-prezidenta-cr-2-kolo-2013/')); $president = array(array('name' => 'Prezidentská kalkulačka 1. kolo', 'friendly_url' => 'volba-prezidenta-cr-2013/')); $sizes = array(array('name' => 'Největší 850x600', 'width' => '850', 'height' => '600'), array('name' => 'Standardní 650x550', 'width' => '650', 'height' => '550', 'selected' => true), array('name' => 'Mobilní 480x320', 'width' => '480', 'height' => '320'), array('name' => 'Mobilní na výšku 320x480', 'width' => '320', 'height' => '480')); $calcs = array('inventory2014' => array('name' => 'Inventura hlasování ve Sněmovně 2014', 'calc' => $inventory2014), 'calc2014praha' => array('name' => 'Volební kalkulačka Praha 2014', 'calc' => $calc2014praha), 'calc2014brno' => array('name' => 'Volební kalkulačka Brno 2014', 'calc' => $calc2014brno), 'calc2014ostrava' => array('name' => 'Volební kalkulačka Ostrava 2014', 'calc' => $calc2014ostrava), 'calc2014plzen' => array('name' => 'Volební kalkulačka Plzeň 2014', 'calc' => $calc2014plzen), 'calc2014pardubice' => array('name' => 'Volební kalkulačka Pardubice 2014', 'calc' => $calc2014pardubice), 'calc2014liberec' => array('name' => 'Volební kalkulačka Liberec 2014', 'calc' => $calc2014liberec), 'calc2014ceskebudejovice' => array('name' => 'Volební kalkulačka České Budějovice 2014', 'calc' => $calc2014ceskebudejovice), 'calc2014olomouc' => array('name' => 'Volební kalkulačka Olomouc 2014', 'calc' => $calc2014olomouc), 'calc2014karlovyvary' => array('name' => 'Volební kalkulačka Karlovy Vary 2014', 'calc' => $calc2014karlovyvary), 'calc2014bohumin' => array('name' => 'Volební kalkulačka Bohumín 2014', 'calc' => $calc2014bohumin), 'calc2014prostejov' => array('name' => 'Volební kalkulačka Prostějov 2014', 'calc' => $calc2014prostejov), 'calc2014decin' => array('name' => 'Volební kalkulačka Děčín 2014', 'calc' => $calc2014decin), 'calc2014trutnov' => array('name' => 'Volební kalkulačka Trutnov 2014', 'calc' => $calc2014trutnov), 'calc2014zdarnadsazavou' => array('name' => 'Volební kalkulačka Žďár nad Sázavou 2014', 'calc' => $calc2014trutnov), 'calc2014liberec2010' => array('name' => 'Inventura hlasování Liberec 2010-2014', 'calc' => $calc2014liberec2010), 'calc2014senat' => array('name' => 'Volební kalkulačka Senát 2014', 'calc' => $calc2014senat), 'calc2014senat1' => array('name' => 'Volební kalkulačka Senát 2014 - Praha 10', 'calc' => $calc2014senat1), 'calc2014ep' => array('name' => 'Volební kalkulačka Evropský parlament 2014', 'calc' => $calc2014ep), 'inventory2014ep' => array('name' => 'Inventura hlasování Evropský parlament 2009-2014', 'calc' => $inventory2014ep), 'all' => array('name' => 'Celá VolebníKalkulačka.cz', 'calc' => array(array('name' => 'VolebníKalkulačka.cz', 'friendly_url' => '?'))), 'calc2013' => array('name' => 'Názorový test volby 2013', 'calc' => $calc2013), 'inventory2013' => array('name' => 'Inventura hlasování 2010-2013', 'calc' => $inventory2013), 'president2' => array('name' => 'Prezidentská kalkulačka 2013 2.kolo', 'calc' => $president2), 'president' => array('name' => 'Prezidentská kalkulačka 2013 1.kolo', 'calc' => $president), 'region' => array('name' => 'Krajské volební kalkulačky 2012', 'calc' => $regions), 'senate' => array('name' => 'Senátní volební kalkulačka 2012', 'calc' => $constit)); //random key $key = randomAlphaNum(8); $smarty->assign('calcs', $calcs); $smarty->assign('key', $key); $smarty->assign('sizes', $sizes); $smarty->display('embed.tpl'); /** * generates random key */ function randomAlphaNum($length) { $rangeMin = pow(36, $length - 1); //smallest number to give length digits in base 36 $rangeMax = pow(36, $length) - 1; //largest number to give length digits in base 36 $base10Rand = mt_rand($rangeMin, $rangeMax); //get the random number