Author Topic: Pointrating?  (Read 28912 times)

0 Members and 1 Guest are viewing this topic.

Offline dosensteck

  • Full Member
  • ***
  • Posts: 160
    • View Profile
Re: Pointrating?
« Reply #15 on: February 02, 2006, 05:25:47 PM »
Will nicht nervig sein, ist nur ein kleiner Push zur erinnerung ;)

Offline dosensteck

  • Full Member
  • ***
  • Posts: 160
    • View Profile
Re: Pointrating?
« Reply #16 on: February 07, 2006, 03:58:57 PM »
so, nachdem das jetzige votingsystem immer neviger wird (eine bewertung unter 5 und man hat fast keine chance mehr in die top 20 zu kommen) bin ich immer noch dran selbst herumzuprobieren

was ich bis jetzt habe:

Code: [Select]
    $sql = "SELECT image_id, image_votes, image_rating
            FROM
                4images_images";
    $result = mysql_query($sql) OR die(mysql_error());
    if(mysql_num_rows($result)) {
        while($row = mysql_fetch_assoc($result)) {
$image_id = $row['image_id'];
$votes = $row['image_votes'];
$rating = $row['image_id'];
           
$votes * $rating = $new_image_rating;

$sql = "UPDATE 4images_images
          SET image_rating = $new_image_rating
          WHERE image_id = $image_id";

        }
    }
 else {
        echo"nichts da";
    }

könnte es so funktionieren? hab zwar ein testsystem eingerichtet, das script läuft auch durch - so wirklich sehe ich aber nicht was es anstellt?
hab es jetzt ohne ".IMAGES_TABLE." usw. gemacht da ich 4 images darauf nicht installiert habe...

Offline IcEcReaM

  • Hero Member
  • *****
  • Posts: 714
    • View Profile
    • My little Testboard
Re: Pointrating?
« Reply #17 on: February 07, 2006, 10:08:53 PM »
Na gut ich helf dir mal.

Erstmal musst du wie du schon selbst erkannt hast,
alle entsprechenden Votings updaten.

Dazu mal nen kleines Skript,
dass du unter votes_update.php abspeicherst und einmal aufrufst.
Damit werden alle bisherigen Votes geupdatet,
d.h. nicht mehr der Durchschnitt ist gespeichert, sondern die Gesamtpunktezahl addiert zusammengerechnet.
Code: [Select]
<?php

define
('ROOT_PATH''./');
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');

$update_count;

$sql "SELECT  image_id, image_votes, image_rating
          FROM "
.IMAGES_TABLE."
          WHERE  image_votes != 0"
;

$result $site_db->query($sql);

while(
$row $site_db->fetch_array($result)) {
     
$image_rating $result[image_rating] * $result[image_votes];
     
$sql "UPDATE ".IMAGES_TABLE."
              SET image_rating = '"
$image_rating."'
              WHERE  image_id = "
.$result[' image_id'];
      
$site_db->query($sql);
     
$update_count++;
}

echo 
"$update_count Datenstze erfolgreich updated";


?>

Danach das Skript löschen,
da sonst bei nochmaligen Aufruf die Daten verflscht werden.
Wenn noch bei keinem Bild gevoted wurde, wird auch nichts geupdated.

So nun musst du  entsprechend die Rating/Vote Funktion im 4images Sktipt anpassen,
damit nachfolgende Votes entsprechend nur noch addiert werden,
und nicht wieder der Durchschnitt angezeigt wird/errechnet.

Dazu musst du in der includes/functions.php folgendes ndern:
Suche
Code: [Select]
$new_rating = (($old_rating * $old_votes) + $rating) / ($old_votes + 1);
und ersetze es mit
Code: [Select]
$new_rating = ($old_rating  + $rating);
Das wars eigentlich schon.
Coding is a everlasting competition between programmers who tries to write larger, better and idiot-safe programs and the universe producing larger and stupider idiots...
...so far the universe won
bump

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: Pointrating?
« Reply #18 on: February 07, 2006, 11:17:15 PM »
@icecream:

Since it involves images and sessions from your inclusion of this block :

Quote

define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');


I think it shoul be :

