#!/usr/bin/php -q <?php // $Id$ // PHP script to add user informations for every user which has no user informations at the moment function update_user_informations() { $login_data = parse_ini_file("/etc/origo/origo.conf"); $host = 'localhost'; mysql_connect($host, $login_data['origo_data_mgmt'], $login_data['origo_data_mgmt_password']) or die ("0"); mysql_select_db('origo'); $log = fopen("add_user_information.log", 'a'); $users = mysql_query("SELECT * FROM user"); while ($row = mysql_fetch_row($users)) { $user_id = $row[0]; $user_name = $row[1]; $user_info = mysql_query("SELECT * FROM user_information WHERE user_id=" . $user_id); if (mysql_numrows($user_info) == 1) { fwrite($log, date('Y-m-d, G:i:s') . " - User: " . $user_name . " ID: " . $user_id . " not touched. \n"); } elseif (mysql_numrows($user_info) == 0) { mysql_query("INSERT INTO `user_information` (`user_id`, `registration_date`) VALUES (" . $user_id . ", UNIX_TIMESTAMP())"); fwrite($log, date('Y-m-d, G:i:s') . " - User: " . $user_name . " ID: " . $user_id . " has now an information entry.\n"); } else { fwrite($log, date('Y-m-d, G:i:s') . " - User: " . $user_name . " ID: " . $user_id . " ERROR. \n"); } } mysql_close(); fclose($log); } update_user_informations(); ?>