コード例 #1
0
/**
 * Action de déplacement de saisies dans le constructeur de formulaires
 *
 * @return void
**/
function action_deplacer_saisie_dist()
{
    include_spip('inc/session');
    $session = _request('session');
    $identifiant = _request('saisie');
    $ou = _request('ou');
    // On récupère le formulaire à son état actuel
    $formulaire_actuel = session_get($session);
    if (!$formulaire_actuel) {
        return '';
    }
    include_spip('inc/saisies');
    $saisies_actuelles = saisies_lister_par_identifiant($formulaire_actuel);
    if (!isset($saisies_actuelles[$identifiant])) {
        return '';
    }
    // tester @id et [@id] (fieldset)
    if ($ou and !isset($saisies_actuelles[$ou]) and !isset($saisies_actuelles[substr($ou, 1, -1)])) {
        return '';
    }
    // on deplace ou c'est demande...
    $formulaire_actuel = saisies_deplacer($formulaire_actuel, $identifiant, $ou);
    // On sauve tout ca
    $formulaire_actuel = session_set($session, $formulaire_actuel);
}
コード例 #2
0
ファイル: index.php プロジェクト: vojtajina/sitellite
 function EditForm()
 {
     parent::MailForm();
     global $cgi, $_helpdoc;
     $this->addWidget('hidden', 'appname');
     $this->addWidget('hidden', 'lang');
     $this->addWidget('hidden', 'helpfile');
     $w =& $this->addWidget('text', 'filename');
     $w->alt = intl_get('File Name (ie. 001-about-myApp)');
     $w->addRule('not empty', intl_get('You must specify a file name.'));
     $w->addRule('not contains ".."', intl_get('Your file name contains invalid characters.'));
     $w->setValue($cgi->helpfile);
     $w =& $this->addWidget('text', 'title');
     $w->alt = intl_get('Title');
     $w->addRule('not empty', intl_get('You must specify a title.'));
     $w->setValue($_helpdoc->title);
     session_set('imagechooser_path', 'inc/app/' . $cgi->appname . '/pix');
     $this->extra = 'onsubmit="xed_copy_value (this, \'body\')"';
     $w =& $this->addWidget('xed.Widget.Xeditor', 'body');
     $w->setValue($_helpdoc->body);
     $w =& $this->addWidget('msubmit', 'submit_button');
     $b =& $w->getButton();
     $b->setValues(intl_get('Save'));
     $b =& $w->addButton('submit_button');
     $b->setValues(intl_get('Cancel'));
     $b->extra = 'onclick="window.location.href = \'' . site_prefix() . '/index/appdoc-helpdoc-action?appname=' . $cgi->appname . '&lang=' . $cgi->lang . '\'; return false"';
 }
コード例 #3
0
ファイル: index.php プロジェクト: vojtajina/sitellite
 function SitetemplateNewtplForm()
 {
     parent::MailForm();
     global $cgi;
     $this->parseSettings('inc/app/sitetemplate/forms/newtpl/settings.php');
     if (@file_exists('inc/app/xed/lib/Widget/Linker.php')) {
         $this->link_chooser = true;
     }
     $mode = 'html';
     $name = 'new file';
     $set = $cgi->set_name;
     $sname = $set;
     session_set('imagechooser_path', site_prefix() . '/inc/html/' . $set . '/pix');
     if (@file_exists('inc/html/' . $set . '/config.ini.php')) {
         $info = parse_ini_file('inc/html/' . $set . '/config.ini.php');
         if (isset($info['set_name'])) {
             $sname = $info['set_name'];
         }
     }
     page_title(intl_get('Editing New Template in') . ': ' . $sname);
     $set = str_replace('/' . $mode . '.' . $name . '.' . $ext, '', $cgi->path);
     //$this->widgets['edit_buttons']->data = array ('mode' => strtoupper ($mode), 'name' => ucfirst ($name), 'link_chooser' => $this->link_chooser);
     //$this->widgets['body']->setValue (join ('', file ('inc/html/' . $sname)));
     $this->widgets['submit_buttons']->data = array('set' => $set);
     $this->widgets['path']->setValue($set);
 }
コード例 #4
0
ファイル: session_test.php プロジェクト: JoshuaGrams/wfpl
function session_test()
{
    tem_load('code/wfpl/test/session_test.html');
    db_delete('wfpl_sessions');
    db_delete('wfpl_session_data');
    session_dump('Clean slate');
    session_new();
    session_dump('new session');
    session_set('username', 'jason');
    session_dump('username jason');
    session_set('username', 'phil');
    session_dump('overwrote username as phil');
    $old = $GLOBALS['session_id'];
    session_new();
    session_dump('new session');
    session_set('username', 'jason');
    session_set('bamph', 'foo');
    session_dump('set username=jason and bamph=foo in new session');
    session_clear('username');
    session_dump('cleared username in new session');
    _kill_session($old);
    session_dump('killed old session');
    kill_session();
    session_dump('kill_session()');
    tem_output();
}
コード例 #5
0
ファイル: SessionsTest.php プロジェクト: hyrmedia/microweber
 public function testSessions()
 {
     $expected = "Session var " . rand();
     session_set('my_sess_var', $expected);
     $session_var = session_get('my_sess_var');
     $this->assertEquals($session_var, $expected);
 }
コード例 #6
0
ファイル: cvt_autosave.php プロジェクト: loorenzooo/aslfc
/**
 * Quand on poste definitivement un formulaire autosave,
 * on peut vider la session autosave
 * et on vide aussi toutes les autosave de plus de 72H (delai par defaut) ou sans __timestamp (vieilles sessions)
 * @param $flux
 * @return
 */
function cvtautosave_formulaire_traiter($flux)
{
    // si on poste 'autosave' c'est qu'on n'a plus besoin de sauvegarder :
    // on elimine les donnees de la session
    if ($cle_autosave = _request('autosave')) {
        include_spip('inc/session');
        session_set('session_autosave_' . $cle_autosave, null);
        // delai par defaut avant purge d'un backup de form : 72H
        if (!defined('_AUTOSAVE_GB_DELAY')) {
            define('_AUTOSAVE_GB_DELAY', 72 * 3600);
        }
        $time_too_old = time() - _AUTOSAVE_GB_DELAY;
        // purger aussi toutes les vieilles autosave
        $session = $GLOBALS['visiteur_session'];
        foreach ($session as $k => $v) {
            if (strncmp($k, 'session_autosave_', 17) == 0) {
                $timestamp = 0;
                if (preg_match(",&__timestamp=(\\d+)\$,", $v, $m)) {
                    $timestamp = intval($m[1]);
                }
                if ($timestamp < $time_too_old) {
                    session_set($k, null);
                }
            }
        }
    }
    return $flux;
}
コード例 #7
0
ファイル: ecrire_auteur.php プロジェクト: genma/spip_ynh
function formulaires_ecrire_auteur_verifier_dist($id_auteur, $id_article, $mail)
{
    $erreurs = array();
    include_spip('inc/filtres');
    if (!($adres = _request('email_message_auteur'))) {
        $erreurs['email_message_auteur'] = _T("info_obligatoire");
    } elseif (!email_valide($adres)) {
        $erreurs['email_message_auteur'] = _T('form_prop_indiquer_email');
    } else {
        include_spip('inc/session');
        session_set('email', $adres);
    }
    if (!($sujet = _request('sujet_message_auteur'))) {
        $erreurs['sujet_message_auteur'] = _T("info_obligatoire");
    } elseif (!(strlen($sujet) > 3)) {
        $erreurs['sujet_message_auteur'] = _T('forum:forum_attention_trois_caracteres');
    }
    if (!($texte = _request('texte_message_auteur'))) {
        $erreurs['texte_message_auteur'] = _T("info_obligatoire");
    } elseif (!(strlen($texte) > 10)) {
        $erreurs['texte_message_auteur'] = _T('forum:forum_attention_dix_caracteres');
    }
    if (_request('nobot')) {
        $erreurs['message_erreur'] = _T('pass_rien_a_faire_ici');
    }
    if (!_request('confirmer') and !count($erreurs)) {
        $erreurs['previsu'] = ' ';
    }
    return $erreurs;
}
コード例 #8
0
 /**
  * Test cases for _g()
  */
 public function testSessionSetterGetter()
 {
     // 1.
     session_set('name.first', 'Sithu');
     session_set('name.last', 'Kyaw');
     $this->assertEqual(session_get('name'), array('first' => 'Sithu', 'last' => 'Kyaw'));
     // 2.
     session_set('name.first', 'Kyaw');
     $this->assertEqual(session_get('name'), array('first' => 'Kyaw', 'last' => 'Kyaw'));
     // 3.
     session_set('foo', 'bar');
     $this->assertEqual(session_get('foo'), 'bar');
     // 4.
     $animals = array('dog', 'cat', 'tiger');
     session_set('animals', $animals);
     $this->assertEqual(session_get('animals'), array('dog', 'cat', 'tiger'));
     // 5.
     session_set('user', array('fullName' => 'Sithu Kyaw', 'firstName' => 'Sithu', 'lastName' => 'Kyaw', 'age' => 31, 'phone' => array('123456', '987654'), 'address' => array('street' => array('no' => 1, 'room' => 2, 'street' => 'Main Street'), 'city' => 'Yangon', 'country' => 'Myanmar', 'zip' => '11001')));
     $this->assertEqual(session_get('user'), array('fullName' => 'Sithu Kyaw', 'firstName' => 'Sithu', 'lastName' => 'Kyaw', 'age' => 31, 'phone' => array('123456', '987654'), 'address' => array('street' => array('no' => 1, 'room' => 2, 'street' => 'Main Street'), 'city' => 'Yangon', 'country' => 'Myanmar', 'zip' => '11001')));
     // 6.
     session_set('user.phone', '123456');
     session_set('user.address.zip', '11111');
     $this->assertEqual(session_get('user'), array('fullName' => 'Sithu Kyaw', 'firstName' => 'Sithu', 'lastName' => 'Kyaw', 'age' => 31, 'phone' => '123456', 'address' => array('street' => array('no' => 1, 'room' => 2, 'street' => 'Main Street'), 'city' => 'Yangon', 'country' => 'Myanmar', 'zip' => '11111')));
     // 7.
     $auth = array('name' => 'tetete', 'email' => '*****@*****.**');
     session_set('auth', $auth, true);
     $this->assertEqual(session_get('auth', true), $auth);
 }
コード例 #9
0
ファイル: index.php プロジェクト: vojtajina/sitellite
 function SitetemplateEditForm()
 {
     parent::MailForm();
     global $cgi;
     $this->parseSettings('inc/app/sitetemplate/forms/edit/settings.php');
     if (@file_exists('inc/app/xed/lib/Widget/Linker.php')) {
         $this->link_chooser = true;
     }
     list($set, $tpl) = explode('/', $cgi->path);
     list($mode, $name, $ext) = preg_split('|\\.|', basename($cgi->path));
     if (@file_exists('inc/html/' . $set . '/config.ini.php')) {
         $info = parse_ini_file('inc/html/' . $set . '/config.ini.php');
         if (isset($info['set_name'])) {
             $sname = $info['set_name'];
         } else {
             $sname = $set;
         }
     } else {
         $sname = $set;
     }
     session_set('imagechooser_path', site_prefix() . '/inc/html/' . $set . '/pix');
     page_title(intl_get('Editing Template') . ': ' . $sname . ' / ' . strtoupper($mode) . ' / ' . ucfirst($name));
     $set = str_replace('/' . $mode . '.' . $name . '.' . $ext, '', $cgi->path);
     $this->widgets['edit_buttons']->data = array('mode' => strtoupper($mode), 'name' => ucfirst($name), 'link_chooser' => $this->link_chooser);
     $this->widgets['body']->setValue(join('', file('inc/html/' . $cgi->path)));
     $this->widgets['submit_buttons']->data = array('set' => $set);
 }
コード例 #10
0
ファイル: index.php プロジェクト: vojtajina/sitellite
 function onSubmit($vals)
 {
     global $cgi;
     if ($vals['submit_buttons'] == 'Cancel') {
         header('Location: ' . $vals['refer']);
         exit;
     }
     loader_import('cms.Versioning.Rex');
     $rex = new Rex('siteblog_post');
     $id = $cgi->_key;
     $subject = $vals['subject'];
     $author = $vals['author'];
     $status = $vals['status'];
     $category = $vals['category'];
     $created = $vals['created'];
     $body = $vals['body'];
     $data = array('subject' => $subject, 'author' => $author, 'status' => $status, 'category' => $category, 'created' => $created, 'body' => $body);
     if (!empty($id)) {
         if (!$data['created']) {
             unset($data['created']);
         }
         $method = $rex->determineAction($id);
         $rex->{$method}($id, $data);
     } else {
         if (!$data['created']) {
             $data['created'] = date('Y-m-d H:i:s');
         }
         $id = $rex->create($data);
     }
     session_set('sitellite_alert', intl_get('Your item has been saved.'));
     // view post
     if (!empty($vals['_return'])) {
         header('Location: ' . $vals['_return']);
     } else {
         header('Location: ' . site_prefix() . '/index/siteblog-post-action/id.' . $id . '/title.' . siteblog_filter_link_title($subject));
     }
     // ping blog directories via pingomatic.com
     $host = 'rpc.pingomatic.com';
     $path = '';
     $out = template_simple('ping.spt', $obj);
     $len = strlen($out);
     $req = 'POST /' . $path . " HTTP/1.0\r\n";
     $req .= 'User-Agent: Sitellite ' . SITELLITE_VERSION . "/SiteBlog\r\n";
     $req .= 'Host: ' . $host . "\r\n";
     $req .= "Content-Type: text/xml\r\n";
     $req .= 'Content-Length: ' . $len . "\r\n\r\n";
     $req .= $out . "\r\n";
     if ($ph = @fsockopen($host, 80)) {
         @fputs($ph, $req);
         //echo '<pre>';
         //echo htmlentities ($req);
         while (!@feof($ph)) {
             $res = @fgets($ph, 128);
             //echo htmlentities ($res);
         }
         @fclose($ph);
     }
     exit;
 }
コード例 #11
0
/**
 * Crée une transaction
 *
 * @param  integer $id_reservation id_reservation
 * @return $id_transaction  Id de la transaction crée
 */
function rb_inserer_transaction($id_reservation)
{
    session_set('id_reservation', $id_reservation);
    //Pas propre, ne devrait pas être dans la session, à améliorer
    $inserer_transaction = charger_fonction("inserer_transaction", "bank");
    $donnees = unserialize(recuperer_fond('inclure/paiement_reservation', array('id_reservation' => $id_reservation, 'cacher_paiement_public' => TRUE)));
    $id_transaction = $inserer_transaction($donnees['montant'], $donnees['options']);
    return $id_transaction;
}
コード例 #12
0
ファイル: Alert.php プロジェクト: vojtajina/sitellite
/**
 * Shows a notice (e.g., "Item deleted.") if one is set.
 */
function cms_alert()
{
    if (!cms_is_alert()) {
        return '';
    }
    $notice = session_get('sitellite_alert');
    session_set('sitellite_alert', null);
    return template_simple('alert.spt', array('msg' => $notice));
}
コード例 #13
0
ファイル: index.php プロジェクト: vojtajina/sitellite
 function onSubmit($vals)
 {
     session_set('xed_source_find', $vals['find']);
     session_set('xed_source_replace', $vals['replace']);
     $vals['find'] = str_replace(array('\\', '\''), array('\\\\', '\\\''), $vals['find']);
     $vals['replace'] = str_replace(array('\\', '\''), array('\\\\', '\\\''), $vals['replace']);
     echo template_simple('replace_return.spt', $vals);
     exit;
 }
コード例 #14
0
ファイル: session_messages.php プロジェクト: JoshuaGrams/wfpl
function session_save_messages()
{
    if (!isset($GLOBALS['wfpl_messages'])) {
        return;
    }
    if (!is_array($GLOBALS['wfpl_messages'])) {
        return;
    }
    init_session();
    session_set('wfpl_messages', array_to_string($GLOBALS['wfpl_messages']));
}
コード例 #15
0
ファイル: index.php プロジェクト: vojtajina/sitellite
 function onSubmit($vals)
 {
     loader_import('cms.Versioning.Rex');
     $collection = $vals['collection'];
     unset($vals['collection']);
     if (empty($collection)) {
         $collection = 'sitellite_page';
     }
     $return = $vals['_return'];
     unset($vals['_return']);
     $changelog = $vals['changelog'];
     unset($vals['changelog']);
     $rex = new Rex($collection);
     //$vals['sitellite_owner'] = session_username ();
     //$vals['sitellite_team'] = session_team ();
     unset($vals['submit_button']);
     unset($vals['tab1']);
     unset($vals['tab2']);
     unset($vals['tab3']);
     unset($vals['tab-end']);
     unset($vals['header_properties']);
     unset($vals['header_contact']);
     unset($vals['header_loc']);
     if ($vals['contact_url'] == 'http://') {
         $vals['contact_url'] = '';
     }
     if ($vals['loc_map'] == 'http://') {
         $vals['loc_map'] = '';
     }
     $res = $rex->create($vals, $changelog);
     if (isset($vals[$rex->key])) {
         $key = $vals[$rex->key];
     } elseif (!is_bool($res)) {
         $key = $res;
     } else {
         $key = 'Unknown';
     }
     if (!$res) {
         if (!$return) {
             $return = site_prefix() . '/index/cms-browse-action?collection=siteevent_event';
         }
         echo loader_box('cms/error', array('message' => $rex->error, 'collection' => $collection, 'key' => $key, 'action' => $method, 'data' => $vals, 'changelog' => $changelog, 'return' => $return));
     } else {
         loader_import('cms.Workflow');
         echo Workflow::trigger('add', array('collection' => $collection, 'key' => $key, 'data' => $vals, 'changelog' => intl_get('Item added.'), 'message' => 'Collection: ' . $collection . ', Item: ' . $key));
         session_set('sitellite_alert', intl_get('Your item has been created.'));
         if ($return) {
             header('Location: ' . $return);
             exit;
         }
     }
     header('Location: ' . site_prefix() . '/index/siteevent-app/id.' . $res);
     exit;
 }
コード例 #16
0
/**
 * Action effectuant 1 action dans la liste des actions à réaliser
 * sur les plugins.
 *
 * Cette action sera relancée tant qu'il reste des actions à faire
 */
function action_actionner_dist()
{
    // droits
    include_spip('inc/autoriser');
    if (!autoriser('configurer', '_plugins')) {
        include_spip('inc/minipres');
        echo minipres();
        exit;
    }
    include_spip('inc/svp_actionner');
    include_spip('inc/headers');
    $actionneur = new Actionneur();
    $actionneur->get_actions();
    if ($actionneur->one_action()) {
        // si SVP a été enlevé des actifs, on redirige sur la fin...
        // sinon cette page d'action/actionner devient introuvable.
        // dans ce cas précis, les autres actions prévues venant après la desactivation de SVP
        // ne pourront être traitees... SVP n'étant plus là !
        if ($actionneur->tester_si_svp_desactive()) {
            $url = _request('redirect');
        } else {
            $url = generer_action_auteur('actionner', '', _request('redirect'));
        }
        // en mode pas à pas, on affiche un bilan entre chaque action
        // et on demande a l'utilistateur de cliquer pour realiser
        // l'action suivante.
        include_spip('inc/config');
        if (lire_config('svp/mode_pas_a_pas') == 'oui') {
            include_spip('inc/minipres');
            $pres = $actionneur->presenter_actions();
            $btn = "<a href='{$url}'>[ Action Suivante ]</a>";
            $styles = "\n\t\t\t\t<style type='text/css'>\n\t\t\t\t#minipres #actionner .fail {color:#c30000;}\n\t\t\t\t#minipres #actionner ul {margin-left: 0.5em;}\n\t\t\t\t#minipres #actionner li {list-style-type:square; margin-left: 0.5em;}\n\t\t\t\t</style>";
            echo minipres(_T('svp:installation_en_cours'), $pres . '<br /><br />' . $btn . $styles);
            die;
        }
        redirige_par_entete(str_replace('&amp;', '&', $url));
    }
    foreach ($actionneur->done as $done) {
        if ($done['todo'] == 'on') {
            if ($voir = session_get('svp_admin_plugin_voir') and $voir == 'inactif') {
                session_set('svp_admin_plugin_voir', 'actif');
            }
            break;
        }
    }
    include_spip('inc/svp_depoter_local');
    svp_actualiser_paquets_locaux();
    if (!_request('redirect')) {
        $GLOBALS['redirect'] = generer_url_ecrire('admin_plugin');
    } else {
        $GLOBALS['redirect'] = str_replace('&amp;', '&', _request('redirect'));
    }
}
コード例 #17
0
ファイル: session.php プロジェクト: genma/spip_ynh
function action_session_dist()
{
    if ($var = _request('var') and preg_match(',^[a-z_0-9-]+$,i', $var)) {
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
            include_spip('inc/session');
            session_set('session_' . $var, $val = _request('val'));
            #spip_log("autosave:$var:$val",'autosave');
        }
    }
    # TODO: mode lecture de session ; n'afficher que ce qu'il faut
    #echo json_encode($GLOBALS['visiteur_session']);
}
コード例 #18
0
ファイル: index.php プロジェクト: vojtajina/sitellite
 function onSubmit($vals)
 {
     loader_import('cms.Workspace.Message');
     $msg = new WorkspaceMessage();
     if (!$vals['response_id']) {
         $vals['response_id'] = '0';
     }
     $res = $msg->send($vals['subject'], $vals['body'], explode(',', $vals['recipients']), array(), $vals['response_id'], $vals['priority'], session_username());
     if (!$res) {
         echo '<p>Error: ' . $msg->error . '</p>';
     }
     session_set('sitellite_alert', intl_get('Your message has been sent.'));
     header('Location: ' . site_prefix() . '/index/cms-cpanel-action?_msg=sent');
     exit;
 }
コード例 #19
0
ファイル: index.php プロジェクト: vojtajina/sitellite
 function onSubmit($vals)
 {
     loader_import('cms.Versioning.Rex');
     $collection = $vals['collection'];
     unset($vals['collection']);
     if (empty($collection)) {
         $collection = 'sitellite_page';
     }
     $return = $vals['_return'];
     unset($vals['_return']);
     $changelog = $vals['changelog'];
     unset($vals['changelog']);
     $rex = new Rex($collection);
     //$vals['sitellite_owner'] = session_username ();
     //$vals['sitellite_team'] = session_team ();
     unset($vals['submit_button']);
     unset($vals['edit-top']);
     unset($vals['edit-middle']);
     unset($vals['edit-middle2']);
     unset($vals['edit-middle3']);
     unset($vals['edit-bottom']);
     unset($vals['cover_heading']);
     $vals['ts'] = date('YmdHis');
     $res = $rex->create($vals, $changelog);
     if (isset($vals[$rex->key])) {
         $key = $vals[$rex->key];
     } elseif (!is_bool($res)) {
         $key = $res;
     } else {
         $key = 'Unknown';
     }
     if (!$res) {
         if (!empty($return)) {
             $return = site_prefix() . '/index/cms-browse-action?collection=sitepresenter_presentation';
         }
         echo loader_box('cms/error', array('message' => $rex->error, 'collection' => $collection, 'key' => $key, 'action' => $method, 'data' => $vals, 'changelog' => $changelog, 'return' => $return));
     } else {
         loader_import('cms.Workflow');
         echo Workflow::trigger('add', array('collection' => $collection, 'key' => $key, 'data' => $vals, 'changelog' => intl_get('Item added.'), 'message' => 'Collection: ' . $collection . ', Item: ' . $key));
         session_set('sitellite_alert', intl_get('Your item has been created.'));
         //if ($return) {
         //	header ('Location: ' . $return);
         //	exit;
         //}
         header('Location: ' . site_prefix() . '/index/sitepresenter-slides-action/id.' . $res);
         exit;
     }
 }
コード例 #20
0
ファイル: index.php プロジェクト: vojtajina/sitellite
 function remove($name, $primary_id, $foreign_id, $table, $field1, $field2)
 {
     if (!$primary_id || $primary_id == 'false') {
         $list = session_get($name . '_joiner');
         if (!is_array($list)) {
             $list = array();
         }
         foreach ($list as $k => $v) {
             if ($v == $foreign_id) {
                 unset($list[$k]);
             }
         }
         session_set($name . '_joiner', $list);
         return true;
     }
     return db_execute(sprintf('delete from %s where %s = ? and %s = ?', $table, $field1, $field2), $primary_id, $foreign_id);
 }
コード例 #21
0
function action_associer_champ_sql_comme_champ_extra($table, $champ)
{
    // recuperer la description du champ
    include_spip('inc/cextras');
    include_spip('inc/iextras');
    $champs = extras_champs_anormaux();
    if (isset($champs[$table][$champ])) {
        $sql = $champs[$table][$champ];
        $saisies = iextras_champs_extras_definis($table);
        include_spip('inc/saisies');
        $saisies_sql = saisies_lister_disponibles_sql();
        $type_saisie = 'textarea';
        $saisies = saisies_inserer($saisies, array('saisie' => $type_saisie, 'options' => array_merge($saisies_sql[$type_saisie]['defaut']['options'], array('nom' => $champ, 'label' => ucfirst($champ)))));
        // sauver
        ecrire_meta('champs_extras_' . $table, serialize($saisies));
        // supprimer la session d'edition du formulaire pour le remettre a zero
        session_set('constructeur_formulaire_champs_extras_' . $table, null);
    }
}
コード例 #22
0
ファイル: accounts.php プロジェクト: Jonic/Rotors
    function accounts_start_session($id)
    {

        if ($user = user_exists('id', $id, TRUE)) {
            extract($user);

            session_set('id',        $id);
            session_set('logged_in', TRUE);
            session_set('username',  $username, FALSE);

            if ($admin !== 0) {
                session_set('admin', TRUE, FALSE);
            }

            mysql_query('UPDATE users SET `last_logged_in` = NOW() WHERE id = ' . $id);

            accounts_logged_in_redirect();
        }

    }
コード例 #23
0
ファイル: index.php プロジェクト: vojtajina/sitellite
 function onSubmit($vals)
 {
     loader_import('cms.Versioning.Rex');
     $rex = new Rex('siteglossary_term');
     $collection = $vals['collection'];
     unset($vals['collection']);
     if (empty($collection)) {
         $collection = 'sitellite_page';
     }
     $return = $vals['_return'];
     unset($vals['_return']);
     $changelog = $vals['changelog'];
     unset($vals['changelog']);
     unset($vals['section']);
     unset($vals['submit_button']);
     $res = $rex->create($vals, $changelog);
     if (isset($vals[$rex->key])) {
         $key = $vals[$rex->key];
     } elseif (!is_bool($res)) {
         $key = $res;
     } else {
         $key = 'Unknown';
     }
     if (!$res) {
         if (!$return) {
             $return = site_prefix() . '/index/siteglossary-app';
         }
         echo loader_box('cms/error', array('message' => $rex->error, 'collection' => $collection, 'key' => $key, 'action' => $method, 'data' => $vals, 'changelog' => $changelog, 'return' => $return));
     } else {
         loader_import('cms.Workflow');
         echo Workflow::trigger('add', array('collection' => $collection, 'key' => $key, 'data' => $vals, 'changelog' => intl_get('Item added.'), 'message' => 'Collection: ' . $collection . ', Item: ' . $key));
         session_set('sitellite_alert', intl_get('Your item has been created.'));
         if ($return) {
             header('Location: ' . $return);
             exit;
         }
     }
     header('Location: ' . site_prefix() . '/index/siteglossary-app#' . $vals['word']);
     exit;
 }
コード例 #24
0
ファイル: index.php プロジェクト: vojtajina/sitellite
 function onSubmit($vals)
 {
     loader_import('cms.Versioning.Rex');
     $rex = new Rex('siteglossary_term');
     $collection = $vals['_collection'];
     unset($vals['_collection']);
     if (empty($collection)) {
         $collection = 'sitellite_page';
     }
     $key = $vals['_key'];
     unset($vals['_key']);
     $return = $vals['_return'];
     unset($vals['_return']);
     $changelog = $vals['changelog'];
     unset($vals['changelog']);
     unset($vals['section']);
     unset($vals['submit_button']);
     $method = $rex->determineAction($key);
     if (!$method) {
         die($rex->error);
     }
     $res = $rex->{$method}($key, $vals, $changelog);
     if (!$res) {
         if (empty($return)) {
             $return = site_prefix() . '/index/siteglossary-app#' . $vals['word'];
         }
         echo loader_box('cms/error', array('message' => $rex->error, 'collection' => $collection, 'key' => $key, 'action' => $method, 'data' => $vals, 'changelog' => $changelog, 'return' => $return));
     } else {
         loader_import('cms.Workflow');
         echo Workflow::trigger('edit', array('collection' => $collection, 'key' => $key, 'action' => $method, 'data' => $vals, 'changelog' => $changelog, 'message' => 'Collection: ' . $collection . ', Item: ' . $key));
         session_set('sitellite_alert', intl_get('Your item has been saved.'));
         if ($return) {
             header('Location: ' . $return);
             exit;
         }
     }
     header('Location: ' . site_prefix() . '/index/siteglossary-app#' . $vals['word']);
     exit;
 }
コード例 #25
0
ファイル: Filechooser.php プロジェクト: vojtajina/sitellite
 /**
  * Returns the display HTML for this widget.  The optional
  * parameter determines whether or not to automatically display the widget
  * nicely, or whether to simply return the widget (for use in a template).
  * 
  * @access	public
  * @param	boolean	$generate_html
  * @return	string
  * 
  */
 function display($generate_html = 0)
 {
     global $simple;
     if ($this->setPath && $this->path) {
         session_set('filechooser_path', $this->path);
     }
     // initialize modal dialog event handlers
     static $included = false;
     if (!$included) {
         page_onclick('checkModal ()');
         page_onfocus('return checkModal ()');
         $included = true;
     }
     $attrstr = $this->getAttrs();
     if ($generate_html) {
         return "\t" . '<tr>' . "\n\t\t" . '<td class="label"><label for="' . $this->name . '"' . $this->invalid() . '>' . $simple->fill($this->label_template, $this, '', true) . '</label></td>' . "\n\t\t" . '<td class="field"><input type="text" ' . $attrstr . ' value="' . htmlentities_compat($this->data_value) . '" ' . $this->extra . ' />&nbsp;' . $this->_link() . '</td>' . "\n\t" . '</tr>' . "\n";
     } else {
         return '<input type="file" ' . $attrstr . ' value="" ' . $this->extra . ' />';
     }
 }
