DragonPrime - LoGD Resource Community
Welcome Guest
  • Good afternoon, Guest.
    Please log in, or register.
  • May 21, 2013, 02:47:27 PM
Home Forums News Links Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
IRC Channels
Search

Pages: 1 2 [3] 4   Go Down
  Print  
Author Topic: Content Download (Mails, Commentary) as PDF  (Read 3047 times)
0 Members and 1 Guest are viewing this topic.
Aeo
Mod God
*****
Offline Offline

Posts: 1079


Doctor.. Who?


View Profile WWW
« Reply #30 on: May 08, 2012, 09:34:19 AM »

A working commentary downloader that has the following settings (so that the module is easily available for all servers):

Commentary Download via FPDF
- Directory for FPDF font files
- Title for downloaded commentary
- Site Url
Commentary Download Lines
- Minimum number of lines to be extracted?
- Maximum number of lines to be extracted?
- Increment between number of lines to be extracted?

For those who want a link to download FPDF, you can find that here.

Grin
« Last Edit: May 08, 2012, 09:44:54 AM by Aeolus » Logged


Time Lords Online - A Doctor Who RPG! Open Now!
~ My Modules: PM me if you'd like me to code something! Smiley ~
Nightborn
Captain of the Guard
***
Offline Offline

Posts: 157


View Profile
« Reply #31 on: May 14, 2012, 06:13:51 AM »

Nah, I don't mind.

And yes, I assumed you already set the font path, hence I assumed you have no file permissions or similiar.

(did that module a long time ago)

If you hit "grab" and it deletes something, the link behind the text is not right.
Logged
Aeo
Mod God
*****
Offline Offline

Posts: 1079


Doctor.. Who?


View Profile WWW
« Reply #32 on: May 21, 2012, 12:41:54 AM »

Anyone know how to get the mail downloader working, so that it actually downloads the mail, instead of deletes them?
Logged


Time Lords Online - A Doctor Who RPG! Open Now!
~ My Modules: PM me if you'd like me to code something! Smiley ~
Nightborn
Captain of the Guard
***
Offline Offline

Posts: 157


View Profile
« Reply #33 on: May 21, 2012, 06:51:44 AM »

What link is behind the button?

can you debug the position where it hooks into the mailform and modifies the link?
debug() the array there and tell us the result ^^
Logged
Aeo
Mod God
*****
Offline Offline

Posts: 1079


Doctor.. Who?


View Profile WWW
« Reply #34 on: May 21, 2012, 07:16:40 AM »

What link is behind the button?

can you debug the position where it hooks into the mailform and modifies the link?
debug() the array there and tell us the result ^^

Yeeeeah... Dunno how to do that. o-o I'm not that skilled in coding, FYI. xD I can attach what I've got so far if you want me to?
Logged


Time Lords Online - A Doctor Who RPG! Open Now!
~ My Modules: PM me if you'd like me to code something! Smiley ~
Nightborn
Captain of the Guard
***
Offline Offline

Posts: 157


View Profile
« Reply #35 on: May 22, 2012, 08:26:04 AM »

If you use Firefox, use Firebug (great great addon) and check out what the form there has as "action"-Attribute, what value the button itself has.

If it deletes, then the wrong value is set or the core just deletes mail if checked and the module is either not executed or does not work correctly (it would never delete mails).
Logged
Aeo
Mod God
*****
Offline Offline

Posts: 1079


Doctor.. Who?


View Profile WWW
« Reply #36 on: May 25, 2012, 05:30:36 AM »

If you use Firefox, use Firebug (great great addon) and check out what the form there has as "action"-Attribute, what value the button itself has.

If it deletes, then the wrong value is set or the core just deletes mail if checked and the module is either not executed or does not work correctly (it would never delete mails).


I had a look around Firebug (already had it installed for my Programming classes xD), and I can't find this "action"-Attribute thing. o.o
Logged


Time Lords Online - A Doctor Who RPG! Open Now!
~ My Modules: PM me if you'd like me to code something! Smiley ~
Aeo
Mod God
*****
Offline Offline

Posts: 1079


Doctor.. Who?


View Profile WWW
« Reply #37 on: May 31, 2012, 11:56:07 AM »

So, I've been poking around the code a bit.. And I wanna see if someone can explain how to fix it. Cheesy

So, under lib/mail/case_default.php, there is the code (once the modulehooks have been added):

Code:
rawoutput("<form action='mail.php?op=process' method='post'><table>");
...
$delchecked = htmlentities(translate_inline("Delete Checked"), ENT_COMPAT, getsetting("charset", "ISO-8859-1"));
rawoutput("<input type='submit' class='button' value=\"$delchecked\">");
// Begin PDF download modulehooking
modulehook("mailform",array());
modulehook("header-mail",array());
// End PDF download modulehooking
rawoutput("</form>");

Under mail.php, one can find:

Code:
}elseif($op=="process"){
$msg = httppost('msg');
if (!is_array($msg) || count($msg)<1){
$session['message'] = "`\$`bYou cannot delete zero messages!  What does this mean?  You pressed \"Delete Checked\" but there are no messages checked!  What sort of world is this that people press buttons that have no meaning?!?`b`0";
header("Location: mail.php");
exit();
}else{
$sql = "DELETE FROM " . db_prefix("mail") . " WHERE msgto='".$session['user']['acctid']."' AND messageid IN ('".join("','",$msg)."')";
db_query($sql);
invalidatedatacache("mail-{$session['user']['acctid']}");
header("Location: mail.php");
exit();
}
}

