Jump to content

Mudsaf

Members
  • Posts

    462
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Mudsaf

  1. Yea, how i can turn the string to expression?
  2. Well the values are not actually important. data = data.replace(smiley_list.smileyList[i].smileyCode,"<img class='" + smiley_list.smileyList[i].smileyCode + "' class='sbSmiley' style='vertical-align:middle;' src='script/shoutbox/smileys/" + smiley_list.smileyList[i].smileyURL + "'>"); So bascially i want to replace all codes where is smiley_list.smileyList.smileyCode with src smiley_list.smileyList.smileyCode
  3. Yes, json array for example my_list.listIndex[0].item
  4. var str = "Twas the night before Xmas...";var newstr = str.replace(/xmas/i, "Christmas");print(newstr); //Returns Twas the night before Christmas... Isn't it similar to mine?
  5. data = data.replace(/<myjson>/g,<mystring>); //Didin't work.
  6. Example my data would be like 500 characters long and might contain 10x strings i want to replace, without me knowing the amount how many strings there is & have to be replaced. <script>var string = "THIS CAN BE REALLY LONG STRING :I: :I: asdas :I:"; //IDK HOW MANY :I: strings there would be//Replace them all</script>
  7. Hello, i'm wondering how to replace all data from content not just the amount $.each function gives. i = 0;$.each(<JSON CODE>, function() {data = data.replace(<REPLACE CODE>,<REPLACE CODE>);i++;}); Example now the result from each is 2 and will replace only 2 items, but if there is more items on data how that works?
  8. So basically you want paragraph with no padding? Try these <p style='margin:0;padding:0;'></p> <!-- Removes margin & padding --><span></span> <!-- Has no padding or spaces --><div></div> <!-- Displayed as block so will leave space after -->
  9. Hello, i'm wondering how to remove all unclosed tags like below <a href='<mysite'>Yeooeoeoo //Remove this<ul><li>Oh no this has links too..</li> //Keep working tags</ul> I'm not sure does strip_tags(); remove them. strip_tags();
  10. I guess there is some function that reads all folders with index file inside.
  11. Hello, i'm wondering does any of you know websites with free smileys. (Legal to use on own website) Added more 10.08.2013 12:31 (GMT +3) Public use No link advertising No title advertising
  12. Im wondering is there anyway to run browser address get query with like this. http://mypage.com?var=1&2&3<?php$_GET['var'][0]; //returns 1 and so on or something similar without repeating var at address bar?>
  13. What you recommend to image size that has max 1000 width + height example 220px?
  14. Mudsaf

    PHP crypt question

    If you want to be secured as possible use sha512 hash('sha512', <yourstring>); This would generate your string to 512 character length of string. If you want security just make some brute-force protection to your website. For example if you try to login 5 times in row in 15 min with wrong account data temp-lock the IP so it cannot login even if it would be correct password. 5 Tries >> 15 min lock >> Unlock >> Repeat Anyways i don't know answer to your question but tried to help in someway
  15. So basically my problem is that the larger comment selection looks way uglier than small, both uses same image but i guess the larger one stretches it. How to fix, need to create larger image or any nice solutions? Element properties background-image: url("<image>");background-size: 100% 100%;
  16. Mudsaf

    Help In PHP

    Make sure you have Apache server & MySQL server on. Make sure your MySQL have remote connection enabled if you're trying to connect anywhere but local address. Make sure that your MySQL user have permissions for selected database. Try this code to your php <?php$host = "<hostaddress>"; //Example 127.0.0.1 or localhost$user = "<MySQL user>"; //Example root$pass = "<MySQL password>"; //Only if you have set, else leave empty$database = "<MySQL database>"; //Database you're trying to connect$con = mysql_connect($host, $user, $pass) or die ("Can't connect to server: " . mysql_error());mysql_select_db($database) or die ("Can't select database: " . mysql_error());/* Yourstuff here *///mysql_close($con); this command to close the connection?>
  17. Hello, i'm stuck on my code and can't seem to get it work. So basically i want to set amount words to check and if there is dot pastes the script. Now it actually does it if sentence is small. <?php $orig_sentence = "What if there was m.aaa. ultiple dotsdmy script work Im not quite sure"; function stip_news($orig_sentence) { //[FUNC] $strip_amount_words = 250; //Example 10 words & find dot position if contains in sentence. $sentence = implode(' ', array_slice(explode(' ', $orig_sentence), 0, $strip_amount_words)); $i = strlen($sentence); while (0 < $i) { // [WHILE] $characters = array("!", ".", "?"); if (substr(substr($sentence,-$i,1),-1) == $characters[0] || substr(substr($sentence,-$i,1),-1) == $characters[1] || substr(substr($sentence,-$i,1),-1) == $characters[2]) { // [CHECK] $sentence = substr($sentence,0, -$i+1); if ($i != 1) { // [CONTAINS DOT] echo "<script> console.log('ORIG: " . $sentence . " Char: " . substr($sentence, -1) . " Num: " . $i . "'); </script>"; echo $sentence; $found = 1; } // [CONTAINS DOT] } // [CHECK] if (!isset($found)) { $found = 0; } //[FOUND 1] $i--; } // [WHILE] if ($found == 0) { // [FOUND 2] echo $orig_sentence; } // [FOUND 2] } //[FUNC]stip_news($orig_sentence);?> Actually almost done with the script, alot of lines removed & soon completed. I will release the results here after i'm finished. Fixed code below, feel free to use & like if u do . Only modify orig_sentence & stop_on_mark functions if needed. Also more arrays can be created to characters but remember to add them to if sentence. <?php $space = " ";$orig_sentence = "First dot. Second dot. Third dot. First questionmark? . LOL."; function stip_news($orig_sentence) { //[FUNC] $stop_on_mark = 2; //Setup how many . ! ? untill sentence stop. $strip_amount_words = strlen($orig_sentence); $sentence = implode(' ', array_slice(explode(' ', $orig_sentence . $space), 0, $strip_amount_words)); $characters = array("!", ".", "?"); $i = strlen($sentence); $count = 0; while (0 < $i) { // [WHILE] if (substr(substr($sentence,-$i,1),-1) == $characters[0] || substr(substr($sentence,-$i,1),-1) == $characters[1] || substr(substr($sentence,-$i,1),-1) == $characters[2]) { // [CHECK] if ($count == $stop_on_mark -1) { echo substr($sentence,0, -$i+1); $found = 1; } $count++; } // [CHECK] $i--; } // [WHILE] if (!isset($found)) { // [FOUND 2] echo $orig_sentence; } // [FOUND 2] } //[FUNC]stip_news($orig_sentence);?> Just had to wait day to get solution from my brain
  18. Ajax solved everything var json_list;$.ajax({ url: "<myfile.js>", dataType: 'json', async: false, success: function(data) { json_list = data; }});
  19. <script>$(function() {var json_list;$.getJSON('../script/json/selectbox.js', function(data) {window.json_list = data;console.log(window.json_list); //Returns undefinedconsole.log(data); //Returns JSON array});});</script>
  20. Well seems like my variable wont pass. Uncaught ReferenceError: json_list is not defined <script>$(function() {var json_list;$.getJSON('<myfile.js>', function(data) {json_list = data;});});</script>/* Later */<script>$(function() { console.log(json_list);});</script>
  21. Hello, i'm wondering is it possible to pass variable inside <script></script> to another <script></script> field. Example i have <script>var message = "Hello";</script><script>alert(message);</script> I know i could add them together in this script i write, but my actual codes is separating the scripts.
  22. Hello, i'm wondering how to store JSON array as javascript variable or something so visitor doesn't have to reload the file all the time. Method getting JSON <script>$(function() {$.getJSON('<myfolder/filename.js>', function(<something>) { /* store <something> */});});</script> "so visitor doesn't have to reload the file all the time", that was badly told. I mean if the script runs more than once at same page.
×
×
  • Create New...