コード例 #26
0
 public function frontend()
 {
     if (isset($_GET['debug'])) {
         if ($this->app->make('config')->get('app.debug')) {
             DB::enableQueryLog();
         }
     }
     event_trigger('mw.controller.index');
     if ($this->render_this_url == false and $this->app->url_manager->is_ajax() == false) {
         $page_url = $this->app->url_manager->string();
     } elseif ($this->render_this_url == false and $this->app->url_manager->is_ajax() == true) {
         $page_url = $this->app->url_manager->string(1);
     } else {
         $page_url = $this->render_this_url;
         $this->render_this_url = false;
     }
     if ($this->page_url != false) {
         $page_url = $this->page_url;
     }
     if (strtolower($page_url) == 'index.php') {
         $page_url = '';
     }
     if ($this->create_new_page == true and $this->page_url != false) {
         $page_url = $this->page_url;
     }
     $page = false;
     if ($page == false and !empty($this->page)) {
         $page = $this->page;
     }
     $page_url = rtrim($page_url, '/');
     $is_admin = $this->app->user_manager->is_admin();
     $page_url_orig = $page_url;
     $simply_a_file = false;
     $show_404_to_non_admin = false;
     // if this is a file path it will load it
     if (isset($_REQUEST['view'])) {
         $is_custom_view = $_REQUEST['view'];
     } else {
         $is_custom_view = $this->app->url_manager->param('view');
         if ($is_custom_view and $is_custom_view != false) {
             $is_custom_view = str_replace('..', '', $is_custom_view);
             $page_url = $this->app->url_manager->param_unset('view', $page_url);
         }
     }
     $is_editmode = $this->app->url_manager->param('editmode');
     $is_no_editmode = $this->app->url_manager->param('no_editmode');
     $is_quick_edit = $this->app->url_manager->param('mw_quick_edit');
     if ($is_quick_edit != false) {
         $page_url = $this->app->url_manager->param_unset('mw_quick_edit', $page_url);
     }
     $is_preview_template = $this->app->url_manager->param('preview_template');
     if (!$is_preview_template) {
         $is_preview_template = false;
         if ($this->return_data == false) {
             if (!defined('MW_FRONTEND')) {
                 define('MW_FRONTEND', true);
             }
         }
         if (mw()->user_manager->session_id() and $is_editmode and $is_no_editmode == false) {
             if ($is_editmode == 'n') {
                 $is_editmode = false;
                 $page_url = $this->app->url_manager->param_unset('editmode', $page_url);
                 $this->app->user_manager->session_set('back_to_editmode', true);
                 $this->app->user_manager->session_set('editmode', false);
                 return $this->app->url_manager->redirect($this->app->url_manager->site_url($page_url));
             } else {
                 $editmode_sess = $this->app->user_manager->session_get('editmode');
                 $page_url = $this->app->url_manager->param_unset('editmode', $page_url);
                 if ($is_admin == true) {
                     if ($editmode_sess == false) {
                         $this->app->user_manager->session_set('editmode', true);
                         $this->app->user_manager->session_set('back_to_editmode', false);
                         $is_editmode = false;
                     }
                     return $this->app->url_manager->redirect($this->app->url_manager->site_url($page_url));
                 } else {
                     $is_editmode = false;
                 }
             }
         }
         if (mw()->user_manager->session_id() and !$is_no_editmode) {
             $is_editmode = $this->app->user_manager->session_get('editmode');
         } else {
             $is_editmode = false;
             $page_url = $this->app->url_manager->param_unset('no_editmode', $page_url);
         }
     } else {
         $is_editmode = false;
         $page_url = $this->app->url_manager->param_unset('preview_template', $page_url);
     }
     if ($is_quick_edit == true) {
         $is_editmode = true;
     }
     $preview_module = false;
     $preview_module_template = false;
     $preview_module_id = false;
     $template_relative_layout_file_from_url = false;
     $is_preview_module = $this->app->url_manager->param('preview_module');
     if ($is_preview_module != false) {
         if ($this->app->user_manager->is_admin()) {
             $is_preview_module = module_name_decode($is_preview_module);
             if (is_module($is_preview_module)) {
                 $is_preview_module_skin = $this->app->url_manager->param('preview_module_template');
                 $preview_module_id = $this->app->url_manager->param('preview_module_id');
                 $preview_module = $is_preview_module;
                 if ($is_preview_module_skin != false) {
                     $preview_module_template = module_name_decode($is_preview_module_skin);
                     $is_editmode = false;
                 }
             }
         }
     }
     $is_layout_file = $this->app->url_manager->param('preview_layout');
     if (!$is_layout_file) {
         $is_layout_file = false;
     } else {
         $page_url = $this->app->url_manager->param_unset('preview_layout', $page_url);
     }
     if (isset($_REQUEST['content_id']) and intval($_REQUEST['content_id']) != 0) {
         $page = $this->app->content_manager->get_by_id($_REQUEST['content_id']);
     }
     if ($is_quick_edit or $is_preview_template == true or isset($_REQUEST['isolate_content_field']) or $this->create_new_page == true) {
         if (isset($_REQUEST['content_id']) and intval($_REQUEST['content_id']) != 0) {
             $page = $this->app->content_manager->get_by_id($_REQUEST['content_id']);
         } else {
             $page['id'] = 0;
             $page['content_type'] = 'page';
             if (isset($_REQUEST['content_type'])) {
                 $page['content_type'] = $this->app->database_manager->escape_string($_REQUEST['content_type']);
             }
             if (isset($_REQUEST['subtype'])) {
                 $page['subtype'] = $this->app->database_manager->escape_string($_REQUEST['subtype']);
             }
             template_var('new_content_type', $page['content_type']);
             $page['parent'] = '0';
             if (isset($_REQUEST['parent_id']) and $_REQUEST['parent_id'] != 0) {
                 $page['parent'] = intval($_REQUEST['parent_id']);
             }
             //$page['url'] = $this->app->url_manager->string();
             if (isset($is_preview_template) and $is_preview_template != false) {
                 $page['active_site_template'] = $is_preview_template;
             } else {
             }
             if (isset($is_layout_file) and $is_layout_file != false) {
                 $page['layout_file'] = $is_layout_file;
             }
             if (isset($_REQUEST['inherit_template_from']) and $_REQUEST['inherit_template_from'] != 0) {
                 $page['parent'] = intval($_REQUEST['inherit_template_from']);
                 $inherit_from = $this->app->content_manager->get_by_id($_REQUEST['inherit_template_from']);
                 //$page['parent'] =  $inherit_from ;
                 if (isset($inherit_from['layout_file']) and $inherit_from['layout_file'] == 'inherit') {
                     $inherit_from_id = $this->app->content_manager->get_inherited_parent($inherit_from['id']);
                     $inherit_from = $this->app->content_manager->get_by_id($inherit_from_id);
                 }
                 if (is_array($inherit_from) and isset($inherit_from['active_site_template'])) {
                     $page['active_site_template'] = $inherit_from['active_site_template'];
                     $is_layout_file = $page['layout_file'] = $inherit_from['layout_file'];
                 }
             }
             if (isset($_REQUEST['content_type']) and $_REQUEST['content_type'] != false) {
                 $page['content_type'] = $_REQUEST['content_type'];
             }
             if ($this->content_data != false) {
                 $page = $this->content_data;
             }
             template_var('new_page', $page);
         }
     }
     $output_cache_timeout = false;
     if (isset($is_preview_template) and $is_preview_template != false) {
         if (!defined('MW_NO_SESSION')) {
             define('MW_NO_SESSION', true);
         }
     }
     if (isset($_REQUEST['recart']) and $_REQUEST['recart'] != false) {
         event_trigger('recover_shopping_cart', $_REQUEST['recart']);
     }
     if ($output_cache_timeout != false) {
         $output_cache_id = __FUNCTION__ . crc32($_SERVER['REQUEST_URI']);
         $output_cache_group = 'content/preview';
         $output_cache_content = $this->app->cache_manager->get($output_cache_id, $output_cache_group, $output_cache_timeout);
         if ($output_cache_content != false) {
             echo $output_cache_content;
             return;
         }
     }
     $the_active_site_template = $this->app->option_manager->get('current_template', 'template');
     $date_format = $this->app->option_manager->get('date_format', 'website');
     if ($date_format == false) {
         $date_format = 'Y-m-d H:i:s';
     }
     if ($page == false or $this->create_new_page == true) {
         if (trim($page_url) == '' and $preview_module == false) {
             $page = $this->app->content_manager->homepage();
         } else {
             $found_mod = false;
             $page = $this->app->content_manager->get_by_url($page_url);
             $page_exact = $this->app->content_manager->get_by_url($page_url, true);
             $page_url_segment_1 = $this->app->url_manager->segment(0, $page_url);
             if ($preview_module != false) {
                 $page_url = $preview_module;
             }
             if ($the_active_site_template == false or $the_active_site_template == '') {
                 $the_active_site_template = 'default';
             }
             if ($page_exact == false and $found_mod == false and $this->app->modules->is_installed($page_url) and $page_url != 'settings' and $page_url != 'admin') {
                 $found_mod = true;
                 $page['id'] = 0;
                 $page['content_type'] = 'page';
                 $page['parent'] = '0';
                 $page['url'] = $this->app->url_manager->string();
                 $page['active_site_template'] = $the_active_site_template;
                 template_var('no_edit', 1);
                 $mod_params = '';
                 if ($preview_module_template != false) {
                     $mod_params = $mod_params . " template='{$preview_module_template}' ";
                 }
                 if ($preview_module_id != false) {
                     $mod_params = $mod_params . " id='{$preview_module_id}' ";
                 }
                 $found_mod = $page_url;
                 $page['content'] = '<microweber module="' . $page_url . '" ' . $mod_params . '  />';
                 //  $page['simply_a_file'] = 'clean.php';
                 $page['layout_file'] = 'clean.php';
                 template_var('content', $page['content']);
                 template_var('new_page', $page);
             }
             if ($found_mod == false) {
                 if (empty($page)) {
                     $the_new_page_file = false;
                     $page_url_segment_1 = $this->app->url_manager->segment(0, $page_url);
                     $td = templates_path() . $page_url_segment_1;
                     $td_base = $td;
                     $page_url_segment_2 = $this->app->url_manager->segment(1, $page_url);
                     $directly_to_file = false;
                     $page_url_segment_3 = $this->app->url_manager->segment(-1, $page_url);
                     $page_url_segment_1 = $the_active_site_template = $this->app->option_manager->get('current_template', 'template');
                     $td_base = templates_path() . $the_active_site_template . DS;
                     $page_url_segment_3_str = implode(DS, $page_url_segment_3);
                     if ($page_url_segment_3_str != '') {
                         $page_url_segment_3_str = rtrim($page_url_segment_3_str, DS);
                         $page_url_segment_3_str = rtrim($page_url_segment_3_str, '\\');
                         $page_url_segment_3_str_copy = $page_url_segment_3_str;
                         $is_ext = get_file_extension($page_url_segment_3_str);
                         if ($is_ext == false or $is_ext != 'php') {
                             $page_url_segment_3_str = $page_url_segment_3_str . '.php';
                         }
                         $td_f = $td_base . DS . $page_url_segment_3_str;
                         $td_fd = $td_base . DS . $page_url_segment_3_str_copy;
                         $td_fd2 = $td_base . DS . $page_url_segment_3[0];
                         if (is_file($td_f)) {
                             $the_new_page_file = $page_url_segment_3_str;
                             $simply_a_file = $directly_to_file = $td_f;
                         } else {
                             if (is_dir($td_fd)) {
                                 $td_fd_index = $td_fd . DS . 'index.php';
                                 if (is_file($td_fd_index)) {
                                     $the_new_page_file = $td_fd_index;
                                     $simply_a_file = $directly_to_file = $td_fd_index;
                                 }
                             } else {
                                 $is_ext = get_file_extension($td_fd);
                                 if ($is_ext == false or $is_ext != 'php') {
                                     $td_fd = $td_fd . '.php';
                                 }
                                 $is_ext = get_file_extension($td_fd2);
                                 if ($is_ext == false or $is_ext != 'php') {
                                     $td_fd2 = $td_fd2 . '.php';
                                 }
                                 if (is_file($td_fd)) {
                                     $the_new_page_file = $td_fd;
                                     $simply_a_file = $directly_to_file = $td_fd;
                                 } elseif (is_file($td_fd2)) {
                                     $the_new_page_file = $td_fd2;
                                     $simply_a_file = $directly_to_file = $td_fd2;
                                 } else {
                                     $td_basedef = templates_path() . 'default' . DS . $page_url_segment_3_str;
                                     if (is_file($td_basedef)) {
                                         $the_new_page_file = $td_basedef;
                                         $simply_a_file = $directly_to_file = $td_basedef;
                                     }
                                 }
                             }
                         }
                     }
                     $fname1 = 'index.php';
                     $fname2 = $page_url_segment_2 . '.php';
                     $fname3 = $page_url_segment_2;
                     $tf1 = $td . DS . $fname1;
                     $tf2 = $td . DS . $fname2;
                     $tf3 = $td . DS . $fname3;
                     if ($directly_to_file == false and is_dir($td)) {
                         if (is_file($tf1)) {
                             $simply_a_file = $tf1;
                             $the_new_page_file = $fname1;
                         }
                         if (is_file($tf2)) {
                             $simply_a_file = $tf2;
                             $the_new_page_file = $fname2;
                         }
                         if (is_file($tf3)) {
                             $simply_a_file = $tf3;
                             $the_new_page_file = $fname3;
                         }
                         if ($simply_a_file != false) {
                             $simply_a_file = str_replace('..', '', $simply_a_file);
                             $simply_a_file = normalize_path($simply_a_file, false);
                         }
                     }
                     if ($simply_a_file == false) {
                         //$page = $this->app->content_manager->homepage();
                         $page = false;
                         if (!is_array($page)) {
                             $page = array();
                             $page['id'] = 0;
                             $page['content_type'] = 'page';
                             $page['parent'] = '0';
                             $page['url'] = $this->app->url_manager->string();
                             //  $page['active_site_template'] = $page_url_segment_1;
                             $page['simply_a_file'] = 'clean.php';
                             $page['layout_file'] = 'clean.php';
                             $show_404_to_non_admin = true;
                         }
                         if (is_array($page_url_segment_3)) {
                             foreach ($page_url_segment_3 as $mvalue) {
                                 if ($found_mod == false and $this->app->modules->is_installed($mvalue)) {
                                     $found_mod = true;
                                     $page['id'] = 0;
                                     $page['content_type'] = 'page';
                                     $page['parent'] = '0';
                                     $page['url'] = $this->app->url_manager->string();
                                     $page['active_site_template'] = $page_url_segment_1;
                                     $page['content'] = '<module type="' . $mvalue . '" />';
                                     $page['simply_a_file'] = 'clean.php';
                                     $page['layout_file'] = 'clean.php';
                                     template_var('content', $page['content']);
                                     template_var('new_page', $page);
                                     $show_404_to_non_admin = false;
                                 }
                             }
                         }
                     } else {
                         if (!is_array($page)) {
                             $page = array();
                         }
                         $page['id'] = 0;
                         if (isset($page_data) and isset($page_data['id'])) {
                             //  $page['id'] = $page_data['id'];
                         }
                         $page['content_type'] = 'page';
                         $page['parent'] = '0';
                         $page['url'] = $this->app->url_manager->string();
                         $page['active_site_template'] = $page_url_segment_1;
                         $page['layout_file'] = $the_new_page_file;
                         $page['simply_a_file'] = $simply_a_file;
                         template_var('new_page', $page);
                         template_var('simply_a_file', $simply_a_file);
                     }
                 }
             }
         }
     }
     if ($page['id'] != 0) {
         // if(!isset($page['layout_file']) or $page['layout_file'] == false){
         $page = $this->app->content_manager->get_by_id($page['id']);
         // }
         if ($page['content_type'] == 'post' and isset($page['parent'])) {
             $content = $page;
             $page = $this->app->content_manager->get_by_id($page['parent']);
         } else {
             $content = $page;
         }
     } else {
         $content = $page;
     }
     if (isset($content['created_at']) and trim($content['created_at']) != '') {
         $content['created_at'] = date($date_format, strtotime($content['created_at']));
     }
     if (isset($content['updated_at']) and trim($content['updated_at']) != '') {
         $content['updated_at'] = date($date_format, strtotime($content['updated_at']));
     }
     if ($is_preview_template != false) {
         $is_preview_template = str_replace('____', DS, $is_preview_template);
         $is_preview_template = str_replace('..', '', $is_preview_template);
         $content['active_site_template'] = $is_preview_template;
     }
     if ($is_layout_file != false and $is_admin == true) {
         $is_layout_file = str_replace('____', DS, $is_layout_file);
         if ($is_layout_file == 'inherit') {
             if (isset($_REQUEST['inherit_template_from']) and intval($_REQUEST['inherit_template_from']) != 0) {
                 $inherit_layout_from_this_page = $this->app->content_manager->get_by_id($_REQUEST['inherit_template_from']);
                 if (isset($inherit_layout_from_this_page['layout_file']) and $inherit_layout_from_this_page['layout_file'] != 'inherit') {
                     $is_layout_file = $inherit_layout_from_this_page['layout_file'];
                 }
                 if (isset($inherit_layout_from_this_page['layout_file']) and $inherit_layout_from_this_page['layout_file'] != 'inherit') {
                     $is_layout_file = $inherit_layout_from_this_page['layout_file'];
                 }
             }
         }
         $content['layout_file'] = $is_layout_file;
     }
     if ($is_custom_view and $is_custom_view != false) {
         $content['custom_view'] = $is_custom_view;
     }
     if (isset($content['is_active']) and ($content['is_active'] == 'n' or $content['is_active'] == 0)) {
         if ($this->app->user_manager->is_admin() == false) {
             $page_non_active = array();
             $page_non_active['id'] = 0;
             $page_non_active['content_type'] = 'page';
             $page_non_active['parent'] = '0';
             $page_non_active['url'] = $this->app->url_manager->string();
             $page_non_active['content'] = 'This page is not published!';
             $page_non_active['simply_a_file'] = 'clean.php';
             $page_non_active['layout_file'] = 'clean.php';
             $page_non_active['page_non_active'] = true;
             template_var('content', $page_non_active['content']);
             $content = $page_non_active;
         }
     } elseif (isset($content['is_deleted']) and $content['is_deleted'] == 1) {
         if ($this->app->user_manager->is_admin() == false) {
             $page_non_active = array();
             $page_non_active['id'] = 0;
             $page_non_active['content_type'] = 'page';
             $page_non_active['parent'] = '0';
             $page_non_active['url'] = $this->app->url_manager->string();
             $page_non_active['content'] = 'This page is deleted!';
             $page_non_active['simply_a_file'] = 'clean.php';
             $page_non_active['layout_file'] = 'clean.php';
             $page_non_active['page_is_deleted'] = true;
             template_var('content', $page_non_active['content']);
             $content = $page_non_active;
         }
     }
     if (isset($content['require_login']) and $content['require_login'] == 1) {
         if ($this->app->user_manager->id() == 0) {
             $page_non_active = array();
             $page_non_active['id'] = 0;
             $page_non_active['content_type'] = 'page';
             $page_non_active['parent'] = '0';
             $page_non_active['url'] = $this->app->url_manager->string();
             $page_non_active['content'] = ' <module type="users/login" class="user-require-login-on-view" /> ';
             $page_non_active['simply_a_file'] = 'clean.php';
             $page_non_active['layout_file'] = 'clean.php';
             $page_non_active['page_require_login'] = true;
             template_var('content', $page_non_active['content']);
             $content = $page_non_active;
         }
     }
     if (!defined('IS_HOME')) {
         if (isset($content['is_home']) and $content['is_home'] == 1) {
             define('IS_HOME', true);
         }
     }
     $this->app->content_manager->define_constants($content);
     event_trigger('mw.front', $content);
     event_trigger('mw_frontend', $content);
     $render_file = $this->app->template->get_layout($content);
     $content['render_file'] = $render_file;
     if (defined('TEMPLATE_DIR')) {
         $load_template_functions = TEMPLATE_DIR . 'functions.php';
         if (is_file($load_template_functions)) {
             include_once $load_template_functions;
         }
     }
     if ($this->return_data != false) {
         return $content;
     }
     if (isset($content['original_link']) and $content['original_link'] != '') {
         $content['original_link'] = str_ireplace('{site_url}', $this->app->url_manager->site(), $content['original_link']);
         $redirect = $this->app->format->prep_url($content['original_link']);
         if ($redirect != '') {
             return $this->app->url_manager->redirect($redirect);
         }
     }
     if (!isset($page['title'])) {
         $page['title'] = 'New page';
     }
     if (!isset($content['title'])) {
         $content['title'] = 'New content';
     }
     $category = false;
     if (defined('CATEGORY_ID')) {
         $category = $this->app->category_manager->get_by_id(CATEGORY_ID);
     }
     if ($render_file) {
         $render_params = array();
         if ($show_404_to_non_admin) {
             if (!is_admin()) {
                 $load_template_404 = template_dir() . '404.php';
                 if (is_file($load_template_404)) {
                     $render_file = $load_template_404;
                 }
             }
         }
         $render_params['render_file'] = $render_file;
         $render_params['page_id'] = PAGE_ID;
         $render_params['content_id'] = CONTENT_ID;
         $render_params['post_id'] = POST_ID;
         $render_params['category_id'] = CATEGORY_ID;
         $render_params['content'] = $content;
         $render_params['category'] = $category;
         $render_params['page'] = $page;
         $l = $this->app->template->render($render_params);
         if (is_object($l)) {
             return $l;
         }
         // used for preview from the admin wysiwyg
         if (isset($_REQUEST['isolate_content_field'])) {
             require_once MW_PATH . 'Utils' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'phpQuery.php';
             $pq = \phpQuery::newDocument($l);
             $isolated_head = pq('head')->eq(0)->html();
             $found_field = false;
             if (isset($_REQUEST['isolate_content_field'])) {
                 foreach ($pq['[field=content]'] as $elem) {
                     $isolated_el = $l = pq($elem)->htmlOuter();
                 }
             }
             $is_admin = $this->app->user_manager->is_admin();
             if ($is_admin == true and isset($isolated_el) != false) {
                 $tb = mw_includes_path() . DS . 'toolbar' . DS . 'editor_tools' . DS . 'wysiwyg' . DS . 'index.php';
                 //$layout_toolbar = file_get_contents($filename);
                 $layout_toolbar = new \Microweber\View($tb);
                 $layout_toolbar = $layout_toolbar->__toString();
                 if ($layout_toolbar != '') {
                     if (strstr($layout_toolbar, '{head}')) {
                         if ($isolated_head != false) {
                             $layout_toolbar = str_replace('{head}', $isolated_head, $layout_toolbar);
                         }
                     }
                     if (strpos($layout_toolbar, '{content}')) {
                         $l = str_replace('{content}', $l, $layout_toolbar);
                     }
                     //$layout_toolbar = mw()->parser->process($layout_toolbar, $options = array('no_apc' => 1));
                 }
             }
         }
         $modify_content = event_trigger('on_load', $content);
         if ($is_editmode == true and !defined('IN_EDIT')) {
             define('IN_EDIT', true);
         }
         if (isset($is_quick_edit) and $is_quick_edit == true and !defined('QUICK_EDIT')) {
             define('QUICK_EDIT', true);
         }
         $l = $this->app->parser->process($l, $options = false);
         if ($preview_module_id != false) {
             $_REQUEST['embed_id'] = $preview_module_id;
         }
         if (isset($_REQUEST['embed_id'])) {
             $find_embed_id = trim($_REQUEST['embed_id']);
             $l = $this->app->parser->get_by_id($find_embed_id, $l);
         }
         $apijs_loaded = $this->app->template->get_apijs_url();
         //$apijs_loaded = $this->app->template->get_apijs_url() . '?id=' . CONTENT_ID;
         $is_admin = $this->app->user_manager->is_admin();
         $default_css = '<link rel="stylesheet" href="' . mw_includes_url() . 'default.css" type="text/css" />';
         $headers = event_trigger('site_header', TEMPLATE_NAME);
         $template_headers_append = '';
         $one = 1;
         if (is_array($headers)) {
             foreach ($headers as $modify) {
                 if ($modify != false and is_string($modify) and $modify != '') {
                     $template_headers_append = $template_headers_append . $modify;
                 }
             }
             if ($template_headers_append != false and $template_headers_append != '') {
                 $l = str_ireplace('</head>', $template_headers_append . '</head>', $l, $one);
             }
         }
         $template_headers_src = $this->app->template->head(true);
         $template_footer_src = $this->app->template->foot(true);
         $template_headers_src_callback = $this->app->template->head_callback($page);
         if (is_array($template_headers_src_callback) and !empty($template_headers_src_callback)) {
             foreach ($template_headers_src_callback as $template_headers_src_callback_str) {
                 if (is_string($template_headers_src_callback_str)) {
                     $template_headers_src = $template_headers_src . "\n" . $template_headers_src_callback_str;
                 }
             }
         }
         if (isset($page['created_by'])) {
             $author = $this->app->user_manager->get_by_id($page['created_by']);
             if (is_array($author) and isset($author['profile_url']) and $author['profile_url'] != false) {
                 $template_headers_src = $template_headers_src . "\n" . '<link rel="author" href="' . trim($author['profile_url']) . '" />' . "\n";
             }
         }
         if ($template_headers_src != false and is_string($template_headers_src)) {
             $l = str_ireplace('</head>', $template_headers_src . '</head>', $l, $one);
         }
         if ($template_footer_src != false and is_string($template_footer_src)) {
             $l = str_ireplace('</body>', $template_footer_src . '</body>', $l, $one);
         }
         $l = str_ireplace('<head>', '<head>' . $default_css, $l);
         if (!stristr($l, $apijs_loaded)) {
             //$apijs_settings_loaded = $this->app->template->get_apijs_settings_url() . '?id=' . CONTENT_ID . '&category_id=' . CATEGORY_ID;;
             $apijs_settings_loaded = $this->app->template->get_apijs_settings_url();
             $apijs_settings_script = "\r\n" . '<script src="' . $apijs_settings_loaded . '"></script>' . "\r\n";
             $apijs_settings_script .= '<script src="' . $apijs_loaded . '"></script>' . "\r\n";
             $l = str_ireplace('<head>', '<head>' . $apijs_settings_script, $l);
         }
         if (isset($content['active_site_template']) and $content['active_site_template'] == 'default' and $the_active_site_template != 'default' and $the_active_site_template != 'mw_default') {
             $content['active_site_template'] = $the_active_site_template;
         }
         if (isset($content['active_site_template']) and trim($content['active_site_template']) != '' and $content['active_site_template'] != 'default') {
             if (!defined('CONTENT_TEMPLATE')) {
                 define('CONTENT_TEMPLATE', $content['active_site_template']);
             }
             $custom_live_edit = TEMPLATES_DIR . DS . $content['active_site_template'] . DS . 'live_edit.css';
             $live_edit_css_folder = userfiles_path() . 'css' . DS . $content['active_site_template'] . DS;
             $live_edit_url_folder = userfiles_url() . 'css/' . $content['active_site_template'] . '/';
             $custom_live_edit = $live_edit_css_folder . DS . 'live_edit.css';
         } else {
             if (!defined('CONTENT_TEMPLATE')) {
                 define('CONTENT_TEMPLATE', $the_active_site_template);
             }
             //                if ($the_active_site_template == 'mw_default') {
             //                    $the_active_site_template = 'default';
             //                }
             $custom_live_edit = TEMPLATE_DIR . DS . 'live_edit.css';
             $live_edit_css_folder = userfiles_path() . 'css' . DS . $the_active_site_template . DS;
             $live_edit_url_folder = userfiles_url() . 'css/' . $the_active_site_template . '/';
             $custom_live_edit = $live_edit_css_folder . 'live_edit.css';
         }
         $custom_live_edit = normalize_path($custom_live_edit, false);
         if (is_file($custom_live_edit)) {
             $custom_live_editmtime = filemtime($custom_live_edit);
             $liv_ed_css = '<link rel="stylesheet" href="' . $live_edit_url_folder . 'live_edit.css?version=' . $custom_live_editmtime . '" id="mw-template-settings" type="text/css" />';
             $l = str_ireplace('</head>', $liv_ed_css . '</head>', $l);
         }
         $liv_ed_css = $this->app->template->get_custom_css_url();
         if ($liv_ed_css != false) {
             $liv_ed_css = '<link rel="stylesheet" href="' . $liv_ed_css . '" id="mw-custom-user-css" type="text/css" />';
             $l = str_ireplace('</head>', $liv_ed_css . '</head>', $l);
         }
         $website_head_tags = $this->app->option_manager->get('website_head', 'website');
         $rep_count = 1;
         if ($website_head_tags != false) {
             $l = str_ireplace('</head>', $website_head_tags . '</head>', $l, $rep_count);
         }
         if (defined('MW_VERSION')) {
             $generator_tag = "\n" . '<meta name="generator" content="Microweber" />' . "\n";
             $l = str_ireplace('</head>', $generator_tag . '</head>', $l, $rep_count);
         }
         if ($is_editmode == true and $this->isolate_by_html_id == false and !isset($_REQUEST['isolate_content_field'])) {
             if ($is_admin == true) {
                 $tb = mw_includes_path() . DS . 'toolbar' . DS . 'toolbar.php';
                 $layout_toolbar = new \Microweber\View($tb);
                 $is_editmode_basic = false;
                 $user_data = $this->app->user_manager->get();
                 if (isset($user_data['basic_mode']) and trim($user_data['basic_mode'] == 'y')) {
                     $is_editmode_basic = true;
                 }
                 if (isset($is_editmode_basic) and $is_editmode_basic == true) {
                     $layout_toolbar->assign('basic_mode', true);
                 } else {
                     $layout_toolbar->assign('basic_mode', false);
                 }
                 event_trigger('mw.live_edit');
                 $layout_toolbar = $layout_toolbar->__toString();
                 if ($layout_toolbar != '') {
                     $layout_toolbar = $this->app->parser->process($layout_toolbar, $options = array('no_apc' => 1));
                     $c = 1;
                     $l = str_ireplace('</body>', $layout_toolbar . '</body>', $l, $c);
                 }
                 $custom_live_edit = TEMPLATES_DIR . DS . TEMPLATE_NAME . DS . 'live_edit.php';
                 $custom_live_edit = normalize_path($custom_live_edit, false);
                 if (is_file($custom_live_edit)) {
                     $layout_live_edit = new \Microweber\View($custom_live_edit);
                     $layout_live_edit = $layout_live_edit->__toString();
                     if ($layout_live_edit != '') {
                         $l = str_ireplace('</body>', $layout_live_edit . '</body>', $l, $c);
                     }
                 }
             }
         } elseif ($is_editmode == false and $is_admin == true and mw()->user_manager->session_id() and !(mw()->user_manager->session_all() == false) and mw()->user_manager->session_get('back_to_editmode')) {
             if (!isset($_REQUEST['isolate_content_field']) and !isset($_REQUEST['content_id'])) {
                 $back_to_editmode = $this->app->user_manager->session_get('back_to_editmode');
                 if ($back_to_editmode == true) {
                     $tb = mw_includes_path() . DS . 'toolbar' . DS . 'toolbar_back.php';
                     $layout_toolbar = new \Microweber\View($tb);
                     $layout_toolbar = $layout_toolbar->__toString();
                     if ($layout_toolbar != '') {
                         $layout_toolbar = $this->app->parser->process($layout_toolbar, $options = array('no_apc' => 1));
                         $c = 1;
                         $l = str_ireplace('</body>', $layout_toolbar . '</body>', $l, $c);
                     }
                 }
             }
         }
         $l = str_replace('{TEMPLATE_URL}', TEMPLATE_URL, $l);
         $l = str_replace('{THIS_TEMPLATE_URL}', THIS_TEMPLATE_URL, $l);
         $l = str_replace('{DEFAULT_TEMPLATE_URL}', DEFAULT_TEMPLATE_URL, $l);
         $l = str_replace('%7BTEMPLATE_URL%7D', TEMPLATE_URL, $l);
         $l = str_replace('%7BTHIS_TEMPLATE_URL%7D', THIS_TEMPLATE_URL, $l);
         $l = str_replace('%7BDEFAULT_TEMPLATE_URL%7D', DEFAULT_TEMPLATE_URL, $l);
         $meta = array();
         $meta['content_image'] = '';
         $meta['description'] = '';
         if (is_home()) {
             $meta['content_url'] = site_url();
         } else {
             $meta['content_url'] = $this->app->url_manager->current(1);
         }
         $meta['og_description'] = $this->app->option_manager->get('website_description', 'website');
         $meta['og_type'] = 'website';
         $meta_content_id = PAGE_ID;
         if (CONTENT_ID > 0) {
             $meta_content_id = CONTENT_ID;
         }
         if ($meta_content_id > 0) {
             $meta = $this->app->content_manager->get_by_id($meta_content_id);
             $content_image = $this->app->media_manager->get_picture($meta_content_id);
             if ($content_image) {
                 $meta['content_image'] = $content_image;
             } else {
                 $meta['content_image'] = '';
             }
             $meta['content_url'] = $this->app->content_manager->link($meta_content_id);
             $meta['og_type'] = $meta['content_type'];
             if ($meta['og_type'] != 'page' and trim($meta['subtype']) != '') {
                 $meta['og_type'] = $meta['subtype'];
             }
             if ($meta['description'] != false and trim($meta['description']) != '') {
                 $meta['description'] = $meta['description'];
             } elseif ($meta['content'] != false and trim($meta['content']) != '') {
                 $meta['description'] = str_replace("\n", ' ', $this->app->format->limit($this->app->format->clean_html(strip_tags($meta['content'])), 500));
             }
             if (isset($meta['description']) and $meta['description'] != '') {
                 $meta['og_description'] = $meta['description'];
             } else {
                 $meta['og_description'] = trim($this->app->format->limit($this->app->format->clean_html(strip_tags($meta['content'])), 500));
             }
         } else {
             $meta['title'] = $this->app->option_manager->get('website_title', 'website');
             $meta['description'] = $this->app->option_manager->get('website_description', 'website');
             $meta['content_meta_keywords'] = $this->app->option_manager->get('website_keywords', 'website');
         }
         $meta['og_site_name'] = $this->app->option_manager->get('website_title', 'website');
         if (!empty($meta)) {
             if (isset($meta['content_meta_title']) and $meta['content_meta_title'] != '') {
                 $meta['title'] = $meta['content_meta_title'];
             } elseif (isset($meta['title']) and $meta['title'] != '') {
             } else {
                 $meta['title'] = $this->app->option_manager->get('website_title', 'website');
             }
             if (isset($meta['description']) and $meta['description'] != '') {
             } else {
                 $meta['description'] = $this->app->option_manager->get('website_description', 'website');
             }
             if (isset($meta['description']) and $meta['description'] != '') {
                 $meta['content_meta_description'] = strip_tags($meta['description']);
                 unset($meta['description']);
             } elseif (isset($meta['content']) and $meta['content'] != '') {
                 $meta['content_meta_description'] = strip_tags($meta['content']);
             } elseif (isset($meta['title']) and $meta['title'] != '') {
                 $meta['content_meta_description'] = strip_tags($meta['title']);
             }
             if (isset($meta['title']) and $meta['title'] != '') {
                 $meta['content_meta_title'] = strip_tags($meta['title']);
             } elseif (isset($found_mod) and $found_mod != false) {
                 $meta['content_meta_title'] = ucwords(str_replace('/', ' ', $found_mod));
             } else {
                 $meta['content_meta_title'] = ucwords(str_replace('/', ' ', $this->app->url_manager->segment(0)));
             }
             if (isset($meta['content_meta_keywords']) and $meta['content_meta_keywords'] != '') {
             } else {
                 $meta['content_meta_keywords'] = $this->app->option_manager->get('website_keywords', 'website');
             }
             if (is_array($meta)) {
                 foreach ($meta as $key => $item) {
                     if (is_string($item)) {
                         $item = html_entity_decode($item);
                         $item = strip_tags($item);
                         $item = str_replace('&amp;zwnj;', ' ', $item);
                         $item = str_replace('"', ' ', $item);
                         $item = str_replace("'", ' ', $item);
                         $item = str_replace('>', '', $item);
                         $item = str_replace('&amp;quot;', ' ', $item);
                         $item = str_replace('quot;', ' ', $item);
                         $item = str_replace('&amp;', ' ', $item);
                         $item = str_replace('amp;', ' ', $item);
                         $item = str_replace('nbsp;', ' ', $item);
                         $item = str_replace('#039;', ' ', $item);
                         $item = str_replace('&amp;nbsp;', ' ', $item);
                         $item = str_replace('&', ' ', $item);
                         $item = str_replace(';', ' ', $item);
                         $item = str_replace('  ', ' ', $item);
                         $item = str_replace(' ', ' ', $item);
                         $l = str_replace('{' . $key . '}', $item, $l);
                     } elseif ($item == false) {
                         $l = str_replace('{' . $key . '}', '', $l);
                     }
                 }
             }
         }
         if ($page != false and empty($this->page)) {
             $this->page = $page;
         }
         $l = execute_document_ready($l);
         event_trigger('frontend');
         $is_embed = $this->app->url_manager->param('embed');
         if ($is_embed != false) {
             $this->isolate_by_html_id = $is_embed;
         }
         if ($this->isolate_by_html_id != false) {
             $id_sel = $this->isolate_by_html_id;
             $this->isolate_by_html_id = false;
             require_once MW_PATH . 'Utils' . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'phpQuery.php';
             $pq = \phpQuery::newDocument($l);
             foreach ($pq['#' . $id_sel] as $elem) {
                 $l = pq($elem)->htmlOuter();
             }
         }
         if (mw()->user_manager->session_id() and !(mw()->user_manager->session_all() == false) and $is_editmode) {
             session_set('last_content_id', CONTENT_ID);
         }
         if ($output_cache_timeout != false) {
             $this->app->cache_manager->save($l, $output_cache_id, $output_cache_group);
         }
         if (isset($_REQUEST['debug'])) {
             if ($this->app->make('config')->get('app.debug')) {
                 $is_admin = $this->app->user_manager->is_admin();
                 if ($is_admin == true) {
                     include mw_includes_path() . 'debug.php';
                 }
             }
         }
         if ($show_404_to_non_admin) {
             $response = \Response::make($l);
             $response->setStatusCode(404);
             return $response;
         }
         return $l;
     } else {
         echo 'Error! Page is not found? Please login in the admin and make a page.';
         $this->app->cache_manager->clear();
         return;
     }
 }
