chris27
Forum Replies Created
-
Forum: Plugins
In reply to: [Plugin: User Access Manager] PHP getfile() not retrieving documentsHi Alex
Thanks for this. I’m so sorry to give you the runaround – I just realised that half of the files my clients have uploaded to the site don’t even have file extensions in the first place! I don’t think this has anything to do with the plugin and so the original line of code (
$file = str_replace($cur_url[0], "", $cur_post->guid);
) works no problem.Now I’ve almost got it working – the only problem that remains is that neither the
fopen()
orreadfile()
functions are allowed on the production server we use for PHP! I’m trying to find a workaround and will let you know if I do but don’t stress, the plugin all seems to be working great now.Cheers
Chris
Forum: Plugins
In reply to: [Plugin: User Access Manager] PHP getfile() not retrieving documentsOK, an update:
The file_exists() function can not be reliably used with HTTP requests, it is intended for direct filepaths only (ie. C:/Program Files/something.txt). I changed
if(file_exists($file))
toif(url_exists($file))
and added this function declaration:function url_exists($url){ $url = str_replace("https://", "", $url); if (strstr($url, "/")) { $url = explode("/", $url, 2); $url[1] = "/".$url[1]; } else { $url = array($url, "/"); } $fh = fsockopen($url[0], 80); if ($fh) { fputs($fh,"GET ".$url[1]." HTTP/1.1\nHost:".$url[0]."\n\n"); if (fread($fh, 22) == "HTTP/1.1 404 Not Found") { return FALSE; } else { return TRUE; } } else { return FALSE;} }
Now I can get past the “File not found” error, as it prompts me to download the file, however it is still missing its file extension and so will not download correctly. Have you noticed any problems with the file extension being stripped at any point in the code?
Cheers
Chris
Forum: Plugins
In reply to: [Plugin: User Access Manager] PHP getfile() not retrieving documentsHi Alex
Thanks for your reply. I’ve set download type to “Normal” but this hasn’t worked. However, I now think that perhaps my original diagnosis was wrong as the code seems to be dying at:
if(file_exists($file)) { $len = filesize($file); header('content-type: '.$cur_post->post_mime_type); header('content-length: '.$len); if(wp_attachment_is_image($cur_id)) { readfile($file); exit; } else { header('content-disposition: attachment; filename='.basename($file)); if($uamOptions['download_type'] == 'fopen') { $fp=fopen($file, 'rb'); while ( ! feof($fp) ) { set_time_limit(30); $buffer = fread($fp, 1024); echo $buffer; } exit; } else { readfile($file); exit; } } } else { echo 'Error: File not found'; }
It is always returing “Error: File not found”. I’m debugging the code now to see what else it may be – the only thing I’ve noticed is that the $filename seems to have lost its file extension, maybe that’s why it never passes the “file_exists” statement?
Regards
Chris
Forum: Requests and Feedback
In reply to: [Plugin: Events Calendar] Link to existing postaf3
Good question, I’ll take a look at it this afternoon. From what I can see, there is no lightbox (thickbox) function with the list view, only the tooltips pop-up which shows more details. On hover, it appears the events are links, but they don’t click through to anything, so it would be nice to make that the link to the relevant post. Hopefully it’ll just about be a copy/paste job.
Chris
Forum: Requests and Feedback
In reply to: [Plugin: Events Calendar] Link to existing postExcellent. Just a quick update – the original bit of code that goes at the end of the file, you should move that up so that it’s just before the third closing curly brace, otherwise it’s outside of the foreach loop and will only execute for one event! Not a problem unless there’s more than one event on the same day, but it’s better to sort it out now.
Cheers
Chris
Forum: Requests and Feedback
In reply to: [Plugin: Events Calendar] Link to existing postAaah of course! Silly me, knew I’d missed something. You have to declare the $postID variable, as it doesn’t take on any value in the current context. Find the start of your variable declarations, near the start of the php file after all the style stuff. It should look like:
<?php foreach($events as $event) { if(($event->accessLevel == 'public') || (current_user_can($event->accessLevel))) : $title = stripslashes($event->eventTitle); $description = preg_replace('#\r?\n#', '<br />', $event->eventDescription); $description = stripslashes($description); $location = stripslashes($event->eventLocation); list($ec_startyear, $ec_startmonth, $ec_startday) = explode("-", $event->eventStartDate); if(!is_null($event->eventStartTime) && !empty($event->eventStartTime)) { list($ec_starthour, $ec_startminute, $ec_startsecond) = explode(":", $event->eventStartTime);
After this you should set the $postID variable so that it knows what it’s trying to retrieve, as follows:
$postID = $event->postID;
This should solve your problem. The reason this works is that when creating the event through the large calendar in admin, if you tick the “create post for event” box, wordpress DOES actually insert the post ID into the database entry for the event, and so the post and event are effectively linked. The only issue is that, as mentioned above, there is no actual built-in functionality with the calendar which lets your users see the link!
Hope this works.
Chris
Forum: Requests and Feedback
In reply to: [Plugin: Events Calendar] Link to existing postBy the way I’m using events calender version 6.4 and a wordpress install version 2.5, if that helps.
Forum: Requests and Feedback
In reply to: [Plugin: Events Calendar] Link to existing postmsieurbush
The end of my ec_day.class.php file looked like this before:
if(!empty($endTime) && !empty($startTime) || !is_null($endTime) && !is_null($startTime)): /* Added for localisation by Heirem --------------------*/ _e('to','events-calendar');?> <strong><?php echo substr($endTime,0,5);?></strong> <?php /* -----------------------------------------------------*/ endif; if(!empty($startTime) || !is_null($startTime)): ?> </div> <?php endif; ?> <hr /> <div for="EC_description" class="EC_description"><?php echo $description;?></div> </p> <?php endif; } [INSERT CODE HERE] } } endif; ?>
So I just put that code before the penultimate closing curly brace. I’m pretty sure that’s all I had to do to get this bit to work, however I previously changed this file to alter the functionality of the thickbox, but I don’t think that would affect this part of the code…
Forum: Requests and Feedback
In reply to: [Plugin: Events Calendar] Link to existing postI’ve been working on this for a couple of days and it seems that this problem can be solved in around 5 lines of PHP code! I’ve now got the calendar working so that clicking an event on the widget calendar brings up a lightbox, and if that event has a post associated with it then it displays a link to the post page. Which opens in the main window. And shuts the lightbox. Perfect! Find the file called ‘ec_day.class.php’ in the events calendar directory. Before the last ‘endif’ statement, after the ‘description’ div stuff, try adding the following code:
if (!empty($postID) && !is_null($postID)) { ?> <a href="<?php echo $root; ?>/?p=<?php echo $postID; ?>" target="_parent">Full details</a></div> <?php } else { echo ('</div>'); }
This works for me, so hopefully may help a few others with the same problem.
Cheers,
Chris