public static function getInstance()
 {
     if (self::$_instance === NULL) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Пример #2
0
function createCSVFile($results)
{
    $csvPath = SettingsStorage::settings()["csv_file_locations"];
    $rand = Utils::generateRandomString(10) . '.csv';
    $results->asCSV(FileStorage::getPath($rand, $csvPath));
    return $rand;
}
Пример #3
0
 /**
  * MammalClassifier constructor.
  * @param null $settings A settings object to run the algorithm
  * @param bool $scientistDataset Switches between running on live data, or scientist data
  */
 public function __construct($settings = null, $scientistDataset = false)
 {
     $this->result = null;
     $this->imageId = null;
     try {
         $this->db = new ClassificationQuery();
     } catch (PDOException $exception) {
         trigger_error("Failure to create a database connection." . " Possibly database settings provided are wrong", E_USER_WARNING);
     }
     if (!$settings) {
         $settings = SettingsStorage::settings();
     }
     $this->scientistDataset = $scientistDataset;
     $this->CONSECUTIVE_EXPECTED = Utils::getValue($settings['consecutive_expected'], 8);
     $this->VOTES_BEFORE_CONSENSUS = Utils::getValue($settings['votes_before_consensus'], 15);
     $this->UNREASONABLE_NUMBER_OF_SPECIES_IN_IMAGE = Utils::getValue($settings['unreasonable_number_of_species_in_image'], 5);
     $this->EVENNESS_THRESHOLD_COUNT = Utils::getValue($settings['evenness_threshold_count'], 0.6899999999999999);
     $this->EVENNESS_THRESHOLD_SPECIES = Utils::getValue($settings['evenness_threshold_species'], 0.7);
     $this->NUMBER_OF_NOTHING_HERE_BEFORE_CLASSIFY = Utils::getValue($settings["number_of_nothing_here_before_classify"], 5);
 }
Пример #4
0
		<thead>
			<tr>
				<th>' . i18n("login_Username") . '</th>
				<th>' . i18n("generic_level") . '</th>
				<th>' . i18n("generic_regdate") . '</th>
				<th>' . i18n("dashboard_Articles") . '</th>
				<th>' . i18n("generic_actions") . '</th>
			</tr>
		</thead>';
    foreach ($currentusers as $username => $userdata) {
        $level = $userdata[level];
        $level = $leveltotext[$level];
        $main_content .= "<tr><form method=\"get\"><input type=\"hidden\" name=\"panel\" value=\"users\" /><input type=\"hidden\" name=\"edit\" value=\"{$username}\" /><td>{$username}</td><td>{$level}</td><td>" . date("j. F Y", $userdata[registered]) . "</td><td></td><td><input type=\"submit\" value=\"" . i18n("generic_edit") . "\" /><input type=\"submit\" name=\"action[delete]\" class=\"delete\" value=\"" . i18n("generic_delete") . "\" /></td></form></tr>";
    }
    $main_content .= '
	</table>
	</fieldset>
	</div><div class="div_extended"><p>Extended options</p></div>';
}
#
#	Delete
#
if ($_GET[action][delete]) {
    $userkey = $_GET[edit];
    $dataclass = new SettingsStorage('settings');
    $users = $dataclass->settings['users'];
    $dataclass->delete("users", $userkey);
    $moduletitle = "Delete article";
    # Give the user a status message
    $statusmessage = "User &quot;{$userkey}&quot; dropped from database.";
}
Пример #5
0
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: X-Requested-With");
if (isset($_REQUEST['action'])) {
    $apiParam = $_REQUEST['action'];
    try {
        if ($apiParam === 'get') {
            $settings = SettingsStorage::settings();
            echo json_encode($settings);
        } else {
            if ($apiParam === 'store') {
                if (isset($_POST['settings'])) {
                    $settingsChange = json_decode($_POST['settings'], true);
                    if (is_null($settingsChange)) {
                        error('Invalid settings provided, couldn\'t parse the JSON');
                    } else {
                        SettingsStorage::set($settingsChange);
                        echo json_encode(["success" => true]);
                    }
                } else {
                    error('You need to set the post field "settings" before storing data');
                }
            } else {
                error("Invalid action");
            }
        }
    } catch (PDOException $e) {
        error("Failure in database connection.");
    }
} else {
    error("No action provided");
}
Пример #6
0
function setGlobalSetting($settingname,$settingvalue)
{
    global $connect, $$settingname, $demoModeOnly;
    if ($demoModeOnly==true && ($settingname=='sitename' || $settingname=='defaultlang' || $settingname=='defaulthtmleditormode' || $settingname=='filterxsshtml'))
    {
        return; //don't save
    }
    $usquery = "update ".db_table_name("settings_global")." set stg_value='".auto_escape($settingvalue)."' where stg_name='$settingname'";
    $connect->Execute($usquery);
    if ($connect->Affected_Rows()==0)
    {
        $usquery = "insert into  ".db_table_name("settings_global")." (stg_value,stg_name) values('".auto_escape($settingvalue)."','$settingname')";
        $connect->Execute($usquery);
    }
    $registry = SettingsStorage::getInstance();
    $registry->set($settingname,$settingvalue);
    if (isset($$settingname)) $$settingname=$settingvalue;
}
Пример #7
0
 private function registerConfig()
 {
     $command = $this->register('config');
     // set description
     $command->setDescription('Sets configuration (api key, country code)');
     // set arguments
     $command->setDefinition(array(new InputArgument('name', InputArgument::REQUIRED, 'Setting name'), new InputArgument('value', InputArgument::REQUIRED, 'Setting value')));
     // set action
     $command->setCode(function (InputInterface $input, OutputInterface $output) {
         $name = $input->getArgument('name');
         if (!in_array($name, ['key', 'code'])) {
             $output->writeln("Config {$name} not supported");
             return;
         }
         // store key
         $value = $input->getArgument('value');
         SettingsStorage::getInstance()->set(['value' => $value], $name);
         SettingsStorage::getInstance()->save();
         $output->writeln("Config {$name} stored witch value {$value}");
     });
 }
