@POST.OLD-update-wiki.php
<?php
$body = trim(file_get_contents("php://input"));
$headers = getallheaders();
$sshDir = dirname(dirname(dirname(__DIR__))).'/8-ssh/';
$log = $sshDir.'/log';
$repo = $_POST['repository']['full_name'];
$keyFileName = 'github_taeluf_webhook';
$gitKeySHA1Hashed = trim($headers['X-Hub-Signature']);
$localKeyRaw = trim(shell_exec('ssh-keygen -y -f '.$sshDir.'/'.$keyFileName));
$localKeySHA1Hashed = 'sha1='.trim(hash_hmac('sha1',$body,$localKeyRaw));
echo "new test\n";
$logData = "Repo '{$repo}'\nReceived:\n{$gitKeySHA1Hashed}\n\nLocallyHashed:\n{$localKeySHA1Hashed}\n\n";
$message = "SUCCESS";
if (!hash_equals($localKeySHA1Hashed,$gitKeySHA1Hashe)){
$message = "FAILURE";
}
echo $message;
$logData .= $message."\nBody:\n{$body}\n\n-------------------------------------\n\n";
file_put_contents($log,$logData,FILE_APPEND|LOCK_EX);
exit;
$projects = [
'Better-Regex',
'Liaison',
'PHP-Documentor'
];
$dir = __DIR__.'/wiki/';
foreach ($projects as $proj){
$url = "https://github.com/Taeluf/".$proj.'.git';
$dirTarget = $dir.$proj.'/';
$dirCheck = $dirTarget.'.git';
if (is_dir($dirCheck)){
$command = "cd {$dirTarget};\ngit pull;";
$output = shell_exec($command);
echo "Did git pull on '{$proj}'\n<br>\n";
continue;
}
if (is_dir($dirTarget)&&count(scandir($dirTarget))>2){
echo "We can't git clone or git pull '{$proj}' because the directory exists, has content, but does NOT have a .git directory.\n<br>\n";
continue;
}
$command = "cd {$dir};\ngit clone https://github.com/Taeluf/{$proj}.git";
$output = shell_exec($command);
echo "Did git clone on '{$proj}'\n<br>\n";
}