--- /home/nozof/Téléchargements/manage-database_launchpad.php 2010-10-22 15:27:28.739558930 +0200
+++ /home/nozof/manage-database_beta1.php 2010-10-21 13:11:08.000000000 +0200
@@ -93,6 +93,15 @@
$site_membre = $value[2];
$statut_membre = $value[3];
$user_id = preg_replace("( )", "_", $nom_membre);
+ $user_id = cleanString($user_id);
+
+ $rs0 = $core->con->select(
+ 'SELECT COUNT(1) '.
+ 'FROM '.$core->prefix.'user WHERE user_id =\''.$user_id.'\'');
+ if ($rs0->f('nb') > 0) {
+ $output = '
'.T_("Two users have the same name, impossible to import. Please try again. Username : ".$user_id).'
';
+ break;
+ }
$cur = $core->con->openCursor($core->prefix."user");
$cur->user_id = $user_id;
@@ -135,10 +144,17 @@
foreach($table['content'] as $key => $value){
$url_flux = $value[0];
$num_membre = $value[1];
- $last_updated = timestamp_to_mysqldatetime($value[2]);
- $status_flux = $value[3];
+ $last_updated = timestamp_to_mysqldatetime($value[3]);
+ $status_flux = $value[4];
$user_id = $tables['membre']['content'][$num_membre][0];
$user_id = preg_replace("( )", "_", $user_id);
+ $user_id = cleanString($user_id);
+ # We build the url of flux
+ $parse = @parse_url($url_flux);
+ if (!$parse['scheme']){
+ $site_membre = $tables['membre']['content'][$num_membre][2];
+ $url_flux = $site_membre.$url_flux;
+ }
$sql = "SELECT site_id FROM ".$core->prefix."site WHERE user_id = '".$user_id."'";
$rs = $core->con->select($sql);
@@ -155,7 +171,7 @@
$cur->user_id = $user_id;
$cur->site_id = $site_id;
$cur->feed_url = $url_flux;
- $cur->feed_checked = $last_checked;
+ $cur->feed_checked = $last_updated;
$cur->feed_status = $status_flux;
$cur->feed_trust = 1;
$cur->created = array(' NOW() ');
@@ -186,29 +202,38 @@
$article_score = $value[6];
$user_id = $tables['membre']['content'][$num_membre][0];
$user_id = preg_replace("( )", "_", $user_id);
+ $user_id = cleanString($user_id);
+ # We build the url of article
+ $parse = @parse_url($article_url);
+ if (!$parse['scheme']){
+ $site_membre = $tables['membre']['content'][$num_membre][2];
+ $article_url = $site_membre.$article_url;
+ }
$sql = "SELECT feed_id FROM ".$core->prefix."feed WHERE user_id = '".$user_id."'";
$rs = $core->con->select($sql);
- $feed_id = $rs->f('feed_id');
- $rs3 = $core->con->select(
- 'SELECT MAX(post_id) '.
- 'FROM '.$core->prefix.'post '
- );
- $next_post_id = (integer) $rs3->f(0) + 1;
- $cur = $core->con->openCursor($core->prefix."post");
- $cur->post_id = $next_post_id;
- $cur->user_id = $user_id;
- $cur->feed_id = $feed_id;
- $cur->post_pubdate = $article_pub;
- $cur->post_permalink = $article_url;
- $cur->post_title = $article_titre;
- $cur->post_content = $article_content;
- $cur->post_status = $article_statut;
- $cur->post_score = $article_score;
- $cur->created = array(' NOW() ');
- $cur->modified = array(' NOW() ');
- $cur->insert();
+ if ($rs->count() > 0) {
+ $feed_id = $rs->f('feed_id');
+ $rs3 = $core->con->select(
+ 'SELECT MAX(post_id) '.
+ 'FROM '.$core->prefix.'post '
+ );
+ $next_post_id = (integer) $rs3->f(0) + 1;
+ $cur = $core->con->openCursor($core->prefix."post");
+ $cur->post_id = $next_post_id;
+ $cur->user_id = $user_id;
+ $cur->feed_id = $feed_id;
+ $cur->post_pubdate = $article_pub;
+ $cur->post_permalink = $article_url;
+ $cur->post_title = $article_titre;
+ $cur->post_content = $article_content;
+ $cur->post_status = $article_statut;
+ $cur->post_score = $article_score;
+ $cur->created = array(' NOW() ');
+ $cur->modified = array(' NOW() ');
+ $cur->insert();
+ }
}
break;
case "votes":
@@ -330,7 +355,8 @@
-
=T_('If you apply the content of one of this file, this action can not be cancelled');?>
+
=T_('If you apply the content of one of this file, this action can not be cancelled');?>
+