Пример #8
0
if ($User->level < 4) {
    die(i18n("login_noaccess"));
}
include "options.php";
$moduletitle = "Manage users";
if ($_POST[adduser]) {
    #
    #	Add a new user (Routine)
    $statusmessage = $User->add();
}
if ($_POST[edituser]) {
    #
    #	Edit user (Routine)
    #
    $now = time();
    $dataclass = new SettingsStorage('settings');
    $currentusers = $dataclass->settings['users'];
    # Remove unwanted stuff!
    $_POST[edituser][name] = sanitize_variables($_POST[edituser][name]);
    $_POST[edituser][password] = sanitize_variables($_POST[edituser][password]);
    $_POST[edituser][email] = sanitize_variables($_POST[edituser][email]);
    $_POST[edituser][url] = sanitize_variables($_POST[edituser][url]);
    $_POST[edituser][profile] = sanitize_variables($_POST[edituser][profile]);
    $adduserkey = urlTitle($_POST[edituser][name]);
    if (!array_key_exists($adduserkey, $currentusers)) {
        $statusmessage = "User &quot;{$adduserkey}&quot; does not exist.<br /><a href=\"javascript:history.go(-1);\">How about choosing another name?</a>";
    } else {
        $olduser = $currentusers[$adduserkey];
        # has the password changed?
        if ($_POST[edituser][password] != "") {
            $_POST[edituser][password] = md5($_POST[edituser][password]);
Пример #9
0
if ($User->level < 4) {
    die(i18n("login_noaccess"));
}
$moduletitle = i18n("options_moduletitle", "12twelve");
$menus["sub_options"] = '

<ul style="margin: 20px 0 15px 45px;">
	<li id="options_menu_users"><a href="?panel=users">' . i18n("menu_users") . '</a></li>
	<li id="options_menu_templates"><a href="?panel=template">' . i18n("menu_templates") . '</a></li>
	<li id="options_menu_categories"><a href="?panel=options&amp;screen=categories">' . i18n("menu_categories") . '</a></li>
	<li id="options_menu_utils"><a href="?panel=options&amp;screen=utils">' . i18n("menu_utils") . '</a></li>
	<li id="options_menu_setup"><a href="?panel=options&amp;screen=setup">' . i18n("menu_setup", SCRIPT_TITLE) . '</a></li>
</ul>
';
$settingclass = new SettingsStorage('settings');
$currentcats = $Settings->ca;
$alltemplates = $Settings->te;
#
# Knife setup
#
if ($_GET[screen] == "setup") {
    if ($_POST[configsave]) {
        foreach ($_POST[config] as $where => $value) {
            $Settings->saveConfig($where, $value);
        }
    } else {
        /*
         *	Setup option values;
         */
        $i18nfiles = FileFolderList("./lang/", $depth = 1, $current = '', $level = 0);
Пример #10
0
<?php

if ($User->level < 4) {
    die(i18n("login_noaccess"));
}
include "options.php";
$moduletitle = i18n("templates_moduletitle");
function html2specialchars($str)
{
    $trans_table = array_flip(get_html_translation_table(HTML_SPECIALCHARS));
    return strtr($str, $trans_table);
}
#	Fetch and set up needed data
$settingclass = new SettingsStorage('settings');
$templates = $settingclass->settings['templates'];
if ($_POST[template] && !$_POST["switch"]) {
    $id = sanitize_variables(stripslashes($_POST[template][id]));
    $templateid = sanitize_variables(stripslashes($_POST[template][id]));
    $data = array("name" => html2specialchars(stripslashes($_POST[template][name])), "listing" => html2specialchars(stripslashes($_POST[template][listing])), "view" => html2specialchars(stripslashes($_POST[template][view])), "comment" => html2specialchars(stripslashes($_POST[template][comment])), "quote" => html2specialchars(stripslashes($_POST[template][quote])), "commentform" => html2specialchars(stripslashes($_POST[template][commentform])));
    $settingclass->settings['templates'][$id] = $data;
    $settingclass->save();
    $statusmessage = "Template &quot;{$data['name']}&quot; updated <br /><a href=\"javascript:history.go(-1);\">Go back</a>";
}
if ($_POST[changet]) {
    $chtdo = $_POST[changet];
    #
    #	Delete template
    #
    if ($chtdo["delete"]) {
        $id = $_POST[id];
        $moduletitle = "Delete Template";