MyBB Community Forums

Full Version: MyAlerts v2.0.4
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
(2015-06-04, 09:09 PM)Euan T Wrote: [ -> ]
(2015-06-04, 12:27 PM)Adamas Wrote: [ -> ]
(2015-06-04, 11:29 AM)Euan T Wrote: [ -> ]
(2015-06-04, 10:09 AM)Adamas Wrote: [ -> ]Euan, when I install MyAlerts, I get a white page when I try to activate it. Do you have any clue what might be going on here?
Hi,

Can you check your server error log and post any errors contained in there?

None of my error logs indicate there's any problem, which is odd. I opened up the Network tab in Chrome's Dev Tools, it's an error 500. All I can tell ATM. *scratches head*

Edit: Narrowed down. It's something within the _activate() function, but I don't know what. I put code at the start and end, then activated: the code at the start ran but the end didn't. My activate function is below.

    global $db, $lang, $PL, $plugins, $cache;

    if (!$lang->myalerts) {
        $lang->load('myalerts');
    }

    if (!file_exists(PLUGINLIBRARY)) {
        flash_message($lang->myalerts_pluginlibrary_missing, 'error');
        admin_redirect('index.php?module=config-plugins');
    }

    $PL or require_once PLUGINLIBRARY;

    if ($PL->version < 9) {
        flash_message('This plugin requires PluginLibrary 9 or newer', 'error');
        admin_redirect('index.php?module=config-plugins');
    }

    $plugin_info = myalerts_info();

    $euantorPlugins = $cache->read('euantor_plugins');

	if (!empty($euantorPlugins) && isset($euantorPlugins['myalerts'])) {
		$oldVersion = $euantorPlugins['myalerts'];

		if ($oldVersion['version'] == '1.05') {
			myalerts_upgrade_105_200();
		}
	}

    $euantorPlugins['myalerts'] = array(
        'title' => 'MyAlerts',
        'version' => $plugin_info['version'],
    );
    $cache->update('euantor_plugins', $euantorPlugins);

    $PL->settings(
        'myalerts',
        $lang->setting_group_myalerts,
        $lang->setting_group_myalerts_desc,
        array(
            'perpage' => array(
                'title' => $lang->setting_myalerts_perpage,
                'description' => $lang->setting_myalerts_perpage_desc,
                'value' => '10',
                'optionscode' => 'text',
            ),
            'dropdown_limit' => array(
                'title' => $lang->setting_myalerts_dropdown_limit,
                'description' => $lang->setting_myalerts_dropdown_limit_desc,
                'value' => '5',
                'optionscode' => 'text',
            ),
            'autorefresh' => array(
                'title' => $lang->setting_myalerts_autorefresh,
                'description' => $lang->setting_myalerts_autorefresh_desc,
                'value' => '0',
                'optionscode' => 'text',
            ),
            'avatar_size' => array(
                'title' => $lang->setting_myalerts_avatar_size,
                'description' => $lang->setting_myalerts_avatar_size_desc,
                'optionscode' => 'text',
                'value' => '64|64',
            ),
        )
    );

    $dir = new DirectoryIterator(MYALERTS_PLUGIN_PATH . '/templates');
    $templates = array();
    foreach ($dir as $file) {
        if (!$file->isDot() && !$file->isDir() && $file->getExtension() == 'html') {
	        $templateName = $file->getPathname();
	        $templateName = basename($templateName, '.html');
            $templates[$templateName] = file_get_contents($file->getPathName());
        }
    }

    $PL->templates(
        'myalerts',
        'MyAlerts',
        $templates
    );

    $stylesheet = file_get_contents(MYALERTS_PLUGIN_PATH . '/stylesheets/alerts.css');

    $PL->stylesheet('alerts.css', $stylesheet);

    // Attach usercp.css to alerts.php
    $query = $db->simple_select('themestylesheets', 'sid,attachedto,tid', "name = 'usercp.css'");

    while ($userCpStylesheet = $db->fetch_array($query)) {
        $sid = (int) $userCpStylesheet['sid'];

        $db->update_query('themestylesheets', array(
            'attachedto' => $db->escape_string($userCpStylesheet['attachedto'] . '|alerts.php'),
        ), "sid = {$sid}"
        );

        update_theme_stylesheet_list((int) $userCpStylesheet['tid']);
    }

    require_once MYBB_ROOT . '/inc/adminfunctions_templates.php';


    find_replace_templatesets('headerinclude', '/$/', '{$myalerts_js}');
    find_replace_templatesets(
        'header_welcomeblock_member',
        "#" . preg_quote('{$modcplink}') . "#i",
        '{$myalerts_headericon}{$modcplink}'
    );
	find_replace_templatesets(
		'footer',
		'/$/',
		'{$myalerts_modal}'
	);

    $taskExists = $db->simple_select('tasks', 'tid', 'file = \'myalerts\'', array('limit' => '1'));
    if ($db->num_rows($taskExists) == 0) {
        require_once MYBB_ROOT . '/inc/functions_task.php';

        $myTask = array(
            'title' => $lang->myalerts_task_title,
            'file' => 'myalerts',
            'description' => $lang->myalerts_task_description,
            'minute' => 0,
            'hour' => 1,
            'day' => '*',
            'weekday' => 1,
            'month' => '*',
            'nextrun' => TIME_NOW + 3600,
            'lastrun' => 0,
            'enabled' => 1,
            'logging' => 1,
            'locked' => 0,
        );

        $task_id = $db->insert_query('tasks', $myTask);
        $theTask = $db->fetch_array($db->simple_select('tasks', '*', 'tid = ' . (int) $task_id, 1));
        $nextrun = fetch_next_run($theTask);
        $db->update_query('tasks', 'nextrun = ' . $nextrun, 'tid = ' . (int) $task_id);
        $plugins->run_hooks('admin_tools_tasks_add_commit');
        $cache->update_tasks();
    } else {
        require_once MYBB_ROOT . '/inc/functions_task.php';
        $theTask = $db->fetch_array($db->simple_select('tasks', '*', 'file = \'myalerts\'', 1));
        $db->update_query('tasks', array('enabled' => 1, 'nextrun' => fetch_next_run($theTask)), 'file = \'myalerts\'');
        $cache->update_tasks();
    }

    $plugins->run_hooks('myalerts_activate');

