Ejemplo n.º 1
0
function tagForGraphCheck($tag, $type)
{
    if (!isValidTag(strtoupper($_GET["tag"]))) {
        printInvalidTag($_GET["tag"]);
        exit;
    }
    if (!tagExists(strtoupper($_GET["tag"]))) {
        printInexistingTag($_GET["tag"]);
        exit;
    }
    if (!graphExists(strtoupper($_GET["tag"]), $type)) {
        printInexistingGraph();
        exit;
    }
}
Ejemplo n.º 2
0
  <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
</head>

<body>

<h1><a href="<?php 
print href("");
?>
">The Stacks project sloganerator</a></h1>

<?php 
$tag = isset($_GET["tag"]) ? $_GET["tag"] : '';
if (!isValidTag($tag)) {
    $message = "The tag that was requested (<code>" . htmlentities($tag) . "</code>) is not a valid tag. You can request a new tag.";
    printError($message);
} elseif (!tagExists($tag)) {
    $message = "The tag that was requested (<code>" . $tag . "</code>) does not exist in the Stacks project. You can request a new tag.";
    printError($message);
} else {
    $meta = json_decode(file_get_contents("http://" . $_SERVER["HTTP_HOST"] . href("data/tag/" . $tag . "/meta")));
    if (in_array($meta->type, array("lemma", "proposition", "remark", "remarks", "theorem"))) {
        print "<p>You can suggest a slogan for <a href='" . href("tag/" . $tag) . "'>tag <code>" . $tag . "</code></a> (label: <code style='font-size: .9em'>" . $meta->label . "</code>), located in<br>";
        $id = explode(".", $meta->book_id);
        print "&nbsp&nbsp;Chapter " . $id[0] . ": " . parseAccents($meta->chapter_name) . "<br>";
        print "&nbsp&nbsp;Section " . $id[1] . ": " . parseAccents($meta->section_name);
        printStatement($tag);
        printForm($tag);
        $slogans = getSlogans($tag);
        if (!empty($slogans) or $meta->slogan != "") {
            printSlogans($slogans, $meta->slogan);
        }
Ejemplo n.º 3
0
require_once "../tags.php";
ini_set('display_errors', 1);
error_reporting(E_ALL);
// read configuration file
$config = parse_ini_file("../../config.ini");
// initialize the global database object
try {
    $database = new PDO("sqlite:" . "../../" . $config["database"]);
} catch (PDOException $e) {
    echo $e->getMessage();
}
if (!isValidTag($_GET["tag"])) {
    print "This tag is not valid.";
    exit;
}
if (!tagExists($_GET["tag"])) {
    print "This tag does not exist.";
    exit;
}
$tag = getTag($_GET["tag"]);
$chapter = getEnclosingChapter($tag["position"]);
$section = getEnclosingSection($tag["position"]);
$result = array();
$result["type"] = $tag["type"];
$result["label"] = $tag["label"];
$result["chapter_page"] = $tag["chapter_page"];
$result["book_page"] = $tag["book_page"];
$result["book_id"] = $tag["book_id"];
$result["value"] = $tag["value"];
$result["slogan"] = $tag["slogan"];
$result["chapter_name"] = $chapter["name"];
Ejemplo n.º 4
0
{
    print "<br><a href='#' onclick='history.go(-2);'>go back</a>";
}
// if this triggers the user is messing with the POST request
if (!isset($_POST['tag']) or !isValidTag($_POST['tag'])) {
    print 'The tag your browser supplied in the request is not in a valid format.';
    printBackLink();
    exit;
}
if ($_POST['tag'] !== $_POST['check']) {
    print 'You did not pass the captcha. Please go back and fill in the correct tag to prove you are not a computer.';
    printBackLink();
    exit;
}
// the tag is not present in the database, when we start handling removed tags this will have to change
if (!tagExists($_POST['tag'])) {
    print 'The tag you are trying to post a comment on does not exist.';
    printBackLink();
    exit;
}
// empty author
if (empty($_POST['name'])) {
    print 'You must supply your name.';
    printBackLink();
    exit;
}
// empty email
if (empty($_POST['mail'])) {
    print 'You must supply your email address. Remark that it will not be posted.';
    printBackLink();
    exit;
Ejemplo n.º 5
0
$userNotFound = false;
$tagName = "";
if (isset($_GET['tag'])) {
    $tagName = $_GET['tag'];
}
//If there is any tags for the user
$tagName = filter($tagName);
$tagName = strtolower($tagName);
$exists = true;
$tagNames = explode(' ', trim($tagName));
$tagcount = count($tagNames);
for ($i = 0; $i < $tagcount; $i++) {
    $tagNames[$i] = trim($tagNames[$i]);
}
foreach ($tagNames as $currentTag) {
    $exists = tagExists($currentTag);
}
require_once 'includes/user.php';
$user = new User();
$currentUsername = $user->getUsername();
$pageUrl = "userb.php?uname=" . $userName . "&amp;tag=" . $tagName;
include 'includes/pagenb.php';
if (!$userName && $currentUsername != null) {
    $userName = $currentUsername;
}
$strPageQuery = "?uname=" . $userName;
if ($tagName != "") {
    $strPageQuery .= "&amp;tag=" . $tagName;
}
//Feed to display in header
$feedToDisplay = array();
Ejemplo n.º 6
0
                 $page = new TagDeletedPage($database, $tag);
             }
         } else {
             $page = new MissingTagPage($database, $tag);
         }
     } else {
         $page = new TagLookupPage($database);
     }
     break;
 case "tag":
     if (!empty($_GET["tag"])) {
         $tag = strtoupper($_GET['tag']);
         if (!isValidTag($tag)) {
             $page = new InvalidTagPage($database, $tag);
         } else {
             if (tagExists($tag)) {
                 if (tagIsActive($tag)) {
                     $page = new TagViewPage($database, $tag);
                 } else {
                     $page = new TagDeletedPage($database, $tag);
                 }
             } else {
                 $page = new MissingTagPage($database, $tag);
             }
         }
     } else {
         $page = new TagLookupPage($database);
     }
     break;
 case "tags":
     $page = new TagsPage($database);
Ejemplo n.º 7
0
function updateTags($b_id, $strTags)
{
    $strTags = trim($strTags);
    $tags = split(" ", $strTags);
    // Get each single tag
    //Remove tags if not there anymore
    //Get old tags
    $strOldTags = returnAllTags($b_id);
    $oldTags = split(" ", $strOldTags);
    // Get each single tag
    foreach ($oldTags as $old_tag) {
        $found = false;
        foreach ($tags as $new_tag) {
            if ($old_tag == $new_tag) {
                $found = true;
                break;
            }
        }
        if (!$found) {
            // Not there anymore, remove the link
            $result = unstoreTag($b_id, $old_tag);
        }
    }
    $nbChars = 0;
    //Add new tags if any
    foreach ($tags as $current_tag) {
        if (tagExists($current_tag)) {
            $tagID = returnTagID($current_tag);
            if (!returnTagLinked($b_id, $tagID)) {
                $result = storeTag($b_id, $current_tag);
            }
        } else {
            // Check max length (30) and if 150 chars have been added
            $nbChars += strlen($current_tag);
            if ($nbChars <= 150 && strlen(trim($current_tag)) <= 30) {
                $result = addTag($current_tag);
                $tagID = returnTagID($current_tag);
                $result2 = storeTag($b_id, $current_tag);
            }
        }
    }
}