Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - alekseyn1

Pages: 1 2 3 4 [5] 6 7
61
4images gurus!!

Please, somebody help! A very useful MOD, but not functioning in 1.7.7....

Could the expert have a look?

62
Попробуй пошаговую модификацию... у меня все сработало с первого раза.... (за исключением подключения к базе, которое Денис исправил.. и все заработало хорошо)

63
Try a function shown at the end of this post
http://www.4homepages.de/forum/index.php?topic=26465.msg143800#msg143800


Code: [Select]
function utf8_to_cp1251($s)
        {
            for ($c=0;$c<strlen($s);$c++)
            {
               $i=ord($s[$c]);
               if ($i<=127) $out.=$s[$c];
                   if ($byte2){
                       $new_c2=($c1&3)*64+($i&63);
                       $new_c1=($c1>>2)&5;
                       $new_i=$new_c1*256+$new_c2;
                   if ($new_i==1025){
                       $out_i=168;
                   } else {
                       if ($new_i==1105){
                           $out_i=184;
                       } else {
                           $out_i=$new_i-848;
                       }
                   }
                   $out.=chr($out_i);
                   $byte2=false;
                   }
               if (($i>>5)==6) {
                   $c1=$i;
                   $byte2=true;
               }
            }
            return $out;
}

64
As far as I can tell this addon will only work if your 4images is integrated with phpBB3, correct?

correct. only with this MOD

http://www.4homepages.de/forum/index.php?topic=26013.0

65
I have made a MOD to show the last posts from forums on the 4images main page...

http://www.4homepages.de/forum/index.php?topic=26465.0

66
Dear all,

this MOD is inspired by Joss in his mod

[MOD] Last topics from phpBB3 forum to index page (php)
http://www.4homepages.de/forum/index.php?topic=26170.0

here is my version: I took the PHPBB hack from one of the forums and made this...

Step 1.

make new file and call it for example recent_phpbb.php

this should be the content of this file:

Code: [Select]
<?php
/*-------------------------------------------------------------------------
|  PHPBB 3.x.x Last Posts Table with Permissions 0.1 (for center block) 10.12.2009 
|  for 4images 1.7.7 with bridge to PHPBB 3.x.x
|  by alekseyn1 <Aleksey Napolskih>
|  http://www.napolskih.com
|  Base on the following code by visiblesoul
/*-------------------------------------------------------------------------
|  MKPortal PHPBB 3.x.x Last Posts Table with Permissions 0.1 (for center block) 26.07.2008 
|  for MKP C 1.x with PHPBB 3.x.x
|  by mike16os <Khan-Cin Hau>
|  http://www.yamc.info/
|  Base on the following code by visiblesoul
/*-------------------------------------------------------------------------
|  MKPortal IPB 2.1.x Last Posts Table with Permissions 2.1 (for center block) 17.05.2006 
|  for MKP 1.1 x IPB 2.1.x
|  by visiblesoul <visiblesoul.net>
|  Support: http://www.visiblesoul.net/resources/forum/
+--------------------------------------------------------------------------*/

global $db$config;

/*---------------------------------------------------------------------------
Config:
--------------------------------------------------------------------------*/
$limit         10 // Number of forum posts to show in block 
$cutoff        60 // Number of characters to display in title
/*------------------------------------------------------------------------
Forum images Config:
--------------------------------------------------------------------------*/
$img_first_topic    ="";
$img_last_topic     ="";
//empty images canbe used by "" eg: $img_first_topic ="";
  
/*-------------------------------------------------------------------------
Language Setting:
--------------------------------------------------------------------------*/
$lang_topic_title        ="Topic Title";
$lang_last_post          ="Last Post";
$lang_last_post_date     ="posted on";
$lang_views              ="Views";
$lang_replies            ="Replies";
$lang_go_to_last_post    ="go to last post...";
$lang_topic_started_by   ="Topic started by";
$lang_on                 ="on";
$lang_by                 ="by";
$lang_last_poster        ="Last poster:";
/*------------------------------------------------------------------------*/

$content "
<tr>
  <td>

    <table width=\"100%\" border=\"0\" cellpadding=\"3\" cellspacing=\"1\">
      <tr>
<td valign=\"top\" class=\"head1\">
$lang_topic_title</td>
<td valign=\"top\" class=\"head1\" align=\"center\">
$lang_last_post</td>
<td valign=\"top\" class=\"head1\" align=\"center\">
$lang_last_post_date</td>
<td valign=\"top\" class=\"head1\" align=\"center\">
$lang_views</td>
<td valign=\"top\" class=\"head1\" align=\"center\">
$lang_replies</td>
      </tr>
"
;

$sql "SELECT forum_id, forum_password FROM ".FORUMS_TABLE."";
 
$result $db->sql_query($sql);

while($f $db->sql_fetchrow($result)) {
 
if ($f['forum_password'] != "" ) {
            
$bad[] = $f['forum_id'];
        
} else {
         
$good[] = $f['forum_id'];
        
}
    
}

 
if ( count($bad) > ) {
     
$qe " AND forum_id NOT IN(".implode(','$bad ).") ";
    
}

$sql1 "SELECT t.topic_last_post_id, t.topic_id, t.topic_title, t.topic_views, t.topic_replies, t.topic_time, t.topic_last_post_time, t.topic_first_poster_name, t.topic_last_poster_name, topic_poster, t.forum_id
    FROM "
.TOPICS_TABLE." t
    LEFT JOIN "
.FORUMS_TABLE." f ON (t.forum_id = f.forum_id)
    WHERE topic_approved != 0 AND topic_approved = 1 AND (topic_moved_id = 0 or topic_moved_id='') 
$qe
    GROUP BY t.topic_title
    ORDER BY t.topic_last_post_id DESC LIMIT 0,
$limit";

$result1 $db->sql_query($sql1);
while ( $post $db->sql_fetchrow($result1)) {
$post['title'] = strip_tags($post['title']);
$post['topic_title'] = str_replace"!" "!" $post['topic_title'] );
$post['topic_title'] = str_replace"&quot;""\""$post['topic_title'] );
if (strlen($post['topic_title']) > $cutoff) {
$post['topic_title'] = substr$post['topic_title'],0,($cutoff 3) ) . "...";
$post['topic_title'] = preg_replace'/&(#(\d+;?)?)?(\.\.\.)?$/''...',$post['topic_title'] );


$title utf8_to_cp1251($post['topic_title']);
 
$tid utf8_to_cp1251($post['topic_id']);
$tlastid utf8_to_cp1251($post['topic_last_post_id']);
                
$views $post['topic_views'];
$posts $post['topic_replies'];
$starter $post['topic_first_poster_name'];
$lastname $post['topic_last_poster_name'];
$lastid $post['topic_poster'];
$forum_id $post['forum_id'];
$startdate  $post['topic_time'];
$lastdate  $post['topic_last_post_time'];

$content .= "
<!-- topic begin -->
      <tr>
<td class=\"row1\" align=\"left\">
  
$img_first_topic <a href=\"./forum/viewtopic.php?f=$forum_id&t=$tid\" title=\"$lang_topic_started_by $starter $lang_on ".format_date($config['date_format']." ".$config['time_format'], $startdate)."\" target = \"_blank\">$title</a>
</td>
<td class=\"row2\" align=\"center\">
  <a href=\"./forum/viewtopic.php?f=
$forum_id&t=$tid&p=$tlastid#p$tlastid\" title=\"$lang_go_to_last_post\" target = \"_blank\">$img_last_topic $lang_last_post</a> $lang_by <a href=\"./forum/memberlist.php?mode=viewprofile&u=$lastid\" title=\"$lang_last_poster $lastname\" target = \"_blank\"><b>$lastname</b></a>
</td>
<td class=\"row1\" align=\"center\">"
.format_date($config['date_format']." ".$config['time_format'], $lastdate)."</td>
<td class=\"row2\" align=\"center\"> 
$views </td>
<td class=\"row1\" align=\"center\"> 
$posts </td>     
</td>
      </tr>
<!-- topic end -->   
"
;
}

$content .= "
    </table>

  </td>
</tr>
"
;  

        
          unset(
$limit);
          unset(
$cutoff);
          unset(
$perms);
          unset(
$good);
          unset(
$bad);
          unset(
$qe);
          unset(
$post);
          unset(
$tid);
          unset(
$title);
          unset(
$views);
          unset(
$posts);
          unset(
$startdate);
          unset(
$lastdate);
          unset(
$starter);
          unset(
$lastname);
          unset(
$lastid);
          unset(
$tlastid);
          unset(
$forum_id);
          unset(
$img_last_topic);
          unset(
$img_first_topic);
          unset(
$lang_topic_title);
          unset(
$lang_last_post);
          unset(
$lang_last_post_date);
          unset(
$lang_views);
          unset(
$lang_replies);
          unset(
$lang_go_to_last_post);
          unset(
$lang_topic_started_by);
          unset(
$lang_on);
          unset(
$lang_by);
          unset(
$lang_last_poster);
                     
