Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: spawner2.php the revenge :)  (Read 4918 times)

0 Members and 1 Guest are viewing this topic.

ypp

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 29
spawner2.php the revenge :)
« on: December 01, 2005, 12:28:07 am »

Hello, I'm not a php programmer but I'm trying to modify spawner.php to get categories in batch mode
because I've to add a lot of categories.

Example:

North America (cat)
       Cars (sub-cat)
       Design (sub-cat)
       Architecture (sub-cat)
       Food (sub-cat)
       etc. etc... 40 sub-categories


    Asia (cat)
       Cars (sub-cat)
       Design (sub-cat)
       Architecture (sub-cat)
       Food (sub-cat)
       etc. etc... 40 sub-categories


The same thing is for Europe, Hispano América, Oceania and Africa...everyone of these with the same 40 sub-categories...
So I modified spawner.php but when I try to upload a file with the category list I get this error: "There was an error while processing a database query"


Below the spawner2.php code:

Code: [Select]
<?php

define
('IN_COPPERMINE'true);

require(
'include/init.inc.php');

if (!
GALLERY_ADMIN_MODEcpg_die(ERROR$lang_errors['access_denied'], __FILE____LINE__);


pageheader('Category spawner');

starttable('100%''Category spawner');


if (
count($_FILES)){

if ($_FILES['userfile']['error']) die('Upload error ' $_FILES['userfile']['error']);


$data file($_FILES['userfile']['tmp_name']);
$category = (int) $_POST['category'];
$description addslashes($_POST['description']);

foreach ($data as $id => $category){
$result cpg_db_query("INSERT INTO {$CONFIG['TABLE_CATEGORIES']} (`title`, `category`, `description`) VALUES ('$title', '$category', '$description')");
$status mysql_affected_rows() ? "Category '$category' added" "<font color=\"red\">Category'$category' not added</font>" ;
echo '<tr><td class="tableb" align="center">'.$status.'</td></tr>';
}

} else {

function get_subcat_data($parent$ident '')
{
     global $CONFIG$CAT_LIST;

     $result cpg_db_query("SELECT cid, name, description FROM {$CONFIG['TABLE_CATEGORIES']} WHERE parent = '$parent' AND cid != 1 ORDER BY pos");
     if (mysql_num_rows($result) > 0) {
         $rowset cpg_db_fetch_rowset($result);
         foreach ($rowset as $subcat) {
             $CAT_LIST[] = array($subcat['cid'], $ident $subcat['name']);
             get_subcat_data($subcat['cid'], $ident '&nbsp;&nbsp;&nbsp;');
         }
     }
}

$CAT_LIST = array();
     $CAT_LIST[] = array(0'* No category *');
     get_subcat_data(0'');

$cats '<select name="category" class="listbox">';

     foreach($CAT_LIST as $category) {
         $cats .='<option value="' $category[0] . '"' . ($cat == $category[0] ? ' selected''') . ">" $category[1] . "</option>\n";
     }

$cats .= '</select>';


echo <<< EOT
<tr>
 <td class="tableb" align="center">

<form action="spawner2.php" METHOD="post" enctype="multipart/form-data">
<p>Upload a file to import<input name="userfile" type="file" size="50" /></p>
<p>Default category description: <input type="text" name="description" size="50" value="" /></p>
<p>
$cats</p>
<br />
<p><input type="submit" value="Spawn2" /></p>
</form>
</td>
</tr>

EOT;


}

endtable();
pagefooter();
?>


Please, Help ???
Logged

Nibbler

  • Guest
Re: spawner2.php the revenge :)
« Reply #1 on: December 01, 2005, 12:41:23 am »

Enable debug mode, that will tell you what the problem is. I would think you'd need to change `title` to `name` and `category` to `parent`.

PS: what does this have to do with plugins ?
Logged

ypp

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 29
Re: spawner2.php the revenge :)
« Reply #2 on: December 01, 2005, 01:12:20 am »

Thank you Nibbler :) , I've tried to change them and now it's possible to upload the file but for every new sub-cat I only obtain a blank row in the cat list... at the moment for me it's all difficult...

Scuse me, for the mistaken thread... :(
Logged
Pages: [1]   Go Up
 

Page created in 0.017 seconds with 20 queries.