Code: [Select]

define ('GET_CACHES', 1);
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();


;)

Offline IcEcReaM

  • Hero Member
  • *****
  • Posts: 714
    • View Profile
    • My little Testboard
Re: Pointrating?
« Reply #19 on: February 07, 2006, 11:25:13 PM »
No its not really necessary,
cause its only an update script,
which will be running just one time,
and then will be deleted.

Its just to update the previous voting result,
so from now on, it's not being displayed the average but the votes summarized.
That what he wanted.
Coding is a everlasting competition between programmers who tries to write larger, better and idiot-safe programs and the universe producing larger and stupider idiots...
...so far the universe won
bump

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: Pointrating?
« Reply #20 on: February 07, 2006, 11:27:39 PM »
Quote

which will be running just one time,
and then will be deleted.


Oh ! ... that explains quite a few things with the GET_CACHES. However, the $user_access is still useful under sessions. ;)

Offline IcEcReaM

  • Hero Member
  • *****
  • Posts: 714
    • View Profile
    • My little Testboard
Re: Pointrating?
« Reply #21 on: February 08, 2006, 12:08:16 AM »
$user_access is here also unnecessary cause you dont need any permissions here.
$user_access is just for getting the category user access settings,
which aren't needed here.
Coding is a everlasting competition between programmers who tries to write larger, better and idiot-safe programs and the universe producing larger and stupider idiots...
...so far the universe won
bump

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: Pointrating?
« Reply #22 on: February 08, 2006, 12:12:17 AM »
Quote

$user_access is just for getting the category user access settings


Yes, that is correct. ;)

However, my apologize. I thought it would be amended in the file above. :)

Offline dosensteck

  • Full Member
  • ***
  • Posts: 160
    • View Profile
Re: Pointrating?
« Reply #23 on: February 08, 2006, 12:49:21 AM »
Dazu mal nen kleines Skript,
dass du unter votes_update.php abspeicherst und einmal aufrufst.
Damit werden alle bisherigen Votes geupdatet,
d.h. nicht mehr der Durchschnitt ist gespeichert, sondern die Gesamtpunktezahl addiert zusammengerechnet.
Code: [Select]
<?php

define
('ROOT_PATH''./');
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');

$update_count;

$sql "SELECT  image_id, image_votes, image_rating
          FROM "
.IMAGES_TABLE."
          WHERE  image_votes != 0"
;

$result $site_db->query($sql);

while(
$row $site_db->fetch_array($result)) {
     
$image_rating $result[image_rating] * $result[image_votes];
     
$sql "UPDATE ".IMAGES_TABLE."
              SET image_rating = '"
$image_rating."'
              WHERE  image_id = "
.$result[' image_id'];
      
$site_db->query($sql);
     
$update_count++;
}

echo 
"$update_count Datenstze erfolgreich updated";


?>

Danach das Skript löschen,
da sonst bei nochmaligen Aufruf die Daten verflscht werden.
Wenn noch bei keinem Bild gevoted wurde, wird auch nichts geupdated.


danke für deine bisherigen bemühungen, allerdings bekomme ich diesen fehler wenn ich das script aufrufe:

Parse error: parse error, unexpected T_VARIABLE in /www/htdocs/v156093/votes_update.php on line 18

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: Pointrating?
« Reply #24 on: February 08, 2006, 01:02:17 AM »
@IcEcReaM,
... das Script war sicherlich nicht zu Ende getestet ...  :wink:

@dosensteck,
... folgendes Plugin mit dem Namen pointrating_update.php nach /admin/plugins kopieren ...
... dann findest du zur Ausführung des Updates das Plugin im ACP ...
... die Kategorien werden einzeln geupdatet ... mit Ergebnisanzeige ...
... so kannst du zunächst an einer Kategorie die Sache testen ...

