Jump to content

jimboppin

Members
  • Posts

    41
  • Joined

  • Last visited

jimboppin's Achievements

Member

Member (2/5)

0

Reputation

  1. hi, im still trying to get my function to work.. i have done this so far its not working the way i want but im getting closer i just cant get it to work properly. function get_media($media_cat, $display_recent) { global $Parsedown, $media_id; if (!empty($media_id)) { if ($media_id == $media_cat) { $display_recent = null; } } $directory = MEDIA_BASEDIR.$media_cat.'/'; $files = array(); $files = glob($directory.'*.txt'); foreach ($files as $file) { $line = file($file); $date_time = $line[0]; $date_time = $Parsedown->text($date_time); uasort($files, function ($a, $b) { global $date_time; return strcmp ($a[$date_time], $b[$date_time]); }); $recent_content = array_slice($files, 0, $display_recent); foreach ($recent_content as $media) { $content = file_get_contents($media); $media_title = basename($media); $media_title = basename($media, '.txt'); thememediatop($media_title, $media_cat); echo $Parsedown->text($content); thememediabottom($date_time); } } } here is the txt file this is a example.. 02/03/2017 5:12pm everything from here on is content some content more content i think its got somthing to do with return strcmp ($a[$date_time], $b[$date_time]); because i get this error String offset cast occurred please help me with what i want here. thanks
  2. heres what i did.. obviousley its wrong.
  3. i did try and implement this, but its not what im looking for.. i just need to read the date and time from the first line and use that line to order my files, i dont see the problem. im not here to argue ill just move on then.
  4. thanks i know its alot better to have a database but its alot more work when i can just make a little function to collect a text file and its contents, also the speed difference sql and txt files is just stupidly fast so for a site that dose not require users or admin i would much rather stick to this function. sorry to take 2 steps back, if you cant or dont want to help me thats fine i can seek help some where else, no affence. i just need to read the first line that will have a date format on it.. read it and arange by that date from the top line then output while ignoring the first line for content. thanks again.
  5. also tutorials and examples are out of date that i found...
  6. Hi, thankyou for reply, i do have sqli, i was on that track but i couldont work out how to get it secure when posting username and password etc i dont want my username or password sniffed out when its going thru to the script, i honestly would need help to get me going on somthing like that, i would need a secure basic sql login and then how to post to the database securley when adding data to it... this is what made me try and make it more simple because i live in notepad++ and filezilla it just made sence to me. im willing to learn if some one is willing to help me get going with it i can self teach the rest but security makes me on edge
  7. sorry i see how that works now, i was hopeing to be able to just upload a txt file no worries, and to do that the only thing i can think of is to put the date and time in the first line of the text file and then read the first line to sort by date first line being line[0] i know how to read the first line im just stuck how to use it in the uasort function thanks
  8. hi im trying to implement this to my code as i found out that if i backup my site then upload it all my news is reset and gets mixed up.. how do i format my txt file so this can read it and sort it out? i imagin somthing like this... date>27/02/2017 6:48pm anything after the above line is content some contentsome contentsomesome contentsome some contentsome contentsome some contentsome content some contentsome content some contentsome content some contentsome contentsome content heres the function... function get_media($media_cat, $display_recent) { global $Parsedown, $media_id; if (isset($media_id)) { if ($media_id == $media_cat) { $display_recent = null; } } $directory = MEDIA_BASEDIR.$media_cat.'/'; $files = array(); $files = glob($directory.'*.txt'); uasort($files, function ($a, $b) { return strcmp ($a['date'], $b['date']); }); $recent_content = array_slice($files, 0, $display_recent); foreach ($recent_content as $media => $fdata) { $content = file_get_contents($fdata); $media_title = basename($fdata); $media_title = basename($fdata, '.txt'); if (file_exists($fdata)) { $date_time = date ('F d Y H:i:s', filectime($fdata)); } THEMEMEDIATOP($media_title, $media_cat); echo $Parsedown->text($content); THEMEMEDIABOTTOM($date_time); } } thanks again
  9. i have this in my mainfile require_once INCLUDES_BASEDIR.'_parsedown.php'; $Parsedown = new Parsedown(); $Parsedown->setMarkupEscaped(true); and this is another update on my function to collect news or announcements etc function get_media($media_cat, $display_recent) { global $Parsedown; if (isset($_GET['id'])) { $media_id = htmlentities($_GET['id'], ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); } if (isset($media_id)) { if ($media_id == $media_cat) { $display_recent = null; } } $media_dir = 'Media/'.$media_cat.'/'; $directory = PAGES_BASEDIR.$media_dir; $files = array(); $files = glob($directory.'*.txt'); usort($files, function($x, $y) { return filemtime($x) < filemtime($y); }); $recent_content = array_slice($files, 0, $display_recent); foreach ($recent_content as $media) { $content = file_get_contents($media); $media_title = basename($media); $media_title = basename($media, '.txt'); if (file_exists($media)) { $date_time = date ('F d Y H:i:s', filemtime($media)); } THEMEMEDIATOP($media_title); echo $Parsedown->text($content); THEMEMEDIABOTTOM($date_time); } } then i just add this into a page i want to show my content <?php get_media('News', 2);?> other then the permissions is this all ok now? i will look into the permissions thanks
  10. markdown is here i hope iv got it right function get_media($media_cat) { global $Parsedown; if (isset($_GET['id'])) { $media_id = htmlentities($_GET['id'], ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); } if (isset($media_id)) { if ($media_id == $media_cat) { $media_dir = 'Media/'.$media_cat.'/'; $directory = PAGES_BASEDIR.$media_dir; $files = array(); $files = glob($directory.'*.txt'); usort($files, function($x, $y) { return filemtime($x) < filemtime($y); }); foreach ($files as $media) { $content = file_get_contents($media); $media_title = basename($media); $media_title = basename($media, '.txt'); if (file_exists($media)) { $date_time = date ('F d Y H:i:s', filemtime($media)); } THEMEMEDIATOP($media_title); echo $Parsedown->text($content); THEMEMEDIABOTTOM($date_time); } } } } also can you point me in the right direction for windows security regarding the files...
  11. there is a .htaccess file in all directories aswell denying all access the only place i found i cant use them is in my css directory
  12. hi, i have decided to change my files to html and changed the code, is this safe? function get_media($media_dir) { $directory = PAGES_BASEDIR.$media_dir; $files = array(); $files = glob($directory.'*.html'); usort($files, function($x, $y) { return filemtime($x) < filemtime($y); }); foreach ($files as $media) { $content = file_get_contents($media); $clean_content = htmlspecialchars($content, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); $clean_content = strip_tags($content, '<br><p><a><img><h1><h2><h3><h4>'); $media_title = basename($media); $media_title = basename($media, '.html'); if (file_exists($media)) { $date_time = date ('F d Y H:i:s', filemtime($media)); } THEMEMEDIATOP($media_title); echo $clean_content; THEMEMEDIABOTTOM($date_time); } } thanks
  13. not realy, i didont look at it like that... i wanted to use a txt file just because there just articles that consist of <br /> etc nothing big... could i not whitelist some of these ? commonly used html tags? and the server im on is windows so im not sure how the file permissions work... i only see black blocks and xxx in filezilla rather then 755 etc..
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.