Hei again.. new problem. I would like to add "updating" stuff for this picture moderating. Like if there show.php?id=(numberofpic) then it opens show.php page, where is possible to moderate(over moderate)... I try, but I dont figure it out. As like I want to add this field, who have moderated this picture.. :(

<?php

#$cur_server_time = date("U");
#$allowed_time = $cur_server_time-172800;
#mysql_query("DELETE FROM DSL_votes where servertime<'$allowed_time' and vote != '10'");

//actions

// approving picture
if($_POST['allow']){
$id=$_GET['id'];
$sqlallow=mysql_query("update photo set active='1', mode='$curUserID' where id='$id'");
$sql_modestats=mysql_query("update myuser set modenud=modenud+1 where ID='$curUserID'"); 

// adding to moderator point

//võtame pildi omaniku ID:
$v_userID = mysql_query("SELECT userid FROM photo WHERE id='$id' AND active='1'");
		$ccc = mysql_fetch_array($v_userID);
		$vuserID = $ccc[0];
//saadame pildi omanikule teate:		
$mailtext = "Your <a href=\"pictures.php?id=".$id."\"><b>piicture</b></a> is approved!";
$lisanuderi=mysql_query("INSERT INTO DSL_notes ( id , `date` , `notetoid` , `notefromid` 

, `text`) VALUES ( NULL , '".date("d.m.Y - H:i")."',  '$vuserID', '$curUserID', 

'$mailtext')");

//how much pictures have this user
		$sqlcp = mysql_query("select count(*) from photo where 

userid='$vuserID'");
		$mitupilti1 = mysql_fetch_row($sqlcp);
		$mitupilti = $mitupilti1[0];
		
		//updating database
		mysql_query("UPDATE myuser SET pilte = '$mitupilti' WHERE ID = 

'$vuserID'");
		mysql_query("where myuser * b_day, b_month, b_year = '$synnip2ev' WHERE 

ID = '$vuserID'");


//adding activityt:
$updateakt2 = mysql_query("UPDATE myuser SET aktiivsus = aktiivsus + 0.04 WHERE ID = 

'$curUserID'");
}

// picture not approved / by moderator
if($_POST['deny']){
$id=$_GET['id'];
$pohjus=addslashes($_POST['reason']);
	
	if($_POST['reason2']){
	$pohjus=$pohjus." (".addslashes($_POST['reason2']).")";
	}

	if(!empty($pohjus)){
	$sqlallow=mysql_query("update photo set active='2', reason='$pohjus', 

mode='$curUserID' where id='$id'");
	$delsrc=$_GET['src'];
	$f="gallery/".$delsrc;
		#if(is_file($f)&&unlink($f)){
		if(is_file($f)){
		
		mysql_query("DELETE FROM DSL_comments WHERE img_id = '$id' AND img_src = 

'$delsrc'") or die("Error: ".mysql_error()); 
		// deleting comments
		
		mysql_query("DELETE FROM DSL_votes WHERE votetoimg = '$id' AND 

voteimg_src = '$delsrc'") or die("Error: ".mysql_error()); 
		// deleting rates


//lets take user ID:
$v_userID = mysql_query("SELECT userid FROM photo WHERE id='$id' AND reason='$pohjus'");
		$ccc = mysql_fetch_array($v_userID);
		$vuserID = $ccc[0];
//send alert to user:		
$mailtext = "Your <a href=\"pictures.php\"><b>picture</b></a> is not approved <br>Reason: ".$pohjus; 
$lisanuderi=mysql_query("INSERT INTO DSL_notes ( id , `date` , `notetoid` , `notefromid` 

, `text`) VALUES ( NULL , '".date("d.m.Y - H:i")."',  '$vuserID', '$curUserID', 

'$mailtext')");

//how many pictures have user? Et uuendada piltide arvu myuser-is
		$sqlcp = mysql_query("select count(*) from photo where 

userid='$vuserID'");
		$mitupilti1 = mysql_fetch_row($sqlcp);
		$mitupilti = $mitupilti1[0];
		
		//update pictures in database:
		mysql_query("UPDATE myuser SET pilte = '$mitupilti' WHERE ID = 

'$vuserID'");


		mysql_query("update myuser set keelanud=keelanud+1 where 

ID='$curUserID'");
		//adding +1 that moderator have not approved pic
		
		//adding activity:
		$updateakt2 = mysql_query("UPDATE myuser SET aktiivsus = aktiivsus + 

0.03 WHERE ID = '$curUserID'");
		}
	}
}

if($_POST['special']){
$id=$_GET['id'];
$eriline=addslashes($_POST['spec_com']);
$sqlallow=mysql_query("update photo set active='1', reason='$eriline', special='1', 

mode='$curUserID' where id='$id'");
$sql_modestats=mysql_query("update myuser set lisaeri=lisaeri+1 where ID='$curUserID'"); 
// adding point to moderator


//lets take picture owner ID:
$eri_userID = mysql_query("SELECT userid FROM photo WHERE special='1' AND 

reason='$eriline' AND id='$id'");
		$ccc = mysql_fetch_array($eri_userID);
		$eriuserID = $ccc[0];
//send alert to user of added to specials:		
$mailtext = "Your <a href=\"picture.php?id=".$id."\"><b>picture</b></a> is added to <a href=\"special.php\"><b>specials</b></a>!"; 
$eri_date = date("d.m.Y - H:i");
$lisanuderi=mysql_query("INSERT INTO DSL_notes ( id , `date` , `notetoid` , `notefromid` 

, `text`) VALUES ( NULL , '$eri_date',  '$eriuserID', '$curUserID', '$mailtext')");

//adding activity to user:
$updateakt2 = mysql_query("UPDATE myuser SET aktiivsus = aktiivsus + 0.04 WHERE ID = 

'$curUserID'");
}



//pictures (are new ones?)
$andmedimg = mysql_query("select * from photo where active='0' order by id LIMIT 1");
$countimg = mysql_num_rows($andmedimg);

if($countimg > 0){

while($DSL_img = mysql_fetch_array($andmedimg)){
	$img_id = $DSL_img["id"];
	$src = $DSL_img["src"];
	$subject = htmlspecialchars(stripslashes($DSL_img["subject"]));
	$comment = stripslashes($DSL_img["comment"]);
	$user_id = $DSL_img["userid"];
	$name_from = $DSL_img["username"];
	$date = $DSL_img["date"];
	$active = $DSL_img["active"];
	$reason = $DSL_img["reason"];
	$imgvoters = $DSL_img["numvotes"];
	$imgvotes = $DSL_img["allvotes"];
	$imgscore = $DSL_img["score"];	
	$usersex = $DSL_img["usersex"];	
	$show_username = showusername($user_id, "index");
}
$vanus = floor( ((date("Y")*10000+date("m")*100+date("d")) - 

($b_year*10000+$b_month*100+$b_day)) / 10000 );
?>
Nothing to see.<br>
<br>
<?php echo $show_username; ?> (<?php 
		echo "$b_day $b_month $b_year (<b>$old</b>)";	
		?>)| added: <?php echo"$date"; ?><br>
<a href="user.php?id=<?php echo"$user_id"; ?>"><img src="gallery/<?php echo"$src"; 

?>" border="0"></a><br>
<font class=imgsubject><?=$subject?></font><br>
<?=$comment?><br><br>





<TABLE border="0" width="640">
<tr>
<td align="left"><font class="ankeedipealkirjad">User pictures:</font><br><br></td>
</tr>

<TR>
        <TD align="left" valign="top" style="padding: 3px;">
		
        <?php
$result = mysql_query($query);
        $andmedimg3 = mysql_query("select * from photo where userid = '$user_id' AND 

active = '1' order by id desc");
        echo '<TABLE>';
        $i=0;
        while($DSL_img3 = mysql_fetch_row($andmedimg3)){
                $img_id3 = $DSL_img3[0];
                $img_src3 = $DSL_img3[1];
                $img_subjec3t = $DSL_img3[2];
                $img_comment23 = $DSL_img3[3];
                $img_userid3 = $DSL_img3[4];
                $img_date3 = $DSL_img3[5];
                $img_active3 = $DSL_img3[6];
                $img_reason3 = htmlspecialchars(stripslashes($DSL_im3[12]));
                $img_comment3=stripslashes($img_comment23);
                $img_subject3=htmlspecialchars(stripslashes($img_subject23));
                if ($i == 0){
                echo '<TR>';
                }
                echo"<TD align=center valign=top><a href=\"show.php?

id=".$img_id3."\"><img src=\"thumb/".$img_src3."\" border=0></a></TD>";
                if($i>=4){
                echo '</TR>';
                $i=0;
                }else{
                $i++;
                }
        }
        echo '</TABLE>';
                ?>        </TD>
</TR>
</TABLE>

<form name="allowf" method="post" action="zshow.php?id=<?=$img_id?>">
<input class="button" type="submit" name="allow" value="picture is ok">
</form>
<br>
<span class="ankeedipealkirjad">Not approving</span><br>
<br>
<form name="denyf" method="post" action="zshow.php?id=<?=$img_id?>&src=<?=$src?>">
	<SELECT NAME="reason">
	<option value="">Põhjus:</option>
	<option value="Täpsusta oma asukohta pildil">Täpsusta oma asukohta 

pildil</option>
	<option value="Pilt peab olema vertikaalses asendis">Pilt peab olema 

vertikaalses asendis</option>
	<option value="Halb kvaliteet">Halb kvaliteet</option>
	<option value="Liigselt või halvasti töödeldud">Liigselt või halvasti 

töödeldud</option>
	<option value="Kinnitage autoriõigusi">Kinnitage autoriõigusi</option>
	<option value="Korduv pilt">Korduv pilt</option>
	<option value="Porno või erootika">Porno või erootika</option>
	<option value="Keelatud aineid propageeriv">Keelatud aineid propageeriv</option>
	<option value="Otsene reklaam">Otsene reklaam</option>
        <option value="Inimene või tema nägu pole pildil piisavalt nähtav">Inimene või 

tema nägu pole pildil piisavalt nähtav</option>	
        <option value="Pead ennast rohkem esile tooma">Pead ennast rohkem esile 

tooma</option>   
        <option value="Võõras pilt">Võõras pilt</option>
        <option value="Kasutaja vanus ei sobinud pildiga!">Kasutaja vanus ei sobinud 

pildiga !</option>
        <option value="Kasutaja sugu ei sobinud pildiga ">Kasutaja sugu ei sobinud 

pildiga</option>
        <option value="Pilt on vigane, proovi lisada uuesti!">Pilt on vigane, lisa 

uuesti</option>
        <option value="Pildi all tekst ei tohi olla ainult võõrkeelne!">Pildi all tekst 

ei tohi olla ainult võõrkeelne!</option>
		<option value="Pildialune tekst/kirjeldus ei vasta 

reeglitele">The text under the picture is not ok.</option> 
        <option value="Pilt ei vasta reeglitele">picture is not OK</option> /// <! -- REASONS --!>
</SELECT>
	<br>
	<input name="reason2" type="text" size="97" maxlength="100">
	<br>
<input class="button" type="submit" name="deny" value="dont approve picture">
</form>
<br><br>
<span class="ankeedipealkirjad">adding to specials</span><br>
<br>
<form name="specialf" method="post" action="zshow.php?id=<?=$img_id?>">
comment: <input class="logout" type="text" size="60" maxlength="150" name="spec_com" 

value="">
<input class="button" type="submit" name="special" value="add to specials">
</form>


<?php
}else{
echo"<br><font size='2' color='#33aa33'><b>No new pictures</b></font><br><br>";
}//end of pictures
?>
Member Avatar for diafol

Jeez Lhizz, could you put up some more code?! What are you trying to do? Where does your code break down?

Jeez Lhizz, could you put up some more code?! What are you trying to do? Where does your code break down?

Sorry of that. I want to make that, show.php?id=4 then it takes picture from the table(mysql) and then shows this picture. But if not setted id, then show random what's not approved. And shows who moderated this picture.
Like this I think:
http://i44.tinypic.com/ilvt51.jpg

Member Avatar for diafol

Well, I won't do the whole lot, but you can do something like this (it's not a replication of your table, but you'll get the idea). If I understand you, show an image from the url 'id', but show a random image that has not been moderated if 'id' is not set or 'id' is not valid or not found in the database. In show.php:

if(isset($_GET['id'])){
  $id = addslashes(htmlentities($_GET['id']));
  $q = "SELECT * FROM images WHERE id='{$id}'";
  $r = mysql_query($q);
  if(mysql_num_rows($r) > 0){
     $d = mysql_fetch_array($r);
  }
}

if(!isset($d)){
  $q = "SELECT * FROM images WHERE moderated <> '1' ORDER BY RAND() LIMIT 0,1"; //there are quicker ways of doing this!
  $r = mysql_query($q);
  if(mysql_num_rows($r) > 0){
     $d = mysql_fetch_array($r);
  }
}

... output your image from the $d array ...


Is that what you need?

Well, I won't do the whole lot, but you can do something like this (it's not a replication of your table, but you'll get the idea). If I understand you, show an image from the url 'id', but show a random image that has not been moderated if 'id' is not set or 'id' is not valid or not found in the database. In show.php:

if(isset($_GET['id'])){
  $id = addslashes(htmlentities($_GET['id']));
  $q = "SELECT * FROM images WHERE id='{$id}'";
  $r = mysql_query($q);
  if(mysql_num_rows($r) > 0){
     $d = mysql_fetch_array($r);
  }
}

if(!isset($d)){
  $q = "SELECT * FROM images WHERE moderated <> '1' ORDER BY RAND() LIMIT 0,1"; //there are quicker ways of doing this!
  $r = mysql_query($q);
  if(mysql_num_rows($r) > 0){
     $d = mysql_fetch_array($r);
  }
}

... output your image from the $d array ...


Is that what you need?

Nope.. I need like "remoderating" page. And if the "ID" is set up, then it takes from the database information...

Member Avatar for diafol

Doesn't my example do that? If '$d' is set, just place all the image info from the $d array into a form, ready for "re-moderation".

So, something like my orig. code with the following:


(I've applied my own field names here and assumed the image info comes from one table)

echo 
"<img src='{$d['filesource']}' alt='{$d['filetitle']}' width='400'/>\n
<dl>\n\t
  <dt>Source:</dt>\n\t
  <dd>{$d['filesource']}</dd>\n\t 
  <dt>Size:</dt>\n\t
  <dd>{$d['filesize']}</dd>\n\t
  <dt>Author:</dt>\n\t
  <dd>{$d['fileauthor']}</dd>\n\t
  <dt>Uploaded:</dt>\n\t
  <dd>{$d['upload_date']}</dd>\n\t
  <dt>Moderated:</dt>\n\t
  <dd>{$d['moderator']} {$d['mod_date']}</dd>\n\t
  <dt>Author:</dt>\n\t
  <dd>{$d['fileauthor']}</dd>\n
</dl>\n\n

<form method='post' action='moderate.php' id='modform' name='modform'>\n\t
   <input type='hidden' id='overmod' name='overmod' value='{$d['id']}' />\n\t
   <label><input type='radio' id='approve' name='action' value ='3' /> Approve image</label>\n\t
   <label><input type='radio' id='decline' name='action' value ='2' /> Decline image</label>\n\t
   <label><input type='radio' id='admin' name='action' value ='1' /> Send to admin</label>\n\t

... etc - more actions and submit and cancel buttons ...

</form>";

The form handling code in moderate.php should then do the data handling and return you (via header() command) to your main moderation page.

Have I still got it wrong??

<?
$id=$_GET["id"];
if($id) {
   $query = "select * from photo where id='$id'";
    $result = @MYSQL_QUERY($query);
    $src = @MYSQL_RESULT($result,0,"src");
    $subject = @MYSQL_RESULT($result,0,"subject");
    $comment = @MYSQL_RESULT($result,0,"comment");
    $user_id = @MYSQL_RESULT($result,0,"userid");
    $username = @MYSQL_RESULT($result,0,"username");
    $reason = @MYSQL_RESULT($result,0,"reason");
echo "<a href='userinfo.php?id=$user_id'><img src='gallery/$src' border='0'></a><br>
<font class=imgsubject>$subject</font><br>$commentofthispicture<br><br>Adder: $username | Added: ($date)<br><form name='allowf' method='post' action='zshow.php?id=$id'><input class='button' 

type='submit' name='allow' value='add pic'></form><br><span class='ankeedipealkirjad'>Picture not allowing</span><br><br><form name='denyf' method='post' action='zshow.php?id=$id&src=$src'>
	<SELECT NAME='reason'>
	<option value=''>Reason:</option>
		<option value='Remove the frame.'>Remove the frame.</option>
        <option value='Where are you on picture?!'>Where are you on picture?!</option>
        <option value='Picture is not ok'>Picture is not ok</option>
</SELECT>

..and so one../reasons

<br><input name='reason2' type='text' size='97' maxlength='100'><br><input class='button' 

type='submit' name='deny' value='dont allow picture'></form>";
}
?>

But if there's ID then it shows this picture what comes "randomly" and that other too.

Url is: zshow.php?id=3
http://i44.tinypic.com/343q90m.jpg

I'm kinda new in PHP and MySql.. so please try to describe more. :/

Member Avatar for diafol

Ah, I see now. OK first of all, I suggest one form for add/deny.

select with options for not allowing
textbox for custom reason
hidden input with image 'id'
submit buttons for 'add' or 'deny'


In the page the form is sent to (e.g. zhow.php), the moderator id is the $_SESSION user variable, you can get a current datestamp from time(). Together with these variables, process the form with the $_POST variable:

if(isset($_POST['deny'])){

   ...find the value of the select option...
   ...get the value of the textbox...
   ...get the image id (from hidden)...
   ...get $_SESSION value of moderator id...
   ...get unix timestamp like this: date('Y-m-d h:i:s',time())...
   ...UPDATE the info in your table with these variables...

}elseif(isset($_POST['add'])){

   ...get $_SESSION value of moderator id...
   ...get unix timestamp...
   ...get the image id (from hidden)...
   ...UPDATE the info in your table with these variables...

}else{
   ...if the form is not sent!! This should not be needed, unless somebody types in the url directly to the address bar...
}

... redirect back to the moderating page ...

Now I am totally freezed. :|
I made a form(new one, like i like), but I have no idea what You mean. :/

http://garry.pri.ee/test/zshow.php form is like this, but this is without PHP and mysql now.. I try to figure out, how to make so - but no idea.. :|

Member Avatar for diafol

OK Lhiz - seen the form. Had a look at the generated source

Will try to get back to you later

Member Avatar for diafol

As promised Lhizz, here's a txt file. Hope it helps, get back if you're still stuck.
It's not tested, just off top of my head.

Sorry everybody else. It's a bit long for a post and if you use a Blackberry, you'd be cursing my soul with all that endless scrolling!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.