Esempio n. 1
0
 /**
  * Comprobar si es necesario limpiar el registro de eventos
  */
 public function checkClear()
 {
     if ($this->view->clear && $this->view->sk && SessionUtil::checkSessionKey($this->view->sk)) {
         if (\SP\Log::clearEvents()) {
             \SP\Response::printJSON(_('Registro de eventos vaciado'), 0, "sysPassUtil.Common.doAction(" . ActionsInterface::ACTION_EVL . "); sysPassUtil.Common.scrollUp();");
         } else {
             \SP\Response::printJSON(_('Error al vaciar el registro de eventos'));
         }
     }
 }
Esempio n. 2
0
    }
    // Leemos el archivo a una variable
    $fileData['content'] = file_get_contents($tmpName);
    if ($fileData['content'] === false) {
        $log->addDescription(_('Error interno al leer el archivo'));
        $log->writeLog();
        \SP\Response::printJSON($log->getDescription());
    }
    if (SP\Files::fileUpload($accountId, $fileData)) {
        $log->addDescription(_('Archivo guardado'));
        $log->writeLog();
        \SP\Response::printJSON($log->getDescription(), 0);
    } else {
        $log->addDescription(_('No se pudo guardar el archivo'));
        $log->writeLog();
        \SP\Response::printJSON($log->getDescription());
    }
}
if ($action == 'download' || $action == 'view') {
    // Verificamos que el ID sea numérico
    if (!is_numeric($fileId) || $fileId === 0) {
        exit(_('No es un ID de archivo válido'));
    }
    $isView = $action == 'view' ? true : false;
    $file = SP\Files::fileDownload($fileId);
    if (!$file) {
        exit(_('El archivo no existe'));
    }
    $fileSize = $file->accfile_size;
    $fileType = $file->accfile_type;
    $fileName = $file->accfile_name;
Esempio n. 3
0
 * You should have received a copy of the GNU General Public License
 * along with sysPass.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
define('APP_ROOT', '.');
require APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
try {
    $ApiRequest = new \SP\ApiRequest();
    switch ($ApiRequest->getAction()) {
        case \SP\Controller\ActionsInterface::ACTION_ACC_VIEW:
            $itemId = \SP\Request::analyze(\SP\ApiRequest::ITEM, 0);
            $out = $ApiRequest->getApi()->getAccountData($itemId);
            break;
        case \SP\Controller\ActionsInterface::ACTION_ACC_VIEW_PASS:
            $ApiRequest->addVar('userPass', \SP\ApiRequest::analyze(\SP\ApiRequest::USER_PASS));
            $itemId = \SP\Request::analyze(\SP\ApiRequest::ITEM, 0);
            $out = $ApiRequest->getApi()->getAccountPassword($itemId);
            break;
        case \SP\Controller\ActionsInterface::ACTION_ACC_SEARCH:
            $search = \SP\Request::analyze(\SP\ApiRequest::SEARCH);
            $count = \SP\Request::analyze(\SP\ApiRequest::SEARCH_COUNT, 10);
            $out = $ApiRequest->getApi()->getAccountSearch($search, $count);
            break;
        default:
            throw new Exception(_('Acción Inválida'));
    }
} catch (Exception $e) {
    \SP\Response::printJSON(array($e->getMessage(), _('Ayuda Parámetros') => \SP\ApiRequest::getHelp()));
}
header('Content-type: application/json');
echo $out;