Exemplo n.º 1
0
/**
 * Get a new file to write an attachment to.
 * This function makes sure it doesn't overwrite other attachments,
 * preventing collisions and race conditions.
 *
 * @return filename of the tempfile only (not full path)
 * @since 1.5.2
 */
function sq_get_attach_tempfile()
{
    global $username, $attachment_dir;
    $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
    // using PHP >= 4.3.2 we can be truly atomic here
    $filemods = check_php_version(4, 3, 2) ? 'x' : 'w';
    // give up after 1000 tries
    $TMP_MAX = 1000;
    for ($try = 0; $try < $TMP_MAX; ++$try) {
        $localfilename = GenerateRandomString(32, '', 7);
        $full_localfilename = "{$hashed_attachment_dir}/{$localfilename}";
        // filename collision. try again
        if (file_exists($full_localfilename)) {
            continue;
        }
        // try to open for (binary) writing
        $fp = @fopen($full_localfilename, $filemods);
        if ($fp !== FALSE) {
            // success! make sure it's not readable, close and return filename
            chmod($full_localfilename, 0600);
            fclose($fp);
            return $localfilename;
        }
    }
    // we tried 1000 times but didn't succeed.
    error_box(_("Could not open temporary file to store attachment. Contact your system administrator to resolve this issue."));
    return FALSE;
}
Exemplo n.º 2
0
/**
 * Use this function to do any backend-specific initialization,
 * e.g. checking requirements, before the password change form
 * is displayed to the user.
 */
function cpw_template_init()
{
    global $oTemplate;
    // plugin is not configured. Handle error gracefully.
    error_box(_("No valid backend defined."));
    // close html and stop script execution
    $oTemplate->display('footer.tpl');
    exit;
}
Exemplo n.º 3
0
/**
 * Helper function for the functions below; checks if the user entered
 * folder name is valid according to the IMAP standard. If not, it
 * bails out with an error and cleanly terminates the IMAP connection.
 */
function folders_checkname($imapConnection, $folder_name, $delimiter)
{
    if (substr_count($folder_name, '"') || substr_count($folder_name, "\\") || substr_count($folder_name, $delimiter) || $folder_name == '') {
        global $color, $oTemplate;
        error_box(_("Illegal folder name.") . "<br />\n" . sprintf(_("The name may not contain any of the following: %s"), '<tt>" \\ ' . $delimiter . '</tt>') . "<br />\n" . _("Please select a different name.") . '<br /><a href="folders.php">' . _("Click here to go back") . '</a>.');
        sqimap_logout($imapConnection);
        $oTemplate->display('footer.tpl');
        exit;
    }
}
Exemplo n.º 4
0
/**
 * Check if php install has all required extensions.
 */
function cpw_merak_init()
{
    global $oTemplate;
    if (!function_exists('curl_init')) {
        // user_error('Curl module NOT available!', E_USER_ERROR);
        error_box(_("PHP Curl extension is NOT available! Unable to change password!"));
        // close html and stop script execution
        $oTemplate->display('footer.tpl');
        exit;
    }
}
Exemplo n.º 5
0
/**
 * Shows translation box in message display window
 * @access private
 */
function translate_read_form_function()
{
    global $color, $translate_server;
    global $message, $translate_dir;
    global $translate_show_read;
    global $imapConnection, $wrap_at, $passed_id, $mailbox;
    global $translate_gpltrans_url;
    global $translate_babelfish_enabled, $translate_go_enabled, $translate_dictionary_enabled, $translate_google_enabled, $translate_gpltrans_enabled, $translate_intertran_enabled, $translate_promt_enabled, $translate_otenet_enabled;
    global $translate_custom_enabled;
    if (!$translate_show_read) {
        return;
    }
    $translate_server_option = 'translate_' . $translate_server . '_enabled';
    if ($translate_server == 'gpltrans' && $translate_gpltrans_url == '' || !${$translate_server_option} || !function_exists('translate_form_' . $translate_server)) {
        error_box(_("Selected translation engine is disabled. Please update your translation preferences."));
        return;
    }
    $translate_dir = 'to';
    $trans_ar = $message->findDisplayEntity(array(), array('text/plain'));
    $body = '';
    $final_body = '';
    if (!empty($trans_ar[0])) {
        for ($i = 0; $i < count($trans_ar); $i++) {
            /* reduced version of formatBody and translateText functions */
            // get message entity information
            $body_message = getEntity($message, $trans_ar[$i]);
            // get message body
            $body = mime_fetch_body($imapConnection, $passed_id, $trans_ar[$i]);
            // convert encoded messages
            $body = decodeBody($body, $body_message->header->encoding);
            /*
             * if message part is html formated - convert spaces, html line feeds,
             * less than and greater than html entities and remove tags
             */
            if ($body_message->header->type1 == 'html') {
                $entity_conv = array('&nbsp;' => ' ', '<p>' => "\n", '<P>' => "\n", '<br>' => "\n", '<BR>' => "\n", '<br />' => "\n", '<BR />' => "\n", '&gt;' => '>', '&lt;' => '<');
                $body = strtr($body, $entity_conv);
                $body = strip_tags($body);
            }
            // remove whitespace
            $body = trim($body);
            // save processed text and parse other entity
            $final_body .= charset_decode($body_message->header->getParameter('charset'), $body);
        }
        // add form if message is not empty
        if (!empty($final_body)) {
            $function = 'translate_form_' . $translate_server;
            $function($final_body);
        }
    }
}
Exemplo n.º 6
0
function sqimap_asearch_error_box($response, $query, $message, $link = '')
{
    global $color;
    // Error message titles according to imap server returned code
    $imap_error_titles = array('OK' => '', 'NO' => _("ERROR : Could not complete request."), 'BAD' => _("ERROR : Bad or malformed request."), 'BYE' => _("ERROR : Imap server closed the connection."), '' => _("ERROR : Connection dropped by imap-server."));
    if (!array_key_exists($response, $imap_error_titles)) {
        $title = _("ERROR : Unknown imap response.");
    } else {
        $title = $imap_error_titles[$response];
    }
    if ($link == '') {
        $message_title = _("Reason Given: ");
    } else {
        $message_title = _("Possible reason : ");
    }
    if (function_exists('sqimap_error_box')) {
        sqimap_error_box($title, $query, $message_title, $message, $link);
    } else {
        //Straight copy of 1.5 imap_general.php:sqimap_error_box(). Can be removed at a later time
        global $color;
        require_once SM_PATH . 'functions/display_messages.php';
        $string = "<font color=\"{$color['2']}\"><b>\n" . $title . "</b><br />\n";
        if ($query != '') {
            $string .= _("Query:") . ' ' . htmlspecialchars($query) . '<br />';
        }
        if ($message_title != '') {
            $string .= $message_title;
        }
        if ($message != '') {
            $string .= htmlspecialchars($message);
        }
        if ($link != '') {
            $string .= $link;
        }
        $string .= "</font><br />\n";
        error_box($string, $color);
    }
}
 * @copyright (c) 1999-2004 The SquirrelMail Project Team
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 * @version $Id: printer_friendly_main.php,v 1.20 2004/10/02 17:21:32 jervfors Exp $
 * @package squirrelmail
 */
