Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class parsexml
- {
- function getchildren( $vals, &$i )
- {
- $children = array( );
- if ( isset( $vals[$i]['value'] ) )
- {
- $children['VALUE'] = $vals[$i]['value'];
- }
- while ( ++$i < count( $vals ) )
- {
- switch ( $vals[$i]['type'] )
- {
- case "cdata" :
- if ( isset( $children['VALUE'] ) )
- {
- $children['VALUE'] .= $vals[$i]['value'];
- }
- else
- {
- $children['VALUE'] = $vals[$i]['value'];
- }
- break;
- case "complete" :
- if ( isset( $vals[$i]['attributes'] ) )
- {
- $children[$vals[$i]['tag']][]['ATTRIBUTES'] = $vals[$i]['attributes'];
- $index = count( $children[$vals[$i]['tag']] ) - 1;
- if ( isset( $vals[$i]['value'] ) )
- {
- $children[$vals[$i]['tag']][$index]['VALUE'] = $vals[$i]['value'];
- }
- else
- {
- $children[$vals[$i]['tag']][$index]['VALUE'] = "";
- }
- }
- else if ( isset( $vals[$i]['value'] ) )
- {
- $children[$vals[$i]['tag']][]['VALUE'] = $vals[$i]['value'];
- }
- else
- {
- $children[$vals[$i]['tag']][]['VALUE'] = "";
- }
- break;
- case "open" :
- if ( isset( $vals[$i]['attributes'] ) )
- {
- $children[$vals[$i]['tag']][]['ATTRIBUTES'] = $vals[$i]['attributes'];
- $index = count( $children[$vals[$i]['tag']] ) - 1;
- $children[$vals[$i]['tag']][$index] = array_merge( $children[$vals[$i]['tag']][$index], $this->getchildren( $vals, $i ) );
- }
- else
- {
- $children[$vals[$i]['tag']][] = $this->getchildren( $vals, $i );
- }
- break;
- case "close" :
- return $children;
- }
- }
- }
- function getxmltree( $xmlloc )
- {
- if ( file_exists( $xmlloc ) )
- {
- $data = implode( "", file( $xmlloc ) );
- }
- else
- {
- $data = "";
- $fp = @fopen( $xmlloc, "r" );
- if ( $fp )
- {
- while ( !feof( $fp ) )
- {
- $data = $data.fread( $fp, 1024 );
- }
- fclose( $fp );
- }
- }
- $parser = xml_parser_create( "ISO-8859-1" );
- xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 1 );
- xml_parse_into_struct( $parser, $data, $vals, $index );
- xml_parser_free( $parser );
- $tree = array( );
- $i = 0;
- if ( isset( $vals[$i]['attributes'] ) )
- {
- $tree[$vals[$i]['tag']][]['ATTRIBUTES'] = $vals[$i]['attributes'];
- $index = count( $tree[$vals[$i]['tag']] ) - 1;
- $tree[$vals[$i]['tag']][$index] = array_merge( $tree[$vals[$i]['tag']][$index], $this->getchildren( $vals, $i ) );
- }
- else
- {
- $tree[$vals[$i]['tag']][] = $this->getchildren( $vals, $i );
- }
- return $tree;
- }
- }
- function randomvalue( $length, $type = 0 )
- {
- if ( $type == 1 )
- {
- $salt = "abchefghjkmnpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- }
- else if ( $type == 2 )
- {
- $salt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- }
- else if ( $type == 3 )
- {
- $salt = "0123456789";
- }
- else
- {
- $salt = "abchefghjkmnpqrstuvwxyz0123456789";
- }
- $strlen = intval( strlen( $salt ) - 1 );
- $randomvalue = "";
- $i = 1;
- for ( ; $i <= $length; ++$i )
- {
- $randomvalue .= substr( $salt, rand( 0, $strlen ), 1 );
- }
- return $randomvalue;
- }
- function httpreferer( )
- {
- if ( isset( $_SERVER['HTTP_REFERER'] ) )
- {
- return $_SERVER['HTTP_REFERER'];
- }
- else if ( isset( $HTTP_SERVER_VARS['HTTP_REFERER'] ) )
- {
- return $HTTP_SERVER_VARS['HTTP_REFERER'];
- }
- else if ( getenv( "HTTP_REFERER" ) )
- {
- return getenv( "HTTP_REFERER" );
- }
- else
- {
- return false;
- }
- }
- function box( $html, $title = "" )
- {
- echo "<div class=\"bluebox\">";
- if ( $title != "" )
- {
- echo "<div class=\"head\"><span class=\"headbg\">{$title}</span></div>";
- }
- echo "{$html}</div>";
- }
- function box2( $html, $title = "" )
- {
- echo "<div class=\"greenbox\">";
- if ( $title != "" )
- {
- echo "<div class=\"head\"><span class=\"headbg\">{$title}</span></div>";
- }
- echo "{$html}</div>";
- }
- function head( $title = "" )
- {
- if ( $title == "" )
- {
- $title = PAGETITLE;
- }
- header( "Cache-Control: max-age=600, must-revalidate" );
- echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">";
- echo "<html><head><title>{$title}</title>\n";
- echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">";
- echo "<link rel=\"styleSheet\" href=\"images/style.css\" type=\"text/css\">\n";
- echo "</head>";
- echo "<body>\n";
- echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
- echo " <tr>";
- echo " <td><img src=\"images/spacer.gif\" width=\"108\" height=\"1\" border=\"0\" alt=\"\"></td>";
- echo " <td><img src=\"images/spacer.gif\" width=\"564\" height=\"1\" border=\"0\" alt=\"\"></td>";
- echo " <td><img src=\"images/spacer.gif\" width=\"98\" height=\"1\" border=\"0\" alt=\"\"></td>";
- echo " <td><img src=\"images/spacer.gif\" width=\"1\" height=\"1\" border=\"0\" alt=\"\"></td>";
- echo " </tr>";
- echo " <tr>";
- echo " <td width=\"50%\" background=\"images/head2_r1_c1.jpg\"> </td>";
- echo " <td><a href=\"index.php\"><img name=\"head2_r1_c2\" src=\"images/head2_r1_c2.jpg\" width=\"564\" height=\"100\" border=\"0\" alt=\"Home\"></a></td>";
- echo " <td width=\"50%\" background=\"images/head2_r1_c3.jpg\"> </td>";
- echo " <td><img src=\"images/spacer.gif\" width=\"1\" height=\"100\" border=\"0\" alt=\"\"></td>";
- echo " </tr>";
- echo "</table>";
- echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"580px\" align=\"center\"><tr><td width=\"100%\">";
- }
- function foot( )
- {
- echo "</td></tr></table></div><center>".COPYRIGHT."<br />".VERSION."<br />(<a href=\"index.php?indexaction=reinstall\">Reinstall</a>)</center></body></html>";
- }
- function generate_serial( $domain, $actcode, $email, $secretkey )
- {
- if ( $domain == "" || $actcode == "" || $email == "" || $secretkey == "" || !is_numeric( $actcode ) )
- {
- return "";
- }
- else
- {
- $domain = str_replace( "www.", "", strtolower( $domain ) );
- $serialstring = $actcode.$domain.strtolower( $email ).strtolower( $secretkey );
- $serialstring = substr( strtoupper( sha1( md5( sha1( $serialstring ) ) ) ), 0, 25 );
- $serialstringarray = string_split( $serialstring, 5 );
- $serial = implode( "-", $serialstringarray );
- return $serial;
- }
- }
- function string_split( $string, $split_length = 1 )
- {
- $count = strlen( $string );
- if ( $split_length < 1 )
- {
- return false;
- }
- else if ( $count < $split_length )
- {
- return array(
- $string
- );
- }
- else
- {
- $num = ( integer )ceil( $count / $split_length );
- $ret = array( );
- $i = 0;
- for ( ; $i < $num; ++$i )
- {
- $ret[] = substr( $string, $i * $split_length, $split_length );
- }
- return $ret;
- }
- }
- ini_set( "log_errors", 0 );
- define( "_INDEX_", true );
- include( "database.php" );
- session_start( );
- define( "PAGETITLE", "Instadigi - Instant Content Generator" );
- define( "COPYRIGHT", "Copyright © Instadigi Solutions" );
- define( "VERSION", "Version 1.1e" );
- define( "DBNAME_CONFIG", "instadigi_config" );
- define( "DBNAME_ICUSERS", "instadigi_created_users" );
- define( "ENCRYPTKEY", "AJFKJSH1JKLNM150KLJA" );
- define( "APPID", "kyOjdlzV34HlP_YLN9rPYY3hsYOcPlK2yRBVdF9R5Mjd0M4355SDmNO8bQIsI0g4" );
- define( "REGION", "us" );
- $xmlparser =& new parsexml( );
- default :
- if ( !$db->db_connect_id )
- {
- head( "".PAGETITLE." Installation Error" );
- $html = "<center>Unable to connect to the forum database!</center>";
- box( $html, "Database Error" );
- foot( );
- }
- else if ( table_exists( "".$prefix."".DBNAME_CONFIG."" ) )
- {
- list( $dbserial, $dbcode, $dbemail ) = $db->sql_fetchrow( $db->sql_query( "SELECT serial, code, email FROM ".$prefix."".DBNAME_CONFIG."" ) );
- if ( $dbserial == generate_serial( $_SERVER['SERVER_NAME'], $dbcode, $dbemail, ENCRYPTKEY ) )
- {
- if ( file_exists( "plugins/".FORUMTYPE."/index.php" ) )
- {
- include( "plugins/".FORUMTYPE."/index.php" );
- }
- else
- {
- head( );
- $html = "<center>Plugin file missing!</center>";
- box( $html, "Error" );
- foot( );
- }
- }
- else
- {
- $query = $db->sql_query( "DROP TABLE IF EXISTS ".$prefix."".DBNAME_CONFIG."" );
- if ( !$query )
- {
- exit( $db->sql_error( ) );
- }
- else
- {
- head( "Invalid Registration Information" );
- $html = "We have detected that this product is registered with an invalid serial number.";
- box( $html, "Error" );
- foot( );
- }
- }
- }
- else if ( intval( $_POST['install'] ) == 1 )
- {
- $key = $_POST['key'];
- $actcode = $_POST['actcode'];
- $paypalemail = $_POST['paypalemail'];
- $forumtype = $_POST['forumtype'];
- $username = $_POST['username'];
- $pass1 = $_POST['pass1'];
- $pass2 = $_POST['pass2'];
- $serial = strtoupper( implode( "-", $key ) );
- $generated_serial = generate_serial( $_SERVER['SERVER_NAME'], $actcode, $paypalemail, ENCRYPTKEY );
- $generated_serial2 = generate_serial( $_SERVER['HTTP_HOST'], $actcode, $paypalemail, ENCRYPTKEY );
- if ( $serial != $generated_serial && $serial != $generated_serial2 )
- {
- head( );
- $html = "Invalid serial number entered. Please try again.";
- box( $html, "Error" );
- foot( );
- }
- else if ( $username == "" )
- {
- head( );
- $html = "Username field empty. You must specify a administrative username to install.";
- box( $html, "Error" );
- foot( );
- }
- else if ( $pass1 != $pass2 || $pass1 == "" || $pass2 == "" )
- {
- head( );
- $html = "Passwords do not match or password fields were left empty. Please fill up the form correctly!";
- box( $html, "Error" );
- foot( );
- }
- else
- {
- $create = $db->sql_query( "DROP TABLE IF EXISTS ".$prefix."".DBNAME_CONFIG."" );
- $create = $db->sql_query( "CREATE TABLE ".$prefix."".DBNAME_CONFIG."(code varchar(255) default NULL, serial varchar(255) default NULL, email varchar(255) default NULL, username varchar(255) default NULL, password varchar(255) default NULL) TYPE=MyISAM" );
- $create2 = $db->sql_query( "DROP TABLE IF EXISTS ".$prefix."".DBNAME_ICUSERS."" );
- $create2 = $db->sql_query( "CREATE TABLE ".$prefix."".DBNAME_ICUSERS." (id int(10) NOT NULL auto_increment, username varchar(255) default NULL, forum_userid int(10) NOT NULL default '0', PRIMARY KEY (`id`)) TYPE=MyISAM" );
- $insert = $db->sql_query( "INSERT INTO ".$prefix."".DBNAME_CONFIG." (code, serial, email, username, password) VALUES({$actcode}, '{$serial}', '{$paypalemail}', '{$username}', '".md5( $pass1 )."')" );
- if ( !$create || !$insert || !$create2 )
- {
- exit( $db->sql_error( ) );
- }
- else
- {
- header( "location: index.php" );
- }
- }
- }
- else
- {
- head( "".PAGETITLE." Installation" );
- $html = "To setup Instadigi Community Content Generator, please fill up the form below and click 'INSTALL'.<br /><br />";
- $html .= "<b>Product Code:</b> ";
- $html .= "<input type=\"text\" name=\"actcode\" size=\"20\" maxlength=\"16\" /><br /><br />";
- $html .= "<b>Email Address:</b> ";
- $html .= "<input type=\"text\" name=\"paypalemail\" size=\"20\" maxlength=\"255\" /><br /><br />";
- $html .= "<b>Serial Number:</b> ";
- $i = 1;
- for ( ; $i <= 5; ++$i )
- {
- $html .= "<input type=\"text\" name=\"key[]\" size=\"5\" maxlength=\"5\" /> ";
- }
- $html2 = "<b>Username:</b> ";
- $html2 .= "<input type=\"text\" name=\"username\" size=\"20\" maxlength=\"16\" /><br /><br />";
- $html2 .= "<b>Password:</b> ";
- $html2 .= "<input type=\"text\" name=\"pass1\" size=\"20\" maxlength=\"16\" /> <b>Repeat Password:</b> ";
- $html2 .= "<input type=\"text\" name=\"pass2\" size=\"20\" maxlength=\"16\" /><br /><br />";
- $html3 = "<center>Please ensure all form fields above are filled in correctly before clicking thie INSTALL button<br /><br /><input type=\"hidden\" name=\"install\" value=\"1\" /><input type=\"submit\" value=\"Install!\" /></center>";
- echo "<form action=\"index.php\" method=\"post\">";
- box( $html, "<b>".PAGETITLE." Installation - License Registration</b>" );
- box( $html2, "<b>".PAGETITLE." Installation - Administration</b>" );
- box2( $html3 );
- echo "</form>";
- foot( );
- switch ( $_REQUEST['indexaction'] )
- {
- case "reinstall" :
- $drop = $db->sql_query( "DROP TABLE IF EXISTS ".$prefix."".DBNAME_CONFIG."" );
- if ( !$drop )
- {
- exit( );
- }
- else
- {
- header( "location: index.php" );
- break;
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement