+<?php
+/************************************************************************
+ * Mailer v0.2.1-FINAL Start: 07/04/2011 *
+ * =================== Last change: 07/04/2011 *
+ * *
+ * -------------------------------------------------------------------- *
+ * File : fix_user_points.php *
+ * -------------------------------------------------------------------- *
+ * Short description : Fixes dublicate entries in user_points table *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung : Repariert doppelte Eintraege in user_points *
+ * -------------------------------------------------------------------- *
+ * $Revision:: $ *
+ * $Date:: $ *
+ * $Tag:: 0.2.1-FINAL $ *
+ * $Author:: $ *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2009 by Roland Haeder *
+ * Copyright (c) 2009 - 2011 by Mailer Developer Team *
+ * For more information visit: http://www.mxchange.org *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
+ * MA 02110-1301 USA *
+ ************************************************************************/
+
+// Some security stuff...
+if (!defined('__SECURITY')) {
+ die();
+} // END - if
+
+// Get all user points
+$result = SQL_QUERY('SELECT
+ `userid`, `points`
+FROM
+ `{?_MYSQL_PREFIX?}_user_points`
+WHERE
+ `ref_depth`=0
+ORDER BY
+ `userid` ASC', __FILE__, __LINE__);
+
+// Do we have entries? (we should have!)
+if (!SQL_HASZERONUMS($result)) {
+ // Load row by row
+ while ($row = SQL_FETCHARRAY($result)) {
+ // We have to fix this amount, so first pay it directly
+ addPointsDirectly('user_null_fix', $row['userid'], $row['points']);
+ } // END - while
+} // END - if
+
+// Free result
+SQL_FREERESULT($result);
+
+// Remove all entries
+SQL_QUERY('DELETE LOW_PRIORITY FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `ref_depth`=0', __FILE__, __LINE__);
+
+// [EOF]
+?>