/**
 * Path for SquirrelMail required files.
 * @ignore
 */
define('SM_PATH', '../');
/* SquirrelMail required files. */
require_once SM_PATH . 'include/validate.php';
/* get those globals into gear */
global $color;
if (!sqgetGlobalVar('passed_ent_id', $passed_ent_id, SQ_GET)) {
    $passed_ent_id = 0;
}
if (!sqgetGlobalVar('mailbox', $mailbox, SQ_GET) || !sqgetGlobalVar('passed_id', $passed_id, SQ_GET)) {
    error_box(_("Invalid URL"), $color);
} else {
    $passed_id = (int) $passed_id;
    /* end globals */
    displayHtmlHeader(_("Printer Friendly"), '', false, true);
    echo '<frameset rows="60, *">' . "\n";
    echo '<frame src="printer_friendly_top.php" name="top_frame" ' . 'scrolling="no" noresize="noresize" frameborder="0" />' . "\n";
    echo '<frame src="printer_friendly_bottom.php?passed_ent_id=' . urlencode($passed_ent_id) . '&amp;mailbox=' . urlencode($mailbox) . '&amp;passed_id=' . $passed_id . '" name="bottom_frame" frameborder="0" />' . "\n";
    echo "</frameset>\n";
}
?>
</html>
function plain_error_message($message, $color)
{
    error_box($message, $color);
}
Exemplo n.º 9
0
/**
 * Helper function for getHashedFile, given a username returns the hashed
 * dir for that username.
 *
 * @param string username the username of the current user
 * @param string dir the SquirrelMail datadir
 * @param string hash_dirs default ''
 * @return the path to the hash dir for username
 * @since 1.2.0
 */
