} // Enviamos una descarga segura $path = $mc['directory_secure']; $path = str_replace("\\", "/", $path); $path = rtrim($path, '/'); if (!file_exists($path . '/' . $file->file())) { redirect_header(DT_URL . '/report.php?item=' . $item->id() . "&error=0", 2, __('We\'re sorry but selected file does not exists!', 'dtransport')); } $st = new DTStatistics(); $st->setDate(time()); $st->setFile($file->id()); $st->setSoftware($item->id()); $st->setUid($xoopsUser ? $xoopsUser->uid() : 0); $st->setIp($_SERVER['REMOTE_ADDR']); $st->save(); $alert = new DTAlert($item->id()); if (!$alert->isNew()) { $alert->setLastActivity(time()); $alert->save(); } unset($_SESSION['dttoken']); $item->addHit(); $file->addHit(); header('Content-type: ' . $file->mime()); header('Cache-control: no-store'); header('Expires: ' . gmdate("D, d M Y H:i:s", time() + 31536000) . 'GMT'); header('Content-disposition: filename=' . urlencode($file->file())); header('Content-Lenght: ' . filesize($path . '/' . $file->file())); header('Last-Modified: ' . gmdate("D, d M Y H:i:s", filemtime($path . '/' . $file->file())) . 'GMT'); readfile($path . '/' . $file->file()); die;
/** * @desc Determina el tiempo transcurrido del envio de una alerta al tiempo actual **/ function checkAlert() { global $xoopsModuleConfig, $db, $xoopsConfig; $db = XoopsDatabaseFactory::getDatabaseConnection(); $file = XOOPS_ROOT_PATH . "/cache/alerts.php"; $datelast = file_get_contents($file); if ($datelast <= time() - $xoopsModuleConfig['hrs_alerts'] * 86400) { //Ejecutamos verificación de alertas $sql = "SELECT * FROM " . $db->prefix('dtrans_alerts'); $result = $db->query($sql); while ($rows = $db->fetchArray($result)) { $alert = new DTAlert(); $alert->assignVars($rows); //Obtenemos los datos de la descarga $sw = new DTSoftware($alert->software()); if (!$sw->getVar('approved')) { continue; } if (!$alert->lastActivity()) { if ($sw->getVar('created') >= time() - $alert->limit() * 86400) { continue; } } //Verificamos la fecha de la última descarga del modulo if ($alert->lastActivity() <= time() - $alert->limit() * 86400) { if ($alert->alerted() && $alert->alerted() < $alert->lastActivity() + $alert->limit() * 86400) { continue; } $errors = ''; //Enviamos alerta al autor de la descarga $xoopsMailer =& getMailer(); $alert->mode() ? $xoopsMailer->useMail() : $xoopsMailer->usePM(); $xoopsMailer->setTemplate('alert.tpl'); $xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']); $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']); $xoopsMailer->assign('SITEURL', XOOPS_URL . "/"); $xoopsMailer->assign('DOWNLOAD', $sw->name()); if ($xoopsModuleConfig['urlmode']) { $url = DT_URL . "/item/" . $sw->nameId(); } else { $url = DT_URL . "/item.php?id=" . $sw->id(); } $xoopsMailer->assign('LINK_RESOURCE', $url); $xoopsMailer->assign('DAYS', $alert->limit()); $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . "/modules/dtransport/language/" . $xoopsConfig['language'] . "/mail_template/"); $xu = new XoopsUser($sw->uid()); $xoopsMailer->setToUsers($xu); $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); $xoopsMailer->setFromName($xoopsConfig['sitename']); $xoopsMailer->setSubject(sprintf(_MS_DT_SUBJECTALERT, $sw->name())); $xoopsMailer->send(true); } } //Almacenamos la fecha de la última verificación de alertas file_put_contents($file, time()); } else { return false; } }