echo 
$content;

function 
utf8_to_cp1251($s)
        {
            for (
$c=0;$c<strlen($s);$c++)
            {
               
$i=ord($s[$c]);
               if (
$i<=127$out.=$s[$c];
                   if (
$byte2){
                       
$new_c2=($c1&3)*64+($i&63);
                       
$new_c1=($c1>>2)&5;
                       
$new_i=$new_c1*256+$new_c2;
                   if (
$new_i==1025){
                       
$out_i=168;
                   } else {
                       if (
$new_i==1105){
                           
$out_i=184;
                       } else {
                           
$out_i=$new_i-848;
                       }
                   }
                   
$out.=chr($out_i);
                   
$byte2=false;
                   }
               if ((
$i>>5)==6) {
                   
$c1=$i;
                   
$byte2=true;
               }
            }
            return 
$out;
}

?>

Step 2.


in your home.html file (in your template directory) include this string in the place where you want your table to show up:

Code: [Select]
 <!--last forum posts -->

 <table width="100%" border="0" cellspacing="0" cellpadding="1">
                    <tr>
                      <td class="head1">
                        <table width="100%" border="0" cellspacing="0" cellpadding="3">
                          <tr>
                            <td class="head1" valign="top" colspan="5">Last forum posts</td>
                          </tr>
 
 <tr>
                            <td class="row1" valign="top" colspan="5"><?php include(ROOT_PATH."/recent_phpbb.php"); ?></td>
                          </tr>

                        </table>
                      </td>
                    </tr>
                  </table>
                  <br />
<!--end last forum posts -->


Notes:

1. In include/constants.php you must set the value to "1" in this define:  define('EXEC_PHP_CODE', 1);
2. This particular version of the code is designed for the database in UTF8 and your 4images site in other encoding (cp1251 in my case). I have only included the function to recode utf8 into windows 1251 - russian encoding. I am sure you can find other functions to recode into your codepage if required
3. you need to modify all occurrences of this code
Code: [Select]
<a href=\"./forum/ to reflect the correct path of your phpBB3 installation
4. of course you are more than welcom to improve and modify this code. Please post your improvements here for everybody's benefit.

see attachment for demo...

67

1- the comment text appears perfect for non-english but some texts (commentformmgs, comments:, joindate:, admin, edit, delete and username) appear like this "�������". the problem happens only after I go to another page or when I post new comments.


2- when I rate a comment (good or bad), the result does not appear instantly. I have to refresh the page. this problem DOES NOT happen if I rate after going to another page or after posting new comments.


I hope I can find solutions or hints.

thanks again

same problem here V@no....


I am pretty sure it's the issue with my code page... my database uses utf-8 and site uses cp1251... but how do you make them work together?...

68
the solution for your request is here
http://www.4homepages.de/forum/index.php?topic=23612.0

and the image validation could be set if you modify the properties of your category and set the upoad to all registered users and set the direct upload to Admins only.

69
Denis, thanks for the fix! Should we download the new phpbb.php or reapply the whole mod again?

Only one line changed in phpbb.php

from
Code: [Select]
    if ($bbuser->data['user_email'] !== $user_info['user_email']) {
to
Code: [Select]
    if ($bbuser->data['user_id'] > 0 && $bbuser->data['user_email'] !== $user_info['user_email']) {

Yes, only this file and only this line.

sorry guys, found a small error... in phpBB Anonymous user has user_id == 1, so the code above should be
Code: [Select]
    if ($bbuser->data['user_id'] > 1 && $bbuser->data['user_email'] !== $user_info['user_email']) {
after that if you refresh 4images while logged off from the forum, the e-mail will stay in the database.

70
Denis, one more glitch... for some reason the registration date of a user is not being transferred from phpBB database into 4images database correctly.. could you please check? For all my newly registered users 4images database shows "0" in the "user_joindate" field ...

71
Mods & Plugins (Releases & Support) / Re: [Mod] User upload limits
« on: December 08, 2009, 08:57:13 PM »
That's too bad...
I have not tried it though....

anyone got it to work with 1.7.7?

72
same problem as reported in another bridge found in this bridge:

Fixed, attached files are updated.


Denis, thanks for the fix! Should we download the new phpbb.php or reapply the whole mod again?

Only one line changed in phpbb.php

from
Code: [Select]
    if ($bbuser->data['user_email'] !== $user_info['user_email']) {
to
Code: [Select]
    if ($bbuser->data['user_id'] > 0 && $bbuser->data['user_email'] !== $user_info['user_email']) {

73
Great! works perfectly!
Thanks very much!

74
Thanks very much for the MOD! Very useful.

I have a problem though...

the return from the script shows as:

[8] ?????, ???????????. (1 h.)
[3] ??????????? ?????? (????????) (1 h.)
[2] ???????? ????? (1 h.)
[2] ???????? ? ????????? ??? ???? (1 h.)
  • ???????? =) (1 h.)


I guess this is wrong database encoding return... any idea how to recode the database return into cp1251?

EDIT:
I have found the solution if anybody is interested:

My problem was that the database information was stored in UTF 8 and my site was displayed in Windows 1251...

here is what you need to do to correct those question marks:

in the code above find:

Code: [Select]
$db = mysql_select_db("your_db_name",$connection) or die("Service temporairly unavailable");
and insert after:

Code: [Select]
@mysql_query('set character set utf8');
then

replace

Code: [Select]
echo "[$row[topic_replies_real]]&nbsp;<a href = \"http://www.yourforumdomain.com/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]&view=unread#unread\" target = \"_blank\">$row[topic_title]</a>&nbsp;(".$time_from_last_reply.")<br>";

with

Code: [Select]
    $s = "[$row[topic_replies_real]]&nbsp;<a href = \"http://www.yourforumdomain.com/viewtopic.php?f=$row[forum_id]&t=$row[topic_id]&view=unread#unread\" target = \"_blank\">$row[topic_title]</a>&nbsp;(".$time_from_last_reply.")<br>";
    echo iconv('utf-8', 'windows-1251', $s);

that did the trick for me... (sorry I presumed that you have iconv installed with your hosting provider)

in case you do not have it installed, you could use recoding functions available online... here are some samples (i did not check them but they were reported as functional)

Code: [Select]
function str_encode ($string,$to="iso-8859-9",$from="utf8") {
    if($to=="iso-8859-9" && $from=="utf8"){
        $str_array = array(
       chr(196).chr(177) => chr(253),
       chr(196).chr(176) => chr(221),
       chr(195).chr(182) => chr(246),
       chr(195).chr(150) => chr(214),
       chr(195).chr(167) => chr(231),
       chr(195).chr(135) => chr(199),
       chr(197).chr(159) => chr(254),
       chr(197).chr(158) => chr(222),
       chr(196).chr(159) => chr(240),
       chr(196).chr(158) => chr(208),
       chr(195).chr(188) => chr(252),
       chr(195).chr(156) => chr(220)
       );
       return str_replace(array_keys($str_array), array_values($str_array), $string);
   
    }   
    return $string;
}

function FixEncoding($x){
  if(mb_detect_encoding($x)=='UTF-8'){
    return $x;
  }else{
    return utf8_encode($x);
  }
}

function cp1251_to_utf8($s)
{
           $c209 = chr(209); $c208 = chr(208); $c129 = chr(129);
           for($i=0; $i<strlen($s); $i++)    {
               $c=ord($s[$i]);
               if ($c>=192 and $c<=239) $t.=$c208.chr($c-48);
               elseif ($c>239) $t.=$c209.chr($c-112);
               elseif ($c==184) $t.=$c209.$c209;
               elseif ($c==168)    $t.=$c208.$c129;
               else $t.=$s[$i];
           }
           return $t;
       }

function utf8_to_cp1251($s)
        {
            for ($c=0;$c<strlen($s);$c++)
            {
               $i=ord($s[$c]);
               if ($i<=127) $out.=$s[$c];
                   if ($byte2){
                       $new_c2=($c1&3)*64+($i&63);
                       $new_c1=($c1>>2)&5;
                       $new_i=$new_c1*256+$new_c2;
                   if ($new_i==1025){
                       $out_i=168;
                   } else {
                       if ($new_i==1105){
                           $out_i=184;
                       } else {
                           $out_i=$new_i-848;
                       }
                   }
                   $out.=chr($out_i);
                   $byte2=false;
                   }
               if (($i>>5)==6) {
                   $c1=$i;
                   $byte2=true;
               }
            }
            return $out;
}


so if you will use functions then your last line will look like this:

Code: [Select]
echo utf8_to_cp1251($s);
I hope this will save lots of research for people )))

75
The trouble is by just refreshing the page with an image, the counter of views keeps adding up...
this is not always good, because if you run a proper large photo community site with ratings being important, then, it's pretty easy to get to the top of the charts as the most viewed image.

Any ideas on how to fix that?

Pages: 1 2 3 4 [5] 6 7