Advertisement
johnburn

index.php

Apr 17th, 2011
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 14.48 KB | None | 0 0
  1. <?php
  2.  
  3. class parsexml
  4. {
  5.  
  6.     function getchildren( $vals, &$i )
  7.     {
  8.         $children = array( );
  9.         if ( isset( $vals[$i]['value'] ) )
  10.         {
  11.             $children['VALUE'] = $vals[$i]['value'];
  12.         }
  13.         while ( ++$i < count( $vals ) )
  14.         {
  15.             switch ( $vals[$i]['type'] )
  16.             {
  17.             case "cdata" :
  18.                 if ( isset( $children['VALUE'] ) )
  19.                 {
  20.                     $children['VALUE'] .= $vals[$i]['value'];
  21.                 }
  22.                 else
  23.                 {
  24.                     $children['VALUE'] = $vals[$i]['value'];
  25.                 }
  26.                 break;
  27.             case "complete" :
  28.                 if ( isset( $vals[$i]['attributes'] ) )
  29.                 {
  30.                     $children[$vals[$i]['tag']][]['ATTRIBUTES'] = $vals[$i]['attributes'];
  31.                     $index = count( $children[$vals[$i]['tag']] ) - 1;
  32.                     if ( isset( $vals[$i]['value'] ) )
  33.                     {
  34.                         $children[$vals[$i]['tag']][$index]['VALUE'] = $vals[$i]['value'];
  35.                     }
  36.                     else
  37.                     {
  38.                         $children[$vals[$i]['tag']][$index]['VALUE'] = "";
  39.                     }
  40.                 }
  41.                 else if ( isset( $vals[$i]['value'] ) )
  42.                 {
  43.                     $children[$vals[$i]['tag']][]['VALUE'] = $vals[$i]['value'];
  44.                 }
  45.                 else
  46.                 {
  47.                     $children[$vals[$i]['tag']][]['VALUE'] = "";
  48.                 }
  49.                 break;
  50.             case "open" :
  51.                 if ( isset( $vals[$i]['attributes'] ) )
  52.                 {
  53.                     $children[$vals[$i]['tag']][]['ATTRIBUTES'] = $vals[$i]['attributes'];
  54.                     $index = count( $children[$vals[$i]['tag']] ) - 1;
  55.                     $children[$vals[$i]['tag']][$index] = array_merge( $children[$vals[$i]['tag']][$index], $this->getchildren( $vals, $i ) );
  56.                 }
  57.                 else
  58.                 {
  59.                     $children[$vals[$i]['tag']][] = $this->getchildren( $vals, $i );
  60.                 }
  61.                 break;
  62.             case "close" :
  63.                 return $children;
  64.             }
  65.         }
  66.     }
  67.  
  68.     function getxmltree( $xmlloc )
  69.     {
  70.         if ( file_exists( $xmlloc ) )
  71.         {
  72.             $data = implode( "", file( $xmlloc ) );
  73.         }
  74.         else
  75.         {
  76.             $data = "";
  77.             $fp = @fopen( $xmlloc, "r" );
  78.             if ( $fp )
  79.             {
  80.                 while ( !feof( $fp ) )
  81.                 {
  82.                     $data = $data.fread( $fp, 1024 );
  83.                 }
  84.                 fclose( $fp );
  85.             }
  86.         }
  87.         $parser = xml_parser_create( "ISO-8859-1" );
  88.         xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 1 );
  89.         xml_parse_into_struct( $parser, $data, $vals, $index );
  90.         xml_parser_free( $parser );
  91.         $tree = array( );
  92.         $i = 0;
  93.         if ( isset( $vals[$i]['attributes'] ) )
  94.         {
  95.             $tree[$vals[$i]['tag']][]['ATTRIBUTES'] = $vals[$i]['attributes'];
  96.             $index = count( $tree[$vals[$i]['tag']] ) - 1;
  97.             $tree[$vals[$i]['tag']][$index] = array_merge( $tree[$vals[$i]['tag']][$index], $this->getchildren( $vals, $i ) );
  98.         }
  99.         else
  100.         {
  101.             $tree[$vals[$i]['tag']][] = $this->getchildren( $vals, $i );
  102.         }
  103.         return $tree;
  104.     }
  105.  
  106. }
  107.  
  108. function randomvalue( $length, $type = 0 )
  109. {
  110.     if ( $type == 1 )
  111.     {
  112.         $salt = "abchefghjkmnpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  113.     }
  114.     else if ( $type == 2 )
  115.     {
  116.         $salt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  117.     }
  118.     else if ( $type == 3 )
  119.     {
  120.         $salt = "0123456789";
  121.     }
  122.     else
  123.     {
  124.         $salt = "abchefghjkmnpqrstuvwxyz0123456789";
  125.     }
  126.     $strlen = intval( strlen( $salt ) - 1 );
  127.     $randomvalue = "";
  128.     $i = 1;
  129.     for ( ; $i <= $length; ++$i )
  130.     {
  131.         $randomvalue .= substr( $salt, rand( 0, $strlen ), 1 );
  132.     }
  133.     return $randomvalue;
  134. }
  135.  
  136. function httpreferer( )
  137. {
  138.     if ( isset( $_SERVER['HTTP_REFERER'] ) )
  139.     {
  140.         return $_SERVER['HTTP_REFERER'];
  141.     }
  142.     else if ( isset( $HTTP_SERVER_VARS['HTTP_REFERER'] ) )
  143.     {
  144.         return $HTTP_SERVER_VARS['HTTP_REFERER'];
  145.     }
  146.     else if ( getenv( "HTTP_REFERER" ) )
  147.     {
  148.         return getenv( "HTTP_REFERER" );
  149.     }
  150.     else
  151.     {
  152.         return false;
  153.     }
  154. }
  155.  
  156. function box( $html, $title = "" )
  157. {
  158.     echo "<div class=\"bluebox\">";
  159.     if ( $title != "" )
  160.     {
  161.         echo "<div class=\"head\"><span class=\"headbg\">{$title}</span></div>";
  162.     }
  163.     echo "{$html}</div>";
  164. }
  165.  
  166. function box2( $html, $title = "" )
  167. {
  168.     echo "<div class=\"greenbox\">";
  169.     if ( $title != "" )
  170.     {
  171.         echo "<div class=\"head\"><span class=\"headbg\">{$title}</span></div>";
  172.     }
  173.     echo "{$html}</div>";
  174. }
  175.  
  176. function head( $title = "" )
  177. {
  178.     if ( $title == "" )
  179.     {
  180.         $title = PAGETITLE;
  181.     }
  182.     header( "Cache-Control: max-age=600, must-revalidate" );
  183.     echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">";
  184.     echo "<html><head><title>{$title}</title>\n";
  185.     echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">";
  186.     echo "<link rel=\"styleSheet\" href=\"images/style.css\" type=\"text/css\">\n";
  187.     echo "</head>";
  188.     echo "<body>\n";
  189.     echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
  190.     echo "  <tr>";
  191.     echo "   <td><img src=\"images/spacer.gif\" width=\"108\" height=\"1\" border=\"0\" alt=\"\"></td>";
  192.     echo "   <td><img src=\"images/spacer.gif\" width=\"564\" height=\"1\" border=\"0\" alt=\"\"></td>";
  193.     echo "   <td><img src=\"images/spacer.gif\" width=\"98\" height=\"1\" border=\"0\" alt=\"\"></td>";
  194.     echo "   <td><img src=\"images/spacer.gif\" width=\"1\" height=\"1\" border=\"0\" alt=\"\"></td>";
  195.     echo "  </tr>";
  196.     echo "  <tr>";
  197.     echo "   <td width=\"50%\" background=\"images/head2_r1_c1.jpg\">&nbsp;</td>";
  198.     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>";
  199.     echo "   <td width=\"50%\" background=\"images/head2_r1_c3.jpg\">&nbsp;</td>";
  200.     echo "   <td><img src=\"images/spacer.gif\" width=\"1\" height=\"100\" border=\"0\" alt=\"\"></td>";
  201.     echo "  </tr>";
  202.     echo "</table>";
  203.     echo "<table cellpadding=\"0\" cellspacing=\"0\" width=\"580px\" align=\"center\"><tr><td width=\"100%\">";
  204. }
  205.  
  206. function foot( )
  207. {
  208.     echo "</td></tr></table></div><center>".COPYRIGHT."<br />".VERSION."<br />(<a href=\"index.php?indexaction=reinstall\">Reinstall</a>)</center></body></html>";
  209. }
  210.  
  211. function generate_serial( $domain, $actcode, $email, $secretkey )
  212. {
  213.     if ( $domain == "" || $actcode == "" || $email == "" || $secretkey == "" || !is_numeric( $actcode ) )
  214.     {
  215.         return "";
  216.     }
  217.     else
  218.     {
  219.         $domain = str_replace( "www.", "", strtolower( $domain ) );
  220.         $serialstring = $actcode.$domain.strtolower( $email ).strtolower( $secretkey );
  221.         $serialstring = substr( strtoupper( sha1( md5( sha1( $serialstring ) ) ) ), 0, 25 );
  222.         $serialstringarray = string_split( $serialstring, 5 );
  223.         $serial = implode( "-", $serialstringarray );
  224.         return $serial;
  225.     }
  226. }
  227.  
  228. function string_split( $string, $split_length = 1 )
  229. {
  230.     $count = strlen( $string );
  231.     if ( $split_length < 1 )
  232.     {
  233.         return false;
  234.     }
  235.     else if ( $count < $split_length )
  236.     {
  237.         return array(
  238.             $string
  239.         );
  240.     }
  241.     else
  242.     {
  243.         $num = ( integer )ceil( $count / $split_length );
  244.         $ret = array( );
  245.         $i = 0;
  246.         for ( ; $i < $num; ++$i )
  247.         {
  248.             $ret[] = substr( $string, $i * $split_length, $split_length );
  249.         }
  250.         return $ret;
  251.     }
  252. }
  253.  
  254. ini_set( "log_errors", 0 );
  255. define( "_INDEX_", true );
  256. include( "database.php" );
  257. session_start( );
  258. define( "PAGETITLE", "Instadigi - Instant Content Generator" );
  259. define( "COPYRIGHT", "Copyright &copy; Instadigi Solutions" );
  260. define( "VERSION", "Version 1.1e" );
  261. define( "DBNAME_CONFIG", "instadigi_config" );
  262. define( "DBNAME_ICUSERS", "instadigi_created_users" );
  263. define( "ENCRYPTKEY", "AJFKJSH1JKLNM150KLJA" );
  264. define( "APPID", "kyOjdlzV34HlP_YLN9rPYY3hsYOcPlK2yRBVdF9R5Mjd0M4355SDmNO8bQIsI0g4" );
  265. define( "REGION", "us" );
  266. $xmlparser =& new parsexml( );
  267. default :
  268.     if ( !$db->db_connect_id )
  269.     {
  270.         head( "".PAGETITLE." Installation Error" );
  271.         $html = "<center>Unable to connect to the forum database!</center>";
  272.         box( $html, "Database Error" );
  273.         foot( );
  274.     }
  275.     else if ( table_exists( "".$prefix."".DBNAME_CONFIG."" ) )
  276.     {
  277.         list( $dbserial, $dbcode, $dbemail ) = $db->sql_fetchrow( $db->sql_query( "SELECT serial, code, email FROM ".$prefix."".DBNAME_CONFIG."" ) );
  278.         if ( $dbserial == generate_serial( $_SERVER['SERVER_NAME'], $dbcode, $dbemail, ENCRYPTKEY ) )
  279.         {
  280.             if ( file_exists( "plugins/".FORUMTYPE."/index.php" ) )
  281.             {
  282.                 include( "plugins/".FORUMTYPE."/index.php" );
  283.             }
  284.             else
  285.             {
  286.                 head( );
  287.                 $html = "<center>Plugin file missing!</center>";
  288.                 box( $html, "Error" );
  289.                 foot( );
  290.             }
  291.         }
  292.         else
  293.         {
  294.             $query = $db->sql_query( "DROP TABLE IF EXISTS ".$prefix."".DBNAME_CONFIG."" );
  295.             if ( !$query )
  296.             {
  297.                 exit( $db->sql_error( ) );
  298.             }
  299.             else
  300.             {
  301.                 head( "Invalid Registration Information" );
  302.                 $html = "We have detected that this product is registered with an invalid serial number.";
  303.                 box( $html, "Error" );
  304.                 foot( );
  305.             }
  306.         }
  307.     }
  308.     else if ( intval( $_POST['install'] ) == 1 )
  309.     {
  310.         $key = $_POST['key'];
  311.         $actcode = $_POST['actcode'];
  312.         $paypalemail = $_POST['paypalemail'];
  313.         $forumtype = $_POST['forumtype'];
  314.         $username = $_POST['username'];
  315.         $pass1 = $_POST['pass1'];
  316.         $pass2 = $_POST['pass2'];
  317.         $serial = strtoupper( implode( "-", $key ) );
  318.         $generated_serial = generate_serial( $_SERVER['SERVER_NAME'], $actcode, $paypalemail, ENCRYPTKEY );
  319.         $generated_serial2 = generate_serial( $_SERVER['HTTP_HOST'], $actcode, $paypalemail, ENCRYPTKEY );
  320.         if ( $serial != $generated_serial && $serial != $generated_serial2 )
  321.         {
  322.             head( );
  323.             $html = "Invalid serial number entered. Please try again.";
  324.             box( $html, "Error" );
  325.             foot( );
  326.         }
  327.         else if ( $username == "" )
  328.         {
  329.             head( );
  330.             $html = "Username field empty. You must specify a administrative username to install.";
  331.             box( $html, "Error" );
  332.             foot( );
  333.         }
  334.         else if ( $pass1 != $pass2 || $pass1 == "" || $pass2 == "" )
  335.         {
  336.             head( );
  337.             $html = "Passwords do not match or password fields were left empty. Please fill up the form correctly!";
  338.             box( $html, "Error" );
  339.             foot( );
  340.         }
  341.         else
  342.         {
  343.             $create = $db->sql_query( "DROP TABLE IF EXISTS ".$prefix."".DBNAME_CONFIG."" );
  344.             $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" );
  345.             $create2 = $db->sql_query( "DROP TABLE IF EXISTS ".$prefix."".DBNAME_ICUSERS."" );
  346.             $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" );
  347.             $insert = $db->sql_query( "INSERT INTO ".$prefix."".DBNAME_CONFIG." (code, serial, email, username, password) VALUES({$actcode}, '{$serial}', '{$paypalemail}', '{$username}', '".md5( $pass1 )."')" );
  348.             if ( !$create || !$insert || !$create2 )
  349.             {
  350.                 exit( $db->sql_error( ) );
  351.             }
  352.             else
  353.             {
  354.                 header( "location: index.php" );
  355.             }
  356.         }
  357.     }
  358.     else
  359.     {
  360.         head( "".PAGETITLE." Installation" );
  361.         $html = "To setup Instadigi Community Content Generator, please fill up the form below and click 'INSTALL'.<br /><br />";
  362.         $html .= "<b>Product Code:</b> ";
  363.         $html .= "<input type=\"text\" name=\"actcode\" size=\"20\" maxlength=\"16\" /><br /><br />";
  364.         $html .= "<b>Email Address:</b> ";
  365.         $html .= "<input type=\"text\" name=\"paypalemail\" size=\"20\" maxlength=\"255\" /><br /><br />";
  366.         $html .= "<b>Serial Number:</b> ";
  367.         $i = 1;
  368.         for ( ; $i <= 5; ++$i )
  369.         {
  370.             $html .= "<input type=\"text\" name=\"key[]\" size=\"5\" maxlength=\"5\" />&nbsp;&nbsp;";
  371.         }
  372.         $html2 = "<b>Username:</b> ";
  373.         $html2 .= "<input type=\"text\" name=\"username\" size=\"20\" maxlength=\"16\" /><br /><br />";
  374.         $html2 .= "<b>Password:</b> ";
  375.         $html2 .= "<input type=\"text\" name=\"pass1\" size=\"20\" maxlength=\"16\" /> <b>Repeat Password:</b> ";
  376.         $html2 .= "<input type=\"text\" name=\"pass2\" size=\"20\" maxlength=\"16\" /><br /><br />";
  377.         $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>";
  378.         echo "<form action=\"index.php\" method=\"post\">";
  379.         box( $html, "<b>".PAGETITLE." Installation - License Registration</b>" );
  380.         box( $html2, "<b>".PAGETITLE." Installation - Administration</b>" );
  381.         box2( $html3 );
  382.         echo "</form>";
  383.         foot( );
  384.         switch ( $_REQUEST['indexaction'] )
  385.         {
  386.         case "reinstall" :
  387.             $drop = $db->sql_query( "DROP TABLE IF EXISTS ".$prefix."".DBNAME_CONFIG."" );
  388.             if ( !$drop )
  389.             {
  390.                 exit( );
  391.             }
  392.             else
  393.             {
  394.                 header( "location: index.php" );
  395.                 break;
  396.             }
  397.         }
  398.     }
  399. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement