Pixelpost

Authentic Photoblog Flavour


Go Back   Pixelpost Forum > DEVELOPMENT > Hacks and Modifications

Post Reply
 
Thread Tools
  #21  
Old 02-22-2005, 04:06 PM
mark Offline
pp veteran
 
Join Date: Feb 2005
Location: Atlanta, GA USA
Posts: 89
are you 100% sure its not working. I took your index.php and put it on my server and ran it.....it worked without any errors.

all boxes displayed...

If you still get the error, what happens to cause it...do you just load it or are you clicking something first?
Reply With Quote
  #22  
Old 02-22-2005, 08:49 PM
iblitz Offline
forum loafer
 
Join Date: Feb 2005
Location: Spain
Posts: 9
100 % sure. I just load admin/index.
__________________
My fotoblog: http://iblitz.fotorecull.tk
Another work: http://fotorecull.tk
Reply With Quote
  #23  
Old 02-22-2005, 09:05 PM
mark Offline
pp veteran
 
Join Date: Feb 2005
Location: Atlanta, GA USA
Posts: 89
Hmm...well can you go ahead and first try to load up your old index.php and remake all the changes from scratch?

i load up your admin/index.php file perfectly...no errors...

Are you sure you sent me the broken version?
Reply With Quote
  #24  
Old 02-23-2005, 03:46 AM
iblitz Offline
forum loafer
 
Join Date: Feb 2005
Location: Spain
Posts: 9
I have made a new/fresh installation of Pixelpost, i have reinstalled de multicategory hack and become de same error at line 316.
__________________
My fotoblog: http://iblitz.fotorecull.tk
Another work: http://fotorecull.tk
Reply With Quote
  #25  
Old 02-23-2005, 04:13 PM
mark Offline
pp veteran
 
Join Date: Feb 2005
Location: Atlanta, GA USA
Posts: 89
hmm...this is strange...I guess its possibe it has something to do with your PHP version on your server, but that would be odd considering all the rest works...

I'd say, lets try this:

Take out the piece that was giving the error.....(the piece that is shown in this forum thread...the part that i forgot) and then run it....You mentioned before you were getting checkboxes on update page, but not new image page, right?

Ok, once you have it working without the error, try JUST changing these lines..

Code:
    File Under Category<br />
    <select name="category">
    <?php
    $query = mysql_query("select * from ".$pixelpost_db_prefix."categories order by name");
    while(list($id,$name) = mysql_fetch_row($query)) {
        $name = pullout($name);
        echo "<option value='$id'>$name</option>\n";
        }
    ?>
    </select><p />
to this...(this means that we are not touching that 316 line)

Code:
    File Under Category<br /><br />
    <?php
    $query = mysql_query("select * from ".$pixelpost_db_prefix."categories order by name");
    while(list($id,$name) = mysql_fetch_row($query)) {
        $name = pullout($name);
        echo "<input type=checkbox name=box[] value=".$id."> ".$name."<br />";
        }
    ?>
    <br /><br />
Reply With Quote
  #26  
Old 02-23-2005, 05:10 PM
Anonymous Offline
pixelpost guru
 
Join Date: Oct 2004
Posts: 810
I'm Sorry:
Parse error: parse error, unexpected T_STRING in /home/reculltk/public_html/iblitz/admin/index.php on line 326

PHP Version 4.3.10

I feel to bother. If you want I leave it.
Reply With Quote
  #27  
Old 02-23-2005, 06:43 PM
mark Offline
pp veteran
 
Join Date: Feb 2005
Location: Atlanta, GA USA
Posts: 89
what is at line 326 ? The version of index.php you sent me the other day is not numbered the same as the one you have now..
Reply With Quote
  #28  
Old 02-23-2005, 07:25 PM
andy Offline
pp regular
 
Join Date: Dec 2004
Location: Minnesota, USA
Posts: 29
Mark,

Thanks for writing this. I've been wanting to do it for a while now, but was too lazy. You made my life much easier. I did put in a few further tweaks along with your code. I removed all references to the old category_id in the main image table and deleted that column (this required a change to the browse page code). I also did not include an ID in the new table. I only have the category and image IDs acting as a composite primary key.

Good work!

Andy
Reply With Quote
  #29  
Old 03-02-2005, 01:45 AM
io Offline
pp regular
 
Join Date: Feb 2005
Location: tokio/japan
Posts: 28
hi!
i really like this addon, and am using it on my fotoblog. but there's something wrong with it. some posted images are multiply categorized, and others aren't.

here is my 'how-to-use MutipleCategoriesAddon'. does it seem to be right?

