function earchive_event_handler($evt)
{
    global $B;
    switch ($evt["code"]) {
        case EVT_LOAD_MODULE:
            // earchive rights class
            include SF_BASE_DIR . '/admin/modules/earchive/class.rights.php';
            // check if the login user have rights to access this module
            // 4 or 5 required (editor or administrator)
            if (FALSE == earchive_rights::ask_access_to_list()) {
                @header('Location: ' . SF_BASE_LOCATION . '/admin/index.php');
                exit;
            }
            // load this module
            include SF_BASE_DIR . '/admin/modules/earchive/module_loader.php';
            break;
        case EVT_INIT:
            // check for install or upgrade
            if (MOD_EARCHIVE_VERSION != (string) $B->sys['module']['earchive']['version']) {
                // set the new version num of this module
                $B->sys['module']['earchive']['version'] = MOD_EARCHIVE_VERSION;
                $B->system_update_flag = TRUE;
            }
            break;
        case EVT_LOGOUT:
            break;
        case EVT_SET_OPTIONS:
            // set user options
            // this event comes from the option module (module_loader.php)
            if (isset($_POST['update_earchive_options_wordindex']) && !empty($_POST['earchive_rebuild_index'])) {
                // the earchive class
                include_once SF_BASE_DIR . '/admin/modules/earchive/class.earchive.php';
                $earchiver =& new earchive();
                include_once SF_BASE_DIR . '/admin/modules/common/class.sfWordIndexer.php';
                $word_indexer =& new word_indexer();
                $fields = array('mid', 'lid', 'subject', 'body', 'sender');
                $result = $earchiver->get_all_messages($fields);
                if (is_object($result)) {
                    while ($row =& $result->FetchRow(DB_FETCHMODE_ASSOC)) {
                        $content = '';
                        $content .= commonUtil::stripslashes($row['sender']);
                        $content .= commonUtil::stripslashes($row['subject']);
                        $content .= commonUtil::stripslashes($row['body']);
                        $word_indexer->indexing_words($content, 'earchive_words_crc32', array('mid' => $row['mid'], 'lid' => $row['lid']), TRUE);
                    }
                }
            }
            // set user options
            // this event comes from the option module (module_loader.php)
            if (isset($_POST['update_earchive_options_fetchemails']) && !empty($_POST['earchive_fetch_emails'])) {
                // the earchive class
                include_once SF_BASE_DIR . '/admin/modules/earchive/fetch_emails.php';
            }
            break;
        case EVT_GET_OPTIONS:
            // get earchive options template
            // to include in the option module
            $B->mod_option[] = SF_BASE_DIR . '/admin/modules/earchive/templates/option.tpl.php';
            break;
        case EVT_SETUP:
            $success = TRUE;
            include SF_BASE_DIR . '/admin/modules/earchive/_setup.php';
            return $success;
            break;
    }
}
Example #2
0
if (!defined('SF_SECURE_INCLUDE')) {
    die('No Permission on ' . __FILE__);
}
// check user rights to access the list
if (FALSE == earchive_rights::ask_access_to_list()) {
    @header('Location: ' . SF_BASE_LOCATION . '/admin/index.php');
    exit;
}
// init
$B->form_error = FALSE;
// delete list
if ($_POST['dellist'] == 1) {
    // check if the user of this request try to delete a list
    // with rights other than administrator 5.
    //
    if (TRUE == earchive_rights::ask_access_to_delete_list()) {
        $B->earchive->delete_list((int) $_REQUEST['lid']);
        // delete word index of this list
        include_once SF_BASE_DIR . '/admin/include/class.sfWordIndexer.php';
        word_indexer::delete_words('earchive_words_crc32', 'lid', (int) $_REQUEST['lid']);
        @header('Location: index.php?m=EARCHIVE');
        exit;
    } else {
        $B->form_error = 'You cant remove this list';
    }
}
// Modify list data
if (isset($_POST['editlist'])) {
    // check if some fields are empty
    if (empty($_POST['name']) || empty($_POST['emailserver']) || empty($_POST['email'])) {
        $B->form_error = 'You have fill out all fields!';
Example #3
0
// http://smart.open-publisher.net/
// ----------------------------------------------------------------------
// LICENSE GPL
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
/**
 * add user script
 *
 */
// Check if this file is included in the Smart environement
//
if (!defined('SF_SECURE_INCLUDE')) {
    die('No Permission on ' . __FILE__);
}
// check if the user of this request have rights
if (FALSE == earchive_rights::ask_access_to_list()) {
    @header('Location: ' . SF_BASE_LOCATION . '/admin/index.php');
    exit;
}
// Init form field values
$B->form_error = FALSE;
$B->form_name = '';
$B->form_emailserver = '';
$B->form_email = '';
$B->form_description = '';
$B->form_status = '';
// Check if some form fields are empty
if (empty($_POST['name']) || empty($_POST['emailserver']) || empty($_POST['email'])) {
    // if empty assign form field with old values
    $B->form_name = htmlspecialchars($B->util->stripSlashes($_POST['name']));
    $B->form_emailserver = htmlspecialchars($B->util->stripSlashes($_POST['emailserver']));
function earchive_event_handler($evt)
{
    global $B;
    switch ($evt["code"]) {
        case EVT_LOAD_MODULE:
            // earchive rights class
            include SF_BASE_DIR . '/admin/modules/earchive/class.rights.php';
            // check if the login user have rights to access this module
            // 4 or 5 required (editor or administrator)
            if (FALSE == earchive_rights::ask_access_to_list()) {
                @header('Location: ' . SF_BASE_LOCATION . '/admin/index.php');
                exit;
            }
            // load this module
            include SF_BASE_DIR . '/admin/modules/earchive/module_loader.php';
            break;
        case EVT_INIT:
            // check for install or upgrade
            if (MOD_EARCHIVE_VERSION != (string) $B->sys['module']['earchive']['version']) {
                $B->setup_error = array();
                $B->conf_val =& $B->sys;
                include SF_BASE_DIR . '/admin/modules/earchive/_setup.php';
                $B->conf->setConfigValues($B->conf_val);
                $B->conf->writeConfigFile("config_system.xml.php", array('filetype' => 'xml', 'mode' => 'pretty'));
                if (count($B->setup_error) > 0) {
                    trigger_error("Setup/upgrade error: " . var_export($B->setup_error, TRUE) . "\n" . __FILE__ . "\n" . __LINE__, E_USER_ERROR);
                }
            }
            break;
        case EVT_LOGOUT:
            break;
        case EVT_SET_OPTIONS:
            // set user options
            // this event comes from the option module (module_loader.php)
            if (!empty($_POST['earchive_rebuild_index'])) {
                // the earchive class
                include_once SF_BASE_DIR . '/admin/modules/earchive/class.earchive.php';
                $earchiver =& new earchive();
                include_once SF_BASE_DIR . '/admin/include/class.sfWordIndexer.php';
                $word_indexer =& new word_indexer();
                $fields = array('mid', 'lid', 'subject', 'body', 'sender');
                $result = $earchiver->get_all_messages($fields);
                if (is_object($result)) {
                    while ($row =& $result->FetchRow(DB_FETCHMODE_ASSOC)) {
                        $content = '';
                        $content .= stripslashes($row['sender']);
                        $content .= stripslashes($row['subject']);
                        $content .= stripslashes($row['body']);
                        $word_indexer->indexing_words($content, 'earchive_words_crc32', array('mid' => $row['mid'], 'lid' => $row['lid']), TRUE);
                    }
                }
            }
            // set user options
            // this event comes from the option module (module_loader.php)
            if (!empty($_POST['earchive_fetch_emails'])) {
                // the earchive class
                include_once SF_BASE_DIR . '/admin/modules/earchive/fetch_emails.php';
            }
            break;
        case EVT_GET_OPTIONS:
            // get earchive options template
            // to include in the option module
            $B->mod_option[] = SF_BASE_DIR . '/admin/modules/earchive/templates/option.tpl.php';
            break;
        case EVT_SETUP:
            $success = TRUE;
            include SF_BASE_DIR . '/admin/modules/earchive/_setup.php';
            return $success;
            break;
    }
}