Beispiel #1
0
 function do_inline($page, $param1, $param2)
 {
     mb_ereg('^(.*?)(?:\\s*,\\s*(.*?))?$', trim($param1), $m);
     $file = $m[1];
     $page = $m[2] == '' ? $page : Page::getinstance($m[2]);
     if (!Attach::getinstance($page)->isexist($file)) {
         return '<span class="warning">ファイルがありません</span>';
     }
     $url = SCRIPTURL . '?cmd=attach' . '&amp;param=download' . '&amp;page=' . rawurlencode($page->getpagename()) . '&amp;file=' . rawurlencode($file);
     return '<a href="' . $url . '">' . htmlspecialchars($file) . '</a>';
 }
/** afficher_image_attach() - genere une image en cache (gestion taille et vignettes) et l'affiche comme il faut
 *
 * @param   string	nom du fichier image
 * @param   string	label pour l'image
 * @param   string	classes html supplementaires
 * @param   int		largeur en pixel de la vignette
 * @param   int		hauteur en pixel de la vignette
 * @param   int		largeur en pixel de l'image redimensionnee
 * @param   int		hauteur en pixel de l'image redimensionnee
 * @return  html    affichage a l'ecran
 */
function afficher_image_attach($idfiche, $nom_image, $label, $class, $largeur_vignette, $hauteur_vignette)
{
    $oldpage = $GLOBALS['wiki']->GetPageTag();
    $GLOBALS['wiki']->tag = $idfiche;
    $GLOBALS['wiki']->page['time'] = date('YmdHis');
    $GLOBALS['wiki']->setParameter("desc", $label);
    $GLOBALS['wiki']->setParameter("file", $nom_image);
    $GLOBALS['wiki']->setParameter("class", $class);
    $GLOBALS['wiki']->setParameter("width", $largeur_vignette);
    $GLOBALS['wiki']->setParameter("height", $hauteur_vignette);
    if (!class_exists('attach')) {
        include 'tools/attach/actions/attach.class.php';
    }
    $attach = new Attach($GLOBALS['wiki']);
    ob_start();
    $attach->doAttach();
    $output = ob_get_contents();
    ob_end_clean();
    $GLOBALS['wiki']->tag = $oldpage;
    $output = preg_replace('/width=\\".*\\".*height=\\".*\\"/U', '', $output);
    preg_match_all('/(\\<img.*\\/\\>)/U', $output, $matches);
    return $matches[0][0];
}
Beispiel #3
0
 function do_inline($page, $param1, $param2)
 {
     mb_ereg('^(.*?)(?:\\s*,\\s*(.*?))?$', trim($param1), $m);
     $file = $m[1];
     $page = $m[2] == '' ? $page : Page::getinstance($m[2]);
     if (!Attach::getinstance($page)->isexist($file)) {
         return '<span class="warning">ファイルがありません</span>';
     }
     if (!mb_ereg('\\.(.+?)$', $file, $m) || !isset(Plugin_image::$type[$m[1]])) {
         return '<span class="warning">.' . htmlspecialchars($m[1]) . 'には対応していません</span>';
     }
     $url = SCRIPTURL . '?plugin=image&amp;page=' . rawurlencode($page->getpagename()) . '&amp;file=' . rawurlencode($file);
     if ($m[1] == 'swf') {
         $smarty = new PluginSmarty('image');
         $smarty->assign('url', $url);
         return $smarty->fetch('swf.tpl.htm');
     } else {
         return '<img src="' . $url . '" />';
     }
 }
Beispiel #4
0
 /**
  * ページ名を変更する(ソースコードを移動する)。
  * 
  * @param	Page	$page	変更前ページ
  * @param	Page	$newpage	変更後ページ
  * @return	bool	成功すればtrue。
  */
 protected function _rename($page, $newpage)
 {
     if ($newpage->isexist()) {
         return false;
     }
     $db = DataBase::getinstance();
     $db->begin();
     $mail = Mail::getinstance();
     $old = $mail->setsending(false);
     $newpage->write($page->getsource());
     $page->write('');
     $mail->setsending($old);
     try {
         Attach::getinstance($page)->move($newpage);
     } catch (DBException $e) {
         $db->rollback();
         return false;
     }
     $this->notify(array($page, $newpage));
     $this->mail($page, $newpage);
     $db->commit();
     return true;
 }
 /**
  * Returns array('success'=>true) or array('error'=>'error message')
  */
 function handleUpload($uploadDirectory, $replaceOldFile = FALSE)
 {
     if (!is_writable($uploadDirectory)) {
         return array('error' => "Le dossier de t&eacute;l&eacute;chargement n'est pas accessible en &eacute;criture.");
     }
     if (!$this->file) {
         return array('error' => 'Pas de fichiers envoy&eacute;s.');
     }
     $size = $this->file->getSize();
     if ($size == 0) {
         return array('error' => 'Le fichier est vide.');
     }
     if ($size > $this->sizeLimit) {
         return array('error' => 'Le fichier est trop large.');
     }
     $pathinfo = pathinfo($this->file->getName());
     $filename = $pathinfo['filename'];
     //$filename = md5(uniqid());
     $ext = strtolower($pathinfo['extension']);
     if ($this->allowedExtensions && !in_array($ext, $this->allowedExtensions)) {
         $these = implode(', ', $this->allowedExtensions);
         return array('error' => "Le fichier n'a pas une extension autoris&eacute;e, voici les autoris&eacute;es : " . $these . '.');
     }
     /*if(!$replaceOldFile){
           /// don't overwrite previous files that were uploaded
           while (file_exists($uploadDirectory . $filename . '.' . $ext)) {
               $filename .= rand(10, 99);
           }
       }*/
     // on enleve les espaces et les accents pour le nom de fichier
     $search = array('@[éèêëÊË]@i', '@[àâäÂÄ]@i', '@[îïÎÏ]@i', '@[ûùüÛÜ]@i', '@[ôöÔÖ]@i', '@[ç]@i', '@[ ]@i', '@[^a-zA-Z0-9_]@');
     $replace = array('e', 'a', 'i', 'u', 'o', 'c', '_', '');
     $filename = preg_replace($search, $replace, utf8_decode($filename));
     $attach = new Attach($GLOBALS['wiki']);
     $GLOBALS['wiki']->setParameter("desc", $filename);
     $GLOBALS['wiki']->setParameter("file", $filename . '.' . $ext);
     // dans le cas d'une nouvelle page, on donne une valeur a la date de création
     if ($GLOBALS['wiki']->page['time'] == '') {
         $GLOBALS['wiki']->page['time'] = date('YmdHis');
     }
     // on envoi l'attachement en retenant l'affichage du résultat dans un buffer
     ob_start();
     $attach->doAttach();
     $fullfilename = $attach->GetFullFilename(true);
     ob_end_clean();
     if ($this->file->save($fullfilename)) {
         return array_map('utf8_encode', array('success' => true, 'filename' => $fullfilename, 'simplefilename' => $filename . '.' . $ext, 'extension' => $ext));
     } else {
         return array_map('utf8_encode', array('error' => 'Impossible de sauver le fichier.' . "L'upload a &eacute;t&eacute; annul&eacute; ou le serveur a plant&eacute;."));
     }
 }
Beispiel #6
0
     }
     if (!preg_match('/\\.(sql|zip|gz|bz2)$/i', $filename, $match)) {
         $output->message('Bad_file_type');
     }
     $file_ext = $match[1];
     if (!$zziplib_loaded && $file_ext == 'zip' || !$zlib_loaded && $file_ext == 'gz' || !$bzip2_loaded && $file_ext == 'bz2') {
         $output->message('Compress_unsupported');
     }
     $data = decompress_filedata($tmp_filename, $file_ext);
     //
     // S'il y a une restriction d'accés par l'open_basedir, et que c'est un fichier uploadé,
     // nous avons dù le déplacer dans le dossier des fichiers temporaires du script, on le supprime.
     //
     if ($unlink) {
         require WA_ROOTDIR . '/includes/class.attach.php';
         Attach::remove_file($tmp_filename);
     }
 } else {
     $output->redirect('./tools.php?mode=restore', 4);
     $message = $lang['Message']['No_data_received'];
     $message .= '<br /><br />' . sprintf($lang['Click_return_back'], '<a href="' . sessid('./tools.php?mode=restore') . '">', '</a>');
     $output->message($message);
 }
 $queries = parseSQL($data);
 $db->beginTransaction();
 fake_header(false);
 foreach ($queries as $query) {
     $db->query($query) || trigger_error('Erreur sql lors de la restauration', ERROR);
     fake_header(true);
 }
 $db->commit();
Beispiel #7
0
 protected static function initNotifier()
 {
     if (empty(self::$notifier)) {
         self::$notifier = new NotifierImpl();
     }
 }
