Firefox PHP

Message icons module

Posted by Maurice Makaay 
Re: Message icons module
February 14, 2006 09:09AM
That's why I originally said "hacked fairly easily". :-)

/\dam

--
My notable Phorum sites:
Movie Deaths Database - "review comments" system mostly powered by Phorum
Learn Chinese! - integrated forum quiz
Re: Message icons module
February 14, 2006 09:18AM
lol, I noticed the H-word. I mainly elaborated for other people interested in module writing ;)


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Message icons module
February 14, 2006 12:13PM
sheik's suggestion of using a smiley will work for me right now. I am mainly concerned with the messages that I am importing using the webbbs to phorum5 script. I just needed a way to mark the files that have a picture embedded in them. Chances of these files be edited are almost 0.

I tried the :camera: idea and it worked perfectly. This will tie me over until some code is created to indicate images versus attachments.

Thanks all
Re: Message icons module
February 16, 2006 11:07AM
Durtdawber, out of interest, can you post the code you use to detect the "img" tag?

Thanks,

/\dam

--
My notable Phorum sites:
Movie Deaths Database - "review comments" system mostly powered by Phorum
Learn Chinese! - integrated forum quiz
Re: Message icons module
February 16, 2006 01:49PM
Here is the code from the webbbs conversion script. This is from the webbs_in.php file. I added code to detect when a post has an image upload file. If so then I appended a smiley tag to the end of the subject. Does not address all issues but it suited my purpose.

<?php
if(!defined("PHORUM5_CONVERSION")) return;

// WeBBS - to - Phorum5 Conversion Library
// written by thomas seifert ( thomas@phorum.org )
// please post comments, enhancements to the thread in the modules-forum:
// [www.phorum.org]

function phorum_convert_selectMessages() {
	GLOBAL $CONVERT,$aryFiles,$aryInput,$aryRev;
	// Build an array of numeric files in current directory
	$aryInput[] = array ( 'ID' => 0,
	'PREVIOUS' => 0,
	'THREAD' => 0
	) ;

	$aryFiles=array();
	$c = 0;

	$dirCurrent2 = dir($CONVERT['old_directory']);
	while($strTemp2 = $dirCurrent2->read()) {
		if($strTemp2 != "." && $strTemp2 != ".." && is_dir($CONVERT['old_directory']."/".$strTemp2)) { // first level
			$dirCurrent = dir($CONVERT['old_directory']."/".$strTemp2);

			while ($strTemp = $dirCurrent->read() ) { // subdir with messages
				if($strTemp2 == "bbs28") {
					print $strTemp."-".$strTemp2."\n";
				}
				if ( (ereg_replace("[^0-9]","",$strTemp) == $strTemp) &&
				( !empty ($strTemp) ) &&
				filesize($CONVERT['old_directory']."/$strTemp2/$strTemp") > 1) {
					$aryFiles[$c] = (int) $strTemp;
					$aryRev[(int)$strTemp]   = $strTemp2;
					$c++;
				}
			}
			$dirCurrent->close();
		}
	}
	$dirCurrent2->close();

	// sort the array
	sort ($aryFiles);

	return 1;
}

