Jump to content

Mudsaf

Members
  • Posts

    462
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Mudsaf

  1. 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

  2. That's right, that's not the correct way to use String.replace. Look at the documentation again.

    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?

     

    NEW

    var data = data.replace(/<myjson>/g,<mystring>); //Didin't work.
  3. 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>
  4. 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?

  5. 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

  6. 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 :)

  7. 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%;

    2151.jpg

    1. Make sure you have Apache server & MySQL server on.
    2. Make sure your MySQL have remote connection enabled if you're trying to connect anywhere but local address.
    3. 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?>
  8. 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 :)

  9. 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...