<commit_before><?php

function action_rename($path, $action, $title, $content)
{
    // Make sure user is an admin
    if(!$_SESSION['admin'])
    {
        $title[] = "Nope";
        $content['Body'] = "get out.";
        
        return array($title, $content);
    }
    
    if(!empty($_POST))
    {
        $path = mysql_real_escape_string($path);
        $page_query = mysql_query("Select ID from `Wiki_Pages` where Path = '{$path}' limit 1");
        list($page_id) = mysql_fetch_array($page_query);

        // We can only change the path of an existing page...
        if($page_id)
        {
            $new = mysql_real_escape_string($_POST['new']);
            mysql_query("Update `Wiki_Pages` set `Path` = '{$new}' where ID = '{$page_id}'");
            
            $content['Title'] = "Page renamed!";
            $content['Body'] = "<p>The old page <b>{$path}</b> has been renamed to <a href='/{$_POST['new']}'>{$_POST['new']}</a></p>";<commit_msg>Fixed rename to automatically convert spaces to hyphens<commit_after><?php

function action_rename($path, $action, $title, $content)
{
    // Make sure user is an admin
    if(!$_SESSION['admin'])
    {
        $title[] = "Nope";
        $content['Body'] = "get out.";
        
        return array($title, $content);
    }
    
    if(!empty($_POST))
    {
        $path = mysql_real_escape_string($path);
        $page_query = mysql_query("Select ID from `Wiki_Pages` where Path = '{$path}' limit 1");
        list($page_id) = mysql_fetch_array($page_query);

        // We can only change the path of an existing page...
        if($page_id)
        {
            $new = str_replace(" ", "-", $_POST['new']);
            mysql_query("Update `Wiki_Pages` set `Path` = '".mysql_real_escape_string($new)."' where ID = '{$page_id}'");
            
            $content['Title'] = "Page renamed!";
            $content['Body'] = "<p>The old page <b>{$path}</b> has been renamed to <a href='/{$new}'>{$_POST['new']}</a></p>";
{'fraction_non_alphanumeric': 0.18580060422960726, 'fraction_numerical': 0.0010070493454179255, 'mean_word_length': 2.5482142857142858, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4093411', 'n_tokens_mistral': 623, 'n_tokens_neox': 620, 'n_words': 149}