[mod] Small hack to make CSV import work (for me at least)

3rd party code for phpList

Postby shumisha » 3:21pm, Tue 18 Apr, 2006

Glad it could help !
shumisha
PL Geek
 
Posts: 82
Joined: 8:06am, Tue 04 Apr, 2006

Postby razor7 » 5:23pm, Fri 21 Apr, 2006

Hello. I cant find the zipped files, could you please send me via email or private message...
thans
razor7
phpLister
 
Posts: 6
Joined: 5:21pm, Fri 21 Apr, 2006

Postby shumisha » 5:27pm, Fri 21 Apr, 2006

Hello Razor7

The files are attached on the 6th post of the first page of this thread. they are still there, I just checked !
shumisha
PL Geek
 
Posts: 82
Joined: 8:06am, Tue 04 Apr, 2006

Postby H2B2 » 5:44am, Sat 29 Apr, 2006

dls4,

I think you should really make sure you're using an absolute path, which on an apache virtual host would look a bit like this:
$tmpdir = '/home/virtual/sitexxx/xxx/var/www/html/phplist/tmp';

You can check this with your host.

Or -if and when you're sure you have the correct path- you may want to check if the .htaccess file is an issue.
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Can't write to tmp directory even though it's chmoded to 777

Postby aksteven » 7:21am, Tue 06 Jun, 2006

I've been struggling with this problem for hours.

Warning: The temporary directory for uploading () is not writable, so import will fail

Fatal Error: Cannot read /List2.txt1149579607. file is not readable !


I have my own root server (Linux/Apache) so I have all the right permissions. I have created a new temporary directory just for PHPList, even though the default /tmp is fully writeable, I have CHMODed this directory to 777 and I have changed ownership from the owner of the site in question, to root, to apache and back to the site owner, but PHPList simply refuses to acknowledge that the temporary directory is writeable.

Now, I know that the path to the temporary directory is correct and that it is writeable because PHPList has written various session files to it - it's just the text file that it won't write. So I uploaded the text file manually, but because PHPList appends a string of numbers to the end of the file name, which change every time you try and import, it's impossible to manually change the file name to trick the application into thinking it's worked.

So then I modified the admin/commonlib/pages/csvimport.php file to hard-code the path to the temporary directory so there was no chance that a cock-up in the config file was to blame. That at least showed the path to the temporary file between the brackets in the error message:

Warning: The temporary directory for uploading (/home/httpd/vhosts/xxxx.co.uk/tmp) is not writable, so import will fail

So, I'm in a situation where I can GUARANTEE that the temporary file is writeable by all, but yet I can't write to it.

Has anyone got any ideas, please?

By the way, I'm using version 2.10.2 and, even though Safe Mode is off in my php.ini file, PHPList still tells me that In Safe Mode things won't work as expected, so maybe there's a clue there?

Thanks in advance for any help you can give.
Andrew
aksteven
phpList newbie
 
Posts: 4
Joined: 8:10pm, Mon 05 Jun, 2006

Postby shumisha » 8:27am, Tue 06 Jun, 2006

Yes this might be a good indication. The test being made (unless you changed that part of the code!) is
Code: Select all
if (!is_dir($GLOBALS["tmpdir"]) || !is_writable($GLOBALS["tmpdir"])) {
  Warn($GLOBALS['I18N']->get('temp_dir_not_writeable')." (".$GLOBALS["tmpdir"].")");
}


So the reason for the test to fail is that either is_dir or is_writable (or both) return false. I have looked up the doc for is_dir, and the first comment you get on php.net is :

Remember that the owner of the directory has to be the same of the script user, otherwise this function will always return false when PHP is running in safe_mode.


As PHPList says it is in Safe mode, then it must be ! You said you did change the directory owner, but your script user may be www or nobody as it is often the case. Do you know what user your php script runs as ? if yes, and you did not try before, you should try chown to this user.
An alternative would be to get out of safe mode. I can suggest two things to try :
1 - safe mode is off in php.ini, but maybe that is not the right php.ini, as there may be several of them
2 - I was using recently PHPLIST on a VPS, and had the same issue of safe_mode being on. It appears the hosting company had left a directive in a configuration file that forced safe mode to be on for each vhost, even though it was off in php.ini.
You should look for "php_admin_flag safe_mode on" in the files located in /etc/apache/conf.d. This might be httpd.conf, or another .conf file located in this directory or not too far from it.
You could do the same in a .htaccess as well, but I think you would know about this if it was so.

Please let us now..
shumisha
PL Geek
 
Posts: 82
Joined: 8:06am, Tue 04 Apr, 2006

tmp directory not writeable

Postby aksteven » 9:14am, Tue 06 Jun, 2006

Shumisha,

Thanks so much for your help - problem solved.

The answer was two-fold. Firstly I went into the vhost's conf/httpd.include file and changed
Code: Select all
php_admin_flag safe_mode on

to off, which killed the safe mode notice.

Then I went back into the config.php file and reset all the paths to the temporary directory to /tmp, which is what they were when the app was first installed. I had previously added
Code: Select all
ini_set('upload_tmp_dir','/tmp');

to the config.php file and I obviously ensured that this too pointed to the server's default temporary directory, however whether this has any bearing on the final successful outcome, I don't know - and I'm not going to find out. It works, so I'm leaving well alone!

Thanks again for your really quick reply and invaluable help.
Andrew[/code]
aksteven
phpList newbie
 
Posts: 4
Joined: 8:10pm, Mon 05 Jun, 2006

Postby shumisha » 10:34am, Tue 06 Jun, 2006

Good to hear ! (or read)
shumisha
PL Geek
 
Posts: 82
Joined: 8:06am, Tue 04 Apr, 2006

Postby gilsurf » 11:55pm, Wed 07 Jun, 2006

I am trying to get a value list based field to import and have not had success.

The import works well, except for importing a value list. I did an export to see how it formats a value list and it comes out:

Value List Name
value1; value2; value3

Is the semi-colon causing an issue on import? The database seems to have an issue and I get an error of more fields than values. it all imports OK, but the value list is ignored on final import (shows values OK in the test window).

Yhe new user(s) is there, but the field with the value list is blank (no boxes checked)

The issue in another thread:
http://www.phplist.com/forums/viewtopic.php?p=17860#17860

has anybody been able to import value list based fields?
gilsurf
PL Geek
 
Posts: 56
Joined: 12:23pm, Tue 28 Feb, 2006

Postby shumisha » 3:59am, Thu 08 Jun, 2006

Yes I imported a select list type field. Are your data enclosed in double-quotes ? if there are any caracters such as : or even ; and , it should help!
shumisha
PL Geek
 
Posts: 82
Joined: 8:06am, Tue 04 Apr, 2006

Postby gilsurf » 10:58am, Thu 08 Jun, 2006

Humm, I tried this, but no luck. I assume you mean the field data and not an entire line, correct?

In test mode, I get the usual more data than felds (bug?):
Code: Select all
Warning: Record has more values than header indicated (6!=4), this may cause trouble: new@ansano.com


And after importing:
Code: Select all
Database error 1064 You have an error in your SQL syntax near 'Casa; Primary; Lower Elementary) and phplist_user_user_attribute.attri' at line 4


The test file is attached. (did not work). The text from import file (TAB delim):

Code: Select all
Email   Send this user HTML emails   First Name   Last Name   VI Montessori Parent   Age Level
new@ansano.com   1   New   Anspacher   Yes   "La Casa; Primary; Lower Elementary"


Using 2.10.2

Thanks for your help
gilsurf
PL Geek
 
Posts: 56
Joined: 12:23pm, Tue 28 Feb, 2006

Postby shumisha » 11:15am, Thu 08 Jun, 2006

Ok, I might understand what the problem is :

In your import file, for each line, you should have only ONE value for the select list field :

Email Send this user HTML emails First Name Last Name VI Montessori Parent Age Level
new@ansano.com 1 New Anspacher Yes "La Casa; Primary; Lower Elementary"


should be :
Code: Select all
Email   Send this user HTML emails   First Name   Last Name   VI Montessori Parent   Age Level
new@ansano.com   1   New   Anspacher   Yes   La Casa


In other words, for each email, you should put in the import txt file only the value required for this person; In your example, "New Anspacher" can only be La Casa, Primary or Lower elementary, but not the three at the same time ?!
shumisha
PL Geek
 
Posts: 82
Joined: 8:06am, Tue 04 Apr, 2006

Postby shumisha » 12:12pm, Thu 08 Jun, 2006

I understand now. However, I don't think this is possible. In a select list, I think at the moment PHPList can only have one choice, not several for the same person. This must be confirmed, I have not done it.

If you do not have too many possible choices, I would suggest that you make 3 additional field, each of them a checkbox:
La Casa : yes
Primary : yes
Elementary : no

This way you are pretty flexible in whatever combination you like to do.

Hope it helps !
shumisha
PL Geek
 
Posts: 82
Joined: 8:06am, Tue 04 Apr, 2006

Postby gilsurf » 12:48pm, Thu 08 Jun, 2006

The reason I did it that way is that is how it comes out on export. And, in the intrerface, a user can be one or more of the values in the list.

So, to achieve this, do i need a line for each value:
Code: Select all
Email  Value List
joe@ansano.com La casa
Joe@ansano.com Primary
joe@ansano.com Elementary


Will that work? Other way to get a series of values in a list to import?
gilsurf
PL Geek
 
Posts: 56
Joined: 12:23pm, Tue 28 Feb, 2006

Postby shumisha » 1:04pm, Thu 08 Jun, 2006

I am confused now by your answer :

multiple selections from a value list (series of checkboxes in 2.10.2


If "multiple selections from a value list", the we are talking about an Attribute of type Select list, from which you can select several lines by holding th Ctrl key

If "series of checkboxes", then we are talking about several Attributes, of type Checkbox, and this is what I just suggested. This is easy to solve.

Please clarify !
shumisha
PL Geek
 
Posts: 82
Joined: 8:06am, Tue 04 Apr, 2006

PreviousNext

Return to Contributions: Plug-ins, Add-ons, Mods

Who is online

Users browsing this forum: No registered users and 3 guests