}
    $s .= ']';
    return $s;
}
function textToHTML($s)
{
    $s = preg_replace('/(\\r?\\n){2,}/', '</p><p>', $s);
    $s = preg_replace('/(\\r?\\n)+/', '<br>', $s);
    return '<p>' . $s . '</p>';
}
$key = makeKey($_POST['name']);
$icon = $_POST['icon'];
$label = $_POST['name'];
$countries = makeYamlArray($_POST['countries']);
$location = sprintf('[%s]', $_POST['location']);
$content = textToHTML($_POST['description']);
$url = $_POST['website'];
$coins = makeYamlArray($_POST['coins']);
$file = './data/services.yaml';
$current = file_get_contents($file);
$yaml = "\n{$key}:\n  label: {$label}\n  icon: {$icon}\n  countries: {$countries}\n  location: {$location}\n  url: {$url}\n  content: |\n    {$content}\n  coins: {$coins}\n";
try {
    $branchname = 'update/' . time() . '_' . $key;
    $git = new Git();
    $git->createNewBranch($branchname);
    $fileInfo = $git->getFileInformation('master');
    $sha = $fileInfo->sha;
    $newFile = base64_encode($current . PHP_EOL . $yaml);
    $git->updateFile($branchname, $sha, $newFile);
    $git->sendPR($branchname);
} catch (Exception $e) {
Example #2
0
if ($userType == VISITOR) {
    errAndDie('Sorry, visitors may not delete posts.');
}
mysqlSetup();
escapes('userName', $userName);
if ($userType == NORMAL) {
    $sqlquery = "SELECT `name` AS `project`,B.`added`,B.`modified`,B.`title`,B.`text`,B.`user` " . "FROM `pb_blog` AS B LEFT JOIN `pb_projects` ON " . "`pb_projects`.`id` = B.`projid` WHERE B.`id` = '{$mpostid}' AND " . "`user` = '{$muserName}'";
} else {
    $sqlquery = "SELECT `name` AS `project`,B.`added`,B.`modified`,B.`title`,B.`text`,B.`user` " . "FROM `pb_blog` AS B LEFT JOIN `pb_projects` ON " . "`pb_projects`.`id` = B.`projid` WHERE B.`id` = '{$mpostid}'";
}
$result = mysql_query($sqlquery) or die('Invalid query: ' . mysql_error());
if (!($row = mysql_fetch_assoc($result))) {
    errAndDie('You are unable to access this post unless you own it or are an admin/siteadmin.');
}
if ($userType == ADMIN && $row['projid'] == -1 && $userName != $row['user']) {
    errAndDie('Admins can only delete their own news posts.');
}
?>
<h2>Post contents:</h2>
<table>
<?php 
foreach ($row as $key => $value) {
    $value = textToHTML($value);
    print "<tr>\n";
    print "\t<th align=\"left\">{$key}</th>\n";
    print "\t<td>{$value}</td>\n";
    print "</tr>\n";
}
print '</table>';
print "<p><a href=\"postDelete.php?postid={$urlpostid}\">" . "Delete this post.</a></p>";
emitBottom();