Also folgendes wird ausgegeben;
Und wie gesagt, der Löschencode sieht so aus;
HTML:
<input type='hidden' name='linenumber' value='1'>
<br>
<table width='100%' bgcolor='#e9e9e9' style='border-width: 2px; border-style: dotted; border-color: #ff7b10;'>
<tr>
<td width='100%'>
<font color='#ff7b10'><b>Test5:</b></font> <a href='http://www.test.de' target='_blank'>http://www.test.de</a>
<br>
<font color='#150185'>Test</font>
</td>
<td valign='top'>
<input type='submit' name='delete_projects' class='button' style='width: 80px; color: #FF0000;' value='Löschen'>
</td>
</tr>
</table>
<input type='hidden' name='linenumber' value='2'>
<br>
<table width='100%' bgcolor='#e9e9e9' style='border-width: 2px; border-style: dotted; border-color: #ff7b10;'>
<tr>
<td width='100%'>
<font color='#ff7b10'><b>Test4:</b></font> <a href='http://www.test.de' target='_blank'>http://www.test.de</a>
<br>
<font color='#150185'>Test</font>
</td>
<td valign='top'>
<input type='submit' name='delete_projects' class='button' style='width: 80px; color: #FF0000;' value='Löschen'>
</td>
</tr>
</table>
<input type='hidden' name='linenumber' value='3'>
<br>
<table width='100%' bgcolor='#e9e9e9' style='border-width: 2px; border-style: dotted; border-color: #ff7b10;'>
<tr>
<td width='100%'>
<font color='#ff7b10'><b>Test3:</b></font> <a href='http://www.test.de' target='_blank'>http://www.test.de</a>
<br>
<font color='#150185'>Test</font>
</td>
<td valign='top'>
<input type='submit' name='delete_projects' class='button' style='width: 80px; color: #FF0000;' value='Löschen'>
</td>
</tr>
</table>
<input type='hidden' name='linenumber' value='4'>
<br>
<table width='100%' bgcolor='#e9e9e9' style='border-width: 2px; border-style: dotted; border-color: #ff7b10;'>
<tr>
<td width='100%'>
<font color='#ff7b10'><b>Test2:</b></font> <a href='http://www.test.de' target='_blank'>http://www.test.de</a>
<br>
<font color='#150185'>Test</font>
</td>
<td valign='top'>
<input type='submit' name='delete_projects' class='button' style='width: 80px; color: #FF0000;' value='Löschen'>
</td>
</tr>
</table>
<input type='hidden' name='linenumber' value='5'>
<br>
<table width='100%' bgcolor='#e9e9e9' style='border-width: 2px; border-style: dotted; border-color: #ff7b10;'>
<tr>
<td width='100%'>
<font color='#ff7b10'><b>Test1:</b></font> <a href='http://www.test.de' target='_blank'>http://www.test.de</a>
<br>
<font color='#150185'>Test</font>
</td>
<td valign='top'>
<input type='submit' name='delete_projects' class='button' style='width: 80px; color: #FF0000;' value='Löschen'>
</td>
</tr>
</table>
Und wie gesagt, der Löschencode sieht so aus;
PHP:
if (isset($_POST['delete_projects']))
{
##################################################################
$intLineNumber = intval($_POST['linenumber']);
$strSourceFile = "intern/projects.txt";
$strDestFile = "intern/_projects.tmp";
$rscSource = fopen($strSourceFile, 'r');
if( is_resource($rscSource) )
{
$rscDestination = fopen($strDestFile, 'w+');
$intLineCounter = 0;
while(! feof($rscSource) )
{
$intLineCounter++;
$strLine = fgets($rscSource, 4096);
if( $intLineCounter !== $intLineNumber )
{
fputs($rscDestination, $strLine);
}
else
{
$arrLine = explode('|', $strLine);
$strImage = 'intern/images/'. $arrLine[0] . '.' . $arrLine[3];
if( is_file($strImage) )
unlink($strImage);
}
}
fclose($rscSource);
fclose($rscDestination);
unlink($strSourceFile);
rename($strDestFile, $strSourceFile);
}
##################################################################
}