<commit_before><?php
/**
 * 
 * properties template, shows the basic page on the properties window
 *
 * @author <NAME>
 * @version 1.0
 * @copyright Copyright (c) 2008,2009 University of Nottingham
 * @package
 */

require_once("../../../config.php");

include "../template_status.php";
include "../screen_size_library.php";
include "../url_library.php";
include "../user_library.php";
include "properties_library.php";

if(is_numeric($_POST['template_id'])){

    $template_id = mysql_real_escape_string($_POST['template_id']);
    $engine = mysql_real_escape_string($_POST['engine']);

    if ($engine != 'flash' && $engine!='javascript')
    {
        $engine = 'javascript';
    }

    // Get extra flags
    $row = db_query_one("SELECT td.extra_flags  FROM {$xerte_toolkits_site->database_table_prefix}templatedetails td WHERE td.template_id = ?", array($template_id));

    $extra_flags = explode(";", $row['extra_flags']);
    $found=false;
    for ($i=0; $i<count($extra_flags); $i++)
    {
        $parameter = explode("=", $extra_flags[$i]);
        if ($parameter[0] == 'engine')
        {
            $extra_flags[$i] = "engine=" . $engine;
            $found = true;
            break;
        }
    }
    if (!$found)
    {
        $extra_flags[] = "engine=" . $engine;
    }
    $db_entry = join(";", $extra_flags);

    $query = "update " . $xerte_toolkits_site->database_table_prefix . "templatedetails SET extra_flags =\"" . str_replace(" ", "_", mysql_real_escape_string($db_entry)) . "\" WHERE template_id =\"" . $template_id . "\"";

    if(mysql_query($query)){

        if ($_REQUEST['page']=='properties')
        {
            properties_display($xerte_toolkits_site,$template_id,true,"engine");
        }
        else
        {
            publish_display($template_id);
        }

    }else{

    }

    mysql_close($database_id);

}
?><commit_msg>remove legacy mysql_ dependence, remove mysql_close() on non-existant $database_id<commit_after><?php
/**
 * 
 * properties template, shows the basic page on the properties window
 *
 * @author <NAME>
 * @version 1.0
 * @copyright Copyright (c) 2008,2009 University of Nottingham
 * @package
 */

require_once("../../../config.php");

include "../template_status.php";
include "../screen_size_library.php";
include "../url_library.php";
include "../user_library.php";
include "properties_library.php";

if(is_numeric($_POST['template_id'])){

    $template_id = (int) $_POST['template_id'];
    $engine = mysql_real_escape_string($_POST['engine']);

    if ($engine != 'flash' && $engine!='javascript')
    {
        $engine = 'javascript';
    }

    // Get extra flags
    $row = db_query_one("SELECT td.extra_flags  FROM {$xerte_toolkits_site->database_table_prefix}templatedetails td WHERE td.template_id = ?", array($template_id));

    $extra_flags = explode(";", $row['extra_flags']);
    $found=false;
    for ($i=0; $i<count($extra_flags); $i++)
    {
        $parameter = explode("=", $extra_flags[$i]);
        if ($parameter[0] == 'engine')
        {
            $extra_flags[$i] = "engine=" . $engine;
            $found = true;
            break;
        }
    }
    if (!$found)
    {
        $extra_flags[] = "engine=" . $engine;
    }

    $db_entry = str_replace(" ", "_", join(";", $extra_flags)); /* curious as to why we do a str_replace here, but don't seem to 'undo' it when reading above. */

    $query = "UPDATE {$xerte_toolkits_site->database_table_prefix}templatedetails SET extra_flags = ? WHERE template_id = ?";
    $params = array($db_entry, $template_id);
    $ok = db_query($query, $params);

    if($ok) { 
        if ($_REQUEST['page']=='properties')
        {
            properties_display($xerte_toolkits_site,$template_id,true,"engine");
        }
        else
        {
            publish_display($template_id);
        }

    }else{

    }
}
{'fraction_non_alphanumeric': 0.1731018398548847, 'fraction_numerical': 0.006219227779217414, 'mean_word_length': 2.9958592132505175, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, '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': '5104731', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1221, 'n_words': 237}