Jump to content

Recommended Posts

What is the initial value of the variable $rp?

 

This works fine:

<?php
$rp = '[TIMES]';
$rp = str_replace('[TIMES]',"<span style='font-family: Times New Roman, Times, serif'>",$rp);
echo $rp;
?>

It echos

<span style='font-family: Times New Roman, Times, serif'>

 

Ken

<select id='font_text' class='text4' onchange='changeFont()'>

<option value='0'>FONT</option>
<option value='ARIAL'>Arial</option>
<option value='TIMES'>Times</option>
<option value='COURIER'>Courier</option>
<option value='GEORGIA'>Georgia</option>
<option value='VERDANA'>Verdana</option>
<option value='GENEVA'>Geneva</option>

</select>

<textarea class='text4' cols='100' rows='15' name='rp' id='rp_area'>$rp</textarea>

 

Javascript:

 


function changeFont(){

if (document.getElementById('font_text').selected=true){

var v = document.getElementById('font_text').value;

var ls = "[";

var rs = "]";

var s = "/";

var y = document.getElementById('rp_area').value;

var x = document.getElementById('rp_area').innerHTML=ls+v+rs;

var z = document.getElementById('rp_area').innerHTML=ls+s+v+rs;

var xz = x+z;

var xy = y+xz;

document.getElementById('rp_area').focus();
document.getElementById('rp_area').value=xy;

document.getElementById('font_text').value=0;

}

}

Sorry I posted the wrong thing.

 