Beispiel #8
0
     if ($format == FORMAT_TEXTE) {
         $link = $tmp_link;
     } else {
         $link = '<a href="' . htmlspecialchars($tmp_link) . '">' . $lang['Label_link'] . '</a>';
     }
 }
 $body = str_replace('{LINKS}', $link, $body);
 $mailer->set_message($body);
 //
 // On s'occupe maintenant des fichiers joints ou incorporés
 // Si les fichiers sont stockés sur un serveur ftp, on les rapatrie le temps du flot d'envoi
 //
 if (isset($files[$row['log_id']]) && count($files[$row['log_id']]) > 0) {
     $total_files = count($files[$row['log_id']]);
     $tmp_files = array();
     $attach = new Attach();
     hasCidReferences($body, $refs);
     for ($i = 0; $i < $total_files; $i++) {
         $real_name = $files[$row['log_id']][$i]['file_real_name'];
         $physical_name = $files[$row['log_id']][$i]['file_physical_name'];
         $mime_type = $files[$row['log_id']][$i]['file_mimetype'];
         $error = FALSE;
         $msg = array();
         $attach->joined_file_exists($physical_name, $error, $msg);
         if ($error) {
             $error = FALSE;
             continue;
         }
         if ($nl_config['use_ftp']) {
             $file_path = $attach->ftp_to_tmp($files[$row['log_id']][$i]);
             array_push($tmp_files, $file_path);
Beispiel #9
0
        //
        if ($move_files) {
            if ($browse = dir($source_upload)) {
                while (($entry = $browse->read()) !== false) {
                    $source_file = $source_upload . $entry;
                    $dest_file = $dest_upload . $entry;
                    if (is_file($source_file)) {
                        //
                        // Copie du fichier
                        //
                        if (copy($source_file, $dest_file)) {
                            @chmod($dest_file, 0644);
                            //
                            // Suppression du fichier de l'ancien répertoire
                            //
                            Attach::remove_file($source_file);
                        }
                    }
                }
                $browse->close();
            }
        }
        $output->message('Success_modif');
    }
} else {
    $new_config = $old_config;
}
require WA_ROOTDIR . '/includes/functions.box.php';
$output->page_header();
$output->set_filenames(array('body' => 'config_body.tpl'));
$output->assign_vars(array('TITLE_CONFIG_LANGUAGE' => $lang['Title']['config_lang'], 'TITLE_CONFIG_PERSO' => $lang['Title']['config_perso'], 'TITLE_CONFIG_COOKIES' => $lang['Title']['config_cookies'], 'TITLE_CONFIG_JOINED_FILES' => $lang['Title']['config_files'], 'TITLE_CONFIG_EMAIL' => $lang['Title']['config_email'], 'L_EXPLAIN' => nl2br($lang['Explain']['config']), 'L_EXPLAIN_COOKIES' => nl2br($lang['Explain']['config_cookies']), 'L_EXPLAIN_JOINED_FILES' => nl2br($lang['Explain']['config_files']), 'L_EXPLAIN_EMAIL' => nl2br(sprintf($lang['Explain']['config_email'], '<a href="' . WA_ROOTDIR . '/docs/faq.' . $lang['CONTENT_LANG'] . '.html#p9">', '</a>')), 'L_DEFAULT_LANG' => $lang['Default_lang'], 'L_SITENAME' => $lang['Sitename'], 'L_URLSITE' => $lang['Urlsite'], 'L_URLSITE_NOTE' => nl2br($lang['Urlsite_note']), 'L_URLSCRIPT' => $lang['Urlscript'], 'L_URLSCRIPT_NOTE' => nl2br($lang['Urlscript_note']), 'L_DATE_FORMAT' => $lang['Dateformat'], 'L_NOTE_DATE' => nl2br(sprintf($lang['Fct_date'], '<a href="http://www.php.net/date">', '</a>')), 'L_ENABLE_PROFIL_CP' => $lang['Enable_profil_cp'], 'L_COOKIE_NAME' => $lang['Cookie_name'], 'L_COOKIE_PATH' => $lang['Cookie_path'], 'L_LENGTH_SESSION' => $lang['Session_length'], 'L_SECONDS' => $lang['Seconds'], 'L_UPLOAD_PATH' => $lang['Upload_path'], 'L_MAX_FILESIZE' => $lang['Max_filesize'], 'L_MAX_FILESIZE_NOTE' => nl2br($lang['Max_filesize_note']), 'L_OCTETS' => $lang['Octets'], 'L_CHECK_EMAIL' => $lang['Check_email'], 'L_CHECK_EMAIL_NOTE' => nl2br(sprintf($lang['Check_email_note'], '<a href="' . WA_ROOTDIR . '/docs/faq.' . $lang['CONTENT_LANG'] . '.html#p11">', '</a>')), 'L_EMAILS_SENDED' => $lang['Emails_paquet'], 'L_EMAILS_SENDED_NOTE' => nl2br($lang['Emails_paquet_note']), 'L_USE_SMTP' => $lang['Use_smtp'], 'L_USE_SMTP_NOTE' => nl2br($lang['Use_smtp_note']), 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], 'L_SMTP_SERVER' => $lang['Smtp_server'], 'L_SMTP_PORT' => $lang['Smtp_port'], 'L_SMTP_PORT_NOTE' => nl2br($lang['Smtp_port_note']), 'L_SMTP_USER' => $lang['Smtp_user'], 'L_SMTP_PASS' => $lang['Smtp_pass'], 'L_AUTH_SMTP_NOTE' => nl2br($lang['Auth_smtp_note']), 'L_VALID_BUTTON' => $lang['Button']['valid'], 'L_RESET_BUTTON' => $lang['Button']['reset'], 'LANG_BOX' => lang_box($new_config['language']), 'SITENAME' => htmlspecialchars($new_config['sitename']), 'URLSITE' => $new_config['urlsite'], 'URLSCRIPT' => $new_config['path'], 'DATE_FORMAT' => $new_config['date_format'], 'CHECKED_PROFIL_CP_ON' => $new_config['enable_profil_cp'] ? ' checked="checked"' : '', 'CHECKED_PROFIL_CP_OFF' => !$new_config['enable_profil_cp'] ? ' checked="checked"' : '', 'COOKIE_NAME' => $new_config['cookie_name'], 'COOKIE_PATH' => $new_config['cookie_path'], 'LENGTH_SESSION' => $new_config['session_length'], 'UPLOAD_PATH' => $new_config['upload_path'], 'MAX_FILESIZE' => $new_config['max_filesize'], 'CHECKED_CHECK_EMAIL_ON' => $new_config['check_email_mx'] ? ' checked="checked"' : '', 'CHECKED_CHECK_EMAIL_OFF' => !$new_config['check_email_mx'] ? ' checked="checked"' : '', 'EMAILS_SENDED' => $new_config['emails_sended'], 'CHECKED_USE_SMTP_ON' => $new_config['use_smtp'] ? ' checked="checked"' : '', 'CHECKED_USE_SMTP_OFF' => !$new_config['use_smtp'] ? ' checked="checked"' : '', 'DISABLED_SMTP' => !function_exists('fsockopen') ? ' disabled="disabled"' : '', 'WARNING_SMTP' => !function_exists('fsockopen') ? ' <span style="color: red;">[not available]</span>' : '', 'SMTP_HOST' => $new_config['smtp_host'], 'SMTP_PORT' => $new_config['smtp_port'], 'SMTP_USER' => $new_config['smtp_user'], 'USE_FTP_STATUS' => $new_config['use_ftp'] ? 'true' : 'false', 'USE_SMTP_STATUS' => $new_config['use_smtp'] ? 'true' : 'false'));
Beispiel #10
0
}
//普通用户
if (!$_G['manager']['id'] && $session) {
    Module::loader('passport', 'function');
    $hash = Passport::session_decode($session);
    if ($hash['id']) {
        $sid = 'member';
    }
}
//会话域
if (!$sid) {
    alert(1, '您当前不在登录状态(' . $sid . ')');
} elseif (empty($_FILES) === FALSE) {
    //连接数据库
    System::connect();
    $res = Attach::savefile(array('field' => 'imgFile', 'filetype' => 'image', 'account' => $sid, 'absolute' => TRUE));
    //关闭数据库
    System::connect();
    if ($res) {
        alert(0, NULL, $res);
    } else {
        alert(1, '文件上传出现错误(' . $sid . ')', $res);
    }
}
/*
	输出消息
	$err	0 无错 1 有错
	$msg	消息内容
	$url	附件地址
*/
function alert($err, $msg, $url = NULL)
Beispiel #11
0
$mode = !empty($_GET['mode']) ? $_GET['mode'] : '';
$file_id = !empty($_GET['fid']) ? intval($_GET['fid']) : 0;
$filename = !empty($_GET['file']) ? trim($_GET['file']) : '';
if ($filename != '') {
    $sql_where = 'jf.file_real_name = \'' . $db->escape($filename) . '\'';
} else {
    $sql_where = 'jf.file_id = ' . $file_id;
}
$sql = "SELECT jf.file_real_name, jf.file_physical_name, jf.file_size, jf.file_mimetype\n\tFROM " . JOINED_FILES_TABLE . " AS jf\n\t\tINNER JOIN " . LOG_FILES_TABLE . " AS lf ON lf.file_id = jf.file_id\n\t\tINNER JOIN " . LOG_TABLE . " AS l ON l.log_id = lf.log_id\n\t\t\tAND l.liste_id = {$listdata['liste_id']}\n\tWHERE {$sql_where}";
if (!($result = $db->query($sql))) {
    plain_error('Impossible de récupérer les données sur le fichier : ' . $db->error);
}
if ($filedata = $result->fetch()) {
    if ($nl_config['use_ftp']) {
        require WA_ROOTDIR . '/includes/class.attach.php';
        $attach = new Attach();
        $tmp_filename = $attach->ftp_to_tmp($filedata);
    } else {
        $tmp_filename = wa_realpath(WA_ROOTDIR . '/' . $nl_config['upload_path'] . $filedata['file_physical_name']);
    }
    $data = '';
    $is_svg = strcasecmp($filedata['file_mimetype'], 'image/svg+xml') == 0;
    if ($mode != 'popup' || $is_svg == true) {
        if (!($fp = @fopen($tmp_filename, 'rb'))) {
            exit('Impossible de récupérer le contenu du fichier (fichier non accessible en lecture)');
        }
        $data = fread($fp, filesize($tmp_filename));
        fclose($fp);
    }
    if ($mode == 'popup') {
        if ($is_svg == true) {
Beispiel #12
0
 // Suppression d'une archive
 //
 if ($action == 'delete') {
     $log_ids = !empty($_POST['log_id']) && is_array($_POST['log_id']) ? array_map('intval', $_POST['log_id']) : array();
     if (count($log_ids) == 0) {
         $output->redirect('./view.php?mode=log', 4);
         $output->message('No_log_id');
     }
     if (isset($_POST['confirm'])) {
         $db->beginTransaction();
         $sql = "DELETE FROM " . LOG_TABLE . " \n\t\t\t\tWHERE log_id IN(" . implode(', ', $log_ids) . ")";
         if (!$db->query($sql)) {
             trigger_error('Impossible de supprimer les logs', ERROR);
         }
         require WA_ROOTDIR . '/includes/class.attach.php';
         $attach = new Attach();
         $attach->delete_joined_files(true, $log_ids);
         $db->commit();
         //
         // Optimisation des tables
         //
         $db->vacuum(array(LOG_TABLE, LOG_FILES_TABLE, JOINED_FILES_TABLE));
         $output->redirect('./view.php?mode=log', 4);
         $message = $lang['Message']['logs_deleted'];
         $message .= '<br /><br />' . sprintf($lang['Click_return_logs'], '<a href="' . sessid('./view.php?mode=log') . '">', '</a>');
         $output->message($message);
     } else {
         unset($log_id);
         $output->addHiddenField('action', 'delete');
         $output->addHiddenField('sessid', $session->session_id);
         foreach ($log_ids as $log_id) {
Beispiel #13
0
 /**
  * launch_sending()
  * 
  * Cette fonction est appellée soit dans envoi.php lors de l'envoi, soit 
  * dans le fichier appellé originellement cron.php 
  * 
  * @param array $listdata      Tableau des données de la liste concernée
  * @param array $logdata       Tableau des données de la newsletter
  * @param array $supp_address  Adresses de destinataires supplémentaires
  * 
  * @return string
  */
 function launch_sending($listdata, $logdata, $supp_address = array())
 {
     global $nl_config, $db, $lang, $other_tags;
     //
     // On commence par poser un verrou sur un fichier lock,
     // il ne faut pas qu'il y ait simultanément plusieurs flôts d'envois
     // pour une même liste de diffusion.
     //
     $lockfile = sprintf(WA_LOCKFILE, $listdata['liste_id']);
     if (file_exists($lockfile)) {
         $isBeginning = false;
         $fp = fopen($lockfile, 'r+');
         $supp_address = array();
         // On en tient pas compte, ça l'a déjà été lors du premier flôt
     } else {
         $isBeginning = true;
         $fp = fopen($lockfile, 'w');
         @chmod($lockfile, 0600);
     }
     if (!flock($fp, LOCK_EX | LOCK_NB)) {
         fclose($fp);
         return $lang['Message']['List_is_busy'];
     }
     if (filesize($lockfile) > 0) {
         //
         // L'envoi a planté au cours d'un "flôt" précédent. On récupère les éventuels
         // identifiants d'abonnés stockés dans le fichier lock et on met à jour la table
         //
         $abo_ids = fread($fp, filesize($lockfile));
         $abo_ids = array_map('trim', explode("\n", trim($abo_ids)));
         if (count($abo_ids) > 0) {
             $abo_ids = array_unique(array_map('intval', $abo_ids));
             $sql = "UPDATE " . ABO_LISTE_TABLE . "\n\t\t\t\tSET send = 1\n\t\t\t\tWHERE abo_id IN(" . implode(', ', $abo_ids) . ")\n\t\t\t\t\tAND liste_id = " . $listdata['liste_id'];
             if (!$db->query($sql)) {
                 trigger_error('Impossible de mettre à jour la table des abonnés', ERROR);
             }
         }
         ftruncate($fp, 0);
         fseek($fp, 0);
     }
     //
     // Initialisation de la classe mailer
     //
     require WAMAILER_DIR . '/class.mailer.php';
     $mailer = new Mailer(WA_ROOTDIR . '/language/email_' . $nl_config['language'] . '/');
     if ($nl_config['use_smtp']) {
         $mailer->smtp_path = WAMAILER_DIR . '/';
         $mailer->use_smtp($nl_config['smtp_host'], $nl_config['smtp_port'], $nl_config['smtp_user'], $nl_config['smtp_pass']);
     }
     $mailer->set_charset($lang['CHARSET']);
     $mailer->set_from($listdata['sender_email'], unhtmlspecialchars($listdata['liste_name']));
     if ($listdata['return_email'] != '') {
         $mailer->set_return_path($listdata['return_email']);
     }
     //
     // On traite les données de la newsletter à envoyer
     //
     if (preg_match('/[\\x80-\\x9F]/', $logdata['log_subject']) || preg_match('/[\\x80-\\x9F]/', $logdata['log_body_text']) || preg_match('/[\\x80-\\x9F]/', $logdata['log_body_html'])) {
         if (TRANSLITE_INVALID_CHARS == false) {
             $logdata['log_subject'] = wan_utf8_encode($logdata['log_subject']);
             $logdata['log_body_text'] = wan_utf8_encode($logdata['log_body_text']);
             $logdata['log_body_html'] = wan_utf8_encode($logdata['log_body_html']);
             $lang['Label_link'] = wan_utf8_encode($lang['Label_link']);
             $mailer->set_charset('UTF-8');
         } else {
             $logdata['log_subject'] = purge_latin1($logdata['log_subject'], true);
             $logdata['log_body_text'] = purge_latin1($logdata['log_body_text'], true);
             $logdata['log_body_html'] = purge_latin1($logdata['log_body_html']);
         }
     }
     $mailer->set_subject($logdata['log_subject']);
     $body = array(FORMAT_TEXTE => $logdata['log_body_text'], FORMAT_HTML => $logdata['log_body_html']);
     //
     // Ajout du lien de désinscription, selon les méthodes d'envoi/format utilisés
     //
     $link = newsletter_links($listdata);
     if ($listdata['use_cron'] || $nl_config['engine_send'] == ENGINE_BCC) {
         $body[FORMAT_TEXTE] = str_replace('{LINKS}', $link[FORMAT_TEXTE], $body[FORMAT_TEXTE]);
         $body[FORMAT_HTML] = str_replace('{LINKS}', $link[FORMAT_HTML], $body[FORMAT_HTML]);
     }
     //
     // On s'occupe maintenant des fichiers joints ou incorporés
     // Si les fichiers sont stockés sur un serveur ftp, on les rapatrie le temps du flot d'envoi
     //
     $total_files = count($logdata['joined_files']);
     $tmp_files = array();
     require WA_ROOTDIR . '/includes/class.attach.php';
     $attach = new Attach();
     hasCidReferences($body[FORMAT_HTML], $refs);
     for ($i = 0; $i < $total_files; $i++) {
         $real_name = $logdata['joined_files'][$i]['file_real_name'];
         $physical_name = $logdata['joined_files'][$i]['file_physical_name'];
         $mime_type = $logdata['joined_files'][$i]['file_mimetype'];
         $error = FALSE;
         $msg = array();
         $attach->joined_file_exists($physical_name, $error, $msg);
         if ($error) {
             $error = FALSE;
             continue;
         }
         if ($nl_config['use_ftp']) {
             $file_path = $attach->ftp_to_tmp($logdata['joined_files'][$i]);
             array_push($tmp_files, $file_path);
         } else {
             $file_path = WA_ROOTDIR . '/' . $nl_config['upload_path'] . $physical_name;
         }
         if (is_array($refs) && in_array($real_name, $refs)) {
             $embedded = TRUE;
         } else {
             $embedded = FALSE;
         }
         $mailer->attachment($file_path, $real_name, 'attachment', $mime_type, $embedded);
     }
     //
     // Récupération des champs des tags personnalisés
     //
     if (count($other_tags) > 0) {
         $fields_str = '';
         foreach ($other_tags as $data) {
             $fields_str .= 'a.' . $data['column_name'] . ', ';
         }
     } else {
         $fields_str = '';
     }
     //
     // Si on en est au premier flôt, on récupère également les adresses email
     // des administrateurs ayant activés l'option de réception de copie
     //
     if ($isBeginning) {
         $sql = "SELECT a.admin_email\n\t\t\tFROM " . ADMIN_TABLE . " AS a\n\t\t\t\tINNER JOIN " . AUTH_ADMIN_TABLE . " AS aa ON aa.admin_id = a.admin_id\n\t\t\t\t\tAND aa.cc_admin = " . TRUE;
         if (!($result = $db->query($sql))) {
             trigger_error('Impossible d\'obtenir la liste des fichiers joints', ERROR);
         }
         while ($email = $result->column('admin_email')) {
             array_push($supp_address, $email);
         }
         $result->free();
         $supp_address = array_unique($supp_address);
         // Au cas où...
     }
     //
     // On récupère les infos sur les abonnés destinataires
     //
     $sql = "SELECT COUNT(a.abo_id) AS total\n\t\tFROM " . ABONNES_TABLE . " AS a\n\t\t\tINNER JOIN " . ABO_LISTE_TABLE . " AS al ON al.abo_id = a.abo_id\n\t\t\t\tAND al.liste_id  = {$listdata['liste_id']}\n\t\t\t\tAND al.confirmed = " . SUBSCRIBE_CONFIRMED . "\n\t\t\t\tAND al.send      = 0\n\t\tWHERE a.abo_status = " . ABO_ACTIF;
     if (!($result = $db->query($sql))) {
         trigger_error('Impossible d\'obtenir le nombre d\'adresses emails', ERROR);
     }
     $total_abo = $result->column('total');
     if ($nl_config['emails_sended'] > 0) {
         $total_abo = min($total_abo, $nl_config['emails_sended']);
     }
     $sql = "SELECT a.abo_id, a.abo_pseudo, {$fields_str} a.abo_email, al.register_key, al.format\n\t\tFROM " . ABONNES_TABLE . " AS a\n\t\t\tINNER JOIN " . ABO_LISTE_TABLE . " AS al ON al.abo_id = a.abo_id\n\t\t\t\tAND al.liste_id  = {$listdata['liste_id']}\n\t\t\t\tAND al.confirmed = " . SUBSCRIBE_CONFIRMED . "\n\t\t\t\tAND al.send      = 0\n\t\tWHERE a.abo_status = " . ABO_ACTIF;
     if ($nl_config['emails_sended'] > 0) {
         $sql .= " LIMIT {$nl_config['emails_sended']} OFFSET 0";
     }
     if (!($result = $db->query($sql))) {
         trigger_error('Impossible d\'obtenir la liste des adresses emails', ERROR);
     }
     $abo_ids = array();
     $format = $listdata['liste_format'] != FORMAT_MULTIPLE ? $listdata['liste_format'] : false;
     if ($row = $result->fetch()) {
         if ($nl_config['engine_send'] == ENGINE_BCC) {
             fake_header(false);
             $abonnes = array(FORMAT_TEXTE => array(), FORMAT_HTML => array());
             $abo_ids = array(FORMAT_TEXTE => array(), FORMAT_HTML => array());
             do {
                 $abo_format = !$format ? $row['format'] : $format;
                 array_push($abo_ids[$abo_format], $row['abo_id']);
                 array_push($abonnes[$abo_format], $row['abo_email']);
                 fake_header(true);
             } while ($row = $result->fetch());
             if ($listdata['liste_format'] != FORMAT_HTML) {
                 $abonnes[FORMAT_TEXTE] = array_merge($abonnes[FORMAT_TEXTE], $supp_address);
             }
             if ($listdata['liste_format'] != FORMAT_TEXTE) {
                 $abonnes[FORMAT_HTML] = array_merge($abonnes[FORMAT_HTML], $supp_address);
             }
             //
             // Tableau pour remplacer les tags par des chaines vides
             // Non utilisation des tags avec le moteur d'envoi en copie cachée
             //
             $tags_replace = array('NAME' => '');
             if (count($other_tags) > 0) {
                 foreach ($other_tags as $data) {
                     $tags_replace[$data['tag_name']] = '';
                 }
             }
             if (count($abonnes[FORMAT_TEXTE]) > 0) {
                 $mailer->set_address($abonnes[FORMAT_TEXTE], 'Bcc');
                 $mailer->set_format(FORMAT_TEXTE);
                 $mailer->set_message($body[FORMAT_TEXTE]);
                 $mailer->assign_tags($tags_replace);
                 if (!$mailer->send()) {
                     trigger_error(sprintf($lang['Message']['Failed_sending2'], $mailer->msg_error), ERROR);
                 }
                 fwrite($fp, implode("\n", $abo_ids[FORMAT_TEXTE]) . "\n");
             }
             $mailer->clear_address();
             if (count($abonnes[FORMAT_HTML]) > 0) {
                 $mailer->set_address($abonnes[FORMAT_HTML], 'Bcc');
                 $mailer->set_format($listdata['liste_format']);
                 $mailer->assign_tags($tags_replace);
                 $mailer->set_message($body[FORMAT_HTML]);
                 if ($listdata['liste_format'] == FORMAT_MULTIPLE) {
                     $mailer->set_altmessage($body[FORMAT_TEXTE]);
                 }
                 if (!$mailer->send()) {
                     trigger_error(sprintf($lang['Message']['Failed_sending2'], $mailer->msg_error), ERROR);
                 }
                 fwrite($fp, implode("\n", $abo_ids[FORMAT_HTML]) . "\n");
             }
             $abo_ids = array_merge($abo_ids[FORMAT_TEXTE], $abo_ids[FORMAT_HTML]);
         } else {
             if ($nl_config['engine_send'] == ENGINE_UNIQ) {
                 if (defined('IN_COMMANDLINE')) {
                     require WA_ROOTDIR . '/contrib/Console/ProgressBar.php';
                     //
                     // Initialisation de la barre de progression des envois
                     //
                     $bar = new Console_ProgressBar('Sending emails %percent% [%bar%] %current% of %max%', '=>', ' ', 80, $total_abo + count($supp_address), array('ansi_terminal' => ANSI_TERMINAL));
                 } else {
                     fake_header(false);
                 }
                 if (($isPHP5 = version_compare(phpversion(), '5.0.0', '>=')) == true) {
                     eval('$mailerText = clone $mailer;');
                     eval('$mailerHTML = clone $mailer;');
                 } else {
                     $mailerText = $mailer;
                     $mailerHTML = $mailer;
                 }
                 if (!$listdata['use_cron']) {
                     $body[FORMAT_TEXTE] = str_replace('{LINKS}', $link[FORMAT_TEXTE], $body[FORMAT_TEXTE]);
                     $body[FORMAT_HTML] = str_replace('{LINKS}', $link[FORMAT_HTML], $body[FORMAT_HTML]);
                 }
                 $mailerText->set_format(FORMAT_TEXTE);
                 $mailerText->set_message($body[FORMAT_TEXTE]);
                 $mailerHTML->set_format(FORMAT_HTML);
                 if ($listdata['liste_format'] == FORMAT_MULTIPLE) {
                     $mailerHTML->set_format(FORMAT_MULTIPLE);
                     $mailerHTML->set_altmessage($body[FORMAT_TEXTE]);
                 }
                 $mailerHTML->set_message($body[FORMAT_HTML]);
                 $supp_address_ok = array();
                 foreach ($supp_address as $address) {
                     if ($listdata['liste_format'] != FORMAT_HTML) {
                         array_push($supp_address_ok, array('format' => FORMAT_TEXTE, 'abo_pseudo' => '', 'abo_email' => $address, 'register_key' => '', 'abo_id' => -1));
                     }
                     if ($listdata['liste_format'] != FORMAT_TEXTE) {
                         array_push($supp_address_ok, array('format' => FORMAT_HTML, 'abo_pseudo' => '', 'abo_email' => $address, 'register_key' => '', 'abo_id' => -1));
                     }
                 }
                 $counter = 0;
                 $sendError = 0;
                 do {
                     $counter++;
                     $abo_format = !$format ? $row['format'] : $format;
                     if ($abo_format == FORMAT_TEXTE) {
                         if ($isPHP5 == true) {
                             eval('$mailer = clone $mailerText;');
                         } else {
                             $mailer = $mailerText;
                         }
                     } else {
                         if ($isPHP5 == true) {
                             eval('$mailer = clone $mailerHTML;');
                         } else {
                             $mailer = $mailerHTML;
                         }
                     }
                     if ($row['abo_pseudo'] != '') {
                         $address = array($row['abo_pseudo'] => $row['abo_email']);
                     } else {
                         $address = $row['abo_email'];
                     }
                     $mailer->clear_address();
                     $mailer->set_address($address);
                     //
                     // Traitement des tags et tags personnalisés
                     //
                     $tags_replace = array();
                     if ($row['abo_pseudo'] != '') {
                         $tags_replace['NAME'] = $abo_format == FORMAT_HTML ? $row['abo_pseudo'] : unhtmlspecialchars($row['abo_pseudo']);
                     } else {
                         $tags_replace['NAME'] = '';
                     }
                     if (count($other_tags) > 0) {
                         foreach ($other_tags as $data) {
                             if (isset($row[$data['column_name']])) {
                                 if (!is_numeric($row[$data['column_name']]) && $abo_format == FORMAT_HTML) {
                                     $row[$data['column_name']] = htmlspecialchars($row[$data['column_name']]);
                                 }
                                 $tags_replace[$data['tag_name']] = $row[$data['column_name']];
                                 continue;
                             }
                             $tags_replace[$data['tag_name']] = '';
                         }
                     }
                     if (!$listdata['use_cron']) {
                         $tags_replace = array_merge($tags_replace, array('WA_CODE' => $row['register_key'], 'WA_EMAIL' => rawurlencode($row['abo_email'])));
                     }
                     $mailer->assign_tags($tags_replace);
                     // envoi
                     if (!$mailer->send()) {
                         $sendError++;
                     }
                     if ($row['abo_id'] != -1) {
                         array_push($abo_ids, $row['abo_id']);
                         fwrite($fp, "{$row['abo_id']}\n");
                     }
                     if (defined('IN_COMMANDLINE')) {
                         $bar->update($counter);
                         if (SEND_DELAY > 0 && $counter % SEND_PACKET == 0) {
                             sleep(SEND_DELAY);
                         }
                     } else {
                         fake_header(true);
                     }
                 } while (($row = $result->fetch()) || ($row = array_pop($supp_address_ok)) != null);
                 //
                 // Aucun email envoyé, il y a manifestement un problème, on affiche le message d'erreur
                 //
                 if ($sendError == $total_abo) {
                     flock($fp, LOCK_UN);
                     fclose($fp);
                     unlink($lockfile);
                     trigger_error(sprintf($lang['Message']['Failed_sending2'], $mailer->msg_error), ERROR);
                 }
             } else {
                 trigger_error('Unknown_engine', ERROR);
             }
         }
         $result->free();
     } else {
         if ($isBeginning) {
             //
             // Aucun abonné dont le champ send soit positionné à 0 et nous sommes au
             // début de l'envoi. Cette liste ne comporte donc pas encore d'abonné.
             //
             return $lang['Message']['No_subscribers'];
         }
     }
     //
     // Si l'option FTP est utilisée, suppression des fichiers temporaires
     //
     if ($nl_config['use_ftp']) {
         foreach ($tmp_files as $filename) {
             $attach->remove_file($filename);
         }
     }
     unset($tmp_files);
     $no_send = $sended = 0;
     if (!$db->ping()) {
         //
         // L'envoi a duré trop longtemps et la connexion au serveur SQL a été perdue
         //
         if (SQL_DRIVER == 'mysqli') {
             trigger_error("La connexion à la base de données a été perdue.<br />\nVous devriez mettre l'option PHP mysqli.reconnect à On dans le php.ini,<br />\npour permettre la reconnexion automatique au serveur.", ERROR);
         } else {
             trigger_error("La connexion à la base de données a été perdue", ERROR);
         }
     }
     if (count($abo_ids) > 0) {
         $sql = "UPDATE " . ABO_LISTE_TABLE . "\n\t\t\tSET send = 1\n\t\t\tWHERE abo_id IN(" . implode(', ', $abo_ids) . ")\n\t\t\t\tAND liste_id = " . $listdata['liste_id'];
         if (!$db->query($sql)) {
             trigger_error('Impossible de mettre à jour la table des abonnés (connexion au serveur sql perdue)', ERROR);
         }
     }
     $sql = "SELECT COUNT(*) AS num_dest, al.send\n\t\tFROM " . ABO_LISTE_TABLE . " AS al\n\t\t\tINNER JOIN " . ABONNES_TABLE . " AS a ON a.abo_id = al.abo_id\n\t\t\t\tAND a.abo_status = " . ABO_ACTIF . "\n\t\tWHERE al.liste_id    = {$listdata['liste_id']}\n\t\t\tAND al.confirmed = " . SUBSCRIBE_CONFIRMED . "\n\t\tGROUP BY al.send";
     if (!($result = $db->query($sql))) {
         trigger_error('Impossible d\'obtenir le nombre d\'envois restants à faire', ERROR);
     }
     while ($row = $result->fetch()) {
         if ($row['send'] == 1) {
             $sended = $row['num_dest'];
         } else {
             $no_send = $row['num_dest'];
         }
     }
     $result->free();
     ftruncate($fp, 0);
     flock($fp, LOCK_UN);
     fclose($fp);
     if ($no_send > 0) {
         $message = sprintf($lang['Message']['Success_send'], $nl_config['emails_sended'], $sended, $sended + $no_send);
         if (!defined('IN_COMMANDLINE')) {
             if (!empty($_GET['step']) && $_GET['step'] == 'auto') {
                 Location("envoi.php?mode=progress&id={$logdata['log_id']}&step=auto");
             }
             $message .= '<br /><br />' . sprintf($lang['Click_resend_auto'], '<a href="' . sessid('./envoi.php?mode=progress&amp;id=' . $logdata['log_id'] . '&amp;step=auto') . '">', '</a>');
             $message .= '<br /><br />' . sprintf($lang['Click_resend_manuel'], '<a href="' . sessid('./envoi.php?mode=progress&amp;id=' . $logdata['log_id']) . '">', '</a>');
         }
     } else {
         unlink($lockfile);
         $db->beginTransaction();
         $sql = "UPDATE " . LOG_TABLE . "\n\t\t\tSET log_status = " . STATUS_SENDED . ",\n\t\t\t\tlog_numdest = {$sended}\n\t\t\tWHERE log_id = " . $logdata['log_id'];
         if (!$db->query($sql)) {
             trigger_error('Impossible de mettre à jour la table des logs', ERROR);
         }
         $sql = "UPDATE " . ABO_LISTE_TABLE . "\n\t\t\tSET send = 0\n\t\t\tWHERE liste_id = " . $listdata['liste_id'];
         if (!$db->query($sql)) {
             trigger_error('Impossible de mettre à jour la table des abonnés', ERROR);
         }
         $sql = "UPDATE " . LISTE_TABLE . "\n\t\t\tSET liste_numlogs = liste_numlogs + 1\n\t\t\tWHERE liste_id = " . $listdata['liste_id'];
         if (!$db->query($sql)) {
             trigger_error('Impossible de mettre à jour la table des listes', ERROR);
         }
         $db->commit();
         $message = sprintf($lang['Message']['Success_send_finish'], $sended);
     }
     return $message;
 }
Beispiel #14
0
                         echo "</result>";
                         echo '<error>complete</error>';
                     } else {
                         echo '<result>false</result>';
                         echo '<error>file</error>';
                     }
                 }
                 echo '</response>';
                 break;
                 /////////////////////////////////////
                 //删除文件
             /////////////////////////////////////
             //删除文件
             case "delete":
                 $file = getgpc('file');
                 $data = Attach::delete($file);
                 if ($data) {
                     echo 'complete';
                 } else {
                     echo 'file';
                 }
                 break;
         }
     }
     break;
     /////////////////////////////////////////////
     //各种服务
 /////////////////////////////////////////////
 //各种服务
 case "service":
     if ($_G['manager']['id']) {
 /**
  * remove_stats()
  * 
  * Suppression/déplacement de stats (lors de la suppression d'une liste) 
  * 
  * @param integer $liste_from  Id de la liste dont on supprime/déplace les stats
  * @param mixed   $liste_to    Id de la liste de destination ou boolean (dans ce cas, on supprime)
  * 
  * @return boolean
  */
 function remove_stats($liste_from, $liste_to = false)
 {
     global $nl_config;
     if ($nl_config['disable_stats'] || !extension_loaded('gd')) {
         return false;
     }
     @set_time_limit(300);
     if ($browse = dir(WA_STATSDIR . '/')) {
         require WA_ROOTDIR . '/includes/class.attach.php';
         $old_stats = array();
         while (($filename = $browse->read()) !== false) {
             if (preg_match("/^([0-9]{4}_[a-zA-Z]+)_list{$liste_from}\\.txt\$/i", $filename, $match)) {
                 if ($liste_to && ($fp = @fopen(WA_STATSDIR . '/' . $filename, 'r'))) {
                     $old_stats[$match[1]] = clean_stats(fread($fp, filesize(WA_STATSDIR . '/' . $filename)));
                     fclose($fp);
                 }
                 Attach::remove_file(WA_STATSDIR . '/' . $filename);
             }
         }
         $browse->close();
         if ($liste_to !== false && count($old_stats)) {
             foreach ($old_stats as $date => $stats_from) {
                 $filename = filename_stats($date, $liste_to);
                 if ($fp = @fopen(WA_STATSDIR . '/' . $filename, 'r')) {
                     $stats_to = clean_stats(fread($fp, filesize(WA_STATSDIR . '/' . $filename)));
                     fclose($fp);
                     for ($i = 0; $i < count($stats_to); $i++) {
                         $stats_to[$i] += $stats_from[$i];
                     }
                     @chmod(WA_STATSDIR . '/' . $filename, 0666);
                     if ($fw = @fopen(WA_STATSDIR . '/' . $filename, 'w')) {
                         fwrite($fw, implode("\n", $stats_to));
                         fclose($fw);
                     }
                 }
             }
         }
         return true;
     }
     return false;
 }
Beispiel #16
0
 public static function getUrlFile($url, $bType)
 {
     if ($content = file_get_contents($url)) {
         $fileNode = explode('.', $url);
         $extension = $fileNode[count($fileNode) - 1];
         if (!in_array($extension, self::$fileExtension)) {
             $extension = 'jpg';
         }
         $fileNode = explode('/', $url);
         $fileName = $fileNode[count($fileNode) - 1];
         $fileMd5 = md5($content);
         $c = new EMongoCriteria();
         $c->hash = $fileMd5;
         $isExists = Attach::model()->find($c);
         if ($isExists) {
             return $isExists->_id;
         }
         $fileNameMd5 = md5($fileName . time());
         $fileRePath = substr($fileNameMd5, 0, 1) . '/' . substr($fileNameMd5, 1, 3) . '/' . substr($fileNameMd5, 4, 5);
         $fileNameMd5 = substr($fileNameMd5, 9, strlen($fileNameMd5));
         $static = Yii::app()->params['static'];
         $uploadPath = $static['uploadPath'];
         $filePath = $uploadPath . '/' . $fileRePath;
         $newFile = $filePath . '/' . $fileNameMd5 . '.' . $extension;
         self::createDir($filePath);
         if ($size = file_put_contents($newFile, $content)) {
             $newAttach = new Attach();
             $newAttach->uploadType = $bType;
             $newAttach->type = mime_content_type($newFile);
             $newAttach->creator = Yii::app()->user->getId();
             $newAttach->name = $fileName;
             $newAttach->size = $size;
             $newAttach->extension = $extension;
             $newAttach->hash = $fileMd5;
             $newAttach->isdel = 0;
             $newAttach->savepath = $fileRePath;
             $newAttach->savename = $fileNameMd5 . '.' . $extension;
             $newAttach->action = 0;
             $newAttach->save();
             return $newAttach->_id;
         }
     }
     return 0;
 }
Beispiel #17
0
                    }
                } else {
                    $upload_mode = 'upload';
                }
                $attach->upload_file($upload_mode, $logdata['log_id'], $filename, $tmp_filename, $filesize, $filetype, $errno_code, $error, $msg_error);
            }
        }
        break;
    case 'unattach':
        $file_ids = !empty($_POST['file_ids']) ? (array) $_POST['file_ids'] : array();
        if ($auth->check_auth(AUTH_ATTACH, $listdata['liste_id']) && count($file_ids) > 0) {
            //
            // Suppression du fichier joint spécifié
            //
            require WA_ROOTDIR . '/includes/class.attach.php';
            $attach = new Attach();
            $attach->delete_joined_files(false, $logdata['log_id'], $file_ids);
            //
            // Optimisation des tables
            //
            $db->vacuum(array(LOG_FILES_TABLE, JOINED_FILES_TABLE));
        }
        break;
}
$file_box = '';
$logdata['joined_files'] = array();
//
// Récupération des fichiers joints de la liste
//
if ($auth->check_auth(AUTH_ATTACH, $listdata['liste_id'])) {
    //
Beispiel #18
0
 public static function savefile($param = array())
 {
     global $_G;
     require_once VI_ROOT . 'source/class/thumb.php';
     require_once VI_ROOT . 'source/class/ftp.php';
     if ($_G['setting']['global']['upload'] != 'on') {
         return FALSE;
     }
     $default = array('field' => 'file', 'model' => 'normal', 'crop' => NULL, 'thumb' => NULL, 'group' => NULL, 'index' => -1, 'absolute' => FALSE, 'account' => 'manager', 'filetype' => '*', 'remote' => $_G['setting']["attach"]["FTP_OPEN"] == 'true', 'watermark' => $_G['setting']['attach']['MARK_OPEN'] == 'true' ? VI_ROOT . $_G['setting']['attach']['MARK_FILE'] : NULL, 'position' => $_G['setting']['attach']['MARK_POSITION'], 'multiple' => $_G['setting']['attach']['MARK_MULTIPLE']);
     $param = array_merge($default, $param);
     ////////////////////////
     if ($param['index'] == -1) {
         $temp = $_FILES[$param['field']];
     } else {
         $temp = array('name' => $_FILES[$param['field']]["name"][$param['index']], 'tmp_name' => $_FILES[$param['field']]["tmp_name"][$param['index']], 'size' => $_FILES[$param['field']]["size"][$param['index']], 'error' => $_FILES[$param['field']]["error"][$param['index']]);
     }
     //var_dump( $temp );
     //上传出错
     if (!isset($temp) || $temp['error']) {
         self::$error = $temp['error'];
         return FALSE;
     }
     ////////////////////////
     $data = self::checkfile($temp['name'], $param['filetype']);
     //未知格式
     if ($data === FALSE) {
         return FALSE;
     }
     //源图信息
     if ($data['type'] == 'image') {
         list($param['origin']['width'], $param['origin']['height']) = getimagesize($temp['tmp_name']);
         $width = $param['origin']['width'];
         $height = $param['origin']['height'];
         //裁切尺寸与原图尺寸一样时不裁切
         if ($param['crop'] && $param['crop'][0] == $width && $param['crop'][1] == $height) {
             $param['crop'] = NULL;
         }
     } else {
         $param['origin'] = NULL;
         $width = $height = 0;
     }
     //水印信息
     if ($param['watermark'] && file_exists($param['watermark'])) {
         list($param['water']['width'], $param['water']['height']) = getimagesize($param['watermark']);
     } else {
         $param['water'] = NULL;
     }
     $file = $param['remote'] ? self::stored_remote($temp['tmp_name'], $data, $param) : self::stored_locale($temp['tmp_name'], $data, $param);
     ////////////////////////
     //记录到最近(宽度,高度,本地文件名,上传文件名,扩展名,文件大小)
     self::$detail = array('width' => $width, 'height' => $height, 'name' => $temp['name'], 'file' => $file, 'extra' => $data['extra'], 'size' => $temp['size']);
     self::$error = 0;
     ////////////////////////
     if ($param['account'] == 'member') {
         $user = array('id' => $_G['member']['id'], 'name' => $_G['member']['username']);
     } else {
         $user = array('id' => $_G['manager']['id'], 'name' => $_G['manager']['account']);
     }
     //写入数据库
     $sql = "INSERT INTO `sys:attach`(aid,account,name,input,dateline,type,size,ip,width,height,remote) values('" . $user['id'] . "','" . $user['name'] . "','" . $file . "','" . $param['field'] . "'," . time() . ",'" . $data['extra'] . "'," . $temp['size'] . ",'" . GetIP() . "',{$width},{$height}," . intval($param['remote']) . ")";
     System::$db->execute($sql);
     ////////////////////////
     //绝对地址
     if ($param['absolute'] && $param['remote'] == FALSE) {
         return substr_replace($file, VI_HOST, 0, strlen(VI_BASE));
     } else {
         return $file;
     }
 }
Beispiel #19
0
 protected function change_attach($attach, $arg)
 {
     if ($arg[0] == 'rename') {
         $head = '添付ファイルの名前が変更されました。';
         $body[] = '旧ファイル名:' . $arg[1];
         $body[] = '新ファイル名:' . $arg[2];
     }
     if ($arg[0] == 'move') {
         $from = Attach::getinstance(Page::getinstance($arg[1]))->getlist();
         $to = Attach::getinstance(Page::getinstance($arg[2]))->getlist();
         if ($from == array() && $to == array()) {
             //添付ファイルがない場合は何もしない
             return;
         }
         $head = '添付ファイルの添付先が変更されました。';
         $body[] = '旧ページ名:' . $arg[1];
         $body[] = '新ページ名:' . $arg[2];
         $body[] = '';
         $body[] = '以下のファイルが新ページに添付されています。';
         $body[] = join("\n", $to);
         $body[] = '以下のファイルが旧ページ添付されています。';
         $body[] = join("\n", $from);
     } else {
         return;
     }
     $subject = '[' . SITENAME . '] ' . $attach->getpage()->getpagename();
     $text[] = $head;
     $text[] = $this->geturl($attach->getpage());
     $text[] = '----------------------------------------------------------------------';
     $text[] = join("\n", $body);
     sendmail($subject, join("\n", $text));
 }
Beispiel #20
0
 function update($show, $arg)
 {
     if ($arg == 'done') {
         $page = $this->getcurrentPage();
         $list = Attach::getinstance($page)->getlist();
         if ($list != array()) {
             $smarty = $this->getSmarty();
             $smarty->assign('attach', $list);
             $smarty->assign('pagename', $page->getpagename());
             $this->setbody($smarty->fetch('page.tpl.htm'));
         }
     }
 }