* Load Language file */ $langfile = dirname(__FILE__) . "/languages/" . LANGUAGE . ".php"; require_once !file_exists($langfile) ? dirname(__FILE__) . "/languages/EN.php" : $langfile; $parser->addGlobal('MOD_DROPLET', $MOD_DROPLET); if (isset($_REQUEST['del']) && is_numeric($_REQUEST['del'])) { $_POST['markeddroplet'] = $_REQUEST['del']; $_REQUEST['delete'] = 1; } if (isset($_REQUEST['toggle']) && is_numeric($_REQUEST['toggle'])) { toggle_active($_REQUEST['toggle']); list_droplets(); } elseif (isset($_REQUEST['add'])) { edit_droplet('new'); } elseif (isset($_REQUEST['edit']) && !isset($_REQUEST['cancel'])) { edit_droplet($_REQUEST['edit']); } elseif (isset($_REQUEST['copy']) && is_numeric($_REQUEST['copy'])) { copy_droplet($_REQUEST['copy']); } elseif (isset($_REQUEST['backups']) && !isset($_REQUEST['cancel'])) { manage_backups(); } elseif (isset($_REQUEST['export']) && !isset($_REQUEST['cancel'])) { $info = export_droplets(); list_droplets($info); } elseif (isset($_REQUEST['import']) && !isset($_REQUEST['cancel'])) { import_droplets(); } elseif (isset($_REQUEST['delete']) && !isset($_REQUEST['cancel'])) { export_droplets(); delete_droplets(); } elseif (isset($_REQUEST['droplet_perms']) && is_numeric($_REQUEST['droplet_perms']) && !isset($_REQUEST['cancel'])) { edit_droplet_perms($_REQUEST['droplet_perms']); } elseif (isset($_REQUEST['perms']) && !isset($_REQUEST['cancel'])) {
/** * copy a droplet **/ function copy_droplet($id) { global $val, $backend; $groups = CAT_Users::get_groups_id(); if (!CAT_Helper_Droplet::is_allowed('modify_droplets', $groups)) { $backend->print_error($backend->lang()->translate("You don't have the permission to do this")); } $data = CAT_Helper_Droplet::getDroplet($id); $tags = array('<?php', '?>', '<?'); $code = addslashes(str_replace($tags, '', $data['code'])); $new_name = $data['name'] . "_copy"; $i = 1; // look for doubles $found = CAT_Helper_Droplet::getDropletByName($new_name); while ($found) { $new_name = $data['name'] . "_copy" . $i; $found = CAT_Helper_Droplet::getDropletByName($new_name); $i++; } $new_id = CAT_Helper_Droplet::insertDroplet(array('name' => $new_name, 'code' => $code, 'description' => $data['description'], 'time' => time(), 'userid' => CAT_Users::get_user_id(), 'comment' => $data['comments'])); if ($new_id) { return edit_droplet($new_id); } else { echo "ERROR: ", $backend->db()->getError(); } }
/** * copy a droplet **/ function copy_droplet($id) { global $database, $admin, $MOD_DROPLET; $groups = $admin->get_groups_id(); if (!is_allowed('Modify_droplets', $groups)) { $admin->print_error($MOD_DROPLET["You don't have the permission to do this"]); } $query = $database->query("SELECT * FROM " . TABLE_PREFIX . "mod_droplets WHERE id = '{$id}'"); $data = $query->fetchRow(MYSQL_ASSOC); $tags = array('<?php', '?>', '<?'); $code = addslashes(str_replace($tags, '', $data['code'])); $new_name = $data['name'] . "_copy"; $i = 1; // look for doubles $found = $database->query('SELECT * FROM ' . TABLE_PREFIX . "mod_droplets WHERE name='{$new_name}'"); while ($found->numRows() > 0) { $new_name = $data['name'] . "_copy" . $i; $found = $database->query('SELECT * FROM ' . TABLE_PREFIX . "mod_droplets WHERE name='{$new_name}'"); $i++; } // generate query $query = "INSERT INTO " . TABLE_PREFIX . "mod_droplets VALUES " . "(''," . "'{$new_name}', " . "'{$code}', " . "'" . $data['description'] . "', " . "'" . time() . "', " . "'" . $admin->get_user_id() . "', " . "1,1,1,0,'" . $data['comments'] . "' )"; // add new droplet $result = $database->query($query); if (!$database->is_error()) { $new_id = $database->db_handle->lastInsertId(); return edit_droplet($new_id); } else { echo "ERROR: ", $database->get_error(); } }