summaryrefslogtreecommitdiffstats
path: root/public/help/cs/wiki_syntax_markdown.html
blob: 08f3f48c1db74c32b177362ebc12188fe132d6a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Wiki formátování</title>
<link rel="stylesheet" type="text/css" href="../wiki_syntax.css" />
</head>
<body>

<h1><h1>Syntaxe Wiki - rychlý náhled</h1> (Markdown)</h1>

<table style="width:100%">
<tr><th colspan="3">Styly písma <span class="more_info">(<a href="wiki_syntax_detailed_markdown.html#5" target="_blank">more</a>)</span></th></tr>
<tr><th><img src="../../images/jstoolbar/bt_strong.png" style="border: 1px solid #bbb;" alt="Strong" /></th><td style="width:50%;">**Tučně**</td><td style="width:50%;"><strong>Tučně</strong></td></tr>
<tr><th><img src="../../images/jstoolbar/bt_em.png" style="border: 1px solid #bbb;" alt="Italic" /></th><td>*Kurzívou*</td><td><em>Kurzívou</em></td></tr>
<tr><th><img src="../../images/jstoolbar/bt_ins.png" style="border: 1px solid #bbb;" alt="Underline" /></th><td>_Underline_</td><td><ins>Underline</ins></td></tr>
<tr><th><img src="../../images/jstoolbar/bt_del.png" style="border: 1px solid #bbb;" alt="Deleted" /></th><td>~~Smazaný~~</td><td><del>Smazaný</del></td></tr>
<tr><th><img src="../../images/jstoolbar/bt_code.png" style="border: 1px solid #bbb;" alt="Inline Code" /></th><td>`Vnořený kód`</td><td><code>Vnořený kód</code></td></tr>
<tr><th><img src="../../images/jstoolbar/bt_pre.png" style="border: 1px solid #bbb;" alt="Preformatted text" /></th><td>```<br />&nbsp;řádky<br />&nbsp;kódu<br />```</td><td>
<pre>
 řádky
 kódu
</pre>
</td></tr>

<tr><th colspan="3">Highlighted code <span class="more_info">(<a href="wiki_syntax_detailed_markdown.html#13" target="_blank">more</a> | <a href="../code_highlighting_languages.html" target="_blank">supported languages</a>)</span></th></tr>
<tr><th><img src="../../images/jstoolbar/bt_precode.png" style="border: 1px solid #bbb;" alt="Highlighted code" /></th><td>``` ruby<br />3.times do<br />&nbsp;&nbsp;puts 'Hello'<br />end<br />```</td><td>
<pre><code class="ruby syntaxhl"><span class="mi">3</span><span class="p">.</span><span class="nf">times</span> <span class="k">do</span>
  <span class="nb">puts</span> <span class="s1">'Hello'</span>
<span class="k">end</span>
</code></pre>
</td></tr>

<tr><th colspan="3">Seznamy</th></tr>
<tr><th><img src="../../images/jstoolbar/bt_ul.png" style="border: 1px solid #bbb;" alt="Unordered list" /></th><td>* Položka 1<br />&nbsp;&nbsp;* Pod<br />* Položka 2</td><td><ul><li>Položka 1<ul><li>Pod</li></ul></li><li>Položka 2</li></ul></td></tr>
<tr><th><img src="../../images/jstoolbar/bt_ol.png" style="border: 1px solid #bbb;" alt="Ordered list" /></th><td>1. Položka 1<br />&nbsp;&nbsp;&nbsp;1. Pod<br />2. Položka 2</td><td><ol><li>Položka 1<ol><li>Pod</li></ol></li><li>Položka 2</li></ol></td></tr>

<tr><th colspan="3">Nadpisy <span class="more_info">(<a href="wiki_syntax_detailed_markdown.html#8" target="_blank">more</a>)</span></th></tr>
<tr><th><img src="../../images/jstoolbar/bt_h1.png" style="border: 1px solid #bbb;" alt="Heading 1" /></th><td># Nadpis 1</td><td><h1>Nadpis 1</h1></td></tr>
<tr><th><img src="../../images/jstoolbar/bt_h2.png" style="border: 1px solid #bbb;" alt="Heading 2" /></th><td>## Nadpis 2</td><td><h2>Nadpis 2</h2></td></tr>
<tr><th><img src="../../images/jstoolbar/bt_h3.png" style="border: 1px solid #bbb;" alt="Heading 3" /></th><td>### Nadpis 3</td><td><h3>Nadpis 3</h3></td></tr>

