Browse Source

Update .gitignore and use Composer

biotorrents 4 years ago
parent
commit
e62f7a933b
7 changed files with 4016 additions and 3105 deletions
  1. 32
    6
      .gitignore
  2. 9
    9
      classes/script_start.php
  3. 0
    1994
      classes/vendor/Parsedown.php
  4. 0
    686
      classes/vendor/ParsedownExtra.php
  5. 0
    410
      classes/vendor/TwitterAPIExchange.php
  6. 52
    0
      composer.json
  7. 3923
    0
      composer.lock

+ 32
- 6
.gitignore View File

1
-classes/config.php
2
-_packages/**/.git/**
1
+# https://github.com/OPSnet/Gazelle/blob/master/.gitignore
3
 
2
 
4
-static/styles/*.css
5
-static/styles/assets/fonts/**
6
-static/common/badges/**
3
+# backup files
4
+*.bak
5
+*.sw*
6
+*~
7
 
7
 
8
+# home folder
8
 .DS_Store
9
 .DS_Store
9
-*.sw*
10
+.bash_history
11
+.cache/
12
+.config/
13
+.histfile
14
+.lesshst
15
+.local/
16
+.npm-global/
17
+.npm/
18
+.npmrc
19
+.php_history
20
+.pki/
21
+.profile
22
+.wget-hsts
23
+.zsh*
24
+__MACOSX/
25
+
26
+# app files
27
+/cache
28
+/classes/config.php
29
+/node_modules
30
+/vendor
31
+
32
+# heavy assets
33
+/static/common/badges/**
34
+/static/styles/**/*.css
35
+/static/styles/assets/fonts/**

+ 9
- 9
classes/script_start.php View File

1
 <?php
1
 <?php
2
 #declare(strict_types=1);
2
 #declare(strict_types=1);
3
 
3
 
4
-# https://www.php.net/manual/en/language.oop5.autoload.php
4
+# Initialize
5
 require_once 'config.php';
5
 require_once 'config.php';
6
 require_once 'security.class.php';
6
 require_once 'security.class.php';
7
 
7
 
8
-# Initialize
9
 $ENV = ENV::go();
8
 $ENV = ENV::go();
10
 $Security = new Security();
9
 $Security = new Security();
11
 $Security->SetupPitfalls();
10
 $Security->SetupPitfalls();
57
 }
56
 }
58
 ob_start(); // Start a buffer, mainly in case there is a mysql error
57
 ob_start(); // Start a buffer, mainly in case there is a mysql error
59
 
58
 
60
-require SERVER_ROOT.'/classes/debug.class.php'; // Require the debug class
61
-require SERVER_ROOT.'/classes/mysql.class.php'; // Require the database wrapper
62
-require SERVER_ROOT.'/classes/cache.class.php'; // Require the caching class
63
-require SERVER_ROOT.'/classes/time.class.php'; // Require the time class
64
-require SERVER_ROOT.'/classes/paranoia.class.php'; // Require the paranoia check_paranoia function
65
-require SERVER_ROOT.'/classes/util.php';
59
+require_once SERVER_ROOT.'/classes/debug.class.php'; // Require the debug class
60
+require_once SERVER_ROOT.'/classes/mysql.class.php'; // Require the database wrapper
61
+require_once SERVER_ROOT.'/classes/cache.class.php'; // Require the caching class
62
+require_once SERVER_ROOT.'/classes/time.class.php'; // Require the time class
63
+require_once SERVER_ROOT.'/classes/paranoia.class.php'; // Require the paranoia check_paranoia function
64
+require_once SERVER_ROOT.'/classes/util.php';
66
 
65
 
67
 $Debug = new DEBUG;
66
 $Debug = new DEBUG;
68
 $Debug->handle_errors();
67
 $Debug->handle_errors();
72
 $Cache = new Cache($ENV->getPriv('MEMCACHED_SERVERS'));
71
 $Cache = new Cache($ENV->getPriv('MEMCACHED_SERVERS'));
73
 
72
 
74
 // Autoload classes.
73
 // Autoload classes.
75
-require SERVER_ROOT.'/classes/autoload.php';
74
+require_once SERVER_ROOT.'/vendor/autoload.php';
75
+#require_once SERVER_ROOT.'/classes/autoload.php';
76
 
76
 
77
 // Note: G::initialize is called twice.
77
 // Note: G::initialize is called twice.
78
 // This is necessary as the code inbetween (initialization of $LoggedUser) makes use of G::$DB and G::$Cache.
78
 // This is necessary as the code inbetween (initialization of $LoggedUser) makes use of G::$DB and G::$Cache.

+ 0
- 1994
classes/vendor/Parsedown.php
File diff suppressed because it is too large
View File


+ 0
- 686
classes/vendor/ParsedownExtra.php View File

1
-<?php
2
-
3
-#
4
-#
5
-# Parsedown Extra
6
-# https://github.com/erusev/parsedown-extra
7
-#
8
-# (c) Emanuil Rusev
9
-# http://erusev.com
10
-#
11
-# For the full license information, view the LICENSE file that was distributed
12
-# with this source code.
13
-#
14
-#
15
-
16
-class ParsedownExtra extends Parsedown
17
-{
18
-    # ~
19
-
20
-    const version = '0.8.0';
21
-
22
-    # ~
23
-
24
-    function __construct()
25
-    {
26
-        if (version_compare(parent::version, '1.7.1') < 0)
27
-        {
28
-            throw new Exception('ParsedownExtra requires a later version of Parsedown');
29
-        }
30
-
31
-        $this->BlockTypes[':'] []= 'DefinitionList';
32
-        $this->BlockTypes['*'] []= 'Abbreviation';
33
-
34
-        # identify footnote definitions before reference definitions
35
-        array_unshift($this->BlockTypes['['], 'Footnote');
36
-
37
-        # identify footnote markers before before links
38
-        array_unshift($this->InlineTypes['['], 'FootnoteMarker');
39
-    }
40
-
41
-    #
42
-    # ~
43
-
44
-    function text($text)
45
-    {
46
-        $Elements = $this->textElements($text);
47
-
48
-        # convert to markup
49
-        $markup = $this->elements($Elements);
50
-
51
-        # trim line breaks
52
-        $markup = trim($markup, "\n");
53
-
54
-        # merge consecutive dl elements
55
-
56
-        $markup = preg_replace('/<\/dl>\s+<dl>\s+/', '', $markup);
57
-
58
-        # add footnotes
59
-
60
-        if (isset($this->DefinitionData['Footnote']))
61
-        {
62
-            $Element = $this->buildFootnoteElement();
63
-
64
-            $markup .= "\n" . $this->element($Element);
65
-        }
66
-
67
-        return $markup;
68
-    }
69
-
70
-    #
71
-    # Blocks
72
-    #
73
-
74
-    #
75
-    # Abbreviation
76
-
77
-    protected function blockAbbreviation($Line)
78
-    {
79
-        if (preg_match('/^\*\[(.+?)\]:[ ]*(.+?)[ ]*$/', $Line['text'], $matches))
80
-        {
81
-            $this->DefinitionData['Abbreviation'][$matches[1]] = $matches[2];
82
-
83
-            $Block = array(
84
-                'hidden' => true,
85
-            );
86
-
87
-            return $Block;
88
-        }
89
-    }
90
-
91
-    #
92
-    # Footnote
93
-
94
-    protected function blockFootnote($Line)
95
-    {
96
-        if (preg_match('/^\[\^(.+?)\]:[ ]?(.*)$/', $Line['text'], $matches))
97
-        {
98
-            $Block = array(
99
-                'label' => $matches[1],
100
-                'text' => $matches[2],
101
-                'hidden' => true,
102
-            );
103
-
104
-            return $Block;
105
-        }
106
-    }
107
-
108
-    protected function blockFootnoteContinue($Line, $Block)
109
-    {
110
-        if ($Line['text'][0] === '[' and preg_match('/^\[\^(.+?)\]:/', $Line['text']))
111
-        {
112
-            return;
113
-        }
114
-
115
-        if (isset($Block['interrupted']))
116
-        {
117
-            if ($Line['indent'] >= 4)
118
-            {
119
-                $Block['text'] .= "\n\n" . $Line['text'];
120
-
121
-                return $Block;
122
-            }
123
-        }
124
-        else
125
-        {
126
-            $Block['text'] .= "\n" . $Line['text'];
127
-
128
-            return $Block;
129
-        }
130
-    }
131
-
132
-    protected function blockFootnoteComplete($Block)
133
-    {
134
-        $this->DefinitionData['Footnote'][$Block['label']] = array(
135
-            'text' => $Block['text'],
136
-            'count' => null,
137
-            'number' => null,
138
-        );
139
-
140
-        return $Block;
141
-    }
142
-
143
-    #
144
-    # Definition List
145
-
146
-    protected function blockDefinitionList($Line, $Block)
147
-    {
148
-        if ( ! isset($Block) or $Block['type'] !== 'Paragraph')
149
-        {
150
-            return;
151
-        }
152
-
153
-        $Element = array(
154
-            'name' => 'dl',
155
-            'elements' => array(),
156
-        );
157
-
158
-        $terms = explode("\n", $Block['element']['handler']['argument']);
159
-
160
-        foreach ($terms as $term)
161
-        {
162
-            $Element['elements'] []= array(
163
-                'name' => 'dt',
164
-                'handler' => array(
165
-                    'function' => 'lineElements',
166
-                    'argument' => $term,
167
-                    'destination' => 'elements'
168
-                ),
169
-            );
170
-        }
171
-
172
-        $Block['element'] = $Element;
173
-
174
-        $Block = $this->addDdElement($Line, $Block);
175
-
176
-        return $Block;
177
-    }
178
-
179
-    protected function blockDefinitionListContinue($Line, array $Block)
180
-    {
181
-        if ($Line['text'][0] === ':')
182
-        {
183
-            $Block = $this->addDdElement($Line, $Block);
184
-
185
-            return $Block;
186
-        }
187
-        else
188
-        {
189
-            if (isset($Block['interrupted']) and $Line['indent'] === 0)
190
-            {
191
-                return;
192
-            }
193
-
194
-            if (isset($Block['interrupted']))
195
-            {
196
-                $Block['dd']['handler']['function'] = 'textElements';
197
-                $Block['dd']['handler']['argument'] .= "\n\n";
198
-
199
-                $Block['dd']['handler']['destination'] = 'elements';
200
-
201
-                unset($Block['interrupted']);
202
-            }
203
-
204
-            $text = substr($Line['body'], min($Line['indent'], 4));
205
-
206
-            $Block['dd']['handler']['argument'] .= "\n" . $text;
207
-
208
-            return $Block;
209
-        }
210
-    }
211
-
212
-    #
213
-    # Header
214
-
215
-    protected function blockHeader($Line)
216
-    {
217
-        $Block = parent::blockHeader($Line);
218
-
219
-        if ($Block !== null && preg_match('/[ #]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['handler']['argument'], $matches, PREG_OFFSET_CAPTURE))
220
-        {
221
-            $attributeString = $matches[1][0];
222
-
223
-            $Block['element']['attributes'] = $this->parseAttributeData($attributeString);
224
-
225
-            $Block['element']['handler']['argument'] = substr($Block['element']['handler']['argument'], 0, $matches[0][1]);
226
-        }
227
-
228
-        return $Block;
229
-    }
230
-
231
-    #
232
-    # Markup
233
-
234
-    protected function blockMarkup($Line)
235
-    {
236
-        if ($this->markupEscaped or $this->safeMode)
237
-        {
238
-            return;
239
-        }
240
-
241
-        if (preg_match('/^<(\w[\w-]*)(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*(\/)?>/', $Line['text'], $matches))
242
-        {
243
-            $element = strtolower($matches[1]);
244
-
245
-            if (in_array($element, $this->textLevelElements))
246
-            {
247
-                return;
248
-            }
249
-
250
-            $Block = array(
251
-                'name' => $matches[1],
252
-                'depth' => 0,
253
-                'element' => array(
254
-                    'rawHtml' => $Line['text'],
255
-                    'autobreak' => true,
256
-                ),
257
-            );
258
-
259
-            $length = strlen($matches[0]);
260
-            $remainder = substr($Line['text'], $length);
261
-
262
-            if (trim($remainder) === '')
263
-            {
264
-                if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
265
-                {
266
-                    $Block['closed'] = true;
267
-                    $Block['void'] = true;
268
-                }
269
-            }
270
-            else
271
-            {
272
-                if (isset($matches[2]) or in_array($matches[1], $this->voidElements))
273
-                {
274
-                    return;
275
-                }
276
-                if (preg_match('/<\/'.$matches[1].'>[ ]*$/i', $remainder))
277
-                {
278
-                    $Block['closed'] = true;
279
-                }
280
-            }
281
-
282
-            return $Block;
283
-        }
284
-    }
285
-
286
-    protected function blockMarkupContinue($Line, array $Block)
287
-    {
288
-        if (isset($Block['closed']))
289
-        {
290
-            return;
291
-        }
292
-
293
-        if (preg_match('/^<'.$Block['name'].'(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*>/i', $Line['text'])) # open
294
-        {
295
-            $Block['depth'] ++;
296
-        }
297
-
298
-        if (preg_match('/(.*?)<\/'.$Block['name'].'>[ ]*$/i', $Line['text'], $matches)) # close
299
-        {
300
-            if ($Block['depth'] > 0)
301
-            {
302
-                $Block['depth'] --;
303
-            }
304
-            else
305
-            {
306
-                $Block['closed'] = true;
307
-            }
308
-        }
309
-
310
-        if (isset($Block['interrupted']))
311
-        {
312
-            $Block['element']['rawHtml'] .= "\n";
313
-            unset($Block['interrupted']);
314
-        }
315
-
316
-        $Block['element']['rawHtml'] .= "\n".$Line['body'];
317
-
318
-        return $Block;
319
-    }
320
-
321
-    protected function blockMarkupComplete($Block)
322
-    {
323
-        if ( ! isset($Block['void']))
324
-        {
325
-            $Block['element']['rawHtml'] = $this->processTag($Block['element']['rawHtml']);
326
-        }
327
-
328
-        return $Block;
329
-    }
330
-
331
-    #
332
-    # Setext
333
-
334
-    protected function blockSetextHeader($Line, array $Block = null)
335
-    {
336
-        $Block = parent::blockSetextHeader($Line, $Block);
337
-
338
-        if ($Block !== null && preg_match('/[ ]*{('.$this->regexAttribute.'+)}[ ]*$/', $Block['element']['handler']['argument'], $matches, PREG_OFFSET_CAPTURE))
339
-        {
340
-            $attributeString = $matches[1][0];
341
-
342
-            $Block['element']['attributes'] = $this->parseAttributeData($attributeString);
343
-
344
-            $Block['element']['handler']['argument'] = substr($Block['element']['handler']['argument'], 0, $matches[0][1]);
345
-        }
346
-
347
-        return $Block;
348
-    }
349
-
350
-    #
351
-    # Inline Elements
352
-    #
353
-
354
-    #
355
-    # Footnote Marker
356
-
357
-    protected function inlineFootnoteMarker($Excerpt)
358
-    {
359
-        if (preg_match('/^\[\^(.+?)\]/', $Excerpt['text'], $matches))
360
-        {
361
-            $name = $matches[1];
362
-
363
-            if ( ! isset($this->DefinitionData['Footnote'][$name]))
364
-            {
365
-                return;
366
-            }
367
-
368
-            $this->DefinitionData['Footnote'][$name]['count'] ++;
369
-
370
-            if ( ! isset($this->DefinitionData['Footnote'][$name]['number']))
371
-            {
372
-                $this->DefinitionData['Footnote'][$name]['number'] = ++ $this->footnoteCount; # » &
373
-            }
374
-
375
-            $Element = array(
376
-                'name' => 'sup',
377
-                'attributes' => array('id' => 'fnref'.$this->DefinitionData['Footnote'][$name]['count'].':'.$name),
378
-                'element' => array(
379
-                    'name' => 'a',
380
-                    'attributes' => array('href' => '#fn:'.$name, 'class' => 'footnote-ref'),
381
-                    'text' => $this->DefinitionData['Footnote'][$name]['number'],
382
-                ),
383
-            );
384
-
385
-            return array(
386
-                'extent' => strlen($matches[0]),
387
-                'element' => $Element,
388
-            );
389
-        }
390
-    }
391
-
392
-    private $footnoteCount = 0;
393
-
394
-    #
395
-    # Link
396
-
397
-    protected function inlineLink($Excerpt)
398
-    {
399
-        $Link = parent::inlineLink($Excerpt);
400
-
401
-        $remainder = $Link !== null ? substr($Excerpt['text'], $Link['extent']) : '';
402
-
403
-        if (preg_match('/^[ ]*{('.$this->regexAttribute.'+)}/', $remainder, $matches))
404
-        {
405
-            $Link['element']['attributes'] += $this->parseAttributeData($matches[1]);
406
-
407
-            $Link['extent'] += strlen($matches[0]);
408
-        }
409
-
410
-        return $Link;
411
-    }
412
-
413
-    #
414
-    # ~
415
-    #
416
-
417
-    private $currentAbreviation;
418
-    private $currentMeaning;
419
-
420
-    protected function insertAbreviation(array $Element)
421
-    {
422
-        if (isset($Element['text']))
423
-        {
424
-            $Element['elements'] = self::pregReplaceElements(
425
-                '/\b'.preg_quote($this->currentAbreviation, '/').'\b/',
426
-                array(
427
-                    array(
428
-                        'name' => 'abbr',
429
-                        'attributes' => array(
430
-                            'title' => $this->currentMeaning,
431
-                        ),
432
-                        'text' => $this->currentAbreviation,
433
-                    )
434
-                ),
435
-                $Element['text']
436
-            );
437
-
438
-            unset($Element['text']);
439
-        }
440
-
441
-        return $Element;
442
-    }
443
-
444
-    protected function inlineText($text)
445
-    {
446
-        $Inline = parent::inlineText($text);
447
-
448
-        if (isset($this->DefinitionData['Abbreviation']))
449
-        {
450
-            foreach ($this->DefinitionData['Abbreviation'] as $abbreviation => $meaning)
451
-            {
452
-                $this->currentAbreviation = $abbreviation;
453
-                $this->currentMeaning = $meaning;
454
-
455
-                $Inline['element'] = $this->elementApplyRecursiveDepthFirst(
456
-                    array($this, 'insertAbreviation'),
457
-                    $Inline['element']
458
-                );
459
-            }
460
-        }
461
-
462
-        return $Inline;
463
-    }
464
-
465
-    #
466
-    # Util Methods
467
-    #
468
-
469
-    protected function addDdElement(array $Line, array $Block)
470
-    {
471
-        $text = substr($Line['text'], 1);
472
-        $text = trim($text);
473
-
474
-        unset($Block['dd']);
475
-
476
-        $Block['dd'] = array(
477
-            'name' => 'dd',
478
-            'handler' => array(
479
-                'function' => 'lineElements',
480
-                'argument' => $text,
481
-                'destination' => 'elements'
482
-            ),
483
-        );
484
-
485
-        if (isset($Block['interrupted']))
486
-        {
487
-            $Block['dd']['handler']['function'] = 'textElements';
488
-
489
-            unset($Block['interrupted']);
490
-        }
491
-
492
-        $Block['element']['elements'] []= & $Block['dd'];
493
-
494
-        return $Block;
495
-    }
496
-
497
-    protected function buildFootnoteElement()
498
-    {
499
-        $Element = array(
500
-            'name' => 'div',
501
-            'attributes' => array('class' => 'footnotes'),
502
-            'elements' => array(
503
-                array('name' => 'hr'),
504
-                array(
505
-                    'name' => 'ol',
506
-                    'elements' => array(),
507
-                ),
508
-            ),
509
-        );
510
-
511
-        uasort($this->DefinitionData['Footnote'], 'self::sortFootnotes');
512
-
513
-        foreach ($this->DefinitionData['Footnote'] as $definitionId => $DefinitionData)
514
-        {
515
-            if ( ! isset($DefinitionData['number']))
516
-            {
517
-                continue;
518
-            }
519
-
520
-            $text = $DefinitionData['text'];
521
-
522
-            $textElements = parent::textElements($text);
523
-
524
-            $numbers = range(1, $DefinitionData['count']);
525
-
526
-            $backLinkElements = array();
527
-
528
-            foreach ($numbers as $number)
529
-            {
530
-                $backLinkElements[] = array('text' => ' ');
531
-                $backLinkElements[] = array(
532
-                    'name' => 'a',
533
-                    'attributes' => array(
534
-                        'href' => "#fnref$number:$definitionId",
535
-                        'rev' => 'footnote',
536
-                        'class' => 'footnote-backref',
537
-                    ),
538
-                    'rawHtml' => '&#8617;',
539
-                    'allowRawHtmlInSafeMode' => true,
540
-                    'autobreak' => false,
541
-                );
542
-            }
543
-
544
-            unset($backLinkElements[0]);
545
-
546
-            $n = count($textElements) -1;
547
-
548
-            if ($textElements[$n]['name'] === 'p')
549
-            {
550
-                $backLinkElements = array_merge(
551
-                    array(
552
-                        array(
553
-                            'rawHtml' => '&#160;',
554
-                            'allowRawHtmlInSafeMode' => true,
555
-                        ),
556
-                    ),
557
-                    $backLinkElements
558
-                );
559
-
560
-                unset($textElements[$n]['name']);
561
-
562
-                $textElements[$n] = array(
563
-                    'name' => 'p',
564
-                    'elements' => array_merge(
565
-                        array($textElements[$n]),
566
-                        $backLinkElements
567
-                    ),
568
-                );
569
-            }
570
-            else
571
-            {
572
-                $textElements[] = array(
573
-                    'name' => 'p',
574
-                    'elements' => $backLinkElements
575
-                );
576
-            }
577
-
578
-            $Element['elements'][1]['elements'] []= array(
579
-                'name' => 'li',
580
-                'attributes' => array('id' => 'fn:'.$definitionId),
581
-                'elements' => array_merge(
582
-                    $textElements
583
-                ),
584
-            );
585
-        }
586
-
587
-        return $Element;
588
-    }
589
-
590
-    # ~
591
-
592
-    protected function parseAttributeData($attributeString)
593
-    {
594
-        $Data = array();
595
-
596
-        $attributes = preg_split('/[ ]+/', $attributeString, - 1, PREG_SPLIT_NO_EMPTY);
597
-
598
-        foreach ($attributes as $attribute)
599
-        {
600
-            if ($attribute[0] === '#')
601
-            {
602
-                $Data['id'] = substr($attribute, 1);
603
-            }
604
-            else # "."
605
-            {
606
-                $classes []= substr($attribute, 1);
607
-            }
608
-        }
609
-
610
-        if (isset($classes))
611
-        {
612
-            $Data['class'] = implode(' ', $classes);
613
-        }
614
-
615
-        return $Data;
616
-    }
617
-
618
-    # ~
619
-
620
-    protected function processTag($elementMarkup) # recursive
621
-    {
622
-        # http://stackoverflow.com/q/1148928/200145
623
-        libxml_use_internal_errors(true);
624
-
625
-        $DOMDocument = new DOMDocument;
626
-
627
-        # http://stackoverflow.com/q/11309194/200145
628
-        $elementMarkup = mb_convert_encoding($elementMarkup, 'HTML-ENTITIES', 'UTF-8');
629
-
630
-        # http://stackoverflow.com/q/4879946/200145
631
-        $DOMDocument->loadHTML($elementMarkup);
632
-        $DOMDocument->removeChild($DOMDocument->doctype);
633
-        $DOMDocument->replaceChild($DOMDocument->firstChild->firstChild->firstChild, $DOMDocument->firstChild);
634
-
635
-        $elementText = '';
636
-
637
-        if ($DOMDocument->documentElement->getAttribute('markdown') === '1')
638
-        {
639
-            foreach ($DOMDocument->documentElement->childNodes as $Node)
640
-            {
641
-                $elementText .= $DOMDocument->saveHTML($Node);
642
-            }
643
-
644
-            $DOMDocument->documentElement->removeAttribute('markdown');
645
-
646
-            $elementText = "\n".$this->text($elementText)."\n";
647
-        }
648
-        else
649
-        {
650
-            foreach ($DOMDocument->documentElement->childNodes as $Node)
651
-            {
652
-                $nodeMarkup = $DOMDocument->saveHTML($Node);
653
-
654
-                if ($Node instanceof DOMElement and ! in_array($Node->nodeName, $this->textLevelElements))
655
-                {
656
-                    $elementText .= $this->processTag($nodeMarkup);
657
-                }
658
-                else
659
-                {
660
-                    $elementText .= $nodeMarkup;
661
-                }
662
-            }
663
-        }
664
-
665
-        # because we don't want for markup to get encoded
666
-        $DOMDocument->documentElement->nodeValue = 'placeholder\x1A';
667
-
668
-        $markup = $DOMDocument->saveHTML($DOMDocument->documentElement);
669
-        $markup = str_replace('placeholder\x1A', $elementText, $markup);
670
-
671
-        return $markup;
672
-    }
673
-
674
-    # ~
675
-
676
-    protected function sortFootnotes($A, $B) # callback
677
-    {
678
-        return $A['number'] - $B['number'];
679
-    }
680
-
681
-    #
682
-    # Fields
683
-    #
684
-
685
-    protected $regexAttribute = '(?:[#.][-\w]+[ ]*)';
686
-}

+ 0
- 410
classes/vendor/TwitterAPIExchange.php View File

1
-<?php
2
-
3
-/**
4
- * Twitter-API-PHP : Simple PHP wrapper for the v1.1 API
5
- *
6
- * PHP version 5.3.10
7
- *
8
- * @category Awesomeness
9
- * @package  Twitter-API-PHP
10
- * @author   James Mallison <me@j7mbo.co.uk>
11
- * @license  MIT License
12
- * @version  1.0.4
13
- * @link     http://github.com/j7mbo/twitter-api-php
14
- */
15
-class TwitterAPIExchange
16
-{
17
-    /**
18
-     * @var string
19
-     */
20
-    private $oauth_access_token;
21
-
22
-    /**
23
-     * @var string
24
-     */
25
-    private $oauth_access_token_secret;
26
-
27
-    /**
28
-     * @var string
29
-     */
30
-    private $consumer_key;
31
-
32
-    /**
33
-     * @var string
34
-     */
35
-    private $consumer_secret;
36
-
37
-    /**
38
-     * @var array
39
-     */
40
-    private $postfields;
41
-
42
-    /**
43
-     * @var string
44
-     */
45
-    private $getfield;
46
-
47
-    /**
48
-     * @var mixed
49
-     */
50
-    protected $oauth;
51
-
52
-    /**
53
-     * @var string
54
-     */
55
-    public $url;
56
-
57
-    /**
58
-     * @var string
59
-     */
60
-    public $requestMethod;
61
-
62
-    /**
63
-     * The HTTP status code from the previous request
64
-     *
65
-     * @var int
66
-     */
67
-    protected $httpStatusCode;
68
-
69
-    /**
70
-     * Create the API access object. Requires an array of settings::
71
-     * oauth access token, oauth access token secret, consumer key, consumer secret
72
-     * These are all available by creating your own application on dev.twitter.com
73
-     * Requires the cURL library
74
-     *
75
-     * @throws \RuntimeException When cURL isn't loaded
76
-     * @throws \InvalidArgumentException When incomplete settings parameters are provided
77
-     *
78
-     * @param array $settings
79
-     */
80
-    public function __construct(array $settings)
81
-    {
82
-        if (!function_exists('curl_init'))
83
-        {
84
-            throw new RuntimeException('TwitterAPIExchange requires cURL extension to be loaded, see: http://curl.haxx.se/docs/install.html');
85
-        }
86
-
87
-        if (!isset($settings['oauth_access_token'])
88
-            || !isset($settings['oauth_access_token_secret'])
89
-            || !isset($settings['consumer_key'])
90
-            || !isset($settings['consumer_secret']))
91
-        {
92
-            throw new InvalidArgumentException('Incomplete settings passed to TwitterAPIExchange');
93
-        }
94
-
95
-        $this->oauth_access_token = $settings['oauth_access_token'];
96
-        $this->oauth_access_token_secret = $settings['oauth_access_token_secret'];
97
-        $this->consumer_key = $settings['consumer_key'];
98
-        $this->consumer_secret = $settings['consumer_secret'];
99
-    }
100
-
101
-    /**
102
-     * Set postfields array, example: array('screen_name' => 'J7mbo')
103
-     *
104
-     * @param array $array Array of parameters to send to API
105
-     *
106
-     * @throws \Exception When you are trying to set both get and post fields
107
-     *
108
-     * @return TwitterAPIExchange Instance of self for method chaining
109
-     */
110
-    public function setPostfields(array $array)
111
-    {
112
-        if (!is_null($this->getGetfield()))
113
-        {
114
-            throw new Exception('You can only choose get OR post fields (post fields include put).');
115
-        }
116
-
117
-        if (isset($array['status']) && substr($array['status'], 0, 1) === '@')
118
-        {
119
-            $array['status'] = sprintf("\0%s", $array['status']);
120
-        }
121
-
122
-        foreach ($array as $key => &$value)
123
-        {
124
-            if (is_bool($value))
125
-            {
126
-                $value = ($value === true) ? 'true' : 'false';
127
-            }
128
-        }
129
-
130
-        $this->postfields = $array;
131
-
132
-        // rebuild oAuth
133
-        if (isset($this->oauth['oauth_signature']))
134
-        {
135
-            $this->buildOauth($this->url, $this->requestMethod);
136
-        }
137
-
138
-        return $this;
139
-    }
140
-
141
-    /**
142
-     * Set getfield string, example: '?screen_name=J7mbo'
143
-     *
144
-     * @param string $string Get key and value pairs as string
145
-     *
146
-     * @throws \Exception
147
-     *
148
-     * @return \TwitterAPIExchange Instance of self for method chaining
149
-     */
150
-    public function setGetfield($string)
151
-    {
152
-        if (!is_null($this->getPostfields()))
153
-        {
154
-            throw new Exception('You can only choose get OR post / post fields.');
155
-        }
156
-
157
-        $getfields = preg_replace('/^\?/', '', explode('&', $string));
158
-        $params = array();
159
-
160
-        foreach ($getfields as $field)
161
-        {
162
-            if ($field !== '')
163
-            {
164
-                list($key, $value) = explode('=', $field);
165
-                $params[$key] = $value;
166
-            }
167
-        }
168
-
169
-        $this->getfield = '?' . http_build_query($params, '', '&');
170
-
171
-        return $this;
172
-    }
173
-
174
-    /**
175
-     * Get getfield string (simple getter)
176
-     *
177
-     * @return string $this->getfields
178
-     */
179
-    public function getGetfield()
180
-    {
181
-        return $this->getfield;
182
-    }
183
-
184
-    /**
185
-     * Get postfields array (simple getter)
186
-     *
187
-     * @return array $this->postfields
188
-     */
189
-    public function getPostfields()
190
-    {
191
-        return $this->postfields;
192
-    }
193
-
194
-    /**
195
-     * Build the Oauth object using params set in construct and additionals
196
-     * passed to this method. For v1.1, see: https://dev.twitter.com/docs/api/1.1
197
-     *
198
-     * @param string $url           The API url to use. Example: https://api.twitter.com/1.1/search/tweets.json
199
-     * @param string $requestMethod Either POST or GET
200
-     *
201
-     * @throws \Exception
202
-     *
203
-     * @return \TwitterAPIExchange Instance of self for method chaining
204
-     */
205
-    public function buildOauth($url, $requestMethod)
206
-    {
207
-        if (!in_array(strtolower($requestMethod), array('post', 'get', 'put', 'delete')))
208
-        {
209
-            throw new Exception('Request method must be either POST, GET or PUT or DELETE');
210
-        }
211
-
212
-        $consumer_key              = $this->consumer_key;
213
-        $consumer_secret           = $this->consumer_secret;
214
-        $oauth_access_token        = $this->oauth_access_token;
215
-        $oauth_access_token_secret = $this->oauth_access_token_secret;
216
-
217
-        $oauth = array(
218
-            'oauth_consumer_key' => $consumer_key,
219
-            'oauth_nonce' => time(),
220
-            'oauth_signature_method' => 'HMAC-SHA1',
221
-            'oauth_token' => $oauth_access_token,
222
-            'oauth_timestamp' => time(),
223
-            'oauth_version' => '1.0'
224
-        );
225
-
226
-        $getfield = $this->getGetfield();
227
-
228
-        if (!is_null($getfield))
229
-        {
230
-            $getfields = str_replace('?', '', explode('&', $getfield));
231
-
232
-            foreach ($getfields as $g)
233
-            {
234
-                $split = explode('=', $g);
235
-
236
-                /** In case a null is passed through **/
237
-                if (isset($split[1]))
238
-                {
239
-                    $oauth[$split[0]] = urldecode($split[1]);
240
-                }
241
-            }
242
-        }
243
-
244
-        $postfields = $this->getPostfields();
245
-
246
-        if (!is_null($postfields)) {
247
-            foreach ($postfields as $key => $value) {
248
-                $oauth[$key] = $value;
249
-            }
250
-        }
251
-
252
-        $base_info = $this->buildBaseString($url, $requestMethod, $oauth);
253
-        $composite_key = rawurlencode($consumer_secret) . '&' . rawurlencode($oauth_access_token_secret);
254
-        $oauth_signature = base64_encode(hash_hmac('sha1', $base_info, $composite_key, true));
255
-        $oauth['oauth_signature'] = $oauth_signature;
256
-
257
-        $this->url           = $url;
258
-        $this->requestMethod = $requestMethod;
259
-        $this->oauth         = $oauth;
260
-
261
-        return $this;
262
-    }
263
-
264
-    /**
265
-     * Perform the actual data retrieval from the API
266
-     *
267
-     * @param boolean $return      If true, returns data. This is left in for backward compatibility reasons
268
-     * @param array   $curlOptions Additional Curl options for this request
269
-     *
270
-     * @throws \Exception
271
-     *
272
-     * @return string json If $return param is true, returns json data.
273
-     */
274
-    public function performRequest($return = true, $curlOptions = array())
275
-    {
276
-        if (!is_bool($return))
277
-        {
278
-            throw new Exception('performRequest parameter must be true or false');
279
-        }
280
-
281
-        $header =  array($this->buildAuthorizationHeader($this->oauth), 'Expect:');
282
-
283
-        $getfield = $this->getGetfield();
284
-        $postfields = $this->getPostfields();
285
-
286
-        if (in_array(strtolower($this->requestMethod), array('put', 'delete')))
287
-        {
288
-            $curlOptions[CURLOPT_CUSTOMREQUEST] = $this->requestMethod;
289
-        }
290
-
291
-        $options = $curlOptions + array(
292
-            CURLOPT_HTTPHEADER => $header,
293
-            CURLOPT_HEADER => false,
294
-            CURLOPT_URL => $this->url,
295
-            CURLOPT_RETURNTRANSFER => true,
296
-            CURLOPT_TIMEOUT => 10,
297
-        );
298
-
299
-        if (!is_null($postfields))
300
-        {
301
-            $options[CURLOPT_POSTFIELDS] = http_build_query($postfields, '', '&');
302
-        }
303
-        else
304
-        {
305
-            if ($getfield !== '')
306
-            {
307
-                $options[CURLOPT_URL] .= $getfield;
308
-            }
309
-        }
310
-
311
-        $feed = curl_init();
312
-        curl_setopt_array($feed, $options);
313
-        $json = curl_exec($feed);
314
-
315
-        $this->httpStatusCode = curl_getinfo($feed, CURLINFO_HTTP_CODE);
316
-
317
-        if (($error = curl_error($feed)) !== '')
318
-        {
319
-            curl_close($feed);
320
-
321
-            throw new \Exception($error);
322
-        }
323
-
324
-        curl_close($feed);
325
-
326
-        return $json;
327
-    }
328
-
329
-    /**
330
-     * Private method to generate the base string used by cURL
331
-     *
332
-     * @param string $baseURI
333
-     * @param string $method
334
-     * @param array  $params
335
-     *
336
-     * @return string Built base string
337
-     */
338
-    private function buildBaseString($baseURI, $method, $params)
339
-    {
340
-        $return = array();
341
-        ksort($params);
342
-
343
-        foreach($params as $key => $value)
344
-        {
345
-            $return[] = rawurlencode($key) . '=' . rawurlencode($value);
346
-        }
347
-
348
-        return $method . "&" . rawurlencode($baseURI) . '&' . rawurlencode(implode('&', $return));
349
-    }
350
-
351
-    /**
352
-     * Private method to generate authorization header used by cURL
353
-     *
354
-     * @param array $oauth Array of oauth data generated by buildOauth()
355
-     *
356
-     * @return string $return Header used by cURL for request
357
-     */
358
-    private function buildAuthorizationHeader(array $oauth)
359
-    {
360
-        $return = 'Authorization: OAuth ';
361
-        $values = array();
362
-
363
-        foreach($oauth as $key => $value)
364
-        {
365
-            if (in_array($key, array('oauth_consumer_key', 'oauth_nonce', 'oauth_signature',
366
-                'oauth_signature_method', 'oauth_timestamp', 'oauth_token', 'oauth_version'))) {
367
-                $values[] = "$key=\"" . rawurlencode($value) . "\"";
368
-            }
369
-        }
370
-
371
-        $return .= implode(', ', $values);
372
-        return $return;
373
-    }
374
-
375
-    /**
376
-     * Helper method to perform our request
377
-     *
378
-     * @param string $url
379
-     * @param string $method
380
-     * @param string $data
381
-     * @param array  $curlOptions
382
-     *
383
-     * @throws \Exception
384
-     *
385
-     * @return string The json response from the server
386
-     */
387
-    public function request($url, $method = 'get', $data = null, $curlOptions = array())
388
-    {
389
-        if (strtolower($method) === 'get')
390
-        {
391
-            $this->setGetfield($data);
392
-        }
393
-        else
394
-        {
395
-            $this->setPostfields($data);
396
-        }
397
-
398
-        return $this->buildOauth($url, $method)->performRequest(true, $curlOptions);
399
-    }
400
-
401
-    /**
402
-     * Get the HTTP status code for the previous request
403
-     *
404
-     * @return integer
405
-     */
406
-    public function getHttpStatusCode()
407
-    {
408
-        return $this->httpStatusCode;
409
-    }
410
-}

