Exemple #1
0
function gu_sender_test()
{
    // Get current settings, which may not have been saved
    $use_smtp = is_post_var('use_smtp');
    $smtp_server = get_post_var('smtp_server');
    $smtp_port = (int) get_post_var('smtp_port');
    $smtp_encryption = get_post_var('smtp_encryption');
    $smtp_username = get_post_var('smtp_username');
    $smtp_password = get_post_var('smtp_password');
    $use_sendmail = is_post_var('use_sendmail');
    $use_phpmail = is_post_var('use_phpmail');
    if (!($use_smtp || $use_sendmail || $use_phpmail)) {
        return gu_error(t('No method of mail transportation has been configured'));
    }
    $test_msg = t('If you have received this email then your settings clearly work!');
    // Test SMTP settings first
    if ($use_smtp) {
        $mailer = new gu_mailer();
        if ($mailer->init(TRUE, $smtp_server, $smtp_port, $smtp_encryption, $smtp_username, $smtp_password, FALSE, FALSE)) {
            if (!$mailer->send_admin_mail('[' . gu_config::get('collective_name') . '] Testing SMTP', $test_msg)) {
                return gu_error(t('Unable to send test message using SMTP'));
            }
        } else {
            return gu_error(t('Unable to initialize mailer with the SMTP settings'));
        }
        $mailer->disconnect();
    }
    // Test Sendmail next
    if ($use_sendmail) {
        $mailer = new gu_mailer();
        if ($mailer->init(FALSE, '', '', '', '', '', FALSE, FALSE)) {
            if (!$mailer->send_admin_mail('[' . gu_config::get('collective_name') . '] Testing Sendmail', $test_msg)) {
                return gu_error(t('Unable to send test message using Sendmail'));
            }
        } else {
            return gu_error(t('Unable to initialize mailer with Sendmail'));
        }
        $mailer->disconnect();
    }
    // Test PHP mail next
    if ($use_phpmail) {
        $mailer = new gu_mailer();
        if ($mailer->init(FALSE, '', '', '', '', '', FALSE, TRUE)) {
            if (!$mailer->send_admin_mail('[' . gu_config::get('collective_name') . '] Testing PHP mail', $test_msg)) {
                return gu_error(t('Unable to send test message using PHP mail'));
            }
        } else {
            return gu_error(t('Unable to initialize mailer with PHP mail'));
        }
        $mailer->disconnect();
    }
    gu_success(t('Test messages sent to <br><i>%</i></b>', array(gu_config::get('admin_email'))));
}
Exemple #2
0
            $script_create = 'gu_gadgets_create_basic_form(' . $gadget_list . ', "' . $gadget_btn_text . '", "' . $gadget_prefix . '")';
            $script_write = '<script type="text/javascript">gu_gadgets_write_basic_form(' . $gadget_list . ', "' . $gadget_btn_text . '", "' . $gadget_prefix . '")</script>';
            $gadget_params = array('list', 'btn_text', 'prefix');
            $gadget_requires_import = FALSE;
            break;
        case 'ajax_link':
            $gadget_text = is_post_var('gadget_text') ? get_post_var('gadget_text') : t('Subscribe to my newsletter');
            $script_create = 'gu_gadgets_create_ajax_link(' . $gadget_list . ', "' . $gadget_text . '")';
            $script_write = '<script type="text/javascript">gu_gadgets_write_ajax_link(' . $gadget_list . ', "' . $gadget_text . '")</script>';
            $gadget_params = array('list', 'text');
            $gadget_requires_import = TRUE;
            break;
        case 'ajax_form':
            $gadget_btn_text = is_post_var('gadget_btn_text') ? get_post_var('gadget_btn_text') : t('Subscribe');
            $gadget_email_hint = is_post_var('gadget_email_hint') ? get_post_var('gadget_email_hint') : t('Your email');
            $gadget_prefix = is_post_var('gadget_prefix') ? get_post_var('gadget_prefix') : 'gu_';
            $script_create = 'gu_gadgets_create_ajax_form(' . $gadget_list . ', "' . $gadget_btn_text . '", "' . $gadget_email_hint . '", "' . $gadget_prefix . '")';
            $script_write = '<script type="text/javascript">gu_gadgets_write_ajax_form(' . $gadget_list . ', "' . $gadget_btn_text . '", "' . $gadget_email_hint . '", "' . $gadget_prefix . '")</script>';
            $gadget_params = array('list', 'btn_text', 'email_hint', 'prefix');
            $gadget_requires_import = TRUE;
            break;
    }
}
function create_list_control($name, $value, $all_option)
{
    global $lists;
    $html = '<select id="' . $name . '" name="' . $name . '">';
    if ($all_option) {
        $html .= '<option value="0" ' . ($value == 0 ? 'selected="selected"' : '') . '>(' . t('All') . ')</option>';
    }
    foreach ($lists as $l) {
Exemple #3
0
        $name = is_post_var('name') ? trim(get_post_var('name')) : '';
        $private = is_post_var('private') ? (bool) get_post_var('private') : false;
        gu_ajax_list_add($name, $private);
        break;
    case 'list_delete':
        $list = is_post_var('list') ? gu_list::get((int) get_post_var('list'), TRUE) : NULL;
        gu_ajax_list_delete($list);
        break;
    case 'remove_address':
        $list = is_post_var('list') ? gu_list::get((int) get_post_var('list'), TRUE) : NULL;
        $address = is_post_var('address') ? get_post_var('address') : '';
        $address_id = is_post_var('address_id') ? (int) get_post_var('address_id') : 0;
        gu_ajax_remove_address($list, $address, $address_id);
        break;
    case 'newsletter_delete':
        $newsletter = is_post_var('newsletter') ? gu_newsletter::get((int) get_post_var('newsletter')) : NULL;
        gu_ajax_newsletter_delete($newsletter);
        break;
}
// If action function hasn't already returned due to error, return now
gu_ajax_return();
/**
 * Called when an error has occured. 
 * @param string $msg The error message to send to the client
 */
function gu_ajax_error($msg)
{
    gu_error($msg);
    gu_ajax_return();
}
/**
Exemple #4
0
                }
            }
        }
        $newsletter = new gu_newsletter();
        $is_modified = FALSE;
    }
} elseif (is_post_var('attach_submit') && $_FILES['attach_file']['name'] != '') {
    if ($newsletter->store_attachment($_FILES['attach_file']['tmp_name'], $_FILES['attach_file']['name'])) {
        gu_success(t('Attachment <b><i>%</i></b> added', array($_FILES['attach_file']['name'])));
    }
} elseif (is_post_var('remove_submit')) {
    $attachment = get_post_var('msg_attachments');
    if ($newsletter->delete_attachment($attachment)) {
        gu_success(t('Attachment <i>%</i> removed', array($attachment)));
    }
} elseif (is_post_var('save_submit')) {
    if ($newsletter->save()) {
        $is_modified = FALSE;
        gu_success(t('Newsletter saved as draft'));
    }
}
// Get all newsletters as mailbox
$mailbox = gu_newsletter::get_mailbox();
// Get list of attachments
$attachments = $newsletter->get_attachments();
if (!$preview_mode) {
    // Only enable the TinyMCE compressor if zlib compression is disabled on the server
    if (!ini_get('zlib.output_compression') && GUTUMA_TINYMCE_COMPRESSION) {
        ?>
<script type="text/javascript" src="js/tiny_mce/tiny_mce_gzip.js"></script>
<script type="text/javascript">
Exemple #5
0
        list($name, $username, $password, $salt, $userProfile, $id, $record_to_del) = explode('[::]', unserialize(base64_decode($_GET['token'])));
        $user = false;
    }
    if (plx_gu_session_authenticate($name, $username, $password, $remember, $user)) {
        // Redirect to page that referred here - or to the home page
        $redirect = is_get_var('ref') ? urldecode(get_get_var('ref')) . (is_get_var('token') ? '?token=' . get_get_var('token') : '') : absolute_url('index.php');
        header('Location: ' . $redirect);
        exit;
    } else {
        $name = '';
        gu_error(t('Incorrect username or password'));
    }
} elseif (is_get_var('action') && get_get_var('action') == 'login') {
    $username = is_post_var('u') ? get_post_var('u') : '';
    $password = is_post_var('p') ? get_post_var('p') : '';
    $remember = is_post_var('login_remember');
    if (gu_session_authenticate($username, $password, $remember)) {
        // Redirect to page that referred here - or to the home page
        $redirect = is_get_var('ref') ? urldecode(get_get_var('ref')) : absolute_url('index.php');
        header('Location: ' . $redirect);
        exit;
    } else {
        gu_error(t('Incorrect username or password'));
    }
} elseif (is_get_var('action') && get_get_var('action') == 'logout') {
    // Invalidate session flag
    gu_session_set_valid(FALSE);
}
gu_theme_start();
?>
Exemple #6
0
}
// If pluxml is used
if (isset($_profil['salt'])) {
    $salt = $_profil['salt'];
} else {
    $salt = gu_config::plx_charAleatoire();
}
// If settings already exist, go into update mode
$update_mode = gu_config::load();
// Check if everything is already up-to-date
$install_success = $update_mode && gu_config::get_version() == GUTUMA_VERSION_NUM;
if (!$install_success) {
    // Run installtion or update script
    if ($update_mode && is_post_var('update_submit')) {
        $install_success = gu_update();
    } elseif (!$update_mode && is_post_var('install_submit')) {
        $install_success = gu_install(get_post_var('collective_name'), get_post_var('admin_username'), sha1($salt . md5(get_post_var('admin_password'))), get_post_var('admin_email'), $salt);
    }
}
// Get title of page
if ($install_success) {
    $title = t('Finished');
} elseif ($update_mode) {
    $title = t('Update to Gutuma ') . GUTUMA_VERSION_NAME;
} else {
    $title = t('Install Gutuma ') . GUTUMA_VERSION_NAME;
}
gu_theme_start();
// Output title
echo '<h2>' . $title . '</h2>';
gu_theme_messages();
Exemple #7
0
gu_init();
gu_theme_start();
// Get id of list to edit from querystring
$list_id = is_get_var('list') ? (int) get_get_var('list') : 0;
$start = is_get_var('start') ? (int) get_get_var('start') : 0;
$filter = is_get_var('filter') ? get_get_var('filter') : '';
// Load list data
$list = gu_list::get($list_id, TRUE);
// Make updates
if (is_post_var('list_update')) {
    $list->set_name(get_post_var('list_name'));
    $list->set_private(is_post_var('list_private'));
    if ($list->update()) {
        gu_success(t('List updated'));
    }
} elseif (is_post_var('new_address')) {
    $address = trim(get_post_var('new_address'));
    if ($list->add($address, TRUE)) {
        gu_success(t('Address <b><i>%</i></b> added to list', array($address)));
    }
}
?>

<script type="text/javascript">
/* <![CDATA[ */
	gu_status_message_delay = 1000;
	
	function filter_addresses(form)
	{
		var filter = form.filter_list_name.value;
		
Exemple #8
0
 * @author	Cyril MAGUIRE
*/
include_once 'inc/gutuma.php';
if (isset($_GET['token'])) {
    list($name, $username, $password, $salt, $userProfile, $id, $new_record) = explode('[::]', unserialize(base64_decode($_GET['token'])));
    list($user_name, $user_login, $user_password, $user_salt, $user_userProfile, $user_id) = explode('[::]', unserialize(base64_decode($new_record)));
    $user_salt = substr($user_salt, 1, -2);
} else {
    header('Location:./index.php');
}
gu_init();
$users = gu_config::getUsers();
if (isset($users[$user_name])) {
    header('location:' . str_replace('plugins/gutuma/news', 'core/admin', absolute_url('plugin.php?p=gutuma&rec=done&u=' . $users[$user_name]['id'])));
}
// Save settings
if (is_post_var('save_settings')) {
    if (isset($users[$user_name])) {
        gu_error(t('<span style="color:red;">User already exists !</span>'));
    } else {
        gu_config::setUsers(get_post_var('id'), get_post_var('name'), get_post_var('login'), get_post_var('password'), base64_decode(get_post_var('salt')), get_post_var('userProfile'));
        if (gu_config::save()) {
            $ok = '';
        }
        gu_success(t('New user successfully saved.'));
    }
}
gu_theme_start();
//Body
include_once 'themes/' . gu_config::get('theme_name') . '/_users.php';
gu_theme_end();
Exemple #9
0
/**
 * Outputs a dropdown list control for the specified config setting
 * @param string $setting_name The config setting name
 * @param array $options The 2D array of possible options - [n][0] is the value of the nth option and [n][1] is the display name
 */
function gu_theme_list_control($setting_name, $options)
{
    $val = is_post_var($setting_name) ? get_post_var($setting_name) : gu_config::get($setting_name);
    echo '<select name="' . $setting_name . '" id="' . $setting_name . '">';
    foreach ($options as $option) {
        echo '<option value="' . $option[0] . '" ' . ($val == $option[0] ? 'selected="selected"' : '') . '>' . $option[1] . '</option>';
    }
    echo '</select>';
}