[Dehs-devel] r66 - trunk

atomo64-guest at alioth.debian.org atomo64-guest at alioth.debian.org
Sun Dec 9 02:03:33 UTC 2007


Author: atomo64-guest
Date: 2007-12-09 02:03:33 +0000 (Sun, 09 Dec 2007)
New Revision: 66

Modified:
   trunk/dehs_pg.php
Log:
Use pg_escape_string instead of addslashes
Reduce the work done by update_bogus() to the minimum

Modified: trunk/dehs_pg.php
===================================================================
--- trunk/dehs_pg.php	2007-12-09 01:31:36 UTC (rev 65)
+++ trunk/dehs_pg.php	2007-12-09 02:03:33 UTC (rev 66)
@@ -137,7 +137,7 @@
             unlink($localfile);
             if ($watch!=NULL) {
                 $watch=iconv("ISO-8859-1","UTF-8",$watch);
-                $watch= addslashes($watch);
+                $watch= pg_escape_string($watch);
                 pg_exec($db, "UPDATE pkgs SET watch='" . $watch . "', md5_diff='" . $res_array[md5_atsource] . "' where name='" . $res_array[name] . "' AND dist='" . $res_array[dist] ."'") or die_status("Query error");
             }
             else pg_exec($db, "UPDATE pkgs SET watch=NULL, md5_diff='" . $res_array[md5_atsource] . "' where name='" . $res_array[name] . "' AND dist='" . $res_array[dist] ."'") or die_status("Errore nella query");
@@ -403,7 +403,7 @@
                 #print "\rName => $matches[1] Install => $matches[2] Vote => $matches[3]";
                 @pg_exec($db, "UPDATE binpkgs SET pop_inst='$matches[2]',pop_vote='$matches[3]' WHERE bin_name='$matches[1]'");
                 $prcessed++;
-                $elapsed_time=time()-$tin;
+                /*$elapsed_time=time()-$tin;
                 if (($elapsed_time % 20)==0 AND $updtime!=$elapsed_time) {
                     $updtime=$elapsed_time;
                     $wprocessed=$processed-$wprocessed;
@@ -412,8 +412,8 @@
                     $countdown=(34701- $processed)/$avg_time;
                     $last_time=time();
                 }
-                //print "\rProcessing Popcon: " .  date("i:s",$countdown=$countdown-(time()-$last_time))   . " =>" . (34701-$processed) . " Media $avg_time";
-                $last_time=time();
+                print "\rProcessing Popcon: " .  date("i:s",$countdown=$countdown-(time()-$last_time))   . " =>" . (34701-$processed) . " Media $avg_time";
+                $last_time=time();*/
             }
         }
         #pg_exec($db, "COMMIT") OR die_status("Impossibile commsionare la transazione");
@@ -457,7 +457,6 @@
     $tot=pg_numrows($rsql);
     while ($res_array=pg_fetch_array($rsql)) {
         $uscan_res=uscan_foo($res_array['name'],$res_array['version'],$res_array['watch']);
-        if($uscan_res[1] !=null) $uscan_res[1]=addslashes($uscan_res[1]);
         #print $uscan_res[0] . "\n Name => $res_array[name]\n";
         $version=$res_array[version];
         print "\rVersion=>" . $uscan_res[3];
@@ -468,7 +467,10 @@
         else $keep_changes=0;
         $up_url=iconv("ISO-8859-1","UTF-8",$uscan_res[2]);
         $up_version=iconv("ISO-8859-1","UTF-8",$uscan_res[0]);
-        $watch_warn=iconv("ISO-8859-1","UTF-8",$uscan_res[1]);
+        $watch_warn='';
+        if($uscan_res[1] != null) {
+            $watch_warn=pg_escape_string(iconv("ISO-8859-1","UTF-8",$uscan_res[1]));
+        }
         pg_exec($db, "UPDATE pkgs SET up_version='" . $up_version . "',up_url='" . $up_url . "', watch_warn='" . $watch_warn . "',keep_changes='$keep_changes', wwiz_version=NULL, wwiz_type=NULL, wwiz=NULL, updated='$updated' WHERE id=$res_array[id]") or die_status("Error in update pkgs upstream");
         #print "\rUpdated " . $res_array['name'] .  " => $updated Up Version => ". $uscan_res[0];
         print "\tUpstream left => " . $tot --;
@@ -554,9 +556,9 @@
             $up_changes=rtrim(implode("\n",$up_changes));
             if ($cmdres==0 AND strlen($up_changes)>20) {
                 $sw=true;
-                $up_changes=addslashes($up_changes);
                 $conv_res=iconv("ISO-8859-1","UTF-8",$up_changes);
                 if ($conv_res) $up_changes=$conv_res;
+                $up_changes=pg_escape_string($up_changes);
                 $up_changes_sql="UPDATE pkgs SET up_changes='$up_changes', keep_changes='f' WHERE id=$res_array[id]";
                 pg_exec($db,$up_changes_sql);
                 #print "\nFound $filename on $res_array[up_url]\n";
@@ -878,22 +880,14 @@
     "X-Mailer: PHP/" . phpversion());
 }
 function update_bogus() {
-    global $email_all;
+    global $email_all,$dbconn;
     $intime=gmdate('D, d M Y H:i:s \C\E\S\T',time()+3600*2);
-    db_add('',false);
-    dl_popcon();
-    db_popcon();
-
-    global $dbconn;
     check_db();
     $db = pg_pconnect($dbconn);
     $sql="SELECT name FROM pkgs WHERE up_version='' AND watch!=''";
     $rsql=pg_exec($db, $sql);
     $res_array=pg_fetch_all($rsql);
     pg_close($db);
-
-    dl_diffs();
-    db_up_error();
     if ($res_array !== false) {
         foreach ($res_array as $entry) {
             db_upstream($entry['name']);




More information about the Dehs-devel mailing list