Пример #1
0
/**
 *	admin_table_postadd() - update the database based on a submitted change
 *
 *	@param $table - the table to act on
 *	@param $unit - the name of the "units" described by the table's records
 *	@param $primary_key - the primary key of the table
 */
function admin_table_postadd($table, $unit, $primary_key)
{
    if (!form_key_is_valid(getStringFromRequest('form_key'))) {
        exit_form_double_submit();
    }
    $field_list = getStringFromRequest('__fields__');
    $fields = split(",", $field_list);
    $values = array();
    foreach ($fields as $field) {
        $values[] = "'" . getStringFromPost($field) . "'";
    }
    $sql = "INSERT INTO {$table} (" . $field_list . ") VALUES (" . implode(",", $values) . ")";
    if (db_query($sql)) {
        printf(_('%1$s successfully added.'), ucfirst(getUnitLabel($unit)));
    } else {
        form_release_key(getStringFromRequest('form_key'));
        echo db_error();
    }
}
Пример #2
0
		<?php 
        snippet_footer(array());
    } else {
        if ($type == 'package') {
            /*
            	Handle insertion of a new package version
            */
            /*
            	See if the package exists first
            */
            $result = db_query("SELECT * FROM snippet_package WHERE snippet_package_id='{$id}'");
            if (!$result || db_numrows($result) < 1) {
                exit_error(_('Error - snippet_package doesn\'t exist'));
            }
            if (getStringFromRequest('post_changes')) {
                if (!form_key_is_valid(getStringFromRequest('form_key'))) {
                    exit_form_double_submit();
                }
                $snippet_package_id = getIntFromRequest('snippet_package_id');
                $changes = getStringFromRequest('changes');
                $version = getStringFromRequest('version');
                /*
                	Create a new snippet entry, then create a new snippet version entry
                */
                if ($changes && $snippet_package_id) {
                    /*
                    	create the snippet package version
                    */
                    $sql = "INSERT INTO snippet_package_version " . "(snippet_package_id,changes,version,submitted_by,post_date) " . "VALUES ('{$snippet_package_id}','" . htmlspecialchars($changes) . "','" . htmlspecialchars($version) . "','" . user_getid() . "','" . time() . "')";
                    $result = db_query($sql);
                    if (!$result) {
Пример #3
0
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with GForge; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
require_once '../../env.inc.php';
require_once $gfwww . 'include/pre.php';
require_once $gfwww . 'include/trove.php';
require_once $gfwww . 'admin/admin_utils.php';
session_require(array('group' => '1', 'admin_flags' => 'A'));
// ########################################################
if (getStringFromRequest('submit')) {
    if (!form_key_is_valid(getStringFromRequest("form_key"))) {
        exit_form_double_submit();
    }
    $form_parent = getStringFromRequest('form_parent');
    $form_shortname = getStringFromRequest('form_shortname');
    $form_fullname = getStringFromRequest('form_fullname');
    $form_description = getStringFromRequest('form_description');
    $newroot = trove_getrootcat($form_parent);
    if ($form_shortname) {
        $res = db_query("\n\t\t\tINSERT INTO trove_cat \n\t\t\t\t(shortname,fullname,description,parent,version,root_parent)\n\t\t\tVALUES (\n\t\t\t\t'" . htmlspecialchars($form_shortname) . "',\n\t\t\t\t'" . htmlspecialchars($form_fullname) . "',\n\t\t\t\t'" . htmlspecialchars($form_description) . "',\n\t\t\t\t'{$form_parent}',\n\t\t\t\t'" . date("Ymd", time()) . "01',\n\t\t\t\t'{$newroot}'\n\t\t\t)\n\t\t");
        if (!$res || db_affected_rows($res) < 1) {
            form_release_key(getStringFromRequest("form_key"));
            exit_error(_('Error In Trove Operation'), db_error());
        }
    }
    // update full paths now