このリポジトリは2023-09-09にアーカイブされています。 ファイルの閲覧とクローンは可能ですが、プッシュ、イシューの作成、プルリクエストはできません。
urloli.php/www/index.php

57 行
1.5 KiB
PHP
Raw Blame 履歴

このファイルには曖昧(ambiguous)なUnicode文字が含まれています

このファイルには、他の文字と見間違える可能性があるUnicode文字が含まれています。 それが意図的なものと考えられる場合は、この警告を無視して構いません。 それらの文字を表示するにはエスケープボタンを使用します。

<?php
require_once('../config.php');
$title = SITE_NAME;
$h1 = SITE_NAME;
function mkstring () {
$stringchars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
$newstring = '';
for ($i = 0; $i < 5; $i++) $newstring .= $stringchars[rand(0, strlen($stringchars))];
foreach ($arr as $k => $v) {
if ($newstring == $k) return mkstring();
}
return $newstring;
}
// パラメートルがなければ、スキップ。
if (isset($_POST['sosin'])) {
$newadd = $_POST['newadd'];
$data = file_get_contents('links.json');
$arr = json_decode($data, true);
$newstring = mkstring();
$arr[$newstring] = $newadd;
$newdata = json_encode($arr);
file_put_contents('links.json', $newdata);
header('Location: /?newurl='.$newstring);
}
else if (null === $_GET['url'] && null !== $_GET['newurl']) {
$newurl = $_GET['newurl'];
include_once('../views/submitted.php');
}
else if (null !== $_GET['url'] && $_GET['url'] != '') {
$data = file_get_contents('links.json');
foreach (json_decode($data) as $k => $v) {
// jsonファイルでキーを見つければ、転送されます。なければ、エラーが出ます。
if ($_GET['url'] == $k) {
header('Location: '.$v);
exit;
}
}
}
else if (null === $_GET['url'] && $_SERVER['REQUEST_URI'] == '/') {
include_once('../views/index.php');
}
else {
$title = '076エラー - 未検出';
$h1 = '【404】未検出';
include_once('../views/404.php');
}
?>