if (isset ($_POST['rp'])){

// define variables

$rp = $_POST['rp'];
$rp_event = $_POST['rp_event'];
$rp_title = $_POST['rp_title'];
$rp_preview = $_POST['rp_preview'];
$rp_category1 = $_POST['rp_category1'];
$rp_category2 = $_POST['rp_category2'];
$rp_category3 = $_POST['rp_category3'];
$rp_global = $_POST['rp_global'];

// error handling

$rp = strip_tags($rp);
$rp_title = strip_tags($rp_title);
$rp_preview = strip_tags($rp_preview);

$rp = stripslashes($rp);
$rp_title = stripslashes($rp_title);
$rp_preview = stripslashes($rp_preview);

$rp = htmlspecialchars($rp);
$rp_title = htmlspecialchars($rp_title);
$rp_preview = htmlspecialchars($rp_preview);

$rp = strtr($rp,"`","");
$rp_title = strtr($rp_title,"`","");
$rp_preview = strtr($rp_preview,"`","");

// current number of RP's for event

$sql_get_counter = mysql_query("SELECT * FROM Worker_RP WHERE worker_id='$worker_id' AND promo_id='$promo_id' AND event_id='$rp_event'");
$counter = mysql_num_rows($sql_get_counter);

// error messages

if ((!$rp_event) || (!$rp_title) || (!$rp) || (!$rp_category1) || (!$rp_global)){

$errormsg = "<p class='text3' style='font-weight: bold; color: #ff0000;'>You did not fill in the following fields</p>";

if (!$rp_event){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>Roleplay Event</p>";

}

if (!$rp_title){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>Roleplay Title</p>";

}

if (!$rp){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>Roleplay</p>";

}

if (!$rp_category1){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>Roleplay Category</p>";

}

if (!$rp_global){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>Roleplay Global Grade</p>";

}

}

else if (str_word_count($rp) > $word_limit){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You went over the word limit!</p>";

}

else if (strlen($rp_preview) > 500){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You went over the maximum 500 character count for your roleplay preview!</p>";

}

else if ($counter >= $rp_limit){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You cannot post more than $rp_limit roleplays!</p>";

}

else if (substr_count($rp, "[b]") != substr_count($rp, "[/b]")){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You have open bold tags!</p>";

}

else if (substr_count($rp, "[i]") != substr_count($rp, "[/i]")){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You have open italic tags!</p>";

}

else if (substr_count($rp, "[u]") != substr_count($rp, "[/u]")){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You have open underline tags!</p>";

}

else if (substr_count($rp, "[ARIAL]") != substr_count($rp, "[/ARIAL]")){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You have open arial tags!</p>";

}

else if (substr_count($rp, "[TIMES]") != substr_count($rp, "[/TIMES]")){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You have open times tags!</p>";

}

else if (substr_count($rp, "[COURIER]") != substr_count($rp, "[/COURIER]")){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You have open courier tags!</p>";

}

else if (substr_count($rp, "[GEORGIA]") != substr_count($rp, "[/GEORGIA]")){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You have open georgia tags!</p>";

}

else if (substr_count($rp, "[VERDANA]") != substr_count($rp, "[/VERDANA]")){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You have open verdana tags!</p>";

}

else if (substr_count($rp, "[GENEVA]") != substr_count($rp, "[/GENEVA]")){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You have open geneva tags!</p>";

}

else if (substr_count($rp, "[sMALL]") != substr_count($rp, "[/sMALL]")){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You have open small tags!</p>";

}

else if (substr_count($rp, "[NORMAL]") != substr_count($rp, "[/NORMAL]")){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You have open normal tags!</p>";

}

else if (substr_count($rp, "[LARGE]") != substr_count($rp, "[/LARGE]")){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You have open large tags!</p>";

}

else if (substr_count($rp, "[bLUE]") != substr_count($rp, "[/bLUE]")){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You have open blue tags!</p>";

}

else if (substr_count($rp, "[RED]") != substr_count($rp, "[/RED]")){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You have open red tags!</p>";

}

else if (substr_count($rp, "[GREEN]") != substr_count($rp, "[/GREEN]")){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You have open green tags!</p>";

}

else if (substr_count($rp, "[YELLOW]") != substr_count($rp, "[/YELLOW]")){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You have open yellow tags!</p>";

}

else if (substr_count($rp, "[ORANGE]") != substr_count($rp, "[/ORANGE]")){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You have open orange tags!</p>";

}

else if (substr_count($rp, "[GRAY]") != substr_count($rp, "[/GRAY]")){

$errormsg .= "<p class='text3' style='font-weight: bold; color: #ff0000;'>You have open gray tags!</p>";

}

else { // error messages are done

$rp = mysql_real_escape_string($rp);
$rp_title = mysql_real_escape_string($rp_title);
$rp_preview = mysql_real_escape_string($rp_preview);

$rp = strtr($rp,"`","");
$rp_title = strtr($rp_title,"`","");
$rp_preview = strtr($rp_preview,"`","");

$rp =  strtr($rp,"[b]","<b>");
$rp =  strtr($rp,"[/b]","</b>");
$rp = strtr($rp, "[i]","<i>");
$rp = strtr($rp,"[/i]","</i>");
$rp = strtr($rp,"[u]","<u>");
$rp = strtr($rp,"[/u]","</u>");

$rp = str_replace('[TIME]',"<span style='color: blue'>",$rp);


/* $rp = strtr($rp,"[TIMES]","<span style='font-family: Times New Roman, Times, serif'>");
$rp = strtr($rp,"[/TIMES]","</span>");
$rp = strtr($rp,"[COURIER]","<span style='font-family: Courier New, Courier, mono'>");
$rp = strtr($rp,"[/COURIER]","</span>");
$rp = strtr($rp,"[GEORGIA]","<span style='font-family: Georgia, Times New Roman, Times, serif'>");
$rp = strtr($rp,"[/GEORGIA]","</span>");
$rp = strtr($rp,"[VERDANA]","<span style='font-family: Verdana, Arial, Helvetica, sans-serif'>");
$rp = strtr($rp,"[/VERDANA]","</span>");
$rp = strtr($rp,"[GENEVA]","<span style='font-family: Geneva, Arial, Helvetica, sans-serif'>");
$rp = strtr($rp,"[/GENEVA]","</span>");
$rp = strtr($rp,"[sMALL]","<span style='font-size: 11px'>");
$rp = strtr($rp,"[/sMALL]","</span>");
$rp = strtr($rp,"[NORMAL]","<span style='font-size: 12px'>");
$rp = strtr($rp,"[/NORMAL]","</span>");
$rp = strtr($rp,"[LARGE]","<span style='font-size: 14px'>");
$rp = strtr($rp,"[/LARGE]","</span>");
$rp = strtr($rp,"[color=blue]","<span style='color: #0000ff'&gt");
$rp = strtr($rp,"[/color]","</span>");
$rp = strtr($rp,"[RED]","<span style='color: #ff0000'>");
$rp = strtr($rp,"[/RED]","</span>");
$rp = strtr($rp,"[GREEN]","<span style='color: #00ff00'>");
$rp = strtr($rp,"[/GREEN]","</span>");
$rp = strtr($rp,"[YELLOW]","<span style='color: #ffff00'>");
$rp = strtr($rp,"[/YELLOW]","</span>");
$rp = strtr($rp,"[ORANGE]","<span style='color: #ffa500'>");
$rp = strtr($rp,"[/ORANGE]","</span>");
$rp = strtr($rp,"[GRAY]","<span style='color: #c0c0c0'>");
$rp = strtr($rp,"[/GRAY]","</span>"); */

$rp_replace = array("<b>" => "","</b>" => "","<i>" => "","</i>" => "","<u>" => "","</u>" => "","<span style='font-family: Arial, Helvetica, sans-serif;'>" => "","<span style='font-family: 'Times New Roman', Times, serif;'>" => "","<span style='font-family: 'Courier New', Courier, mono;'>" => "","<span style='font-family: Georgia, 'Times New Roman', Times, serif;'>" => "","<span style='font-family: Verdana, Arial, Helvetica, sans-serif;'>" => "","<span style='font-family: Geneva, Arial, Helvetica, sans-serif;'>" => "","<span style='font-size: 11px;'>" => "","<span style='font-size: 12px;'>" => "","<span style='font-size: 14px;'>" => "","<span style='color: #0000ff;'>" => "","<span style='color: #ff0000;'>" => "","<span style='color: #00ff00;'>" => "","<span style='color: #ffff00;'>" => "","<span style='color: #ffa500;'>" => "","<span style='color: #c0c0c0;'>" => "","</span>" => "");

$new_rp = strtr($rp, $rp_replace);

$rp_word_count = str_word_count($new_rp);

if ($rp_preview == ""){

$rp_preview = substr($rp, 0, 500);

}

$sql_insert_rp = mysql_query("INSERT INTO Worker_RP (worker_id, promo_id, event_id, category_id1, category_id2, category_id3, words, time_posted, date_posted, preview, content, title, allow_global_grade, posted) VALUES ('$worker_id' , '$promo_id' , '$rp_event' , '$rp_category1' , '$rp_category2' , '$rp_category3' , '$rp_word_count' , CURTIME() , CURDATE() , '$rp_preview' , '$rp' , '$rp_title' , '$rp_global' , now())") or die (mysql_error());

$errormsg = "<p class='text3' style='font-weight: bold; color: #ff0000;'>You have successfully submitted your Roleplay!</p>";

// clear variables

$rp = "";
$rp_event = "";
$rp_title = "";
$rp_preview = "";
$rp_category1 = "";
$rp_category2 = "";
$rp_category3 = "";
$rp_global = "";

}

} 