Edit again: It's in the GitHub repo too. Ran that code, no dice. I'm about to go to sleep, so if it's of any use, my PHP version is 5.3.23, Apache 2.2.27.
Strange. If it's an error 500, it should be logged by the server explaining what the actual error is. Without the error message, it's very difficult to establish the cause.

Hello again Euan, did some more narrowing down of code, it appears to be something to do with this piece of code:

    $dir = new DirectoryIterator(MYALERTS_PLUGIN_PATH . '/templates');
    $templates = array();
    foreach ($dir as $file) {
        if (!$file->isDot() && !$file->isDir() && $file->getExtension() == 'html') {
	        $templateName = $file->getPathname();
	        $templateName = basename($templateName, '.html');
            $templates[$templateName] = file_get_contents($file->getPathName());
        }
    }

Specifically the foreach. Before this, code runs. Nothing runs after it. It appears the $file object is empty, as echoing $templateName does nothing, but echoing random strings works. Will do some more testing and get back.

Edit: Curiouser and curiouser. The if statement is failing. PHP is 5.3.28 so the methods required do, in fact, exist...
Hi,

Which version of PHP are you using? I hadn't realised until yesterday, but "getExtension()" only works on PHP > 5.3.6. If the version is less than that, change the code above to the following:

$dir = new DirectoryIterator(MYALERTS_PLUGIN_PATH . '/templates');
    $templates = array();
    foreach ($dir as $file) {
        if (!$file->isDot() && !$file->isDir() && pathinfo($file->getPathname(), PATHINFO_EXTENSION) === 'html') {
            $templateName = $file->getPathname();
            $templateName = basename($templateName, '.html');
            $templates[$templateName] = file_get_contents($file->getPathName());
        }
    } 
I'm using 5.3.28. I will try that code though, see if it works.

Edit: That broke literally everything; white pages everywhere. Still no error logs despite every effort to enable them, so I'll undo that code and try again.
Edit 2: Entire ACP broken. Am forcibly uninstalling. Tomorrow I'll do a complete fresh reinstall.
Edit 3: Completely reinstalled MyBB and tried to install MyAlerts onto a totally vanilla install. No dice, same issue. Sad
Strange. If you want, send me some FTP and ACP details and I'll take a look.
(2015-06-06, 07:20 AM)Euan T Wrote: [ -> ]
(2015-06-05, 09:40 PM)Phantomer Wrote: [ -> ]
(2015-06-05, 07:34 PM)Euan T Wrote: [ -> ]Strange, can you send me your URL and a test account?

I sent you a PM with all the details.

Thanks, I'll take a look this morning.

(2015-06-06, 02:05 AM)bekircem Wrote: [ -> ]When i upload the MyAlerts plugin's file to FTP my plugins tab is not open on ACP. I think reason is the old installation. How i completly uninstall MyAlerts for clean install?

Hi, simply press the uninstall button, though you should only need to disable before uploading the current version.

I can't see uninstall button because plugin tab is not seems. I try to delete Myalerts table on Phpmyadmin but dont work for me.
Hi,

Is the whole page just white or what? How did you upload the plugin? Can you post a screenshot of your /inc/plugins folder?
(2015-06-06, 02:55 PM)Euan T Wrote: [ -> ]Hi,

Is the whole page just white or what? How did you upload the plugin? Can you post a screenshot of your /inc/plugins folder?

I think i made the mistake on older version installation. When i click plugins tab, header seems but plugin list not seems. When i delete /inc/plugins/myalerts.php file plugin tabs fixed and plugin list seems to me.
Strange. Which PHP version are you using? It may be a similar issue to that seen above, which I will be patching during the week.
(2015-06-06, 04:45 PM)Euan T Wrote: [ -> ]Strange. Which PHP version are you using? It may be a similar issue to that seen above, which I will be patching during the week.

My PHP version is 5.4.41.
Strange, it should work in that case. Not having any errors logged makes it very hard to diagnose. Can you send me a screenshot of your /inc/plugins/ folder?