I think that ^ is what is deleting the YoMs instead of downloading the mails. Soo... How might I fix that? (I'm not entirely knowledgeable with form tags and such.) Tongue
Logged


Time Lords Online - A Doctor Who RPG! Open Now!
~ My Modules: PM me if you'd like me to code something! Smiley ~
Boris735
Mod God
*****
Offline Offline

Posts: 532


View Profile
« Reply #38 on: May 31, 2012, 11:10:40 PM »

OK, here's what is going on as I understand it: The mail downloader code hooks into "header-mail", checks whether the PDF download was called, and handles that if so.  It then exits before the normal mail processing can be called.

However, there is no "header-mail" hook.  The "header-*" hooks are registered for pages that use page_header().  But mail is a popup, and popups use popup_header() instead, so that hook does not get registered.  The result is that the module is never called, and those items are passed to the normal handling which deletes them.

There are two easy resolutions.  The first would be a core edit to insert the "header-mail" hook explicitly into mail.php.  The better approach would be to change the module to hook into "header-popup" instead (remembering to change the name in the do_hook() function also).  For extra safety you should check that the script name is "mail.php", although in practice you can get by without that check.
Logged
Aeo
Mod God
*****
Offline Offline

Posts: 1079


Doctor.. Who?


View Profile WWW
« Reply #39 on: June 01, 2012, 12:27:48 AM »

The better approach would be to change the module to hook into "header-popup" instead (remembering to change the name in the do_hook() function also).

Just tried that.. And it still deletes the mail. x.x
Logged


Time Lords Online - A Doctor Who RPG! Open Now!
~ My Modules: PM me if you'd like me to code something! Smiley ~
staticobj
Militia
**
Offline Offline

Posts: 90

Keep it Simple Stupid


View Profile WWW
« Reply #40 on: June 01, 2012, 01:18:31 AM »

With a quick glance at the source, and what you seem to be attempting to do. The only way to prevent the messages from deleting and handle the selected messages with other logic will be to add a hook as I believe was mentioned or use the possibly expensive everyhit-loggedin as popup_header is not called before the deletion is handled.

Code: (PHP)
<?php
case "everyhit-loggedin":
// This will prevent the code from running on anything but mail.php, except under rare circumstances
if (strpos($_SERVER['PHP_SELF'], "mail.php") === false) return $args;
// There is also the local SCRIPT_NAME global if you'd rather not use _SERVER
$op httpget("op");
$msg httppost("msg");
if ($op == "process" 
&& is_array($msg)) {
// Add some logic for how to handle the messages here

// Clear the messages from _POST to avoid deletion
$_POST['msg'] = null;
}
break;

Of course, this will need a way to see if the user is attempting to back up messages as a PDF, etc.

Code: (PHP)
<?php
case "everyhit-loggedin":
// This will prevent the code from running on anything but mail.php, except under rare circumstances
if (strpos($_SERVER['PHP_SELF'], "mail.php") === false) return $args;
// There is also the local SCRIPT_NAME global if you'd rather not use _SERVER
$op httpget("op");
$msg httppost("msg");
if ($op == "process" 
&& is_array($msg)) {
$format httpget("format");
switch($format) {
case "pdf":
// Add some logic for how to handle the messages here

// Clear the messages from _POST to avoid deletion
break;
default:
}// Only added the switch for other possible formats
if (!empty($format)) $_POST['msg'] = null;
}
break;
« Last Edit: June 01, 2012, 01:25:26 AM by staticobj » Logged

Want a custom template? Private Message me for a quote.
Click here for web hosting offer. I'm willing to work with you. Please send a Private Message for further details.
www.legacyofdragon.com
Boris735
Mod God
*****
Offline Offline

Posts: 532


View Profile
« Reply #41 on: June 01, 2012, 04:16:32 AM »

With a quick glance at the source, and what you seem to be attempting to do. The only way to prevent the messages from deleting and handle the selected messages with other logic will be to add a hook as I believe was mentioned or use the possibly expensive everyhit-loggedin as popup_header is not called before the deletion is handled.

Ah, excellent point.  Apologies for not noticing this when I previously posted.
Logged
Nightborn
Captain of the Guard
***
Offline Offline

Posts: 157


View Profile
« Reply #42 on: June 04, 2012, 09:04:35 AM »

Those hooks are heavy-duty, which is why I did not use them really ^^ too much load.

I believe I included a description how to implement those things in DP Edition, hence it lacks necessary hooks. Mailfunctions is a pretty nice hook btw.
Logged
Aeo
Mod God
*****
Offline Offline

Posts: 1079


Doctor.. Who?


View Profile WWW
« Reply #43 on: June 04, 2012, 09:14:23 AM »

Those hooks are heavy-duty, which is why I did not use them really ^^ too much load.

I believe I included a description how to implement those things in DP Edition, hence it lacks necessary hooks. Mailfunctions is a pretty nice hook btw.

I added the mentioned implementations.. and it resulted in a problem I posted earlier.
Logged


Time Lords Online - A Doctor Who RPG! Open Now!
~ My Modules: PM me if you'd like me to code something! Smiley ~
Nightborn
Captain of the Guard
***
Offline Offline

Posts: 157


View Profile
« Reply #44 on: June 06, 2012, 02:10:39 PM »

I believe I mentioned "how to plug it in". The delete function does only check "hey, did you hit a post button?" and not what kind of info gets through.

So it just deletes any checked messages. It will not check "hey, do I need to delete or is the POST going on for something else?"

That's bad handling core-wise, from what I recall.
Logged
Pages: 1 2 [3] 4   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Version 1.1.2 is the current supported version and is available for download.

Support Us
$100 raised this year
Your help is greatly appreciated!
Who's Online
32 Guests, 0 Users
DragonPrime LoGD
Recent Topics
Home Forums News Links Downloads Login Register Advanced Search