Jump to content

-iSynthesis

Member
  • Posts

    2,604
  • Joined

  • Last visited

Reputation Activity

  1. Like
    -iSynthesis got a reaction from Dat Guy in PHP Help   
    I don't want to make it too complicated. It is a website for a school project and i want a few others to be able to add text (an article) to one file (other-site.php). 
  2. Informative
    -iSynthesis reacted to mariushm in PHP Help   
    Don't use $_GET , use POST method to submit forms. 

    Then use $_REQUEST to retrieve data , $_REQUEST holds both $_GET and $_POST, so it can be used throughout pages for simple things like $_REQUEST['id']  for pages like viewarticle.php?id=1  or for more complex stuff like whole chunks of text that wouldn't fit inside the URL ( which would be how data is sent to the server and then shows up in $_GET array
     
    Don't replace text within PHP files.  Store the data inside individual text files, see functions like file_get_contents to read the contents of a whole file into a string in memory, or file_put_contents  to store data into a file.
     
    The most complicated part would be having unique IDs for each page in your Wiki. A database would take care of unique IDs very easily but if you don't want to use databases, you can store this information into a separate text file.
     
    For example, your configuration file would be something like this (you make the assumption that the content of page with unique id 1 will be saved in the 1.txt and so on)
     
    1|Main Page
    3|About
    4|Random Page
     
    And when you want to add a unique page you just have to read all those lines in memory and determine the last number  and increment that by one and write it to file.
    Here's some simple code for that

     
    <?php $enter = chr(0x0D).chr(0x0A); // two characters in Windows CR + LF (carriage return and line feed) $cfgfile_contents = file_get_contents('database.txt'); // splits the whole contents of the database.txt wherever it detects the enter character combination, and puts it into an array // so $rows[0] = '1|main page' ; $rows[1]='3|About'; $rows[2]='4|Random Page'; and so on. $rows = explode($enter, cfgfile_contents); $rows_count = count($rows)-1; // because arrays start from 0 .. so if we have two lines in the text file, $last_id = 1; // we assume the last used unique ID was 1 because so far we don't know how many pages there are in the cms // now we go through each entry and separate 1 and the title of the wiki page foreach ($rows as $key => $value) { // key is 0,1,2,3 the unique position in the array, the $row holds the actual value for that position in array // key isn't necessarily equal to the unique id, because you may delete some pages at some point and you won't reuse those numbers $rows[$key] = explode('|',$value); // now $rows[0][0] = 1; $rows[0][1] = 'Main Page'; now $rows[1][0] = 2; $rows[1][1] = 'About'; ... and so on if ($rows[$key][0] > $last_id) $last_id = $rows[$key][0]; } // if you want to add a page to your cms . $last_id = $last_id + 1; $rows_count = $rows_count+1; $rows[$rows_count] = array( 0 => $last_id, 1 => 'New title page'); // if you want to delete a page, just set the title to an empty string and when you save the text file you don't write that line // if you want to save changes $file_handle = fopen('database.txt','w'); // open a file handle with the mode 'w' , write only ) $first_line=TRUE; foreach ($rows as $key => $row) { if ($row[1] !=='') { // page title is not empty aka you didn't delete this page if ($first_line==FALSE) fwrite($file_handle,$enter); // no need to advance to new line if we're writing the first ever line in the text file $first_line=FALSE; fwrite($file_handle,$row[0].'|'.$row[1]); } } fclose($file_handle); // close the file ?> and the page that shows what user entered, would read the text file (1.txt, 3.txt, 4.txt etc ) using something like file_get_contents(filename) but you don't just use echo $file_contents  because some characters are not allowed to be printed directly into a html page.
    Use a function like htmlspecialchars to convert characters that have special meaning like <  and > and & into a combination of characters that's safely parsed by browsers.
     
    if you learn some url_rewrite rules, you can make your cms have nice urls like  www.yoursite.org/pages/1/Main_Page , www.yoursite.org/pages/3/About  and so on
    The web server converts those URLs based on the url_rewrite rules to your viewarticle.php?id=1 , viewarticle.php?id=3 and so on  then your code in viewarticle.php  uses $_REQUEST['id] to get the unique ID from the URL , makes sure the is actually a number, optionally read database.txt to extract the page title for your page if you won't save the title as a first line in your 1.txt, 2.txt , 3.txt and so on
    then echo/print the contents of the unique text file after you escape the contents using functions like the one i mentioned above.
     
  3. Informative
    -iSynthesis reacted to mariushm in PHP Help   
    The problem with non-database CMS systems is that it's more difficult to prevent two or more users simultaneously apply edits to a page. Especially if all the content is stored in a single big file.
    In addition to that, some file systems are slower when there's lots of files inside one folder ... for example, NTFS is much slower at parsing the contents of a folder and reading the first byte of a file if a folder has more than maybe 1000-2000 files in it, regardless of their size. Write a small php script with scandir or a c program with the windows api functions like findfirstfile and so on, and time how long it takes with a large folder and with a small folder.
    That's why lots of websites (for example mediawiki based sites) store files in multiple subfolders,for example they create a unique SHA1 hash for each file and then store the file on disk in "files/01/0156/01560024d4ae.. " in order to reduce the chance of one folder going over around 1000 files.
    When there's a chance multiple users may hit save and change a file at the same time, you'd have to complicate your life with your script LOCKING the file to be read/write only to that thread, make changes, unlock the file ... if another script tries to save at same time it would be unable to open the file because it's locked by another instance of the script (which would be often if you store all pages in a single big file), you'd have to implement a sort of "delay and retry a few times until you obtain a lock on the file"
     
    With a database, you'd have row level locking at least so you can start a transaction and lock that row, read the contents, make the edits, save them , close transaction and you can be sure no other thread messed with the content between the moment you read it from the row and made the changes.
    Think mediawiki (wikipedia and sites like it) and how they make DIFFs between current version and the changes made by user (that he wants to save) where they create revisions and store the changes in order to allow for undo/revert changes .. the creation of such diffs can take time which means those rows can be locked for a few seconds.
     
    With plain files you also have the issue of them being cached by the operating system and not having control over when they're dropped from memory, and if they're not cached but you have lots of people reading different pages, you're limited by the hard drive's i/o throughput especially with small files ,,, run a hdd benchmark tool like Crystal Disk Mark and see how fast a regular hard drive can read 4KB chunks of data (hint: it's below a few MB/s)
     
    A smart database system would cache the whole table in memory and keep it there, if it has the memory to do so, and would only commit changes to disk. it would also cache the queries like "get me the title of the page with the unique id 123456" - you wouldn't have to read the contents of a whole file in memory and parse it to find the line with id 123456 and retrieve the page title from there, the database would know it made that query at some point in the past, so it knowns the data is in row xyz in table abc, already cached in memory at position xxxx so it jumps there, reads the bytes for that row and returns the title of the page. 
     
    So basically, your scripts will retrieve the content of each page much faster.  And, in the case of systems like mediawiki where  a page can be made of multiple other pages, it's way faster to retrieve all components, parse/compile them , then store a "compiled" version of the page in memory using something like "memcached" 
     
    // apologies for typos, damn temporary keyboard (broke my old one and it's not sold anymore so have to search for a new one) ... not used to the layout of the keys on this crap one and it's much harder on the fingers compared to my old one so sometimes i miss some keys by not pressing deep enough
  4. Agree
    -iSynthesis got a reaction from i_build_nanosuits in 1050 Ti for Game design   
    While I have not worked a lot with engines, i highly doubt this. Battlefield 3 was created even before the HD 7000 Series of AMD. After your theory, they must've had a terrible experience creating the game.
    Of course, Engines have become more demanding but OP is (probably) not trying to create the next AAA game so i see no problem. 
     
    Unreal Engine lists "DirectX 11 compatible graphics card" as recommended hardware so...
     
    Edit: As to your question, @Zando Bob: I guess there would only be the RX 460 which is under 140$ and i believe the 1050ti performs better in most cases, though both gpus will be good options.
  5. Like
    -iSynthesis got a reaction from Akamii in Backplate really matters?   
    It looks good, other than that they have little to no use. Until one or two years back almost no GPU had a backplate.
  6. Like
    -iSynthesis got a reaction from madknight3 in Changing code style in Jetbrains Webstorm   
    You honestly saved my life, thought i had to abandon this program already^^
  7. Agree
    -iSynthesis got a reaction from Dat Guy in I'm confused about the commenting part in python   
    Why not. It helps a lot, f.e. when looking at older code of yours to have comments. Saying you don't comment for yourself is stupid because it can help a lot. If you're writing a larger program you will likely not remember what some methods do or what a variable is used for etc. 
    Edit:
    I guess another good example is html. On a website with several <div> tags in a row it helps a lot to comment where which div tag ends, instead of just </div>
  8. Funny
    -iSynthesis reacted to hardtofindinthefuture in Whats Your Response to this ad   
    thats offensive to me
  9. Funny
    -iSynthesis reacted to FRN in Calculations not printing   
    I certainly hope this isn't the source code of CSGO.
  10. Agree
    -iSynthesis reacted to Arty in Random poll: What text editor do you use?   
    Brackets.io
  11. Agree
    -iSynthesis reacted to TheBestUserName in What can I buy for 500   
    A really great hooker for the evening. 
  12. Agree
    -iSynthesis got a reaction from MrDynamicMan in Click bate with CES content makes it frustrating to know what the product is   
    It's obvious that a title like that draws views. That's what it's for, still doesn't make neutral news though. TBH, the example is quite unfortunate because theres not much to talk about a rgb water cooling fitting, IMO a video on a thing like that is unnecessary. It would be enough to just shortly mention it in another video of EK. I'll give an example where i find the title o.k.: "Slim Gaming Notebook for $800" - Gives precise information. No clickbait, just a short description of what the video will be about. You still want to know more information about the laptop, that's what the video is for. Then i'll give you an example of a worse title: "$599 Cube of DREAMS" - What is this Cube? Is it a Computer? Why would it be a dream of mine? Clickbait at it's finest. The title could just as well be "Cube-shaped computer priced at $599" or something similar and thereby be neutral. 
  13. Agree
    -iSynthesis got a reaction from SSL in Click bate with CES content makes it frustrating to know what the product is   
    It's obvious that a title like that draws views. That's what it's for, still doesn't make neutral news though. TBH, the example is quite unfortunate because theres not much to talk about a rgb water cooling fitting, IMO a video on a thing like that is unnecessary. It would be enough to just shortly mention it in another video of EK. I'll give an example where i find the title o.k.: "Slim Gaming Notebook for $800" - Gives precise information. No clickbait, just a short description of what the video will be about. You still want to know more information about the laptop, that's what the video is for. Then i'll give you an example of a worse title: "$599 Cube of DREAMS" - What is this Cube? Is it a Computer? Why would it be a dream of mine? Clickbait at it's finest. The title could just as well be "Cube-shaped computer priced at $599" or something similar and thereby be neutral. 
  14. Agree
    -iSynthesis reacted to mrchow19910319 in Click bate with CES content makes it frustrating to know what the product is   
    Agree. Unsubbed long time ago. Everything feels too cheesy for me. The ridiculous thumbnail, all the obvious product placement, also let's not even forget  about all those "I spend $100000000 on a pc so I am cool" videos. Compare to watching his vids, I prefer sometimes come here and chat with people, see the latest tech related news and stuff. I know I am not the only one who feels this way. So. *hand shake*
  15. Agree
    -iSynthesis got a reaction from dalekphalm in Click bate with CES content makes it frustrating to know what the product is   
    Well it's what differs quality news from click bait. You saying you wouldn't watch the video because the title gives the most important information of the video is like saying you wouldn't read a newspaper article because the title gives the most important information. 
  16. Like
    -iSynthesis got a reaction from Siard in Disappointing performance RX480   
    I maxed out BF1 (Beta though, probs. a bit better performing now...) on my RX 470 and got around 60-70FPS. I would suspect your CPU to be the issue here. Battlefield is quite CPU intensive and your i5 is 4 years old now. 
    Edit: Should've read the last few posts i guess, sorry
  17. Informative
    -iSynthesis reacted to AJJaxNet in Short question on AudioConverter (Java)   
    You can use the Path object in java : https://docs.oracle.com/javase/tutorial/essential/io/pathOps.html
  18. Like
    -iSynthesis got a reaction from AJJaxNet in Short question on AudioConverter (Java)   
    Thanks a lot, that's all i needed^^
  19. Informative
    -iSynthesis got a reaction from shadowbyte in CS GO on the 360?!   
    Lol. I cant even play tomb raider on controller, with aim assist
  20. Like
    -iSynthesis got a reaction from Misanthrope in RX 480 4GB vs 8GB   
    Well they haven't put any pictures up etc. but here's the link:
    http://www.mindfactory.de/product_info.php/4096MB-Sapphire-Radeon-RX-480-Nitro-OC--4GB-GDDR5--DVI--2x-HDMI--2x-Disp_1114532.html
    Thanks!
  21. Funny
    -iSynthesis reacted to BuckGup in flying on a airplane next week   
  22. Agree
    -iSynthesis reacted to iiNNeX in GTX 970...Faulty Again ?????   
    I would honestly try and get a refund and save for the gtx 1070 or amd rx 480. The 970 was a disaster from release in my eyes...
  23. Agree
    -iSynthesis got a reaction from Prokart2000 in Best less $50 gaming keyboard   
    The Microsoft Sidewinder x4 is quite amazing for its price. 
  24. Like
    -iSynthesis got a reaction from Mr.Meerkat in Will PC components become more expensive   
    I don't think so. I have not heard of a single person in germany wanting to leave the EU, it's basicly just the "AfD" which is just a, excuse my language, fucktarded right-populist nazi party. (They are the ones who thinks that we should shoot at unarmed refugees outside of our borders so... )
  25. Agree
    -iSynthesis got a reaction from PlayStation 2 in Apple...   
    Well Microsoft gives the Option to upgrade, why the hell would you not do it, lol. A normal User, who wants to use his PC normally and has no idea how to clean install an OS is ignorant and lazy to you? If Microsoft gives the option it damn has to work otherwise its Microsoft fault for implementing something which doesn't work. Then take a look at how many reddit posts, forum threads etc. exist around "start menu windows 10 not working". As said, i tried your sfc /scannow which did nothing. Later ran the often reccomended option of: Get-AppXPackage -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}, which worked until the next restart, same goes with the .bat file.
    You call OSX an operating system, which only "technology-incompetent" people use. Completly disregarding that most Professional Users actually use OSX, not Windows, if it's Image Editors, Programmers, Video Editors etc.
    You're one of the typical "Microsoft peasants", no OS out there could ever be better than Windows and everybody in the entire world wants to go into the cmd to get an OS working, otherwise they are technology-incompetent. Good logic. 
     
    Edit: As this is turning into one of the thousands of Apple-Microsoft wars, maybe accept other peoples opinions and don't always think that your option is the best? Thanks. 
     
×