1) after performing "install_assoc.php", rewrite "index.php" as following;
replace
Code:
    if($_GET['x'] == "browse") {
    $thumb_output = "";
    $where = "";
    if($_GET['category'] != "") { $where = "and (category='".$_GET['category']."')"; }
    $query = mysql_query("select id,headline,image from ".$pixelpost_db_prefix."pixelpost where (datetime<='$cdate') $where order by datetime desc");
    while(list($id,$title,$name) = mysql_fetch_row($query)) {
    $title = pullout($title);
    $thumbnail = "thumbnails/thumb_$name";
    $thumb_output .= "<a href='$PHP_SELF?showimage=$id'><img src='$thumbnail' alt='$title' title='$title' class='thumbnails' /></a>";
    }
    $tpl = ereg_replace("<THUMBNAILS>",$thumb_output,$tpl);
    }

    // build browse menu
with

Code:
[color=red]if($_GET['x'] == "browse") {
    $thumb_output = "";
    $where = "";
    if($_GET['category'] != "") {
    $query = mysql_query("select t2.id,headline,image,datetime from ".$pixelpost_db_prefix."catassoc as t1 inner join ".$pixelpost_db_prefix."pixelpost t2 on t2.id = t1.image_id where t1.cat_id = '".$_GET['category']."' order by datetime desc");

    } ELSE IF ($_GET['archivedate'] != "") {
    $where = "and (DATE_FORMAT(datetime, '%Y-%m')='".$_GET['archivedate']."')"; //DATE_FORMAT(foo, '%Y-%m-%d')
    $query = mysql_query("select id,headline,image, datetime from ".$pixelpost_db_prefix."pixelpost where (datetime<='$cdate') $where order by datetime desc");
    } ELSE {

    $query = mysql_query("select id,headline,image from ".$pixelpost_db_prefix."pixelpost where (datetime<='$cdate') order by datetime desc");
    }
    while(list($id,$title,$name) = mysql_fetch_row($query)) {
    $title = pullout($title);
    $thumbnail = "thumbnails/thumb_$name";
    $thumb_output .= "<a href='$PHP_SELF?showimage=$id'><img src='$thumbnail' alt='$title' title='$title' class='thumbnails' /></a>";
    }
    $tpl = ereg_replace("<THUMBNAILS>",$thumb_output,$tpl);
    }

    // build browse menu[/color]
2)rewrite admin/index.php as following;
! There're six parts to be replaced