function getHashedDir($username, $dir, $hash_dirs = '')
{
    global $dir_hash_level;
    /* Remove trailing slash from $dir if found */
    if (substr($dir, -1) == '/') {
        $dir = substr($dir, 0, strlen($dir) - 1);
    }
    /* If necessary, populate the hash dir variable. */
    if ($hash_dirs == '') {
        $hash_dirs = computeHashDirs($username);
    }
    /* Make sure the full hash directory exists. */
    $real_hash_dir = $dir;
    for ($h = 0; $h < $dir_hash_level; ++$h) {
        $real_hash_dir .= '/' . $hash_dirs[$h];
        if (!@is_dir($real_hash_dir)) {
            //FIXME: When safe_mode is turned on, the error suppression below makes debugging safe_mode UID/GID restrictions tricky... for now, I will add a check in configtest
            if (!@mkdir($real_hash_dir, 0770)) {
                error_box(sprintf(_("Error creating directory %s."), $real_hash_dir) . "\n" . _("Could not create hashed directory structure!") . "\n" . _("Please contact your system administrator and report this error."));
                exit;
            }
        }
    }
    /* And return that directory. */
    return $real_hash_dir;
}
Exemplo n.º 10
0
/**
   Create and initialize an addressbook object.
   Returns the created object
*/
function addressbook_init($showerr = true, $onlylocal = false)
{
    global $data_dir, $username, $color, $ldap_server, $address_book_global_filename;
    global $addrbook_dsn, $addrbook_table;
    // Shared file based address book globals
    global $abook_global_file, $abook_global_file_writeable, $abook_global_file_listing;
    // Shared DB based address book globals
    global $addrbook_global_dsn, $addrbook_global_table, $addrbook_global_writeable, $addrbook_global_listing;
    // Record size restriction in file based address books
    global $abook_file_line_length;
    /* Create a new addressbook object */
    $abook = new AddressBook();
    /* Create empty error message */
    $abook_init_error = '';
    /*
        Always add a local backend. We use *either* file-based *or* a
        database addressbook. If $addrbook_dsn is set, the database
        backend is used. If not, addressbooks are stores in files.
    */
    if (isset($addrbook_dsn) && !empty($addrbook_dsn)) {
        /* Database */
        if (!isset($addrbook_table) || empty($addrbook_table)) {
            $addrbook_table = 'address';
        }
        $r = $abook->add_backend('database', array('dsn' => $addrbook_dsn, 'owner' => $username, 'table' => $addrbook_table));
        if (!$r && $showerr) {
            $abook_init_error .= _("Error initializing address book database.") . ' ' . $abook->error;
        }
    } else {
        /* File */
        $filename = getHashedFile($username, $data_dir, "{$username}.abook");
        $r = $abook->add_backend('local_file', array('filename' => $filename, 'line_length' => $abook_file_line_length, 'create' => true));
        if (!$r && $showerr) {
            $abook_init_error .= sprintf(_("Error opening file %s"), $filename);
        }
    }
    /* This would be for the global addressbook */
    if (isset($abook_global_file) && isset($abook_global_file_writeable) && trim($abook_global_file) != '') {
        // Detect place of address book
        if (!preg_match("/[\\/\\\\]/", $abook_global_file)) {
            /* no path chars, address book stored in data directory
             * make sure that there is a slash between data directory
             * and address book file name
             */
            $abook_global_filename = $data_dir . (substr($data_dir, -1) != '/' ? '/' : '') . $abook_global_file;
        } elseif (preg_match("/^\\/|\\w:/", $abook_global_file)) {
            // full path is set in options (starts with slash or x:)
            $abook_global_filename = $abook_global_file;
        } else {
            $abook_global_filename = SM_PATH . $abook_global_file;
        }
        $r = $abook->add_backend('local_file', array('filename' => $abook_global_filename, 'name' => _("Global address book"), 'detect_writeable' => false, 'line_length' => $abook_file_line_length, 'writeable' => $abook_global_file_writeable, 'listing' => $abook_global_file_listing));
        if (!$r && $showerr) {
            if ($abook_init_error != '') {
                $abook_init_error .= "\n";
            }
            $abook_init_error .= _("Error initializing global address book.") . "\n" . $abook->error;
        }
    }
    /* Load global addressbook from SQL if configured */
    if (isset($addrbook_global_dsn) && !empty($addrbook_global_dsn)) {
        /* Database configured */
        if (!isset($addrbook_global_table) || empty($addrbook_global_table)) {
            $addrbook_global_table = 'global_abook';
        }
        $r = $abook->add_backend('database', array('dsn' => $addrbook_global_dsn, 'owner' => 'global', 'name' => _("Global address book"), 'writeable' => $addrbook_global_writeable, 'listing' => $addrbook_global_listing, 'table' => $addrbook_global_table));
        if (!$r && $showerr) {
            if ($abook_init_error != '') {
                $abook_init_error .= "\n";
            }
            $abook_init_error .= _("Error initializing global address book.") . "\n" . $abook->error;
        }
    }
    /*
     * hook allows to include different address book backends.
     * plugins should extract $abook and $r from arguments
     * and use same add_backend commands as above functions.
     * @since 1.5.1 and 1.4.5
     */
    $hookReturn = do_hook('abook_init', $abook, $r);
    $abook = $hookReturn[1];
    $r = $hookReturn[2];
    if (!$onlylocal) {
        /* Load configured LDAP servers (if PHP has LDAP support) */
        if (isset($ldap_server) && is_array($ldap_server) && function_exists('ldap_connect')) {
            reset($ldap_server);
            while (list($undef, $param) = each($ldap_server)) {
                if (is_array($param)) {
                    $r = $abook->add_backend('ldap_server', $param);
                    if (!$r && $showerr) {
                        if ($abook_init_error != '') {
                            $abook_init_error .= "\n";
                        }
                        $abook_init_error .= sprintf(_("Error initializing LDAP server %s:") . "\n", $param['host']);
                        $abook_init_error .= $abook->error;
                    }
                }
            }
        }
    }
    // end of remote abook backends init
    /**
     * display address book init errors.
     */
    if ($abook_init_error != '' && $showerr) {
        $abook_init_error = htmlspecialchars($abook_init_error);
        error_box($abook_init_error, $color);
    }
    /* Return the initialized object */
    return $abook;
}
Exemplo n.º 11
0
sqgetGlobalVar('send_to', $send_to, SQ_GET);
sqgetGlobalVar('subject', $subject, SQ_GET);
sqgetGlobalVar('body', $body, SQ_GET);
sqgetGlobalVar('action', $action, SQ_GET);
switch ($action) {
    case 'help':
        $out_string = _("This will send a message to %s requesting help for this list. You will receive an emailed response at the address below.");
        break;
    case 'subscribe':
        $out_string = _("This will send a message to %s requesting that you will be subscribed to this list. You will be subscribed with the address below.");
        break;
    case 'unsubscribe':
        $out_string = _("This will send a message to %s requesting that you will be unsubscribed from this list. It will try to unsubscribe the adress below.");
        break;
    default:
        error_box(sprintf(_("Unknown action: %s"), htmlspecialchars($action)), $color);
        exit;
}
echo html_tag('p', '', 'left') . html_tag('table', '', 'center', $color[0], 'border="0" width="75%"') . "\n" . html_tag('tr', html_tag('th', _("Mailinglist") . ' ' . _($action), '', $color[9])) . html_tag('tr') . html_tag('td', '', 'left');
printf($out_string, htmlspecialchars($send_to));
echo '<form method="post" action="../../src/compose.php">';
$idents = get_identities();
echo html_tag('p', '', 'center') . _("From:") . ' ';
if (count($idents) > 1) {
    echo '<select name="identity">';
    foreach ($idents as $nr => $data) {
        echo '<option value="' . $nr . '">' . htmlspecialchars($data['full_name'] . ' <' . $data['email_address'] . ">\n");
    }
    echo '</select>' . "\n";
} else {
    echo htmlspecialchars('"' . $idents[0]['full_name'] . '" <' . $idents[0]['email_address'] . '>');
Exemplo n.º 12
0
  * Update/modify address                       *
  ***********************************************/
 if (!empty($editaddr)) {
     /* Stage one: Copy data into form */
     if (isset($sel) && sizeof($sel) > 0) {
         if (sizeof($sel) > 1) {
             $formerror = _("You can only edit one address at the time");
             $showaddrlist = true;
             $defselected = $sel;
         } else {
             $abortform = true;
             list($ebackend, $enick) = explode('_', current($sel), 2);
             $olddata = $abook->lookup($enick, $ebackend);
             // Test if $olddata really contains anything and return an error message if it doesn't
             if (!$olddata) {
                 error_box(nl2br(sm_encode_html_special_chars($abook->error)));
             } else {
                 /* Display the "new address" form */
                 echo abook_create_form($form_url, 'editaddr', _("Update address"), _("Update address"), $current_backend, $olddata);
                 echo addHidden('oldnick', $olddata['nickname']) . addHidden('backend', $olddata['backend']) . addHidden('doedit', '1') . '</form>';
             }
         }
     } elseif ($doedit == 1) {
         /* Stage two: Write new data */
         $newdata = $editaddr;
         $r = $abook->modify($oldnick, $newdata, $backend);
         /* Handle error messages */
         if (!$r) {
             /* Display error */
             plain_error_message(nl2br(sm_encode_html_special_chars($abook->error)));
             /* Display the "new address" form again */
Exemplo n.º 13
0
$nbsp = $oTemplate->fetch('non_breaking_space.tpl');
$br = $oTemplate->fetch('line_break.tpl');
/**
 * Set up the language.
 *
 * This code block corresponds to the *default* block of the switch
 * statement above, but the language cannot be set up until after the
 * template is instantiated, so we set $set_up_langage_after_template_setup
 * above and do the linguistic stuff now.
 */
if ($set_up_langage_after_template_setup) {
    $err = set_up_language(getPref($data_dir, $username, 'language'));
    // Japanese translation used without mbstring support
    if ($err == 2) {
        $sError = "<p>Your administrator needs to have PHP installed with the multibyte string extension enabled (using configure option --enable-mbstring).</p>\n" . "<p>This system has assumed that you accidently switched to Japanese and has reverted your language preference to English.</p>\n" . "<p>Please refresh this page in order to continue using your webmail.</p>\n";
        error_box($sError);
    }
}
/**
 * Initialize our custom error handler object
 */
$oErrorHandler = new ErrorHandler($oTemplate, 'error_message.tpl');
/**
 * Activate custom error handling
 */
if (version_compare(PHP_VERSION, "4.3.0", ">=")) {
    $oldErrorHandler = set_error_handler(array($oErrorHandler, 'SquirrelMailErrorhandler'));
} else {
    $oldErrorHandler = set_error_handler('SquirrelMailErrorhandler');
}
// ============================================================================
Exemplo n.º 14
0
/**
 * Selects a mailbox
 */
function sqimap_mailbox_select($imap_stream, $mailbox)
{
    global $auto_expunge;
    if (empty($mailbox)) {
        return;
    }
    /**
     * Default UW IMAP server configuration allows to access other files
     * on server. $imap_server_type is not checked because interface can
     * be used with 'other' or any other server type setting. $mailbox
     * variable can be modified in any script that uses variable from GET 
     * or POST. This code blocks all standard SquirrelMail IMAP API requests 
     * that use mailbox with full path (/etc/passwd) or with ../ characters 
     * in path (../../etc/passwd)
     */
    if (strstr($mailbox, '../') || substr($mailbox, 0, 1) == '/') {
        global $color;
        include_once SM_PATH . 'functions/display_messages.php';
        error_box(sprintf(_("Invalid mailbox name: %s"), htmlspecialchars($mailbox)), $color);
        sqimap_logout($imap_stream);
        die('</body></html>');
    }
    // cleanup $mailbox in order to prevent IMAP injection attacks
    $mailbox = str_replace(array("\r", "\n"), array("", ""), $mailbox);
    $read = sqimap_run_command($imap_stream, "SELECT \"{$mailbox}\"", true, $response, $message);
    $result = array();
    for ($i = 0, $cnt = count($read); $i < $cnt; $i++) {
        if (preg_match('/^\\*\\s+OK\\s\\[(\\w+)\\s(\\w+)\\]/', $read[$i], $regs)) {
            $result[strtoupper($regs[1])] = $regs[2];
        } else {
            if (preg_match('/^\\*\\s([0-9]+)\\s(\\w+)/', $read[$i], $regs)) {
                $result[strtoupper($regs[2])] = $regs[1];
            } else {
                if (preg_match("/PERMANENTFLAGS(.*)/i", $read[$i], $regs)) {
                    $regs[1] = trim(preg_replace(array("/\\(/", "/\\)/", "/\\]/"), '', $regs[1]));
                    $result['PERMANENTFLAGS'] = $regs[1];
                } else {
                    if (preg_match("/FLAGS(.*)/i", $read[$i], $regs)) {
                        $regs[1] = trim(preg_replace(array("/\\(/", "/\\)/"), '', $regs[1]));
                        $result['FLAGS'] = $regs[1];
                    }
                }
            }
        }
    }
    if (preg_match('/^\\[(.+)\\]/', $message, $regs)) {
        $result['RIGHTS'] = $regs[1];
    }
    if ($auto_expunge) {
        $tmp = sqimap_run_command($imap_stream, 'EXPUNGE', false, $a, $b);
    }
    return $result;
}
Exemplo n.º 15
0
 * @subpackage squirrelspell
 */
/**
 * Include the SquirrelMail initialization file.
 */
require '../../include/init.php';
/**
 * Set a couple of constants and defaults. Don't change these,
 * the configurable stuff is in sqspell_config.php
 * @todo do we really need $SQSPELL_DIR var?
 */
$SQSPELL_DIR = 'plugins/squirrelspell/';
$SQSPELL_CRYPTO = FALSE;
include_once SM_PATH . $SQSPELL_DIR . 'sqspell_functions.php';
/**
 * $MOD is the name of the module to invoke.
 * If $MOD is unspecified, assign "options_main" to it. Else check for
 * security breach attempts.
 */
if (!sqgetGlobalVar('MOD', $MOD, SQ_FORM)) {
    $MOD = 'options_main';
}
sqspell_ckMOD($MOD);
/* Load the stuff already. */
if (file_exists(SM_PATH . $SQSPELL_DIR . "modules/{$MOD}.mod")) {
    require_once SM_PATH . $SQSPELL_DIR . "modules/{$MOD}.mod";
} else {
    error_box(_("Invalid SquirrelSpell module."));
    // display footer (closes html tags)
    $oTemplate->display('footer.tpl');
}
Exemplo n.º 16
0
 /**
  * List all addresses
  * @return array list of all addresses
  */
 function list_addr()
 {
     // check if listing is not disabled
     if (isset($this->listing) && !$this->listing) {
         return array();
     }
     $res = array();
     $this->open();
     @rewind($this->filehandle);
     while ($row = @fgetcsv($this->filehandle, $this->line_length, '|')) {
         if (count($row) < 5) {
             /** address book is corrupted. */
             global $color;
             error_box(_("Address book is corrupted. Required fields are missing."), $color);
             die('</body></html>');
         } else {
             array_push($res, array('nickname' => $row[0], 'name' => $row[1] . ' ' . $row[2], 'firstname' => $row[1], 'lastname' => $row[2], 'email' => $row[3], 'label' => $row[4], 'backend' => $this->bnum, 'source' => &$this->sname));
         }
     }
     return $res;
 }
Exemplo n.º 17
0
 * @package squirrelmail
 * @subpackage prefs
 * @since 1.1.3
 */
/** This is the options_identities page */
define('PAGE_NAME', 'options_identities');
/**
 * Include the SquirrelMail initialization file.
 */
require '../include/init.php';
/* SquirrelMail required files. */
require_once SM_PATH . 'functions/identity.php';
require_once SM_PATH . 'functions/forms.php';
/* make sure that page is not available when $edit_identity is false */
if (!$edit_identity) {
    error_box(_("Editing identities is disabled."));
    $oTemplate->display('footer.tpl');
    die;
}
if (!sqgetGlobalVar('identities', $identities, SQ_SESSION)) {
    $identities = get_identities();
}
sqgetGlobalVar('newidentities', $newidentities, SQ_POST);
sqgetGlobalVar('smaction', $smaction, SQ_POST);
sqgetGlobalVar('return', $return, SQ_POST);
sqgetGlobalVar('smtoken', $submitted_token, SQ_POST, '');
// First lets see if there are any actions to perform //
if (!empty($smaction) && is_array($smaction)) {
    // first do a security check
    sm_validate_security_token($submitted_token, -1, TRUE);
    $doaction = '';
Exemplo n.º 18
0
/**
 * Checks if configuration is correct
 */
function cpw_peardb_init()
{
    global $oTemplate, $cpw_peardb_detect, $cpw_peardb_dsn, $cpw_peardb_table;
    if (!$cpw_peardb_detect) {
        error_box(_("Plugin is unable to use PHP Pear DB libraries. PHP Pear includes must be available in your PHP include_path setting."));
        $oTemplate->display('footer.tpl');
        exit;
    }
    // Test required settings
    if (is_string($cpw_peardb_dsn) && trim($cpw_peardb_dsn) == '' || trim($cpw_peardb_table) == '') {
        error_box(_("Required change password backend configuration options are missing."));
        $oTemplate->display('footer.tpl');
        exit;
    }
}
Exemplo n.º 19
0
 * @since 1.1.3
 */
/** Unknown database */
define('SMDB_UNKNOWN', 0);
/** MySQL */
define('SMDB_MYSQL', 1);
/** PostgreSQL */
define('SMDB_PGSQL', 2);
require_once SM_PATH . 'config/config.php';
if (!(include_once 'DB.php')) {
    // same error also in abook_database.php
    require_once SM_PATH . 'functions/display_messages.php';
    $error = _("Could not include PEAR database functions required for the database backend.") . "<br />\n";
    $error .= sprintf(_("Is PEAR installed, and is the include path set correctly to find %s?"), '<tt>DB.php</tt>') . "<br />\n";
    $error .= _("Please contact your system administrator and report this error.");
    error_box($error, $color);
    exit;
}
global $prefs_are_cached, $prefs_cache;
/**
 * @ignore
 */
function cachePrefValues($username)
{
    global $prefs_are_cached, $prefs_cache;
    sqgetGlobalVar('prefs_are_cached', $prefs_are_cached, SQ_SESSION);
    if ($prefs_are_cached) {
        sqgetGlobalVar('prefs_cache', $prefs_cache, SQ_SESSION);
        return;
    }
    sqsession_unregister('prefs_cache');
Exemplo n.º 20
0
function sqimap_append_checkresponse($response, $folder)
{
    if (preg_match("/(.*)(BAD|NO)(.*)\$/", $response, $regs)) {
        global $squirrelmail_language, $color;
        set_up_language($squirrelmail_language);
        require_once SM_PATH . 'functions/display_messages.php';
        $reason = $regs[3];
        if ($regs[2] == 'NO') {
            $string = "<b><font color=\"{$color['2']}\">\n" . _("ERROR: Could not append message to") . " {$folder}." . "</b><br />\n" . _("Server responded:") . ' ' . $reason . "<br />\n";
            if (preg_match("/(.*)(quota)(.*)\$/i", $reason, $regs)) {
                $string .= _("Solution:") . ' ' . _("Remove unneccessary messages from your folders. Start with your Trash folder.") . "<br />\n";
            }
            $string .= "</font>\n";
            error_box($string, $color);
        } else {
            $string = "<b><font color=\"{$color['2']}\">\n" . _("ERROR: Bad or malformed request.") . "</b><br />\n" . _("Server responded:") . ' ' . $reason . "</font><br />\n";
            error_box($string, $color);
            exit;
        }
    }
}
Exemplo n.º 21
0
/**
 * Create and initialize an addressbook object.
 * @param boolean $showerr display any address book init errors. html page header
 * must be created before calling addressbook_init() with $showerr enabled.
 * @param boolean $onlylocal enable only local address book backends. Should 
 *  be used when code does not need access to remote backends. Backends
 *  that provide read only address books with limited listing options can be
 *  tagged as remote.
 * @return object address book object.
 */
function addressbook_init($showerr = true, $onlylocal = false)
{
    global $data_dir, $username, $ldap_server, $address_book_global_filename;
    global $addrbook_dsn, $addrbook_table;
    global $abook_global_file, $abook_global_file_writeable, $abook_global_file_listing;
    global $addrbook_global_dsn, $addrbook_global_table, $addrbook_global_writeable, $addrbook_global_listing;
    global $abook_file_line_length;
    /* Create a new addressbook object */
    $abook = new AddressBook();
    /* Create empty error message */
    $abook_init_error = '';
    /*
        Always add a local backend. We use *either* file-based *or* a
        database addressbook. If $addrbook_dsn is set, the database
        backend is used. If not, addressbooks are stores in files.
    */
    if (isset($addrbook_dsn) && !empty($addrbook_dsn)) {
        /* Database */
        if (!isset($addrbook_table) || empty($addrbook_table)) {
            $addrbook_table = 'address';
        }
        $r = $abook->add_backend('database', array('dsn' => $addrbook_dsn, 'owner' => $username, 'table' => $addrbook_table));
        if (!$r && $showerr) {
            $abook_init_error .= _("Error initializing address book database.") . "\n" . $abook->error;
        }
    } else {
        /* File */
        $filename = getHashedFile($username, $data_dir, "{$username}.abook");
        $r = $abook->add_backend('local_file', array('filename' => $filename, 'umask' => 077, 'line_length' => $abook_file_line_length, 'create' => true));
        if (!$r && $showerr) {
            // no need to use $abook->error, because message explains error.
            $abook_init_error .= sprintf(_("Error opening file %s"), $filename);
        }
    }
    /* Global file based addressbook */
    if (isset($abook_global_file) && isset($abook_global_file_writeable) && isset($abook_global_file_listing) && trim($abook_global_file) != '') {
        // Detect place of address book
        if (!preg_match("/[\\/\\\\]/", $abook_global_file)) {
            /* no path chars, address book stored in data directory
             * make sure that there is a slash between data directory
             * and address book file name
             */
            $abook_global_filename = $data_dir . (substr($data_dir, -1) != '/' ? '/' : '') . $abook_global_file;
        } elseif (preg_match("/^\\/|\\w:/", $abook_global_file)) {
            // full path is set in options (starts with slash or x:)
            $abook_global_filename = $abook_global_file;
        } else {
            $abook_global_filename = SM_PATH . $abook_global_file;
        }
        $r = $abook->add_backend('local_file', array('filename' => $abook_global_filename, 'name' => _("Global Address Book"), 'detect_writeable' => false, 'line_length' => $abook_file_line_length, 'writeable' => $abook_global_file_writeable, 'listing' => $abook_global_file_listing));
        /* global abook init error is not fatal. add error message and continue */
        if (!$r && $showerr) {
            if ($abook_init_error != '') {
                $abook_init_error .= "\n";
            }
            $abook_init_error .= _("Error initializing global address book.") . "\n" . $abook->error;
        }
    }
    /* Load global addressbook from SQL if configured */
    if (isset($addrbook_global_dsn) && !empty($addrbook_global_dsn)) {
        /* Database configured */
        if (!isset($addrbook_global_table) || empty($addrbook_global_table)) {
            $addrbook_global_table = 'global_abook';
        }
        $r = $abook->add_backend('database', array('dsn' => $addrbook_global_dsn, 'owner' => 'global', 'name' => _("Global Address Book"), 'writeable' => $addrbook_global_writeable, 'listing' => $addrbook_global_listing, 'table' => $addrbook_global_table));
        /* global abook init error is not fatal. add error message and continue */
        if (!$r && $showerr) {
            if ($abook_init_error != '') {
                $abook_init_error .= "\n";
            }
            $abook_init_error .= _("Error initializing global address book.") . "\n" . $abook->error;
        }
    }
    /*
     * hook allows to include different address book backends.
     * plugins should extract $abook and $r from arguments
     * and use same add_backend commands as above functions.
     * Since 1.5.2 hook sends third ($onlylocal) argument to address book
     * plugins in order to allow detection of local address book init.
     * @since 1.5.1 and 1.4.5
     * Since 1.5.2, the plugin arguments are passed inside an array
     * and by reference, so plugins hooking in here need to accept arguments
     * in an array and change those values as needed instead of returning
     * the changed values.
     */
    $temp = array(&$abook, &$r, &$onlylocal);
    do_hook('abook_init', $temp);
    if (!$r && $showerr) {
        if ($abook_init_error != '') {
            $abook_init_error .= "\n";
        }
        $abook_init_error .= _("Error initializing other address books.") . "\n" . $abook->error;
    }
    /* Load configured LDAP servers (if PHP has LDAP support) */
    if (isset($ldap_server) && is_array($ldap_server)) {
        reset($ldap_server);
        while (list($undef, $param) = each($ldap_server)) {
            if (!is_array($param)) {
                continue;
            }
            /* if onlylocal is true, we only add writeable ldap servers */
            if ($onlylocal && (!isset($param['writeable']) || $param['writeable'] != true)) {
                continue;
            }
            $r = $abook->add_backend('ldap_server', $param);
            if (!$r && $showerr) {
                if ($abook_init_error != '') {
                    $abook_init_error .= "\n";
                }
                $abook_init_error .= sprintf(_("Error initializing LDAP server %s:"), $param['host']) . "\n";
                $abook_init_error .= $abook->error;
            }
        }
    }
    // end of ldap server init
    /**
     * display address book init errors.
     */
    if ($abook_init_error != '' && $showerr) {
        error_box(nl2br(sm_encode_html_special_chars($abook_init_error)));
    }
    /* Return the initialized object */
    return $abook;
}
Exemplo n.º 22
0
 * @since 1.1.3
 */
/**
 * Path for SquirrelMail required files.
 * @ignore
 */
define('SM_PATH', '../');
/* SquirrelMail required files. */
require_once SM_PATH . 'include/validate.php';
include_once SM_PATH . 'functions/global.php';
include_once SM_PATH . 'functions/display_messages.php';
include_once SM_PATH . 'functions/html.php';
include_once SM_PATH . 'functions/identity.php';
/* make sure that page is not available when $edit_identity is false */
if (!$edit_identity) {
    error_box(_("Editing identities is disabled."), $color);
    die('</body></html>');
}
if (!sqgetGlobalVar('identities', $identities, SQ_SESSION)) {
    $identities = get_identities();
}
sqgetGlobalVar('newidentities', $newidentities, SQ_POST);
sqgetGlobalVar('smaction', $smaction, SQ_POST);
sqgetGlobalVar('return', $return, SQ_POST);
// First lets see if there are any actions to perform //
if (!empty($smaction) && is_array($smaction)) {
    $doaction = '';
    $identid = 0;
    foreach ($smaction as $action => $row) {
        // we only need to extract the action and the identity we are
        // altering
Exemplo n.º 23
0
/**
 * Displays error message
 * 
 * Second argument ($color array) is changed to boolean $return_output as of 1.5.2.
 *
 * @param string $message error message
 * @param boolean $return_output When TRUE, output is returned to caller
 *                               instead of being sent to browser (OPTIONAL;
 *                               default = FALSE)
 * @since 1.0
 */
function plain_error_message($message, $return_output = FALSE)
{
    return error_box($message, NULL, $return_output);
}
Exemplo n.º 24
0
/**
 * Update sent_subfolders settings
 *
 * function updates default sent folder value and
 * creates required imap folders
 */
function sent_subfolders_update_sentfolder_do()
{
    global $sent_folder, $username, $data_dir, $imapServerAddress, $imapPort, $imap_stream_options, $move_to_sent;
    sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
    $use_sent_subfolders = getPref($data_dir, $username, 'use_sent_subfolders', SMPREF_OFF);
    $sent_subfolders_setting = getPref($data_dir, $username, 'sent_subfolders_setting', SMPREF_SENT_SUBFOLDERS_DISABLED);
    $sent_subfolders_base = getPref($data_dir, $username, 'sent_subfolders_base', $sent_folder);
    if ($use_sent_subfolders || $move_to_sent) {
        $year = date('Y');
        $month = date('m');
        $quarter = sent_subfolder_getQuarter($month);
        /**
         * Regarding the structure we've got three main possibilities.
         * One sent holder. level 0.
         * Multiple year holders with messages in it. level 1.
         * Multiple year folders with holders in it. level 2.
         */
        switch ($sent_subfolders_setting) {
            case SMPREF_SENT_SUBFOLDERS_YEARLY:
                $level = 1;
                $sent_subfolder = $sent_subfolders_base . $delimiter . $year;
                break;
            case SMPREF_SENT_SUBFOLDERS_QUARTERLY:
                $level = 2;
                $sent_subfolder = $sent_subfolders_base . $delimiter . $year . $delimiter . $quarter;
                $year_folder = $sent_subfolders_base . $delimiter . $year;
                break;
            case SMPREF_SENT_SUBFOLDERS_MONTHLY:
                $level = 2;
                $sent_subfolder = $sent_subfolders_base . $delimiter . $year . $delimiter . $month;
                $year_folder = $sent_subfolders_base . $delimiter . $year;
                break;
            case SMPREF_SENT_SUBFOLDERS_DISABLED:
            default:
                $level = 0;
                $sent_subfolder = $sent_folder;
                $year_folder = $sent_folder;
        }
        /* If this folder is NOT the current sent folder, update stuff. */
        if ($sent_subfolder != $sent_folder) {
            /* Auto-create folders, if they do not yet exist. */
            if ($sent_subfolder != 'none') {
                /* Create the imap connection. */
                $ic = sqimap_login($username, false, $imapServerAddress, $imapPort, 10, $imap_stream_options);
                $boxes = false;
                /**
                 * If sent_subfolder can't store messages (noselect) ||
                 * year_folder can't store subfolders (noinferiors) in level=2 setup ||
                 * subfolder_base can't store subfolders (noinferiors), setup is broken
                 */
                if (sqimap_mailbox_is_noselect($ic, $sent_subfolder, $boxes) || $level == 2 && sqimap_mailbox_is_noinferiors($ic, $year_folder, $boxes) || sqimap_mailbox_is_noinferiors($ic, $sent_subfolders_base, $boxes)) {
                    error_box(_("Sent subfolders options are misconfigured."));
                } else {
                    if ($level == 2) {
                        /* Auto-create the year folder, if it does not yet exist. */
                        if (!sqimap_mailbox_exists($ic, $year_folder)) {
                            sqimap_mailbox_create($ic, $year_folder, 'noselect');
                            // TODO: safety check for imap servers that can't create subfolders
                        } else {
                            if (!sqimap_mailbox_is_subscribed($ic, $year_folder)) {
                                sqimap_subscribe($ic, $year_folder);
                            }
                        }
                    }
                    /* Auto-create the subfolder, if it does not yet exist. */
                    if (!sqimap_mailbox_exists($ic, $sent_subfolder)) {
                        sqimap_mailbox_create($ic, $sent_subfolder, '');
                    } else {
                        if (!sqimap_mailbox_is_subscribed($ic, $sent_subfolder)) {
                            sqimap_subscribe($ic, $sent_subfolder);
                        }
                    }
                    /* Update sent_folder setting in prefs only if the base
                       subfolders setting is not the same as the normal sent
                       folder...  otherwise, it is quite misleading to the user.
                       If the sent folder is the same as the subfolders base, it's
                       OK to leave the sent folder as is.
                       The sent_folder setting itself needs to be the actual
                       subfolder (not the base) for proper functionality */
                    if ($sent_subfolders_base != $sent_folder) {
                        setPref($data_dir, $username, 'sent_folder', $sent_subfolders_base);
                        setPref($data_dir, $username, 'move_to_sent', SMPREF_ON);
                        setPref($data_dir, $username, 'translate_special_folders', SMPREF_OFF);
                    }
                    $sent_folder = $sent_subfolder;
                    $move_to_sent = SMPREF_ON;
                }
                /* Close the imap connection. */
                sqimap_logout($ic);
            }
        }
    }
}
Exemplo n.º 25
0
<?php

if ($user->data['user_id'] == ANONYMOUS) {
    error_box("Erreur", "Vous devez être connecté pour accèder à cette page.", "index.php");
    exit;
}
$tpl = new raintpl();
if (!empty($user->data['partner']) && !empty($user->data['tokken'])) {
    $tpl->assign("link", "https://steamcommunity.com/tradeoffer/new/?partner=" . $user->data['partner'] . "&token=" . $user->data['tokken'] . "");
}
draw($tpl->draw("page_trade", $return_string = true), "Mise à jour");
Exemplo n.º 26
0
<?php

if ($user->data['user_id'] == ANONYMOUS) {
    error_box("Erreur", "Vous devez vous connecter pour acceder a cette page.");
    exit;
}
if ($user->data['steamid'] == 'notset' || $user->data['steamid'] == '') {
    error_box("Erreur", "Vous devez vous connecter pour acceder a cette page.");
    exit;
}
$query = mysql_query("SELECT * FROM `srv_bans` WHERE `SteamID`='" . $user->data['steamid'] . "' AND (`Length`='0' OR `EndTime`>UNIX_TIMESTAMP()) AND `is_unban`='0';");
while ($row2 = mysql_fetch_array($query)) {
    error_box("Erreur", "Vous etes bannis d'un de nos serveurs, et n'avez pas acces a cette page.");
    exit;
}
$tpl = new raintpl();
$tpl->assign('steamid', str_replace("STEAM_0", "STEAM_1", $user->data['steamid']));
draw($tpl->draw("page_report", $return_string = true), "Plainte téléphone", array("angular.min.js"));
Exemplo n.º 27
0
function sqimap_append_done($imap_stream, $folder = '')
{
    global $squirrelmail_language, $color;
    fputs($imap_stream, "\r\n");
    $tmp = fgets($imap_stream, 1024);
    if (preg_match("/(.*)(BAD|NO)(.*)\$/", $tmp, $regs)) {
        set_up_language($squirrelmail_language);
        require_once SM_PATH . 'functions/display_messages.php';
        $reason = $regs[3];
        if ($regs[2] == 'NO') {
            $string = "<b><font color={$color['2']}>\n" . _("ERROR : Could not append message to") . " {$folder}." . "</b><br>\n" . _("Server responded: ") . $reason . "<br>\n";
            if (preg_match("/(.*)(quota)(.*)\$/i", $reason, $regs)) {
                $string .= _("Solution: ") . _("Remove unneccessary messages from your folder and start with your Trash folder.") . "<br>\n";
            }
            $string .= "</font>\n";
            error_box($string, $color);
        } else {
            $string = "<b><font color={$color['2']}>\n" . _("ERROR : Bad or malformed request.") . "</b><br>\n" . _("Server responded: ") . $tmp . "</font><br>\n";
            error_box($string, $color);
            exit;
        }
    }
}
Exemplo n.º 28
0
 */
// This is the bug_report options page
//
define('PAGE_NAME', 'bug_report_options');
// Include the SquirrelMail initialization file.
//
require '../../include/init.php';
// load plugin functions
//
require_once SM_PATH . 'plugins/bug_report/functions.php';
displayPageHeader($color);
// error out when bug_report plugin is disabled
// or is called by the wrong user
//
if (!is_plugin_enabled('bug_report') || !bug_report_check_user()) {
    error_box(_("Plugin is disabled."));
    $oTemplate->display('footer.tpl');
    exit;
}
// get system specs
//
require_once SM_PATH . 'plugins/bug_report/system_specs.php';
list($body, $warnings, $corrections) = get_system_specs();
$body_top = "I am subscribed to the this mailing list.\n" . " (applies when you are sending email to SquirrelMail mailing list)\n" . "  [ ]  True - No need to CC me when replying\n" . "  [ ]  False - Please CC me when replying\n" . "\n" . "This bug occurs when I ...\n" . "  ... view a particular message\n" . "  ... use a specific plugin/function\n" . "  ... try to do/view/use ....\n" . "\n\n\n" . "The description of the bug:\n\n\n" . "I can reproduce the bug by:\n\n\n" . "(Optional) I got bored and found the bug occurs in:\n\n\n" . "(Optional) I got really bored and here's a fix:\n\n\n" . "----------------------------------------------\n\n";
$body = $body_top . $body;
global $oTemplate, $bug_report_admin_email;
if (!empty($bug_report_admin_email)) {
    $oTemplate->assign('admin_email', $bug_report_admin_email);
}
$oTemplate->assign('message_body', $body);
$oTemplate->assign('title_bg_color', $color[0]);
Exemplo n.º 29
0
/**
 * Saves calendar data
 * @return void
 * @access private
 */
function writecalendardata()
{
    global $calendardata, $username, $data_dir, $year, $color;
    $filetmp = getHashedFile($username, $data_dir, "{$username}.{$year}.cal.tmp");
    $filename = getHashedFile($username, $data_dir, "{$username}.{$year}.cal");
    $fp = fopen($filetmp, "w");
    if ($fp) {
        while ($calfoo = each($calendardata)) {
            while ($calbar = each($calfoo['value'])) {
                $calfoobar = $calendardata[$calfoo['key']][$calbar['key']];
                array_walk($calfoobar, 'calendar_encodedata');
                /**
                 * Make sure that reminder field is set. Calendar forms don't implement it, 
                 * but it is still used for calendar data. Backwards compatibility.
                 */
                if (!isset($calfoobar['reminder'])) {
                    $calfoobar['reminder'] = '';
                }
                $calstr = "{$calfoo['key']}|{$calbar['key']}|{$calfoobar['length']}|{$calfoobar['priority']}|{$calfoobar['title']}|{$calfoobar['message']}|{$calfoobar['reminder']}\n";
                if (sq_fwrite($fp, $calstr, 4096) === FALSE) {
                    error_box(_("Could not write calendar file %s", "{$username}.{$year}.cal.tmp"), $color);
                }
            }
        }
        fclose($fp);
        @unlink($filename);
        rename($filetmp, $filename);
    }
}
Exemplo n.º 30
0
/**
 * This detects if the IMAP server has logins disabled, and if so, 
 * squelches the display of the login form and puts up a message
 * explaining the situation.
 */
if ($imap_auth_mech == 'login') {
    $imap = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls);
    $logindisabled = sqimap_capability($imap, 'LOGINDISABLED');
    sqimap_logout($imap);
    if ($logindisabled) {
        $string = _("The IMAP server is reporting that plain text logins are disabled.") . '<br />' . _("Using CRAM-MD5 or DIGEST-MD5 authentication instead may work.") . '<br />';
        if (!$use_imap_tls) {
            $string .= _("Also, the use of TLS may allow SquirrelMail to login.") . '<br />';
        }
        $string .= _("Please contact your system administrator and report this error.");
        error_box($string, $color);
        exit;
    }
}
do_hook('login_cookie');
/* Output the javascript onload function. */
$header = "<script language=\"JavaScript\" type=\"text/javascript\">\n" . "<!--\n" . "  function squirrelmail_loginpage_onload() {\n" . "    var textElements = 0;\n" . "    for (i = 0; i < document.forms[0].elements.length; i++) {\n" . "      if (document.forms[0].elements[i].type == \"text\" || document.forms[0].elements[i].type == \"password\") {\n" . "        textElements++;\n" . "        if (textElements == " . (isset($loginname) ? 2 : 1) . ") {\n" . "          document.forms[0].elements[i].focus();\n" . "          break;\n" . "        }\n" . "      }\n" . "    }\n" . "  }\n" . "// -->\n" . "</script>\n";
if (@file_exists($theme[$theme_default]['PATH'])) {
    @(include $theme[$theme_default]['PATH']);
}
displayHtmlHeader("{$org_name} - " . _("Login"), $header, FALSE);
echo "<body text=\"{$color['8']}\" bgcolor=\"{$color['4']}\" link=\"{$color['7']}\" vlink=\"{$color['7']}\" alink=\"{$color['7']}\" onLoad=\"squirrelmail_loginpage_onload()\">" . "\n" . '<form action="redirect.php" method="post" onSubmit="document.forms[0].js_autodetect_results.value=\'' . SMPREF_JS_ON . '\';">' . "\n";
$username_form_name = 'login_username';
$password_form_name = 'secretkey';
do_hook('login_top');
$loginname_value = sqGetGlobalVar('loginname', $loginname) ? htmlspecialchars($loginname) : '';