• Hi, I tried other plugins for importing csv, but this simple plugin is great. But there are several problems on my webhosting:

    1) Open_basedir restriction with /tmp directory and function tempnam
    $t_fname = tempnam(md5(''), __CLASS__ . '_');
    I have to change it to $t_fname = @tempnam(md5(''), __CLASS__ . '_');and now it works for me.

    2) Plugin uses file_get_contents which is blocked by my webhoster. Is it possible to change it to curl or any other way?
    I uncomment this line $res = fopen($this->_filename, 'r'); and commented this line: // $res = $this->_patch(); and it works now, but I am not sure if there is any hidden problem…

    3) Feature request: Is it possible to create Post Title from for example three columns? For example author in column 1 and title in column 2 and I want to create post title “author: title”. It would be great. I know that I can do it directly in the file, but I need to do it everyday which is really boring…

    Thank you very much for this great little plugin.

Viewing 15 replies - 1 through 15 (of 26 total)
  • 1) Could you post the exact open_basedir restriction error that you’re getting? But see 2) first.

    2) Yes, there are several problems here. First of all, the change you’ve made in 1) no longer makes sense – since you’re no longer using _patch() that code is never executed. Second, _patch() fixes some CSV files that would otherwise fail to parse correctly. If you don’t use any language other than English in your CSV files and the values are always enclosed in quotes correctly than you might be able to get away with not using _patch().

    All file_get_contents() is doing here is reading a local file into a string, so we don’t need curl in this case.

    3) The problem here is that I don’t know how to specify which columns should be combined without making the plugin’s interface overly complex. Do you?

    Thread Starter pavelevap

    (@pavelevap)

    Thank you very much for your answers.

    Ad 1,2) Yes, I know that my changes are not a very good idea, but it was the only way to make your plugin work.

    Error:

    Warning: tempnam() [function.tempnam]: open_basedir restriction in effect. File(/tmp) is not within the allowed path(s): (/var/www/web5/domain.com) in /var/www/web5/domain.com/subdomain.domain.com/wp-content/plugins/csv-importer/File_CSV_DataSource/DataSource.php on line 2310
    
    Warning: fgetcsv() expects parameter 1 to be resource, boolean given in /var/www/web5/domain.com/subdomain.domain.com/wp-content/plugins/csv-importer/File_CSV_DataSource/DataSource.php on line 2157
    
    Warning: fclose(): supplied argument is not a valid stream resource in /var/www/web5/domain.com/subdomain.domain.com/wp-content/plugins/csv-importer/File_CSV_DataSource/DataSource.php on line 2168
    
    Warning: unlink() [function.unlink]: No such file or directory in /var/www/web5/domain.com/subdomain.domain.com/wp-content/plugins/csv-importer/File_CSV_DataSource/DataSource.php on line 2339

    My open_basedir in phpinfo is set to /var/www/web5/domain.com

    Ad 3) Maybe it could be for example csv_post_title_1, csv_post_title_2, etc. (+ custom separator).

    1) Could you create the following php file somewhere in your public_html directory, run it and post its output here?

    <?php
         echo 'Temporary directory is: ' . sys_get_temp_dir();
    ?>

    I’m trying to find out whether PHP can report the correct temporary directory for your installation.

    2) The latest version of the plugin doesn’t use function file_get_contents(), so you shouldn’t get that error anymore. However, we still need to sort 1) out before the plugin will function correctly.

    3) Right now I’m working on a drag-and-drop interface for the plugin which will allow to combine and rearrange columns easily before importing.

    Thread Starter pavelevap

    (@pavelevap)

    Thank you very much for your help…

    1) Fatal error: Call to undefined function sys_get_temp_dir() in … πŸ™ This function is probably not allowed by my webhoster. I could give you link to my phpinfo, but I do not want to post it here publicly…

    2 and 3) Great! It would be very helpfull. I can beta test if you are interested…

    1) Damn. It looks like you’re not allowed to create temporary files, period. I’d contact the webhoster and ask what they can do about it, whether sys_get_temp_dir() function is really blocked and what other functions are blocked too.

    Wow, is this a likely problem with many webhosts? Are there any you know where this won’t be a problem and otherwise have a good service.

    Thread Starter pavelevap

    (@pavelevap)

    I asked my webhoster and he told me that this function is not supported before PHP 5.2.1. My PHP Version is 5.2.0-8+etch15. There are no other blocked functions related to tmp directory. So, is there any other way to make your plugin work on my hosting? I used many plugins and there were no similar problems. Thank you very much for your help…

    realistdreamer: I don’t think it’s a common problem. At least, it’s the first time I hear about a webhosting that restricts access to /tmp, which is a standard directory for temporary files.

    pavelevap: Short answer: it seems like I can’t do anything about it. Long answer: with such open_basedir restriction in place, the only directory the plugin can possibly write to is /var/www/web5/domain.com. I can’t hardcode this directory into the plugin’s source and there’s no way for the plugin to determine it automatically. What you can do is either persuade your webhosting to add /tmp to open_basedir or change

    $t_fname = tempnam(md5(''), __CLASS__ . '_');

    to

    $t_fname = tempnam('/var/www/web5/domain.com', __CLASS__ . '_');

    on line 2310 in File_CSV_DataSource/DataSource.php. But you would have to remember to change it every time you update the plugin, so it’s really preferable to add /tmp to open_basedir.

    Ok, I hope this is an easy one…

    How do I configure column titles for custom fields and their accompanying values?

    I am using one custom field named “screen” and its value is always a link to an image related to the post.

    Thanks for your help.

    paintgirl: That’s probably because you have the same link to an image on each row in the ‘screen’ column in your file. To be sure I would have to take a look at the file you’re trying to import or at least a couple of rows from it.

    I guess I did a bad job of wording my question before. I’ll try again.

    I’m including an image of my “Add New Post” page so I can explain better. I marked the sections A and B so it make more sense. The image is at (www.countymerchant.com/privacy.html)

    I understand if I have a custom field (A) that my column title should be “custom_field_1”. And if I have additional custom field that would be “custom_field_2”. What I need to know is what is the column title for the value (B).

    Also is there any way to download my posts into a .csv file? Just wondering.

    paintgirl: To have a custom field named “screen” you should have a column named “screen” in your csv file. Values for that field come from the rows in the same “screen” column, not from a different column.

    It’s really best explained by example. You should take a careful look at the sample.csv file included with the plugin, import it and examine the resulting posts.

    By default, WordPress can only export posts in its own XML format. There might be plugins that allow you to export posts in a different format though.

    Thank you, that is exactly what I needed. Worked perfect.

    I spent the last 7 hours trying to get this plugin to work, but I’m stuck with the following error upon uploading my file:

    “Invalid CSV file: header length and/or row lengths do not match.”

    My CSV file however, looks perfect to me. Even the timestamp is OK. The only thing that is different from the sample.csv, is the “new line” which is a small rectangle character in your sample.csv but an actual new line in my CSV. I don’t know how to change that though.

    Managed to get rid of the error by using double-quotes within the posts and saving the file as UTF-8. But when importing that file, the csv_post_title becomes a custom field.

Viewing 15 replies - 1 through 15 (of 26 total)
  • The topic ‘[Plugin: CSV Importer] Some problems with this great plugin’ is closed to new replies.