else { 

$errormsg = "<p class='text3' style='font-weight: bold; color: #ff0000;'>All of the fields are required except for you only need one Roleplay Category!</p>";

}


$content = " $errormsg

<form action='fed_roleplays.php?promotion_id=$promo_id&create_rp' method='post'>

<p class='text3'>Roleplaying as <a href='workers.php?worker_id=$worker_id' style='font-weight: bold'>$worker_firstname $worker_lastname</a></p>

<div style='width: 250px; float: left;'>

<p class='text3' style='font-weight: bold;'>Roleplaying for</p>

</div>

<div style='width: 538px; float: left;'>

<p class='text3'>

<select name='rp_event' size='1'>

<option value='$rp_event'>$rp_event</option>
$upcoming_events

</select>

</p>

</div>

<div class='line'></div>

<div style='width: 250px; float: left;'>

<p class='text3' style='font-weight: bold;'>Title</p>

</div>

<div style='width: 538px; float: left;'>

<p class='text3'>

<input class='text4' type='text' name='rp_title' value='$rp_title' size='20' />

</p>

</div>

<div class='line'></div>

<div style='width: 250px; float: left;'>

<p class='text3' style='font-weight: bold;'>Roleplay (Word Limit: $word_limit_format)</p>

</div>

<div style='width: 538px; float: left;'>

