/** * Save feature */ function dt_save_log($edit) { global $item, $log, $tpl, $xoopsTpl, $mc, $dtfunc; $query = ''; foreach ($_POST as $k => $v) { ${$k} = $v; } $db = XoopsDatabaseFactory::getDatabaseConnection(); if ($edit) { //Verificamos que la característica exista $lg = new DTLog($log); if ($lg->isNew()) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/logs/' . $item->id() . '/' : '/?p=cpanel&action=logs&id=' . $item->id()), 1, __('Specified log does not exists!', 'dtransport')); } } else { $lg = new DTLog(); } $tc = TextCleaner::getInstance(); //Comprueba que el título de la característica no exista $sql = "SELECT COUNT(*) FROM " . $db->prefix('dtrans_logs') . " WHERE title='{$title}' AND id_log!=" . $lg->id() . " AND id_soft=" . $item->id(); list($num) = $db->fetchRow($db->queryF($sql)); if ($num > 0) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/logs/' . $item->id() . '/edit/' . $lg->id() : '/?p=cpanel&action=logs&id=' . $item->id() . '/&op=edit&log=' . $lg->id()), 1, __('Another log with same title already exists!', 'dtransport')); } $lg->setSoftware($item->id()); $lg->setTitle($title); $lg->setLog($content); $lg->setDate(time()); if (!$lg->save()) { redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/logs/' . $item->id() . '/' : '/?p=cpanel&action=logs&id=' . $item->id()), 1, __('Log could not be saved! Please try again.', 'dtransport')); } redirect_header(DT_URL . ($mc['permalinks'] ? '/cp/logs/' . $item->id() . '/' : '/?p=cpanel&action=logs&id=' . $item->id()), 1, __('Log saved successfully!', 'dtransport')); }
/** * @desc Almacena los datos del log en la base de datos **/ function dt_save_log($edit = 0) { global $xoopsSecurity; $query = ''; foreach ($_POST as $k => $v) { ${$k} = $v; if ($k == 'XOOPS_TOKEN_REQUEST' || ($k = 'action')) { continue; } $query = $query == '' ? $k . '=' . urlencode($v) : "&{$k}=" . urlencode($v); } //Verificamos si el software es válido if ($item <= 0) { redirectMsg('items.php', __('Download item ID not provided!', 'dtransport'), RMMSG_WARN); } //Verificamos si existe el software $sw = new DTSoftware($item); if ($sw->isNew()) { redirectMsg('items.php', __('Specified download item does not exists!', 'dtransport'), RMMSG_WARN); } if (!$xoopsSecurity->check()) { redirectMsg('logs.php?item=' . $item, __('Session token not valid!', 'dtransport'), RMMSG_ERROR); } if ($edit) { $action = 'action=edit'; // Edición del registro if ($id <= 0) { redirectMsg('logs.php?item=' . $item, __('Item log ID not provided!', 'dtransport'), 1); } $lg = new DTLog($id); if ($lg->isNew()) { redirectMsg('logs.php?item=' . $item, __('Specified log does not exists!', 'dtransport'), 1); } } else { $action = 'action=new'; $lg = new DTLog(); } $lg->setSoftware($item); $lg->setTitle($title); $lg->setLog($log); $lg->setDate(time()); if (!$lg->save()) { redirectMsg('logs.php?' . $query . '&' . $action, __('Item log could not be saved!', 'dtransport') . '<br />' . $lg->error(), RMMSG_ERROR); } else { redirectMsg('logs.php?item=' . $item, __('Database updated successfully!', 'dtransport'), RMMSG_SAVED); } }