Exemplo n.º 1
0
 /**
  * funkce pro aktualizaci struktury
  * @param type $relativePath 
  */
 public function updateStructure($relativePath, $ownerId = 0)
 {
     if (empty($relativePath)) {
         return true;
     }
     $relativePath = \Nette\Utils\Strings::endsWith($relativePath, "/") ? substr($relativePath, 0, -1) : $relativePath;
     $parts = explode("/", $relativePath);
     $create = false;
     $count = count($parts);
     $c = 0;
     $parent = 0;
     if ($parts && $count > 0) {
         foreach ($parts as $part) {
             $folder = $this->connection->fetch("SELECT * FROM [:vd:folders] WHERE [name] = %s", $part);
             if (!$folder || $create) {
                 $data = array('parent' => $parent, 'has_child' => $c < $count ? 1 : 0, 'name' => $part, 'nicename' => \Nette\Utils\Strings::webalize($part), 'editor_id' => $ownerId ?: 0);
                 if (!empty($part)) {
                     $this->connection->query('INSERT INTO [:vd:folders] ', $data);
                     $parent = $this->connection->getInsertId();
                 }
             } elseif ($folder) {
                 $parent = $folder['folder_id'];
             }
             if (!$folder || !$folder['has_child']) {
                 $create = true;
             }
             $c++;
         }
     }
     return $parent;
 }
Exemplo n.º 2
0
        $pairs = $res->fetchPairs('id', 'title');
        echo "<option value='' class='optionTexts' selected></option>";
        foreach ($pairs as $id => $title) {
            echo "<option value='{$id}' class='optionTexts'>{$title}</option>";
        }
        break;
    case "selecttesttype":
        $language = mysql_real_escape_string(isset($_GET['la']) ? $_GET['la'] : $default_language);
        $res = $db->query('SELECT * FROM TestTypes WHERE language="' . $language . '" AND public=1');
        $pairs = $res->fetchPairs('id', 'title');
        echo "<option value='' class='optionTestTypes' selected></option>";
        foreach ($pairs as $id => $title) {
            echo "<option value='{$id}' class='optionTestTypes'>{$title}</option>";
        }
        break;
    case "inserttext":
        $id = mysql_real_escape_string(isset($_GET['id']) ? $_GET['id'] : '0');
        $text = $db->fetchSingle('SELECT text FROM Texts WHERE id="' . $id . '"');
        echo $text;
        break;
    case "gettesttype":
        $id = mysql_real_escape_string(isset($_GET['id']) ? $_GET['id'] : '0');
        $row = $db->fetch('SELECT * FROM TestTypes WHERE id="' . $id . '" LIMIT 1');
        $terms = $row->terms;
        $function = $row->function;
        $json = array('terms' => $terms, 'functionName' => $function);
        header("Content-Type: application/json", true);
        echo json_encode($json);
    case "":
        break;
}
Exemplo n.º 3
0
<?php

require_once 'vendor/autoload.php';
require_once 'config.php';
use Dibi\Dibi;
$db = new DibiConnection($database_configuration);
$secret = isset($_GET['secret']) ? $_GET['secret'] : '';
if ($minimise_code) {
    $minimise = ".min";
} else {
    $minimise = "";
}
$row = $db->fetch('SELECT * FROM Tests WHERE secret="' . $secret . '" LIMIT 1');
$language = $row->language;
$textId = (int) $row->text;
$testTypeId = (int) $row->testtype;
$testText = $row->test;
$solution = $row->solution;
$level = $row->level;
$save = (bool) $row->save;
$public = (bool) $row->public;
if (strlen($language) == 2) {
    setcookie('language', $language);
    $locale = $db->fetchSingle('SELECT locale FROM Languages WHERE code="' . $language . '"');
} else {
    $language = $default_language;
    if (isset($_COOKIE['language'])) {
        $locale = $db->fetchSingle('SELECT locale FROM Languages WHERE code="' . $_COOKIE['language'] . '"');
    } else {
        setcookie('language', $default_language);
        $locale = $db->fetchSingle('SELECT locale FROM Languages WHERE code="' . $default_language . '"');