コード例 #27
0
ファイル: autoriser.php プロジェクト: JLuc/SPIP
/**
 * Autorisation de prévisualiser un contenu
 *
 * @param  string $faire Action demandée
 * @param  string $type  Type d'objet sur lequel appliquer l'action
 * @param  int    $id    Identifiant de l'objet
 * @param  array  $qui   Description de l'auteur demandant l'autorisation
 * @param  array  $opt   Options de cette autorisation
 * @return bool          true s'il a le droit, false sinon
**/
function autoriser_previsualiser_dist($faire, $type, $id, $qui, $opt)
{
    // Le visiteur a-t-il un statut prevu par la config ?
    if (strpos($GLOBALS['meta']['preview'], "," . $qui['statut'] . ",") !== false) {
        return test_previsualiser_objet_champ($type, $id, $qui, $opt);
    }
    // Sinon, on regarde s'il a un jeton (var_token) et on lui pose
    // le cas echeant une session contenant l'autorisation
    // de l'utilisateur ayant produit le jeton
    if ($token = _request('var_previewtoken')) {
        include_spip('inc/session');
        session_set('previewtoken', $token);
    }
    // A-t-on un token valable ?
    if (is_array($GLOBALS['visiteur_session']) and $token = session_get('previewtoken') and preg_match('/^(\\d+)\\*(.*)$/', $token, $r) and $action = 'previsualiser' and include_spip('inc/securiser_action') and ($r[2] == _action_auteur($action, $r[1], null, 'alea_ephemere') or $r[2] == _action_auteur($action, $r[1], null, 'alea_ephemere_ancien'))) {
        return true;
    }
    return false;
}
コード例 #28
0
        redirige_url_ecrire("install");
    } else {
        // Si on est dans le site public, dire que qq s'en occupe
        include_spip('inc/minipres');
        utiliser_langue_visiteur();
        echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . "</p>");
        exit;
    }
    // autrement c'est une install ad hoc (spikini...), on sait pas faire
}
// memoriser un tri sessionne eventuel
if (isset($_REQUEST['var_memotri']) and $t = $_REQUEST['var_memotri'] and (strncmp($t, 'trisession', 10) == 0 or strncmp($t, 'senssession', 11) == 0)) {
    if (!function_exists('session_set')) {
        include_spip('inc/session');
    }
    session_set($t, _request($t));
}
/**
 * Header "Composed-By"
 *
 * Vanter notre art de la composition typographique
 * La globale $spip_header_silencieux permet de rendre le header minimal pour raisons de securite
 */
