function commons_get_list_exclude($db) { global $config; foreach ($config['catremove'] as $element => $category) { // set exclude to 2 in fotos so we know later which images are no longer in this category on commons $sql = "UPDATE `" . $config['dbprefix'] . "fotos` SET `exclude`='1' WHERE `exclude`='2'"; $db->query($sql); // get list of images from commons $url = 'http://commons.wikimedia.org/w/api.php?action=query&list=categorymembers&format=xml&cmtitle=Category:' . $category . '&cmprop=title&continue'; // read data and save to db $continue = getdata_exclude($url, $db); while ($continue != "") { if ($continue == "connection error") { // log error if ($config['log'] != "NO") { append_file("log/cron.txt", "\n\t" . date(DATE_RFC822) . "connection error\tcommons_get_list_exclude()"); } return "STOP"; } // read data and save to db $continue = getdata_exclude($url . "=-||&cmcontinue=" . $continue, $db); } // end api loop // set exclude to 0 in fotos for images that are no longer in this category on commons $sql = "UPDATE `" . $config['dbprefix'] . "fotos` SET `exclude`='0' WHERE `exclude`='2'"; $db->query($sql); } }
/** * Wiki Loves Jurytool * * @author Ruben Demus * @copyright 2015 Ruben Demus * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE * License as published by the Free Software Foundation; either * version 3 of the License, or any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU AFFERO GENERAL PUBLIC LICENSE for more details. * * You should have received a copy of the GNU Affero General Public * License along with this library. If not, see <http://www.gnu.org/licenses/>. * */ function login($db, $type = "v_") { global $config; global $text; $numuser = 0; if (isset($_GET["p"])) { if ($_GET["p"] == "logout") { if (version_compare(phpversion(), '5.4.0', '>=')) { if (session_status() != PHP_SESSION_NONE) { session_destroy(); } } else { if (session_id() != "") { session_destroy(); } } $_SESSION['us'] = ""; $_SESSION['pw'] = ""; } } if (isset($_POST["name"])) { $_SESSION['us'] = $_POST["name"]; $_SESSION['pw'] = $db->real_escape_string(sha1($_POST["pw"] . $config["salt"])); } if (isset($_SESSION['us'])) { $user = $db->real_escape_string($_SESSION['us']); $pw = $db->real_escape_string($_SESSION['pw']); $sql = "SELECT `width`, `info`, `userlevel` FROM `" . $config['dbprefix'] . $type . "jury` WHERE `lname` LIKE '{$user}' AND `pw` LIKE '{$pw}'"; $res = $db->query($sql); $numuser = $res->num_rows; } if ($numuser == 1) { $row = $res->fetch_array(MYSQLI_ASSOC); $user = $db->real_escape_string($_SESSION['us']); $_SESSION['width'] = $row['width']; $_SESSION['info'] = $row['info']; $_SESSION['userlevel'] = $row['userlevel']; $sql = "UPDATE `" . $config['dbprefix'] . $type . "jury` SET `time`='" . time() . "' WHERE `lname`= '" . $user . "'"; $db->query($sql); return "OK"; } else { if (isset($_POST["name"]) && $config['log'] != "NO") { append_file("../log/login.txt", "\n" . date(DATE_RFC822) . "\t" . $_SESSION['us'] . "\t" . $_SESSION['pw']); } return "<p style=\"color: orange;\"> <br><b>Login</b><br> </p>\n\t\t<form action=\"index.php\" method=\"post\">\n\n\t\t<table width=\"180\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n\t\t\t<tr valign=\"top\">\n\t\t\t\t<td>\n\t\t\t\t\t" . $text["username"] . ":<br> \n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<input name=\"name\"><br> \n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr valign=\"top\">\n\t\t\t\t<td>\n\t\t\t\t\t" . $text["password"] . ":<br>\n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<input type=\"password\" name=\"pw\"><br> \n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr valign=\"top\">\n\t\t\t\t<td> <br> \n\t\t\t\t</td>\n\t\t\t\t<td>\n\t\t\t\t\t<div align=\"right\"><input type=\"submit\" value=\" " . $text["login"] . " \"><div>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</table>\n\t\t</form></div>"; } $res->close(); }
function commons_get_licence($db) { global $config; // get information about files from commons $sql = "SELECT `name` FROM `" . $config['dbprefix'] . "fotos` WHERE `license` LIKE '' AND (`online`=1 OR `online`=2)"; $res = $db->query($sql); if ($res) { while ($row = $res->fetch_array(MYSQLI_ASSOC)) { // commons api query $url = 'http://commons.wikimedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=xml&titles=' . urlencode($row['name']); $file = $db->real_escape_string($row['name']); // read data $str = @file_get_contents($url); if ($str === FALSE) { if ($config['log'] != "NO") { append_file("log/cron.txt", "\n" . date(DATE_RFC822) . "\tfile:" . $url . "\tcommons_get_licence()"); } } else { $xml = new SimpleXMLElement($str); if (isset($xml->query->pages->page->revisions->rev)) { foreach ($config['license'] as $license) { if (stripos($xml->query->pages->page->revisions->rev[0], $license) !== false) { $sql = "UPDATE `" . $config['dbprefix'] . "fotos` SET license='" . $license . "' WHERE `name` = '" . $file . "'"; $db->query($sql); } } // foreach } // if(!isset($xml->query->pages->page->revisions->rev)) } // ($str !== FALSE) } // row } }
<title><?php echo $config['title'] . " - " . $text['admin']; ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" href="../theme/styles.css"> <?php $log = "-"; // mysql $db = new mysqli($config['dbhost'], $config['dbuser'], $config['dbpassword'], $config['dbname']); if ($db->connect_error) { // log error if ($config['log'] != "NO") { append_file("log/admin.txt", "\n" . date(DATE_RFC822) . "\tdb connect_error\tmain()"); } } else { $menue = $uploader = ""; // prejury or jury admin or manager $log = login($db, "v_"); if ($log != "OK") { $log = login($db, ""); // try jury } else { $userlevel = $_SESSION['userlevel']; $log = login($db, ""); // try jury if ($log != "OK") { $log = login($db, "v_"); } else {
function bpi_route_command($cmd) { print "<p class='gohome'><a href='index.php'>BPI Home</a></p>"; switch ($cmd) { ///////////////////////////ADD GROUP//////////////////////////// case 'add': //and new group form //do stuff print "<div class='container'>"; if (isset($_POST['addSubmitted'])) { $config = process_post($_POST); if (isset($config)) { append_file($config); } print "<p><a href='index.php?cmd=add'>Add More Groups</a></p>"; } else { empty_form(); } print "</div>\n"; break; ///////////////////////////DELETE GROUP//////////////////////////// ///////////////////////////DELETE GROUP//////////////////////////// case 'delete': //delete stuff if (isset($_GET['arg'])) { //add javascript confirmation of group deletion $arg = htmlentities(trim($_GET['arg'])); delete_group($arg); } else { print "<p class='error'>Error: No BPI Group specifies to delete.</p>"; } break; ///////////////////////////EDIT GROUP//////////////////////////// ///////////////////////////EDIT GROUP//////////////////////////// case 'edit': print "<div class='container'>"; //edit existing groups if (isset($_GET['arg'])) { //add javascript confirmation of group deletion $arg = htmlentities(trim($_GET['arg'])); $config = get_config_array($arg); if (isset($_POST['editSubmitted'])) { $config = process_post($_POST); //process the form data, make sure it comes back valid if (isset($config)) { edit_group($arg, $config); } } else { loaded_form($config); } } else { print "<p class='error'>Error: No BPI Group specifies to delete.</p>"; } print "</div>\n"; break; case 'fixconfig': include 'config_functions/fix_config.php'; break; default: //default to view page if value is bad send_home(); break; } //end SWITCH }
function commons_get_list($db) { global $config; // set online to 2 in fotos so we know later which images are no longer in this category on commons $sql = "UPDATE `" . $config['dbprefix'] . "fotos` SET `online`='1' WHERE `online`='2'"; $db->query($sql); if ($config['log'] == "PARANOID" || $config['log'] == "DEBUG") { append_file("log/cron.txt", "\n" . date(DATE_RFC822) . "\t" . $sql . "\tcommons_get_list()"); } foreach ($config['catadd'] as $element => $category) { $sql = "UPDATE `" . $config['dbprefix'] . "fotos_commons` SET online='1' WHERE `commons` = '{$category}' AND `online`='2'"; $db->query($sql); if ($config['log'] == "PARANOID" || $config['log'] == "DEBUG") { append_file("log/cron.txt", "\n" . date(DATE_RFC822) . "\t" . $sql . "\tcommons_get_list()"); } // commons api query $url = 'http://commons.wikimedia.org/w/api.php?action=query&list=categorymembers&format=xml&cmtitle=Category:' . $category . '&cmprop=title&continue'; // read data and save to db $continue = getdata($url, $db, $category); while ($continue != "") { if ($continue == "connection error") { // log error if ($config['log'] != "NO") { append_file("log/cron.txt", "\n" . date(DATE_RFC822) . "\tconnection error\tcommons_get_list()"); } return "STOP"; } // read data and save to db $continue = getdata($url . "=-||&cmcontinue=" . $continue, $db, $category); } // end api loop $sql = "UPDATE `" . $config['dbprefix'] . "fotos_commons` SET online='0' WHERE `commons` = '{$category}' AND `online`='1'"; $db->query($sql); if ($config['log'] == "PARANOID" || $config['log'] == "DEBUG") { append_file("log/cron.txt", "\n" . date(DATE_RFC822) . "\t" . $sql . "\tcommons_get_list()"); } } // set online to 0 in fotos for images that are no longer in this category on commons $sql = "UPDATE `" . $config['dbprefix'] . "fotos` SET `online`='0' WHERE `online`='1'"; $db->query($sql); if ($config['log'] == "PARANOID" || $config['log'] == "DEBUG") { append_file("log/cron.txt", "\n" . date(DATE_RFC822) . "\t" . $sql . "\tcommons_get_list()"); } }
} function read_file($filename) { $f=fopen($filename,"r"); $data=fread($f,filesize($filename)); fclose($f); return $data; } $ka_bantable = 'banlist'; include_once('../auth.php'); $mysql_db = 'minecraft'; $write_location = 'banned_names.txt'; $con = mysql_connect($mysql_host,$mysql_user,$mysql_pass); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db($mysql_db, $con); $result = mysql_query("SELECT name FROM banlist"); while($row = mysql_fetch_array($result)) { //add more data ot the existing file append_file($write_location,$row['name'].' '); } echo 'Bans written!'; ?>
<title><?php echo $config['title'] . " - " . $text['jury']; ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" href="../theme/styles.css"> <?php $menue = $uploader = $settings = ""; $log = "-"; // mysql $db = new mysqli($config['dbhost'], $config['dbuser'], $config['dbpassword'], $config['dbname']); if ($db->connect_error) { // log error if ($config['log'] != "NO") { append_file("../log/jury.txt", "\n" . date(DATE_RFC822) . "\tdb connect_error\tmain()"); } } else { $log = login($db, ""); if ($log == "OK") { // user settings width if (isset($_GET["width"])) { $width = $db->real_escape_string($_GET['width']); $_SESSION['width'] = $width; $user = $db->real_escape_string($_SESSION['us']); $sql = "UPDATE `" . $config['dbprefix'] . "jury` SET `width`='" . $width . "' WHERE `lname`= '" . $user . "'"; $db->query($sql); } // menue // set hide menue if (isset($_GET["h"])) {
<?php $base = arg('b base') ?: plural($name); $vars = compact('pk', 'base', 'name', 'fields', 'model_class'); $skel_dir = path(dirname(__DIR__), 'assets'); $out_file = path(APP_PATH, 'app', 'controllers', "{$base}.php"); if (!is_file($out_file) or arg('f force')) { $routes = render(path($skel_dir, 'routes.php'), $vars); $controller = render(path($skel_dir, 'controller.php'), $vars); $show_view = render(path($skel_dir, 'views', 'show.php'), $vars); $error_view = render(path($skel_dir, 'views', 'error.php'), $vars); $index_view = render(path($skel_dir, 'views', 'index.php'), $vars); $create_view = render(path($skel_dir, 'views', 'create.php'), $vars); $modify_view = render(path($skel_dir, 'views', 'modify.php'), $vars); $klass = preg_quote($model_class, '/'); $based = preg_quote($base, '/'); add_controller($base, TRUE); inject_into_file($out_file, $controller, array('unless' => "/\\b{$klass}::/", 'before' => '/\\}[^{}]*?$/')); create_dir(path(APP_PATH, 'app', 'views', $base)); create_file(path(APP_PATH, 'app', 'views', $base, 'show.php.neddle'), $show_view); create_file(path(APP_PATH, 'app', 'views', $base, 'index.php.neddle'), $index_view); create_file(path(APP_PATH, 'app', 'views', $base, 'create.php.neddle'), $create_view); create_file(path(APP_PATH, 'app', 'views', $base, 'modify.php.neddle'), $modify_view); create_file(path(APP_PATH, 'app', 'views', $base, 'errors.php.neddle'), $error_view); append_file(path(APP_PATH, 'config', 'routes.php'), "\n{$routes}", "/'root'\\s*=>\\s*'\\/{$based}'/"); } else { error("\n Scaffold for '{$base}' already exists\n"); }