+ 52
- 0
composer.json View File

1
+{
2
+  "name": "biotorrents/gazelle",
3
+  "description": "Web framework for private BitTorrent trackers using Ocelot",
4
+
5
+  "type": "project",
6
+  "license": "Unlicense",
7
+
8
+  "authors": [
9
+    { "name": "What.cd" },
10
+    { "name": "Oppaitime" },
11
+    { "name": "BioTorrents.de" }
12
+  ],
13
+
14
+  "autoload": {
15
+    "classmap": ["classes/"],
16
+    "files": ["classes/autoload.php"]
17
+  },
18
+
19
+  "config": {
20
+    "sort-packages": true
21
+  },
22
+
23
+  "require": {
24
+    "php": ">=7.4",
25
+
26
+    "ext-apcu": "*",
27
+    "ext-blake3": "*",
28
+    "ext-curl": "*",
29
+    "ext-json": "*",
30
+    "ext-mbstring": "*",
31
+    "ext-memcache": "*",
32
+    "ext-mysqli": "*",
33
+
34
+    "erusev/parsedown": "^1.8.0-beta-7",
35
+    "erusev/parsedown-extra": "^0.8.1",
36
+    "j7mbo/twitter-api-php": "^1.0.6",
37
+    "orpheusnet/bencode-torrent": "^1.1.1",
38
+    "robmorgan/phinx": "^0.12.7",
39
+    "twig/twig": "^3.3.2"
40
+  },
41
+
42
+  "require-dev": {
43
+    "phpstan/phpstan": "^0.12.92",
44
+    "phpunit/phpunit": "^9.5.6",
45
+    "squizlabs/php_codesniffer": "^3.6.0"
46
+  },
47
+
48
+  "scripts": {
49
+    "phpstan": "phpstan analyse",
50
+    "test": "phpunit"
51
+  }
52
+}

+ 3923
- 0
composer.lock
File diff suppressed because it is too large
View File


Loading…
Cancel
Save