#1
replace
Code:
    if($_GET['view'] == "") {
    ?>
    <div id='jcaption'>
    Post a New Image</div>
    <div id="content">
    <form method="post" action="<?php echo $PHP_SELF; ?>?x=save" enctype="multipart/form-data">
    Image Title<br />
    <input type="text" name="headline" style="width:95%;" /><p />

    File Under Category<br />
    <select name="category">
    <?php
    $query = mysql_query("select * from ".$pixelpost_db_prefix."categories order by name");
    while(list($id,$name) = mysql_fetch_row($query)) {
    $name = pullout($name);
    echo "<option value='$id'>$name</option>\n";
    }
    ?>
    </select><p />
with

Code:
    [color=red]if($_GET['view'] == "") {
    ?>
    <div id='jcaption'>
    Post a New Image</div>
    <div id="content">
    <form method="post" action="<?php echo $PHP_SELF; ?>?x=save" enctype="multipart/form-data">
    Image Title<br />
    <input type="text" name="headline" style="width:95%;" /><p />

    File Under Category<br /><br />
    <?php
    $query = mysql_query("select * from ".$pixelpost_db_prefix."categories order by name");
    while(list($id,$name) = mysql_fetch_row($query)) {
    $name = pullout($name);
    echo "<input type=checkbox name=box[] value=".$id."> ".$name."<br/>";
    }
    ?>
    <br /><br />[/color]
#2
replace
Code:
// insert post in mysql
$image = $filnamn;
if($status == "ok") {
$query = "insert into ".$pixelpost_db_prefix."pixelpost(id,datetime,headline,body,image, category)
VALUES('NULL','$datetime','$headline','$body','$image','$category')";
$result = mysql_query($query) || die("Error: ".mysql_error());
// done
with

Code:
[color=red]// insert post in mysql
    $image = $filnamn;
    if($status == "ok") {
    $query = "insert into ".$pixelpost_db_prefix."pixelpost(id,datetime,headline,body,image, category)
    VALUES('NULL','$datetime','$headline','$body','$image','$category')";
    $result = mysql_query($query) || die("Error: ".mysql_error());

    $theid = mysql_insert_id(); //Gets the id of the last added image to use in the next "insert"

    foreach($_POST['box'] as $val) {
    $query ="insert into ".$pixelpost_db_prefix."catassoc(id,cat_id,image_id) VALUES('NULL','$val','$theid')";
    $result = mysql_query($query) || die("Error: ".mysql_error());
    }
    // done[/color]
#3
replace

Code:
// view=images
if($_GET['view'] == "images") {
// x=update
if($_GET['x'] == "update") {
$headline = clean($_POST['headline']);
$body = clean($_POST['body']);
$getid = $_GET['imageid'];
$newdatetime = $_POST['newdatetime'];
$category = clean($_POST['category']);
$query = "update ".$pixelpost_db_prefix."pixelpost set datetime='$newdatetime', headline='$headline', body='$body', category='$category' where id='$getid'";
$result = mysql_query($query) ||("Error: ".mysql_error());
echo "<div id='jcaption'>Image update</div>
<div id='content'>Updated image #$getid.</div><p />";
}
with

Code:
 [color=red]if($_GET['view'] == "images") {
    // x=update
    if($_GET['x'] == "update") {
    $headline = clean($_POST['headline']);
    $body = clean($_POST['body']);
    $getid = $_GET['imageid'];
    $newdatetime = $_POST['newdatetime'];

    // Since I really couldnt come up with a better way to do this without checking to see what boxes are still checked
    // since it was created, I decided to just delete all rows in the database and then re-update them. It really does
    // no harm to do it this way
    $query = "delete from ".$pixelpost_db_prefix."catassoc where image_id='$getid'";
    $result = mysql_query($query) ||("Error: ".mysql_error());

    // Now Im adding them back
    foreach($_POST['box'] as $val) {
    $category = $val;
    $query ="insert into ".$pixelpost_db_prefix."catassoc(id,cat_id,image_id) VALUES('NULL','$val','$getid')";
    $result = mysql_query($query) || die("Error: ".mysql_error());
    }

    $query = "update ".$pixelpost_db_prefix."pixelpost set datetime='$newdatetime', headline='$headline', body='$body', category='$category' where id='$getid'";
    $result = mysql_query($query) ||("Error: ".mysql_error());
    echo "<div id='jcaption'>Image update</div>
    <div id='content'>Updated image #$getid.</div><p />";
    }[/color]
#4
replace
Code:
 if($_GET['x'] == "delete") {
    $getid = $_GET['imageid'];
    $images = mysql_query("SELECT image FROM ".$pixelpost_db_prefix."pixelpost where id='$getid'");
    $imagerow = mysql_fetch_array($images);
    $image = $imagerow['image'];
    $file_to_del = "$upload_dir".$imagerow['image'];

    echo "<div id='jcaption'>Post removal / Image deletion / thumbnail deletion</div>
    <div id='content'>";

    $query = "delete from ".$pixelpost_db_prefix."pixelpost where id='$getid'";
    $result = mysql_query($query) ||("Error: ".mysql_error());
    echo "Post deleted.<p />";

    if(unlink($file_to_del)) {
    $image_message = "Image deleted.<p />";
    } else { $image_message = "Could not delete imagefile. You have to do that some other way, with your ftp software perhaps.<p />"; }

    echo $image_message;

    $file_to_del = "../thumbnails/thumb_".$imagerow['image'];
    if(unlink($file_to_del)) {
    $image_message = "Thumbnail deleted.<p />";
    } else { $image_message = "Could not delete thumbnail. You have to do that some other way, with your ftp software perhaps.<p />"; }

    echo $image_message."</div>";
    }
with

Code:
[color=red]if($_GET['x'] == "delete") {
    $getid = $_GET['imageid'];
    $images = mysql_query("SELECT image FROM ".$pixelpost_db_prefix."pixelpost where id='$getid'");
    $imagerow = mysql_fetch_array($images);
    $image = $imagerow['image'];
    $file_to_del = "$upload_dir".$imagerow['image'];

    echo "<div id='jcaption'>Post removal / Image deletion / thumbnail deletion</div>
    <div id='content'>";

    $query = "delete from ".$pixelpost_db_prefix."pixelpost where id='$getid'";
    $result = mysql_query($query) ||("Error: ".mysql_error());

    // Delete the associations for image to be deleted
    $query = "delete from ".$pixelpost_db_prefix."catassoc where image_id='$getid'";
    $result = mysql_query($query) ||("Error: ".mysql_error());

    echo "Post deleted. Associated categories deleted<p />";

    if(unlink($file_to_del)) {
    $image_message = "Image deleted.<p />";
    } else { $image_message = "Could not delete imagefile. You have to do that some other way, with your ftp software perhaps.<p />"; }

    echo $image_message;

    $file_to_del = "../thumbnails/thumb_".$imagerow['image'];
    if(unlink($file_to_del)) {
    $image_message = "Thumbnail deleted.<p />";
    } else { $image_message = "Could not delete thumbnail. You have to do that some other way, with your ftp software perhaps.<p />"; }

    echo $image_message."</div>";
    }
[/color]
#5
replace
Code:
// print out a list over images/posts
if($_GET['id'] == "") {
echo "<div id='jcaption'>Images / Posts - Edit or Delete an image</div>
<div id='content'><ul>";
if($_GET['page'] == "") { $page = "0"; } else { $page = $_GET['page']; }
$pagec = 0;
$images = mysql_query("SELECT * FROM ".$pixelpost_db_prefix."pixelpost ORDER BY datetime DESC limit $page,10");
while(list($id,$datetime,$headline,$body,$image) = mysql_fetch_row($images)) {
$headline = pullout($headline);
echo "<li>
<img src='../thumbnails/thumb_$image' />
<strong>$headline</strong><br />
<a href=\"$PHP_SELF?view=images&id=$id\">[edit]</a>     
<a onclick=\"return confirmSubmit()\" href=\"$PHP_SELF?view=images&x=delete&imageid=$id\">[delete]</a></li>
";
$pagec++;
}
echo "</ul>
with

Code:
[color=red]// print out a list over images/posts
    if($_GET['id'] == "") {
    echo "<div id='jcaption'>Images / Posts - Edit or Delete an image</div>
    <div id='content'><ul>";
    if($_GET['page'] == "") { $page = "0"; } else { $page = $_GET['page']; }
    $pagec = 0;
    $images = mysql_query("SELECT * FROM ".$pixelpost_db_prefix."pixelpost ORDER BY datetime DESC limit $page,100");
    while(list($id,$datetime,$headline,$body,$image) = mysql_fetch_row($images)) {
    $headline = pullout($headline);
    echo "<li>
    <img src='../thumbnails/thumb_$image' />
    <strong>$headline</strong><br />
    <a href=\"$PHP_SELF?view=images&id=$id\">[edit]</a>     
    <a onclick=\"return confirmSubmit()\" href=\"$PHP_SELF?view=images&x=delete&imageid=$id\">[delete]</a>  
    ";
    $category_list = mysql_query("SELECT t2.name FROM ".$pixelpost_db_prefix."catassoc t1 inner join ".$pixelpost_db_prefix."categories t2 on t1.cat_id = t2.id where t1.image_id = '$id'");
    while(list($category_name) = mysql_fetch_row($category_list)) {
    $category_name = pullout($category_name);
    echo "[$category_name]";
    }
    echo "</li>";

    $pagec++;
    }

    echo "</ul>
[/color]
#6
replace
Code:
<div id='jcaption'>
Edit Image
</div>
<div id='content'>
<form method='post' action='$PHP_SELF?view=images&x=update&imageid=$getid'>
Title<br />
<input type='text' name='headline' value='$headline' style='width:300px;' /><p />
Text / description<br />
<textarea name='body' style='width:95%;height:100px;'>$body</textarea><p />
Category<br />
<select name='category'>
";
$query = mysql_query("select name from ".$pixelpost_db_prefix."categories where id='$category'");
$query = mysql_fetch_array($query);
$nice_category = pullout($query['name']);
echo "
<option value='$category'>$nice_category</option>
<option value=''> - Set New Category - </option>
";
$query = mysql_query("select * from ".$pixelpost_db_prefix."categories order by name");
while(list($id,$name) = mysql_fetch_row($query)) {
$name = pullout($name);
echo "<option value='$id'>$name</option>\n";
}
echo "
</select><p />
with

Code:
[color=red]<div id='jcaption'>
Edit Image
</div>
<div id='content'>
<form method='post' action='$PHP_SELF?view=images&x=update&imageid=$getid'>
Title<br />
<input type='text' name='headline' value='$headline' style='width:300px;' /><p />
Text / description<br />
<textarea name='body' style='width:95%;height:100px;'>$body</textarea><p />
Category<br />
";
$query = mysql_query("select t1.id, name, image_id from ".$pixelpost_db_prefix."categories as t1 left join ".$pixelpost_db_prefix."catassoc t2 on t2.cat_id = t1.id and t2.image_id='$getid'");
while(list($id,$name,$image_id) = mysql_fetch_row($query)) {
$name = pullout($name);
$id = pullout($id);
if ($image_id != "") {
echo "<input type=checkbox CHECKED name=box[] value=".$id."> ".$name."<br/>";
} else {echo "<input type=checkbox name=box[] value=".$id."> ".$name."<br/>";}
}
echo "
<p />[/color]
Sorry to have made the text long.

And this is the way i have done for this addon. it seems to work fine, but as I mentioned before, some posted images are multiplly categorized, and some aren't.

Could someone give me a hint?

io
Reply With Quote
  #30  
Old 03-02-2005, 05:12 AM
mark Offline
pp veteran
 
Join Date: Feb 2005
Location: Atlanta, GA USA
Posts: 89
without going through all the above stuff...im gonna assume its very similar to my doc??

as to the post that are not multi categorized, are you postive that they have been assigned more then one category?
Reply With Quote
Post Reply


Thread Tools




All times are GMT. The time now is 11:27 AM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. | Style Design: d3 designs