Jump to content

lawless

Members
  • Posts

    19
  • Joined

  • Last visited

lawless's Achievements

Newbie

Newbie (1/5)

1

Reputation

  1. Just after sending I realized the solution I can simply name the array I am using directly at the source, when it first gets written. foreach ( $array_dbtable as $key => $value ) { $this->array_dbtable[$value['id']] = $value; } My old approach: $this->array_dbtable = $array_dbtable;
  2. Hello there again! I have the following construct of array now (schematics): array[0] array[id] = "1" array[title] = "title" array[1] array[id] = "3" array[title] = "another title" Now what i want to do, is to assign the parent-array keys to the IDs of it's contents. This is what it should look like: array[1] array[id] = "1" array[title] = "title" array[3] array[id] = "3" array[title] = "another title" How do I do that again? I know I did this some years ago, but I can not remember how.
  3. Well I had the insane idea, that I must - Create an array which contains the wildcards as KEYS and the variable (as string) as VALUES - run through an foreach loop to replace those (string) VALUES with the correct VALUES - run through another foreach loop to replace the actual template wildcards with the (now) correct VALUES This was one logical approach I do not wish anyone to think about For the solution I did the following: - Create an array with the acutal VALUES that should be entered in the string - run the strtr() function This is so much easier then whatever twisted thought I had in mind before. The problems with the first approach were (a) that is was too complicated and (b) catching the string to replace with the value. For that I would have had to run another foreach loop to rush through the array and replace the placeholder values with the correct values anyways. So why not directly inserting the correct value at the first time Thank you very much for your help. I guess sometimes you've gotta take a small break from overthinking an solution.
  4. Hello there I'm looking for an solution to an very specific problem. In order to make my template system working, I need to replace certain strings with different values. For example %%title%% will become $value['title']. Now when trying this manually with strtr() or str_replace() everything works fine. This is kinda much to code, so I'm running an array through the strtr() function. The problem is, that my array does not take the value : $value['title'] (string) $array1['%%title%%'] = "{$value['title']}"; // same as $array1 = array( "%%title%%" => "{$value['title']}"); I tried it with brackets, without, with escaping (backslash), with reference and I don't know why this does not work. The $value variable is another array which contains entries from the database (already running inside an foreach loop where this code is situated at). Without the array, I can echo out the content without problems. After I add this value to my array, var_dump() gives me: Array ( [%%title%%] => ) It SHOULD give me: Array ( [%%title%%] => $value['title'] ) That is what i need to run the string replacement function. And yes, I tried it with different keys. This key does work properly as intended (function does take it as normal string). So the problem only can be situated at why my array does not take this string. Can I mark this as string somehow I do not know of?
  5. Webapplications are generally unsafe, unless you make them safe. The only way to do this is the following: (picture attached) Only if you follow these steps, your webapplication may be secure for the most of the time. It is much more easy to secure an piece of software that is running constantly (locally installed software) instead of an application which runs once and then dies. I see this aspect as an main component for unsecure websites. Then again million of websites are not using SSL, because, well, nothing much happens. Even if you lose a few sets of data to an attacker, nothing much will be lost. Reset the password, disable the account until the user verified his account by email and you're done. My bank has to use SSL, because if they don't I will have no money. This site or other communities do not need that harsh security measurements, just because there is no valuable data to lose (in terms of money speaking). A few obstacles in the way for the attacker, like checking for special characters, control characters and encoding / decoding, email-verification and so on are quite good enough for those kind of sites. You won't need to buy the right to use an SSL certificate, only if you are in need of it (running an webshop, handling money transactions and so on). By changing the user's input on the client side you do not know what really happens. Maybe there is an attacker using encrypted "test" user logins, while you just accept them (because they are encrypted, that's why my javascript did work - i do not need to worry about it). Javascript is nice for handling client requests, loading parts of your website and having nice (or annoying) graphical effects. But then again for security: do not use. Let's say your application is locally installed with an encryption system. You do not want to give the full system to your user. The client shall request an encryption method after authentification (maybe paired with an auth key), then encrypt the data with that particular instruction, send it using an secure protocol and only receive the answer after he is officially validated as user X. This compaired with regular re-checks of his authentification and validation thereof grants great security. Something that is missing (except when using SSL) for webapplications written in PHP, ASP and other languages that run the same way PHP does.
  6. Awesome, you just made my day I really don't know how I could not see that.. Thank you very much Jacques!
  7. Hello there After a few years of spending less and less time coding, I've got a lot of catching up to do. Back when I left I usually would run without classes. Now this is a big deal for me today. I do understand the concept of classes and already did some working models, mostly from my learning process. Now here is what is bothering me: <?PHP class database { // Variables public $test; // Constructor public function __construct() { $test = "4"; } // Functions // public function test() { var_dump($this->test); } } $test = new database; $test->test(); ?> Wether I run this script on itself, nor through another file, this does work. What i get is: NULL The constructor does run, I did an echo inside it. Also it does not matter if the variable is public, private or protected - it will be always NULL. Error_reporting is on E_ALL, does not show any errors. What have I overlooked?
  8. Testsettings 1 FF 30.0 Active: * Javascript * Flash * Cookies * CSS Blockers: * Ghostery * AdBlock Plus * Popups - Not found -- Login -- Menu - Register -- Country settings do not show any values -- 'eye' button on the password does not work - Newsletter -- Confirmation box pops up without me noticing the first time (wrong placement / too fast gone) - Buttons to Webapplication -- Give me a link to the startpage with an hashtag added (http://www.aptugo.com/#) Ending test Testsetting 2 Opera 23.0 Active: * Javascript * Flash * Cookies * CSS Blockers: * Popups - Register -- Country had to be added (may add 'test', 'test2', etc to spam your database) - API function list -- Unknown column 'Functions1409866626.CodeSample' in 'field list' (Gives me nice opportunity to recreate database scheme) - Pricing -- Extensive details on payment options lead to the entry page / free page - Languages -- Changing the language does nothing - Links -- Privacy policy & -- Terms of service are no where to be found - Comments -- Comments do load from Disqus instead of your own site? Why the outsourcing? - Buttons to Webapplication -- Give me a link to the startpage with an hashtag added (http://www.aptugo.com/#) Ending test Overall.. nothing works for me. The main browser (FireFox) with adblockers and social deniers active, I do not even see the top navigation. There is no application loading which I could possibly use to create anything. I do not know how to navigate your site. I'm pissed of by the use of Disqus. What I do like is the design (and the name). It's quite straight forward. When everything does show up where it's supposed to be on the user's display, it's quite intuitive how to use. The navigation is a bit awkward though, most of all because I do not know where the "main" application is hidden. The pages load quite well and fast. There are some bugs in your project. Also you are showing some to people with (custom?) error messages. I just got another one when cruising through your website again. What to do: Catch the errors into a file and make them only visible to yourself. I know it's open beta and stuff, but I (the user) do not care about your database errors in particular. Show a 'out of order, coming back soon' page without further details. Catch up on why i cannot open your webapplication and please do replicate why FireFox won't show the top navigation. This is crucial - always check what the user's display will show. In my case, I would have left your site without ever trying again. Disqus is a nice feature, millions of people like it. I do not. It is generally blocked by Ghostery and I will only unblock it / use another browser if I feel, that your web project will fill my needs. What I do want to see when I'm visiting this kind of project website is a demo. I don't really care if this is an Youtube video, some kind of screenshots with textual explanation or an actual demo where I may click myself through some functions. Deploy this on the main page (or at least one big enough button 'DEMO' whatsoever) and I might stay a while. As I could not do anything except exploring some content on your website, I can not tell on your project status.
  9. You can store the date as timestamp in your database, then when you read it out, use the date() function to convert it to the format you need to display. I'd recommend another column with TIMESTAMP (timestamp type), and the setting STANDARD to CURRENT_TIMESTAMP. Like the ID, this field will then be automatically filled, so you don't have to worry about manually saving the time into your database. When you get the data from your database, simply convert it: $date = date("d.m.Y, H:i", $timestamp); For the complete set of options how you can convert timestamps into readable dates, there is a list on the php manual page. http://php.net/manual/en/function.date.php You can also group the day, month and year together and use another variable for hours and minutes. That's up to your preference.
  10. Define "working". The e-mail check on the contact page does sure work. If you want to actually send data through the internet (or save it anywhere), you will have to tell us what server-side language you are working with (if not php), what your script looks like, where the data will be send / stored, etc. For now I do not conclude how your forms could possibly work with this current setup.
  11. Basically yes. The system will run your code like that: // index-file include("grabber.php"); // runs the file "grabber" here, variables are set now echo $title; // works, because the title variable has been set already And yes the syntax is quite wrong, I just made it a scheme for better understanding. The correct way would be to do a single query instead of three different ones, and to manipulate the result given so you may use it in array-form. $id = "1"; $query = "SELECT * FROM table WHERE id = '$id'; $result = mysqli_query($query); while($data = mysql_fetch_assoc($result)) { echo $data['title']; echo $data['content']; echo $data['author']; } You may use this script (or the one that works for you) everywhere in your file you want, just make sure the code for the DB connection comes first.
  12. Yes, IP bans are not really working. If you think of the mobile phone network where a LOT of users share the same IP, you are asking for trouble. The concept of keeping certain people out is nothing more than the concept of letting certain people in. With an upright registration process ((self-made) captcha, e-mail activation) and and good user management are the keys that you are looking for. Anonymous or in that case unregistered users should only have access where they can not inflict any damage on your project. But keep in mind, that every security measure can be bypassed, set on the skill levels of the uninvited guest. So don't make it too hard for your upright users to use your project.
  13. If you have a code without functions (which is called procedural programming), which you have right now, the program goes like that: connect db write contents to db get contents from db In that case you can connect to the database within the whole script, as long as the connection to the database comes first. If you are going to structure it (without classes) you will have to pass in the connection to the specific functions, which need the connection in order to work. // This gets executed first in your script $connection = mysqli_connect(data); // your function declaration function read_stuff($connection, $data) { // query } // use the function (i.e. in index.php) read_stuff($connection, "data"); Without passing on the connection to the functions, the function will fail to execute with "no database access" error. Yes, there are better ways to do it, where we would ask about classes again Pass in the connection and it will work. The messy code you have right now is simply because it is not well organized. With time and practice you will understand what component does what and you will be better and structuring your code. The good thing is: you already started outsourcing your code with the use of your 'connect.php', 'header.php' and so on. That's the first step towards an organized structure. Keep it up!
  14. You should divide your files by usefulness in the project. How much you divide those files is up to you (how many files you make). There are simple approaches with procedural (top-down) programming, some more advanced procedural with functions and the object oriented approach with classes. For the beginning, I would start with procedural with functions. First of, write down a scheme pen & paper style, what you want and what the different files will do. Let's start from the most important to the less important - RIGHT to LEFT. 1) The database is where all my data is stored. It's the most important thing, because where there is no data, there is no script to write for. (Alternative text files) 2) In order to access the data, I need some kind of database connection. I name it database.php, which contains the connection 3) I have the connection, but I still need to read / write data. Therefore i have functions that allow me to do so. 4) The data i have to write in order to put it into the database AND the retrieved data which will be shown on the index For easier understanding: // index.php <?PHP require("database.php"); require("inputOutput.php"); writestuff("MyStuff"); readstuff("DBStuff"); ?> // inputOutput.php <?PHP function writeStuff() {} function readStuff() {} ?> // database.php <?PHP function connectDB() {} ?> You may use this procedural / function based style to widen your skillset, until you are ready for object oriented programming. This style i showed you still works fine and is used throughout the internet. Of course, bigger software will be very hard to accomplish without objects, but you are learning at the moment, start at the beginning. With this style you can simply add new functions (and new files) as you wish without too much hard work and change a bit here and there without searching through thousands of lines of source code. Remember: Pen & paper and most of the work is done.
  15. A simple checkup before you go for the query should work this out. Just check if the value has been stored into the variable, else put some default value there. $mxitid = $_SERVER["HTTP_X_MXIT_USERID_R"]; if(!isset($mxitid)) { $mxitid = "DEFAULT"; }
×
×
  • 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.