0

Is there any way I can export user details from joomla database such as name, password, email address, and import them into owncloud database via a cronjob?

3
  • Have a look in the ROOT/cli directory where you will find a couple of scripts that you base base your own script on.
    – Lodder
    Aug 17, 2016 at 17:47
  • hi, thanks for the reply, I'll take a look but first i need to identify whether its possible, someone told me the owncloud and joomla encoding algorithm for password generation is different Aug 17, 2016 at 17:51
  • I don't know about owncloud, so perhaps it may be easier for you to create a simple PHP file with 1 single variable <?php $foo = 'bar'; ?> and then try to push this value to the database.
    – Lodder
    Aug 17, 2016 at 17:54

1 Answer 1

1

There might be others, more elegant ways to do it but I did it pretty simple - I created a non-Joomla PHP file, which connects to Joomla's DB and dumps user table into a CSV file. I then scheduled to open this page with CRON.

Notice the headers for pushing the file as a download are commented out, so the file will be created and saved in the same directory with your PHP file.

<?php

// Database Connection

$host="localhost";
$uname="dbuser";
$pass="dbP@$$";
$database = "joomla_db"; 

$connection=mysql_connect($host,$uname,$pass); 

echo mysql_error();

//or die("Database Connection Failed");
$selectdb=mysql_select_db($database) or 
die("Database could not be selected"); 

$result=mysql_select_db($database)
or die("database cannot be selected <br>");

$output = "";
$table = "ab7cd_users"; // Enter Your Table Name 
$sql = mysql_query("select id,name,username,email,block from $table");
$columns_total = mysql_num_fields($sql);

// Get The Field Name

for ($i = 0; $i < $columns_total; $i++) {
$heading = mysql_field_name($sql, $i);
$output .= $heading."\t";
}
$output = substr($output, 0, -1);
$output .="\r\n";

// Get Records from the table

while ($row = mysql_fetch_array($sql)) {
for ($i = 0; $i < $columns_total; $i++) {
$output .=$row["$i"]."\t";
}
$output = substr($output, 0, -1);
$output .="\r\n";
}

// Download the file

$filename = "users.csv";
/*
header('Content-type: application/csv');
header('Content-Disposition: attachment; filename='.$filename);

echo $output;
*/

file_put_contents ($filename , $output);

echo "Success";

exit;

?>
2
  • hi, thanks for the reply, that looks like a good script, i have one similar, what would you suggest to upload the data into owncloud db? and do you know whether importing joomla! passwords will work in owncloud? Aug 17, 2016 at 21:45
  • I am not familiar with owncloud but I doubt that it will work with Joomla password encryption algorithm. Aug 18, 2016 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.