Code: [Select]
<?php // PLUGIN_TITLE: Point Rating Update
$nozip 1;
define('IN_CP'1);
$root_path "./../../";
define('ROOT_PATH'$root_path);
require(
ROOT_PATH.'admin/admin_global.php');
define('POINTRATING_UPDATE_TITEL'"Point Rating Update");
define('POINTRATING_UPDATE_CAT'"Point Rating Update für die Kategorie <small><span style=\"FONT-WEIGHT: normal\">[ Hier die Kategorie-ID einzeln eintragen ! ]<br><br>Alle deine Kategorien musst du hier einzeln abarbeiten. Das Ergebnis wird unten angezeigt.<br><span style=\"color:#FF0000;\">Wichtig :</span> Nach erfolgreichem Point Rating Update das Plugin wieder löschen !</span></small>");
define('POINTRATING_UPDATE_BUTTON'"Update");
show_admin_header();
show_form_header("pointrating_update.php""pointrating_update");
show_table_header(POINTRATING_UPDATE_TITEL2);
show_input_row(POINTRATING_UPDATE_CAT"update_id"""40);
show_form_footer(POINTRATING_UPDATE_BUTTON""2);
$update_id $HTTP_POST_VARS['update_id'];
$counter;
if (
$update_id != ""){
$sql "SELECT image_id, image_name, cat_id, image_votes, image_rating
          FROM "
.IMAGES_TABLE."
          WHERE  image_votes != 0
          AND cat_id = 
$update_id";
  $image_result $site_db->query($sql);
  while ($image_row $site_db->fetch_array($image_result)) {
  $new_image_rating $image_row['image_rating'] * $image_row['image_votes'];
  $sql "UPDATE ".IMAGES_TABLE."
          SET image_rating = "
.$new_image_rating."
          WHERE  image_id = "
.$image_row['image_id'];
   if ($site_db->query($sql)) {
      $counter++;
      echo "<b>Update für Bild Nr.: ".$counter."</b><br>";
      echo "Image Name : ".$image_row['image_name']." - Image ID : ".$image_row['image_id']."<br>";
      echo "Votes : ".$image_row['image_votes']." - Old Rating : ".$image_row['image_rating']." - <span style=\"color:#FF0000;\">Resultat New Rating : ".$new_image_rating."</span><br><br>";
    }
    else {
      echo "Es gab nichts zu updaten<br><br>";
    }
}
if (
$counter 1){
$total_counter "0";
}else{
$total_counter $counter;
}
echo 
"<br>".$total_counter." Datensätze zum Point-Rating wurden erfolgreich geupdated !";
}

show_admin_footer();
?>



Hab es auf einer frischen 4images-Installation erfolgreich getestet ... sicherlich trotzdem nicht vollendet ...  :wink:
Viel Erfolg .... mawenzi
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: Pointrating?
« Reply #25 on: February 08, 2006, 01:11:19 AM »
@mawenzi:

Universalsprache ? 8)

(Sorry for my limited words in German, I only know a few words).  :mrgreen:

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: Pointrating?
« Reply #26 on: February 08, 2006, 01:15:22 AM »
@ TheOracle,

1. Deutsch ist Universalsprache in diesem .de-Forum ...
2. das Plugin ist für dosensteck ...
3. wenn das Plugin erfolgreich sein sollte, kann man es auch ins Englische übertragen ...  :wink:
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: Pointrating?
« Reply #27 on: February 08, 2006, 01:18:27 AM »
Yes, you're right. This topic subject was in German in the first place as it is also a plugin file. ;)

Quote

3. wenn das Plugin erfolgreich sein sollte, kann man es auch ins Englische übertragen ...


Sure, I will start translating right now. 8)

Offline dosensteck

  • Full Member
  • ***
  • Posts: 160
    • View Profile
Re: Pointrating?
« Reply #28 on: February 08, 2006, 01:34:56 AM »
Tausend Dank! Funktioniert einwandfrei und hab schon alles umgestellt.

Als kleines Dankeschön (anders kann ich leider nicht)
http://www.hobby-fotografen.com/
einfach auf die letzte news guggen, vielleicht fallen ja ein paar klicks ab :)

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: Pointrating?
« Reply #29 on: February 08, 2006, 01:52:19 AM »
@dosensteck,

... na dann haben wir heute wenigstens etwas Vernünftiges zu Stande gebracht ...
... ein kleiner Bildupload (auf besagte Adresse) hätte es auch schon getan ...  :mrgreen:
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...