if (!defined('_HEADER_COMPOSED_BY')) {
    define('_HEADER_COMPOSED_BY', "Composed-By: SPIP");
}
if (!headers_sent()) {
    header("Vary: Cookie, Accept-Encoding");
    if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
        header(_HEADER_COMPOSED_BY . " {$spip_version_affichee} @ www.spip.net" . (isset($GLOBALS['meta']['plugin_header']) ? " + " . $GLOBALS['meta']['plugin_header'] : ""));
    } else {
コード例 #29
0
ファイル: session.php プロジェクト: JLuc/SPIP
/**
 * En fin de hit, synchroniser toutes les sessions
 */
function terminer_actualiser_sessions()
{
    // se remettre dans le dossier de travail au cas ou Apache a change
    chdir(_ROOT_CWD);
    // recuperer les variables a effacer
    $remove = session_set(false);
    // mettre a jour toutes les sessions
    actualiser_sessions($GLOBALS['visiteur_session'], $remove);
}
コード例 #30
0
ファイル: forum.php プロジェクト: genma/spip_ynh
/**
 * Verifier la saisie de #FORMULAIRE_FORUM
 * @param string $objet
 * @param int $id_objet
 * @param int $id_forum
 * @param int|array $ajouter_mot
 *   mots ajout�s coch�s par defaut
 * @param $ajouter_groupe
 *   groupes ajoutables
 * @param $afficher_previsu
 *   previsu oui ou non
 * @param $retour
 *   url de retour
 * @return array|bool
 */
function formulaires_forum_verifier_dist($objet, $id_objet, $id_forum, $ajouter_mot, $ajouter_groupe, $afficher_previsu, $retour)
{
    include_spip('inc/acces');
    include_spip('inc/texte');
    include_spip('inc/session');
    include_spip('base/abstract_sql');
    $erreurs = array();
    $doc = array();
    // desactiver id_rubrique si un id_article ou autre existe dans le contexte
    // if ($id_article OR $id_breve OR $id_forum OR $id_syndic)
    //	$id_rubrique = 0;
    // stocker un eventuel document dans un espace temporaire
    // portant la cle du formulaire ; et ses metadonnees avec
    if (isset($_FILES['ajouter_document']) and $_FILES['ajouter_document']['tmp_name']) {
        $acceptes = forum_documents_acceptes();
        if (!count($acceptes) or _request('cle_ajouter_document') != calculer_cle_action($a = "ajouter-document-{$objet}-{$id_objet}")) {
            $erreurs['document_forum'] = _T('forum:documents_interdits_forum');
            unset($_FILES['ajouter_document']);
        } else {
            if (!isset($GLOBALS['visiteur_session']['tmp_forum_document'])) {
                session_set('tmp_forum_document', sous_repertoire(_DIR_TMP, 'documents_forum') . md5(uniqid(rand())));
            }
            $tmp = $GLOBALS['visiteur_session']['tmp_forum_document'];
            $doc =& $_FILES['ajouter_document'];
            include_spip('inc/joindre_document');
            include_spip('action/ajouter_documents');
            list($extension, $doc['name']) = fixer_extension_document($doc);
            if (!in_array($extension, $acceptes)) {
                $erreurs['document_forum'] = _T('public:formats_acceptes', array('formats' => join(', ', $acceptes)));
            } else {
                include_spip('inc/getdocument');
                if (!deplacer_fichier_upload($doc['tmp_name'], $tmp . '.bin')) {
                    $erreurs['document_forum'] = _T('copie_document_impossible');
                }
                #		else if (...)
                #		verifier le type_document autorise
                #		retailler eventuellement les photos
            }
            // si ok on stocke les meta donnees, sinon on efface
            if (isset($erreurs['document_forum'])) {
                spip_unlink($tmp . '.bin');
                unset($_FILES['ajouter_document']);
            } else {
                $doc['tmp_name'] = $tmp . '.bin';
                ecrire_fichier($tmp . '.txt', serialize($doc));
            }
        }
    } elseif (isset($GLOBALS['visiteur_session']['tmp_forum_document']) and $tmp = $GLOBALS['visiteur_session']['tmp_forum_document'] and file_exists($tmp . '.bin')) {
        if (_request('supprimer_document_ajoute')) {
            spip_unlink($tmp . '.bin');
            spip_unlink($tmp . '.txt');
        } elseif (lire_fichier($tmp . '.txt', $meta)) {
            $doc =& $_FILES['ajouter_document'];
            $doc = @unserialize($meta);
        }
    }
    $min_length = defined('_FORUM_LONGUEUR_MINI') ? _FORUM_LONGUEUR_MINI : 10;
    if (strlen($texte = _request('texte')) < $min_length and !$ajouter_mot and $GLOBALS['meta']['forums_texte'] == 'oui') {
        $erreurs['texte'] = _T($min_length == 10 ? 'forum:forum_attention_dix_caracteres' : 'forum:forum_attention_nb_caracteres_mini', array('min' => $min_length));
    } elseif (defined('_FORUM_LONGUEUR_MAXI') and _FORUM_LONGUEUR_MAXI > 0 and strlen($texte) > _FORUM_LONGUEUR_MAXI) {
        $erreurs['texte'] = _T('forum:forum_attention_trop_caracteres', array('compte' => strlen($texte), 'max' => _FORUM_LONGUEUR_MAXI));
    }
    if (array_reduce($_POST, 'reduce_strlen', 20 * 1024) < 0) {
        $erreurs['erreur_message'] = _T('forum:forum_message_trop_long');
    } else {
        // Ne pas autoriser d'envoi hacke si forum sur abonnement
        if (controler_forum($objet, $id_objet) == 'abo' and !test_espace_prive()) {
            if (!isset($GLOBALS['visiteur_session']) or !isset($GLOBALS['visiteur_session']['statut'])) {
                $erreurs['erreur_message'] = _T('forum_non_inscrit');
            } elseif ($GLOBALS['visiteur_session']['statut'] == '5poubelle') {
                $erreurs['erreur_message'] = _T('forum:forum_acces_refuse');
            }
        }
    }
    if (strlen($titre = _request('titre')) < 3 and $GLOBALS['meta']['forums_titre'] == 'oui') {
        $erreurs['titre'] = _T('forum:forum_attention_trois_caracteres');
    }
    if (!count($erreurs) and !_request('confirmer_previsu_forum')) {
        if ($afficher_previsu != 'non') {
            $previsu = inclure_previsu($texte, $titre, _request('url_site'), _request('nom_site'), _request('ajouter_mot'), $doc, $objet, $id_objet, $id_forum);
            $erreurs['previsu'] = $previsu;
        }
    }
    //  Si forum avec previsu sans bon hash de securite, echec
    if (!count($erreurs)) {
        if (!test_espace_prive() and $afficher_previsu != 'non' and forum_insert_noprevisu()) {
            $erreurs['erreur_message'] = _T('forum:forum_acces_refuse');
        }
    }
    return $erreurs;
}