<tr><th colspan="3">Odkazy <span class="more_info">(<a href="wiki_syntax_detailed_markdown.html#4" target="_blank">more</a>)</span></th></tr>
<tr><th></th><td>http://foo.bar</td><td><a href="#">http://foo.bar</a></td></tr>
<tr><th></th><td>[Odkaz](http://foo.bar)</td><td><a href="#">Foo</a></td></tr>

<tr><th colspan="3">Redmine odkazy <span class="more_info">(<a href="wiki_syntax_detailed_markdown.html#3" target="_blank">more</a>)</span></th></tr>
<tr><th><img src="../../images/jstoolbar/bt_link.png" style="border: 1px solid #bbb;" alt="Link to a Wiki page" /></th><td>[[Wiki stránka]]</td><td><a href="#">Wiki stránka</a></td></tr>
<tr><th></th><td>Úkol #12</td><td>Úkol <a href="#">#12</a></td></tr>
<tr><th></th><td>##12</td><td><a href="#">Bug #12</a>: The issue subject</td></tr>
<tr><th></th><td>Revize r43</td><td>Revize <a href="#">r43</a></td></tr>
<tr><th></th><td>commit:f30e13e43</td><td><a href="#">f30e13e4</a></td></tr>
<tr><th></th><td>source:some/file</td><td><a href="#">source:some/file</a></td></tr>

<tr><th colspan="3">Vnořené obrázky <span class="more_info">(<a href="wiki_syntax_detailed_markdown.html#7" target="_blank">more</a>)</span></th></tr>
<tr><th><img src="../../images/jstoolbar/bt_img.png" style="border: 1px solid #bbb;" alt="Image" /></th><td>![](<em>url_obrázku</em>)</td><td></td></tr>
<tr><th></th><td>![](<em>vnořený_obrázek</em>)</td><td></td></tr>

<tr><th colspan="3">Tabulky</th></tr>
<tr>
  <th></th>
  <td>| A | B | C |<br />|---|---|---|<br />| A | B | C |<br />| D | E | F |</td>
  <td>
    <table class="sample">
      <tbody>
        <th>A</th><th>B</th><th>C</th>
        <tr><td>A</td><td>B</td><td>C</td></tr>
        <tr><td>D</td><td>E</td><td>F</td></tr>
      </tbody>
    </table>
  </td>
</tr>

</table>

<p><a href="wiki_syntax_detailed_markdown.html" onclick="window.open('wiki_syntax_detailed_markdown.html', '', ''); return false;">Více informací</a></p>

</body>
</html>
ble29'>backport/49009/49009-stable29 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Security/RateLimiting/Backend/DatabaseBackend.php
blob: 9fb237f2f720a1048b542889fd789a785562a29f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php

declare(strict_types=1);

/**
 * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
namespace OC\Security\RateLimiting\Backend;

use OCP\AppFramework\Utility\ITimeFactory;
use OCP\DB\Exception;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;

class DatabaseBackend implements IBackend {
	private const TABLE_NAME = 'ratelimit_entries';

	public function __construct(
		private IConfig $config,
		private IDBConnection $dbConnection,
		private ITimeFactory $timeFactory,
	) {
	}

	private function hash(
		string $methodIdentifier,
		string $userIdentifier,
	): string {
		return hash('sha512', $methodIdentifier . $userIdentifier);
	}

	/**
	 * @throws Exception
	 */
	private function getExistingAttemptCount(
		string $identifier,
	): int {
		$currentTime = $this->timeFactory->getDateTime();

		$qb = $this->dbConnection->getQueryBuilder();
		$qb->delete(self::TABLE_NAME)
			->where(
				$qb->expr()->lte('delete_after', $qb->createNamedParameter($currentTime, IQueryBuilder::PARAM_DATETIME_MUTABLE))
			)
			->executeStatement();

		$qb = $this->dbConnection->getQueryBuilder();
		$qb->select($qb->func()->count())
			->from(self::TABLE_NAME)
			->where(
				$qb->expr()->eq('hash', $qb->createNamedParameter($identifier, IQueryBuilder::PARAM_STR))
			);

		$cursor = $qb->executeQuery();
		$row = $cursor->fetchOne();
		$cursor->closeCursor();

		return (int)$row;
	}

	/**
	 * {@inheritDoc}
	 */
	public function getAttempts(
		string $methodIdentifier,
		string $userIdentifier,
	): int {
		$identifier = $this->hash($methodIdentifier, $userIdentifier);
		return $this->getExistingAttemptCount($identifier);
	}

	/**
	 * {@inheritDoc}
	 */
	public function registerAttempt(
		string $methodIdentifier,
		string $userIdentifier,
		int $period,
	): void {
		$identifier = $this->hash($methodIdentifier, $userIdentifier);
		$deleteAfter = $this->timeFactory->getDateTime()->add(new \DateInterval("PT{$period}S"));

		$qb = $this->dbConnection->getQueryBuilder();

		$qb->insert(self::TABLE_NAME)
			->values([
				'hash' => $qb->createNamedParameter($identifier, IQueryBuilder::PARAM_STR),
				'delete_after' => $qb->createNamedParameter($deleteAfter, IQueryBuilder::PARAM_DATETIME_MUTABLE),
			]);

		if (!$this->config->getSystemValueBool('ratelimit.protection.enabled', true)) {
			return;
		}

		$qb->executeStatement();
	}
}