}\r
\r
function saveExisting() {\r
- if (($f = fopen($this->infoCSVConst, 'r')) == false) return false; // error\r
+ if (($f = fopen($this->infoCSVConst, 'r+')) == false) return false; // error\r
$index = 0;\r
- $indexSave = 0;\r
while (!feof($f))\r
{\r
+ $index = ftell($f);\r
$d = fgetcsv($f, 4096);\r
- $index++;\r
- if ($d[0] == $this->id)\r
+ if ($d[0] == $this->id)\r
{\r
- fclose($f);\r
- if (($f = fopen($this->infoCSVConst, 'r+')) == false) return false; // error\r
- while ($indexSave!=($index-1)) { fgetcsv($f, 4096); $indexSave++; }\r
- fputcsv($f, array($this->id, $this->tema, $this->url, $this->autor, $this->comentario, $this->ranking, $this->fecha));\r
+ fseek($f,$index);\r
+ fputcsv($f, array($this->id, $this->tema, $this->url, $this->autor, $this->comentario, $this->ranking, $this->fecha));\r
fclose($f);\r
return true;\r
}\r
return $resultado;\r
}\r
\r
- function modificar( $pId, $pTema, $pURL, $pAutor, $pComentario ) {\r
- $this->saveLoadThis( $pId, $pTema, $pURL, $pAutor, $pComentario );\r
- $resultado = "";\r
- if (!$this->saveExisting()) {\r
- $resultado = "<strong>ERROR</strong> al modificar la informacion. Revise que los parametros sean los adecuados";\r
- file_log_add($pAutor,$resultado);\r
- } else {\r
- file_log_add($pAutor,"Se modificó la información");\r
- }\r
- return $resultado;\r
- }\r
-\r
function toHTML() {\r
?><tr>\r
<td><img src="<?php echo $this->tema_icono;?>" border="0" alt="icono tema"/></td>\r
}\r
\r
function incrementarRanking() {\r
- file_log_add($_SESSION['user']->getId(),"Se visitó " . $this->url);\r
+ //file_log_add($_SESSION['user']->getId(),"Se visitó una informacion (" . $this->url . ")");\r
$this->ranking = $this->ranking + 1;\r
return $this->saveExisting();\r
}\r