<p class='text3'>

<input type='button' id='bold_text' class='text3' style='padding: 3px; font-weight: bold;' value='B' onclick='changeBold()' />
<input type='button' id='italic_text' class='text3' style='padding: 3px; font-weight: bold;' value='I' onclick='changeItalic()' />
<input type='button' id='underline_text' class='text3' style='padding: 3px; font-weight: bold;' value='U' onclick='changeUnderline()' />

<select id='font_text' class='text4' onchange='changeFont()'>

<option value='0'>FONT</option>
<option value='ARIAL'>Arial</option>
<option value='TIMES'>Times</option>
<option value='COURIER'>Courier</option>
<option value='GEORGIA'>Georgia</option>
<option value='VERDANA'>Verdana</option>
<option value='GENEVA'>Geneva</option>

</select>

<select id='size_text' class='text4' onchange='changeSize()'>

<option value='0'>SIZE</option>
<option value='SMALL'>Small</option>
<option value='NORMAL'>Normal</option>
<option value='LARGE'>Large</option>

</select>

<select id='color_text' class='text4' onchange='changeColor()'>

<option value='0'>COLOR</option>
<option value='BLUE' style='color: #0000ff;'>Blue</option>
<option value='RED' style='color: #ff0000;'>Red</option>
<option value='GREEN' style='color: #00ff00;'>Green</option>
<option value='YELLOW' style='color: #ffff00;'>Yellow</option>
<option value='ORANGE' style='color: #ffa500;'>Orange</option>
<option value='GRAY' style='color: #c0c0c0;'>Gray</option>

</select>

</p>

<p class='text3'>

<textarea class='text4' cols='100' rows='15' name='rp' id='rp_area'>$rp</textarea>

</p>

</div>

<div class='line'></div>

<div style='width: 250px; float: left;'>

<p class='text3' style='font-weight: bold;'>Custom Preview (Leave blank if no, max. 500 characters)</p>

</div>

<div style='width: 538px; float: left;'>

<p class='text3'>

<textarea class='text4' cols='100' rows='7' name='rp_preview'>$rp_preview</textarea>

</p>

</div>

<div class='line'></div>

<div style='width: 250px; float: left;'>

<p class='text3' style='font-weight: bold;'>Category (min. 1, max. 3)</p>

</div>

<div style='width: 179px; float: left;'>

<p class='text3'>

<select name='rp_category1' size='1'>

<option value='$rp_category1'>$rp_category1</option>
<option value='1'>Action</option>

</select>

</p>

</div>

<div style='width: 179px; float: left;'>

<p class='text3'>

<select name='rp_category2' size='1'>

<option value='$rp_category2'>$rp_category2</option>

</select>

</p>

</div>

<div style='width: 179px; float: left;'>

<p class='text3'>

<select name='rp_category3' size='1'>

<option value='$rp_category3'>$rp_category3</option>

</select>

</p>

</div>

<div class='line'></div>

<div style='width: 250px; float: left;'>

<p class='text3' style='font-weight: bold;'>Allow global grading?</p>

</div>

<div style='width: 538px; float: left;'>

<p class='text3' style='font-weight: bold;'>

<input type='radio' name='rp_global' value='a' /> All Users

</p>

<p class='text3' style='font-weight: bold;'>

<input type='radio' name='rp_global' value='f' /> Only Friends

</p>

<p class='text3' style='font-weight: bold;'>

<input type='radio' name='rp_global' value='n' /> No One

</p>

</div>

<div class='line'></div>

<div style='width: 788px;' align='center'>

<p class='text3'>

<input type='submit' class='text3' value='Create Roleplay' />

</p>

</div>

</form>";

}
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.