Jump to content
MakeWebGames

Help with converter


Brad

Recommended Posts

Can someone fix this it dont work as the coverter.

 

 

<?php 
switch($_GET['convert']) 
{ 
case 'to_v1': 
conv_v1(); 
break; 
case 'to_v2': 
conv_v2(); 
break; 
default: 
conv_home(); 
break; 
} 
function conv_home() 
{ 
echo <<<EOF 
<title>MC Codes Converter</title> 
<center><h3>MC Codes Version Converter<h3> 
<form action=javascript:action; method='post'> 
<select onChange="this.form.action=this.options[this.selectedIndex].value;"> 
<option default value="">--Select One--</option> 
<option value="mccodes_converter.php?convert=to_v2">v1->v2</option> 
<option value="mccodes_converter.php?convert=to_v1">v2->v1</option> 
</select>

<textarea rows='20' cols='100' name='convtext'></textarea>

<input value='Convert' type='submit' /></center> 
EOF; 
} 
function conv_v2() 
{ 
$convtext=($_POST['convtext']); 
$tobereplaced = array( 
'mysql_query', 
'fetch_array', 
'mysql_', 
); 
$replacedwith = array( 
'$db->query', 
'fetch_row', 
'$db->', 
); 
$convedtext = str_replace($tobereplaced, $replacedwith, $convtext); 
print "<center><title>Converted to V2</title> 
<h3>Converted to V2</h3> 
<textarea rows='20' cols='100' readonly>$convedtext</textarea></center>"; 
} 
function conv_v1() 
{ 
$convtext=($_POST['convtext']); 
$tobereplaced = array( 
'$db->query', 
'fetch_row', 
'$db->', 
); 
$replacedwith = array( 
'mysql_query', 
'fetch_array', 
'mysql_', 
); 
$convedtext = str_replace($tobereplaced, $replacedwith, $convtext); 
print "<center><title>Converted to V1</title> 
<h3>Converted to V1</h3> 
<textarea rows='20' cols='100' readonly>$convedtext</textarea></center>"; 
} 
?>
Link to comment
Share on other sites

  $tobereplaced = array( 
     '$db->query', 
     'fetch_row', 
     '$db->', 
  ); 
  $replacedwith = array( 
     'mysql_query', 
     'fetch_array', 
     'mysql_', 
  ); 
if ( $blah == 'v1') {
  $convedtext = str_replace($tobereplaced, $replacedwith, $convtext);
} elseif ( $blah == 'v2' ) {
  $convedtext = str_replace($replacedwith, $tobereplaced, $convtext);
}

Bored... lol

Link to comment
Share on other sites

Give me til tonight. I will make everyone a working convertor. I just have to run down the road for a couple hours. Then I'll finish a when I get back.

So don't everyone go making one, lol, I"m 85% done already, just have to handle some stuff, then I'll finish it. It will be done tonight.

Maybe staff will sticky my post with it??

Link to comment
Share on other sites

Ok, this is not complete yet, but posting it so you know I haven't forgot...So far it appears it works on everything EXCEPT for the top of the page.

I have not added that yet. When I get that in. I will Make another topic. Maybe the mods here will sticky it. Cause I know it will be useful to a lot of people.

 

<?php
/******
***Mccode page converter
***Created by AlabamaHit
***Enjoy, and give credit where due.
******/

echo '<h2>Code Convertor</h2>';

if(isset($_POST['v1']))
{
$old = array('fetch_row','$db->'); 
$new = array('fetch_assoc','mysql_');
$newtext = str_replace($old, $new, $_POST['code']);
echo '
	<h2>Code Converted to v1</h2>
	<form action="convertor.php" method="post" name="form">
	<textarea rows="150" cols="150" name="code">'.$newtext.'</textarea>


	<input type="submit" name="v2" value="Go Back" />
	</form>';
	focus();
}
else if(isset($_POST['v2']))
{ 
$old = array('fetch_array','mysql_','global $ir');
$new = array('fetch_row','$db->','global $db,$ir');
$newtext = str_replace($old, $new, $_POST['code']);

echo '
	<h2>Code Converted to v2</h2>
	Just remeber there still might be some errors. This don\'t work 100% of the time.


	<form action="convertor.php" method="post" name="form">
	<textarea rows="150" cols="150" name="code">'.$newtext.'</textarea>


	<input type="submit" name="v1" value="Go Back" />
	</form>';
	focus();
}
else
{
echo '
	Place code in text box and click on how to convert it.


	<form action="convertor.php" method="post" name="form">
	<textarea rows="150" cols="150" name="code"></textarea>


	<input type="submit" name="v1" value="Convert to v1" />


	<input type="submit" name="v2" value="Convert to v2" />
	</form>';
	focus();

}
//
//No reason really for this.
//But I'm using it anyway.
function focus()
{
echo '<script type="text/javascript" language="JavaScript">';
echo "document.forms['form'].elements['code'].focus();";
echo '</script>';
}

?>

 

Remeber this is not done yet.

Link to comment
Share on other sites

How about Ctrl + H?

Do Ctrl + H type in the find box: "$db->" and in replace box: "mysql_"

Do the same thing but replace "mysql_fetch_row" with "mysql_fetch_array"

Simple eh?

Your saying simple eh? - I can say fail eh?

Link to comment
Share on other sites

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.   Paste as plain text instead

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