function phorum_convert_getNextMessage($b,$fileid) {
	global $aryFiles, $aryInput, $aryRev, $CONVERT;

	$strFile = $fileid;
	// Set ID to current record counter
	$aryInput[$strFile]['ID'] = $b + 1;
	$body = "";
	$filename=$CONVERT['old_directory']."/".$aryRev[$fileid]."/".$strFile;
	$aryCurrFile = file ($filename);

	for ($a = 0; $a < count($aryCurrFile); $a++ ) {
		$strLine = $aryCurrFile[$a];
		// pull lines into either specified tags or the body
		if ( ereg ("^SUBJECT>",$strLine) ||
		ereg ("^POSTER>",$strLine) ||
		ereg ("^EMAIL>",$strLine) ||
		ereg ("^DATE>",$strLine) ||
		ereg ("^EMAILNOTICES>",$strLine) ||
		ereg ("^IP_ADDRESS>",$strLine) ||
		ereg ("^NEXT>",$strLine) ||
		ereg ("^IMAGE>",$strLine) ||
		ereg ("^LINKNAME>",$strLine) ||
		ereg ("^LINKURL>",$strLine) ||
		ereg ("^PASSWORD>",$strLine) ) {
			$tag = strtolower(trim(substr($strLine,0,strpos($strLine,">"))));
			$value = trim(substr($strLine,strpos($strLine,">") + 1,strlen($strLine) - 1));
			$$tag = $value;
		} elseif ( ereg ("^PREVIOUS>",$strLine) ) {
			$value = trim(substr($strLine,strpos($strLine,">") + 1,strlen($strLine) - 1));
			$aryInput[$strFile]['PREVIOUS'] = $value;
		} else {
			$body .= trim($strLine);
		}
	}
	// clean up body to format used by phorum
	$body = trim(ereg_replace('<P>',"\n",ereg_replace('<BR>',"\n",$body)));
	// attempt to assign threads
	if (empty ($aryInput[$strFile]['PREVIOUS'])) {
		$aryInput[$strFile]['THREAD'] = $aryInput[$strFile]['ID'];
	} else {
		$aryInput[$strFile]['THREAD'] = $aryInput[($aryInput[$strFile]['PREVIOUS'])]['THREAD'] ;
		$aryInput[$strFile]['PREVIOUS'] = $aryInput[($aryInput[$strFile]['PREVIOUS'])]['ID'] ;
	}
	// trim IP_ADDRESS to actual IP_ADDRESS.
	$ip_address = trim(substr($ip_address,strrpos($ip_address,":")+1,strlen($ip_address)));
	// If you care about host names (and don't mind the slowdown) comment this line in:
	// $ip_address = gethostbyaddress($ip_address);

  $image = "<img src=".$image.">";
	// set up and write insert commands to sql files
	$id = $aryInput[$strFile]['ID'];
	$thread = $aryInput[$strFile]['THREAD'];
	if (empty ($thread)) { $thread = $id; }
	$parent = $aryInput[$strFile]['PREVIOUS'];
	$body = stripslashes($body);
  $subject = preg_replace("/<img.*?>/i","",$subject);
  if (trim($body) == '') {
    $body = "n/t";
  }
  if ($image != "<img src=>") {
    $body = $body . "<br>" . $image;
    $subject = $subject . " :attach:";
  }

	// email-replies currently ignored!
	if (empty ($emailnotices) || $emailnotices == "no") {
		$email_reply = 'N';
	} else {
		$email_reply = 'N';
	}


	$max_id= $CONVERT['max_id'];

	$mdata['id']=$id;

	$closed=0;
	$post_status=PHORUM_STATUS_APPROVED;
	$post_sort=PHORUM_SORT_DEFAULT;

	$parentid=($parent>0)?($parent+$max_id):0;

	$mdata['author'] =$poster;
	$mdata['subject']=$subject;
	$mdata['body']   =$body;
	$mdata['email']  =$email;
	$mdata['unixtime']=$date;
	$mdata['thread'] =$thread;
	$mdata['parent'] =$parent;
	$mdata['host']   =$ip_address;
	$mdata['msgid']  ="";

	$userid = (isset($mdata['userid']) ? $mdata['userid'] : 0);

	// building the new message
	$newmessage = array(
	'message_id'=> $mdata['id']+$max_id,
	'forum_id'  => $CONVERT['forum_id'],
	'datestamp' => $mdata['unixtime'],
	'thread'    => ($mdata['thread']+$max_id),
	'parent_id' => $parentid,
	'author'    => $mdata['author'],
	'subject'   => $mdata['subject'],
	'email'     => $mdata['email'],
	'ip'        => $mdata['host'],
	'user_id'   => $userid,
	'moderator_post' => 0,
	'status'    => $post_status,
	'sort'      => $post_sort,
	'msgid'     => $mdata['msgid'],
	'closed'    => $closed,
	'body'      => $mdata['body']
	);
	if(isset($mdata['viewcount'])) {
		$newmessage['viewcount']=$mdata['viewcount'];
	}
	$newmessage['viewcount'] = (isset($mdata['viewcount']) ? $mdata['viewcount'] : 0);

	return $newmessage;
}

?>
Re: Message icons module
April 04, 2006 11:48AM
Can I make a suggestion?

I'd really like one that puts a box of (x) # of smileys that the users can select in a check or radio button to put at the front of their subject headline.
Re: Message icons module
April 04, 2006 12:04PM
Your suggestion is outside the scope of what this mod is trying to accomplish. It's not one to give users control over settings an icon for their postings.

How about using the smileys module for adding smileys to the subject line? You could write a mod that displays the radio buttons and smileys in the posting form and adds the selected smiley to the start of the subject, before writing the message to the database. It could use the settings from the smileys mod to determine what smileys are available for use in the subject.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Message icons module
April 06, 2006 04:24AM
Thanks mmakaay, was just throwing stuff out there. I got a hack of editor_tools and smileys to do what I wanted to. Removed the carats from my forum, but I did have this module installed and it works well even with headline smileys :)
Re: Message icons module
May 06, 2006 12:56PM
is there any way to remove link on icons ?

See that : [pocketpcdev.free.fr]

Maybe you can't access it...
Re: Message icons module
May 06, 2006 06:53PM
I can't access that forum. Is there a problem with having the icons clickable? This mod adds the icon to the start of the subject and the full subject is clickable. So there's no way to keep the icon outside the link.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, only registered users may post in this forum.

Click here to login