3 * Code Snippets Repository
5 * Copyright 1999-2001 (c) VA Linux Systems
6 * http://fusionforge.org
8 * This file is part of FusionForge. FusionForge is free software;
9 * you can redistribute it and/or modify it under the terms of the
10 * GNU General Public License as published by the Free Software
11 * Foundation; either version 2 of the Licence, or (at your option)
14 * FusionForge is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 require_once('../env.inc.php');
25 require_once $gfcommon.'include/pre.php';
26 require_once $gfwww.'snippet/snippet_utils.php';
28 if (session_loggedin()) {
30 if (getStringFromRequest('post_changes')) {
31 if (!form_key_is_valid(getStringFromRequest('form_key'))) {
32 exit_form_double_submit();
35 $name = getStringFromRequest('name');
36 $description = getStringFromRequest('description');
37 $language = getIntFromRequest('language');
38 $license = getStringFromRequest('license');
39 $category = getIntFromRequest('category');
40 $type = getStringFromRequest('type');
41 $version = getStringFromRequest('version');
42 $code = getStringFromRequest('code');
43 $changes = getStringFromRequest('changes');
46 Create a new snippet entry, then create a new snippet version entry
48 if ($name && $description && $language != 0 && $category != 0 && $type != 0 && $version && $code) {
50 $result = db_query_params ('INSERT INTO snippet (category,created_by,name,description,type,language,license) VALUES ($1,$2,$3,$4,$5,$6,$7)',
53 htmlspecialchars($name),
54 htmlspecialchars($description),
59 $error_msg = _('ERROR DOING SNIPPET INSERT!');
62 $feedback = _('Snippet Added Successfully.');
63 $snippet_id=db_insertid($result,'snippet','snippet_id');
65 create the snippet version
67 $result = db_query_params ('INSERT INTO snippet_version (snippet_id,changes,version,submitted_by,post_date,code) VALUES ($1,$2,$3,$4,$5,$6)',
69 htmlspecialchars($changes),
70 htmlspecialchars($version),
73 htmlspecialchars($code)));
75 $feedback = _('ERROR DOING SNIPPET VERSION INSERT!');
78 $feedback = _('Snippet Added Successfully.');
82 form_release_key(getStringFromRequest("form_key"));
83 exit_error(_('Error - Go back and fill in all the information'));
87 snippet_header(array('title'=>_('Snippet submit')));
91 <?php echo _('You can post a new code snippet and share it with other people around the world. Just fill in this information. <strong>Give a good description</strong> and <strong>comment your code</strong> so others can read and understand it.'); ?>
94 <?php echo _('<span class="important">Note:</span> You can submit a new version of an existing snippet by browsing the library. You should only use this page if you are submitting an entirely new script or function.'); ?>
96 <form action="<?php echo getStringFromServer('PHP_SELF'); ?>" method="post" id="snippet_submit">
98 echo $HTML->html_input('form_key', '', '', 'hidden', form_generate_key());
99 echo $HTML->html_input('post_changes', '', '', 'hidden', 'y');
100 echo $HTML->html_input('changes', '', '', 'hidden', 'First Posted Version');
106 <?php echo $HTML->html_input('name', '', _('Title') . ' :' . utils_requiredField(), 'text', '', array('size' => '45', 'maxlength' => '60')); ?>
110 <?php echo $HTML->html_textarea('description', '', _('Description') . ' :' . utils_requiredField(), '', array('rows' => '5', 'cols' => '45')); ?>
115 <?php echo $HTML->html_select ($SCRIPT_TYPE, 'type', _('Script Type') . ' :' . utils_requiredField() ); ?>
119 <?php echo $HTML->html_select ($SCRIPT_LICENSE, 'license', _('License') . ' :'); ?>
125 <?php echo $HTML->html_select ($SCRIPT_LANGUAGE, 'language', _('Language') . ' :' . utils_requiredField()); ?>
127 <!-- FIXME: Where should this link go to? <?php echo util_make_link ('/support/?func=addsupport&group_id=1',_('Suggest a Language')); ?> -->
131 <?php echo $HTML->html_select ($SCRIPT_CATEGORY, 'category', _('Category') . ' :' . utils_requiredField()); ?>
133 <!-- FIXME: Where should this link go to? <?php echo util_make_link ('/support/?func=addsupport&group_id=1',_('Suggest a Category')); ?> -->
138 <?php echo $HTML->html_input('version', '', _('Version') . ' :' . utils_requiredField(), 'text', '', array('size' => '10', 'maxlength' => '15')); ?>
142 <?php echo $HTML->html_textarea('code', '', _('Paste the Code Here') . ' :' . utils_requiredField(), '', array('rows' => '30', 'cols' => '85')); ?>
145 <tr><td colspan="2" class="align-center">
146 <?php echo $HTML->html_input('submit', '', _('Make sure all info is complete and accurate'), 'submit', _('SUBMIT')); ?>
151 snippet_footer(array());
155 exit_not_logged_in();
161 // c-file-style: "bsd"