Support » Plugin: Javelin Email Marketing » [Plugin: WP Autoresponder And Newsletter Plugin] system tmp directory hard coded instead of WP_TEMP_

  • mikemee

    (@mikemee)


    Hi, I’m hosting wordpress at nearlyfreespeech.net which does not allow access to the /tmp directory. I’ve set the WP_TEMP_DIR variable correctly in the wp-config.php file, but the wp responder plugin seems to be hard coded to use /tmp.

    E.g. this is the error I get when I try to go to the plugin setting page:

    Warning: is_writable() [function.is-writable]: open_basedir restriction in effect. File(/tmp/.dougb) is not within the allowed path(s): (/f5/mypath/:/nfsn/apps/php5/lib/php/:/nfsn/apps/php/lib/php/:/nfsn/content/content/nfsn/:/usr/local/php/lib/:/usr/local/php/5.2.17/lib/:/usr/local/php/5.3.5-nfsn1/lib/) in /f5/mypath/public/wp-content/plugins/wp-responder-email-autoresponder-and-newsletter-plugin/lib/preferences.php on line 25

    I hacked around this by changing the code in the above lib/preferences.php file to:

    <br />
    if (is_writable(WP_TEMP_DIR))<br />
    {<br />
      Swift_Preferences::getInstance()<br />
        -> setTempDir(WP_TEMP_DIR)<br />
        -> setCacheType('disk');<br />
    }<br />

    but there is likely a more correct way to change the defaults so others don’t hit this.

    http://wordpress.org/extend/plugins/wp-responder-email-autoresponder-and-newsletter-plugin/

Viewing 2 replies - 1 through 2 (of 2 total)
  • mikemee

    (@mikemee)

    A followup for another tweak to support non-standard temp directories. When importing from csv, there is a call to standard php function tmpfile. Unfortunately that doesn’t work either. Apparently wordpress have patched around this and have a function called wp_tempnam() in wp-admin/includes/file.php. I didn’t work out how to get the includes all working correctly, but I hacked together a quick fix as follows and confirmed that this workaround works:

    function foo_tempnam($filename = '', $dir = '') {
            if ( empty($dir) )
                    $dir = get_temp_dir();
            $filename = basename($filename);
            if ( empty($filename) )
                    $filename = time();
    
            $filename = preg_replace('|\..*$|', '.tmp', $filename);
            $filename = $dir . wp_unique_filename($dir, $filename);
            touch($filename);
            return $filename;
    }
    
    function splitToArray($data)
    {
            $csvcontent = implode("\n",$data);
            $tempfile = foo_tempnam($file);
            $fp = fopen($tempfile, 'w+');
    
    /* original code continues... */

    This around the original line number of 176.

    Its quite likely an unlink() is needed here too somewhere…

    rajasekharan

    (@rajasekharan)

    Hi Mike,

    Thank you for pointing this out.

    I’ve noted this issue down. I currently use GitHub for hosting the public repository of this plugin. You can find the repo URL here:

    https://github.com/rajasekharan/WP-Autoresponder

    Please report all future issues there.

    https://github.com/rajasekharan/WP-Autoresponder/issues

    All issues will be tracked and resolved there. Please report future issues there.

    Raj

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: WP Autoresponder And Newsletter Plugin] system tmp directory hard coded instead of WP_TEMP_’ is closed to new replies.