Jump to content


  • Posts

  • Joined

  • Last visited

Previous Fields

  • Languages
    [X]HTML[5], CSS[3], PHP, MySQL, JQuery

Contact Methods

  • Website URL
  • ICQ

Profile Information

  • Interests
    web design, web development, photography

Lykos22's Achievements


Newbie (1/7)



  1. No I'm afraid you 're probably refering to the adjaceny model. I use the nested sets model ( mptt ). This link explains each one pretty well. I would also have to change and the left (lft) and right (rgt) values not only from the node selected, but from the rest of the nodes of the tree too.
  2. Yes I have set up my database like this id (pk)menu_itemparent_id lftrgt and I have also created the functionality for adding nodes/menu items and deleting them. Now I'd like to do the update functionality, where basicly I can move nodes (and their child nodes too if any) everywhere inside the tree. for that I'm planning to use the nestedSortable plugin ( http://mjsarfatti.com/sandbox/nestedSortable/ ). Ijust can't figure out the "update nodes" logic, you know, what steps I should follow to do that. Could you give me some pseudo - sql queries that are used for this functionality?
  3. Hi, I'd like some help please. I'm trying to create the functionality for managing menu items, using nested sets. So far I have created the functionality for adding new nodes/menu items and also deleting them and works fine (INSERTING and DELETING). My problem is that I can't figure out how to do the UPDATE, i.e to move a node and its child nodes (if any) and set it as a child node, change the node/menu items order of display etc etc. I did a research on google, but wasn't friendly enough, perhaps I used and wrong keywords. Adnyway does anyone knows what pseudo - sql queries I must use and the logic in order to update nodes? thanks in advance
  4. Thanks for your reply. What do you mean? 1st way?
  5. Lets take for example the following tables Posts-------------------------postID (pk)titlecategoryID (fk)etc etcProducts-----------------------productID (pk)namecategoryID (fk)etc etcFaqs---------------------faqID (pk)questioncategoryID (fk)etc etc All 3 tables contain a field categoryID, so basicle each post, product, question etc belong to a specific category. I'd like to know which is the best way to create my categories. 1. Create n-different category tables each time, such as posts_categories, products_categories, faq_categories etc etc, so basicly there all will be indipendent. 2. Create a single table for all categories with the following fields Categories--------------------categoryIDcategorytype * // values (probably set as ENUM type - from a dropdown menu): posts, products, faqs etc etc Example [table=width: 500][tr] [td]categoryID[/td] [td]category[/td] [td]type[/td][/tr][tr] [td]1[/td] [td]Science[/td] [td]posts[/td][/tr][tr] [td]2[/td] [td]Shirts[/td] [td]products[/td][/tr][tr] [td]3[/td] [td]Design[/td] [td]faqs[/td][/tr][/table]Which do you believe is the best way to organize my categories ???
  6. Hi, I'm building a custom cms, in which I'd like to add multilingual functionality. I'm trying to design my database structure at the moment, did a little google research and found two database models, so I was hopping if you could recommend which is the best way to follow. Lets take as an example the Posts table, but same thing applies and with CMS-Pages, News, FAQ etc etc 1st scenario: table Posts (will have all items that will not require translations)---------------------------------------------------------------------post_id (pk)date_addeddate_publishedis_visibletrashetc etctable Posts_lang (will have all items that require translations)-----------------------------------------------------------------id (pk)lang_idpost_idtitlepost_bodytable Languages (the available languages)------------------------------------------------------------------lang_idlanguagelang_code So in order to fetch the data from the database, I will have to JOIN, like: SELECT `posts`.`post_id`, `posts`.`date_added`, `posts`.`date_published`, `posts`.`is_visible`, `posts_lang`.`title`, `posts_lang`.`post_body`FROM `posts` LEFT JOIN `posts_lang` ON `posts`.`post_id` = `posts_lang`.`post_id`WHERE `posts_lang`.`lang_id` = 1 // or use the lang_code instead: // WHERE `posts_lang`.`lang_code` = `eng` This looks quite easy, but I have some blank spots that I'd hope to make them clear. 1. how would the INSERT or the UPDATE be? Do I have to store the post on default language first and then do the translations, or do all at once ? 2. What if there's a cms-page or post that don't have all translated versions, or they have only the default versions? For example a post might have only one language (the default) or 2 / 3 (assuming we have 3 languages available, this post has only 2 languages)?? 2nd scenario: table: Posts------------------------post_id (pk)date_addeddate_publishedis_visibletrashtitlecontentetc etctable: Post_translations---------------------------------------post_trans_idpost_trans_titlepost_trans_contentlang_idtable Languages (the available languages)------------------------------------------------------------------lang_idlanguagelang_code So what you can basicly do, is to store default language content inside posts table, as you would normally do in a no-multilingual scenario, and all translated contents store them inside the posts_translations. However I'm not quite sure how the queries are going to be in order to fetch the data. Which of these two scenarios do you think its better to follow? Also is there a better way you believe I should follow? I'd be happy to hear!
  7. Ok, I've tried to convert it using crypt(), so here is what I've come up with: Case1: in a personal website, where there's only one user, me $password = $_POST['password'];$salt = "L0r3mIpsUmD0l0rS1tAm3t";$hashed_password = crypt($password', '$2a$12$' . $salt); Case2: having a site with more than one users $password = $_POST['password']; function generate_salt() { $salt = uniqid(sha1("L0r3mIpsUmD0l0rS1tAm3tc0ns3CT3tur4d1p1sc1ng3lit".microtime())); $salt = substr(sha1($salt), 0, 22); return $salt;}$hashed_password = crypt($password', '$2a$12$' . generate_salt()); How about this?? Does still needs improvements???
  8. Well, I have done this in case of a personal website, where there's only one user,me: $password = $_POST['password']; // password: my_sercretp@ssword123function en_crypt($password){$salt = "lorem_ipsumd0l0rs1t@m3tc0ns3ct3tur@d1p1sc1ng3lit";return hash('sha256', $salt.$password); // can use also different algorithm like sha512 or whirlpool}$hashed_password = en_crypt($password); and in case where there's a site with more than one users (eg blog, e-commerce etc etc) I have this: $password = $_POST['password'];function generate_salt() { $salt = uniqid(md5("lorem_ipsumd0l0rs1t@m3tc0ns3ct3tur@d1p1sc1ng3lit".microtime())); $salt = hash('sha256', $salt);// can use also different algorithm like sha512 or whirlpool return $salt;}function en_crypt($password,$salt){ return hash('sha256', $salt.$password);// can use also different algorithm like sha512 or whirlpool}$hashed_password = en_crypt($password,generate_salt()); Is this considered secure and safe enough (in each case)??? How can Improverd it with crypt()??
  9. Before I begin, I tried to do some research about this subject (the Search field seems its broken and through google was a little bit painful) in the forum, so I'd like to apologise if I'm repeating it once again. I have read some articles about hashing passwords saying that md5 and sha1 are no longer safe and should use better hashing algorithms, how to hash passwords properly by avoiding double hashing, hashing with different algorithms etc etc, so I 've come up with some questions/spots that I haven't cleared them out completely. 1. Doing just this is consinder no safe, although md5 and sha1 cannot be reversed: $password=md5('my_sercretpassword123'); //for instance my password is my_sercretpassword123 although its a bad practice$password=sha1('my_sercretpassword123'); My first question is If I use one of these, using a salt isn't consider safe? eg: $password= 'my_sercretpassword123';$salt = 'lorem_ipsumd0l0rs1t@m3tc0ns3ct3tur@d1p1sc1ng3lit';$password = md5($password.$hash); //same with sha1 If anyone manages to crack this hash, will get the string 'my_sercretpassword123lorem_ipsumd0l0rs1t@m3tc0ns3ct3tur@d1p1sc1ng3lit', which isn't the actual password, right? 2. Supposing the 1st option note is not approved, then I guess I have use a better hashing algorithm like whirlpool or sha256, sha512 ect etc. So If I apply the same functionality like this: $password= 'my_sercretp@ssword123';$salt = 'lorem_ipsumd0l0rs1t@m3tc0ns3ct3tur@d1p1sc1ng3lit';$hashed_password = $password.$hash;$hashed_password = hash('whirlpool',$hashed_password); is it safe enough or I have better come with something more difficult?? I tried to google for some tutorials on this, just to get some ideas, but most of them, if not all, use plain md5 or sha1. Could you give me some examples or ideas on that?
  10. So I'll have to go with this approach , right?? In this case the forms for INSERT and UPDATE statements will look something like this: <form action="" method="post"><label for="title">Title:</label><input type="text" name="title" id="title" /> <label for="description">Description:</label><textarea name="description"></textarea> <label for="lang">Language:</label><select><option value="eng">English</option><option value="fre">French</option></select></form> or do I have to create 2 input text and textareas for each language??
  11. Ok, I'd like to expand the topic a little bit more and refer to the case that I have some content on a page that comes from the database. which is the best way to structure the database in that case???For example I have also a page that outputs albums with images with some descriptions (also apply and in posts/ articles/ pages etc etc) and the db table I have created looks like this: (table name:)albums: (fields) album_id, title_eng, title_fre, description_eng, description_fre, ... Is this a correct approach? From a search I did in google I saw 2 different: 1st. Just add another field named 'language' where gets from a select menu the language (eng, fre) like this: (table name:)albums: (fields) album_id, title, description, language 2nd. Like this with the tick. Which approach is better???
  12. I don't understand how its going to be. Could you give me a simple example or what terms can I use to google for some examples?? Also what if I do this: 1. create two html pages inside includes folder, one named about_eng.php and the other about_fre.php, where each page has all the html content in the specific language2. inside my about.php (root dir) do this: if(isset($_SESSION['lang']) === true){ $pages = scandir('includes', 0); unset($pages[0], $pages[1]); $pg_lang = urlencode($_SESSION['lang']); //check if the value of pages exist in the array if(in_array('about_'.$pg_lang.'.php', $pages) === true){ include('includes/about_'.$pg_lang.'.php'); }}else{ //set default page content include("includes/about_eng.php");}
  13. I don't know XML to be honest , so I'm not quite sure how to do this..
  14. Hi, I have created a website in which I have added the ability the user to choose a language. The structure of my site looks like in the image. Inside core folder, there's the initialize.php file where I have put this: $allowed_languages = array('fre', 'eng');if(isset($_GET['lang']) === true && in_array($_GET['lang'], $allowed_languages) === true){$_SESSION['lang'] = $_GET['lang'];}elseif(isset($_SESSION['lang']) === false){//set default language if not selected$_SESSION['lang'] = 'eng';}include_once("includes/langs/".$_SESSION['lang'].".php"); and inside the langs folder there are both eng.php and fre.php so the code inside them looks like this: //eng.php$lang = array();// Menu - Nav$lang['HOME'] = 'Home';$lang['ABOUT'] = 'About';$lang['CONTACT'] = 'Contact';// Index page$lang['WELCOME'] = 'Welcome to my website!';//About page$lang['ABOUT_PAGE'] = 'This is the about page.'; So in navigation I do: <a href="index.php"><?php echo $lang['HOME']; ?></a>,in index.php for example I do: <h2><?php echo $lang['WELCOME']; ?></h2>, etc etc. My question is if there's a page, for example the about.php, in which I have a lot of content like headings, paragraphs, lists etc etc which is the best way to output it on the page??Do I have to do it all like this $lang['PARAGRAPH_1'] = 'This is the first paragraph.';$lang['PARAGRAPH_2'] = 'This is another paragraph.';$lang['LISTITEM_1'] = 'This is the first list item.';.....<h2><?php echo $lang['ABOUT_PAGE'] ; ?></h2><p><?php echo $lang['PARAGRAPH_1'] ; ?></p><p><?php echo $lang['PARAGRAPH_2'] ; ?></p> or in pages like this there's a "better" way to approach this???
  15. I tried to google the problem but the most results show errors that happend in Aptana's interface etc, I 've also post my problem and to Aptana support pages and waiting for some reply
  • Create New...