<?
include "header.php";


$data = "<?
/////////////////////////
//  BACKUP MYSQL FILE  //
//                     //
//  TABLES BACKED UP   //
//   IMS               //
//   IMS_ADMIN         //
//   IMS_FAQ           //
//   IMS_FAQCAT        //
//   IMS_FOLDERS       //
//   IMS_IMAGE         //
//   IMS_PLANS         //
//                     //
/////////////////////////
";


$max = mysql_fetch_assoc(mysql_query("SELECT max(u_id) AS u_id FROM ims"));
$max_u_id = $max[u_id] + 1;

$data .= "

// TABLE STRUCTURE FOR IMS
mysql_query(\"
CREATE TABLE ims (
  u_id bigint(10) NOT NULL auto_increment,
  email varchar(200) default NULL,
  password varchar(100) default NULL,
  code varchar(255) default NULL,
  first_login varchar(255) default NULL,
  payer_paypal_email varchar(255) default NULL,
  subscribed varchar(255) default NULL,
  fname varchar(255) default NULL,
  lname varchar(255) default NULL,
  account_active varchar(100) default NULL,
  reset varchar(255) default NULL,
  new_email_id varchar(255) default NULL,
  new_email varchar(255) default NULL,
  new_email_time varchar(255) default NULL,
  plan varchar(255) default NULL,
  price varchar(255) default NULL,
  paypal_email varchar(255) default NULL,
  signup_date varchar(255) default NULL,
  IP varchar(255) default NULL,
  last_login varchar(255) default NULL,
  ext_list varchar(200) default NULL,
  space_avail bigint(10) default NULL,
  folders_avail bigint(10) default NULL,
  max_filesize bigint(10) default NULL,
  bandwidth_used varchar(255) default NULL,
  bandwidth_allotted varchar(255) default NULL,
  photo_album varchar(255) default NULL,
  notes text,
  is_approved varchar(50) default NULL,
  prefs_newwin varchar(10) default NULL,
  prefs_listby varchar(255) default NULL,
  prefs_images_per_page varchar(255) default NULL,
  albumprefs_on varchar(10) default NULL,
  albumprefs_privacy varchar(10) default NULL,
  albumprefs_password varchar(255) default NULL,
  albumprefs_logo varchar(255) default NULL,
  albumprefs_thumbs varchar(10) default NULL,
  albumprefs_align varchar(10) default NULL,
  albumprefs_width varchar(5) default NULL,
  albumprefs_head text,
  albumprefs_foot text,
  PRIMARY KEY  (u_id)
) TYPE=MyISAM AUTO_INCREMENT=$max_u_id
\");

// DATA DUMP FOR IMS TABLE";


$ims = mysql_query("SELECT * FROM ims");
while($ims_info = mysql_fetch_assoc($ims)) {

$ims_info[fname] = addslashes($ims_info[fname]);
$ims_info[lname] = addslashes($ims_info[lname]);
$ims_info[notes] = addslashes($ims_info[notes]);
$ims_info[albumprefs_password] = addslashes($ims_info[albumprefs_password]);
$ims_info[albumprefs_logo] = addslashes($ims_info[albumprefs_logo]);
$ims_info[albumprefs_head] = addslashes($ims_info[albumprefs_head]);
$ims_info[albumprefs_foot] = addslashes($ims_info[albumprefs_foot]);
$data .= "
mysql_query(\"INSERT INTO ims VALUES ('$ims_info[u_id]', '$ims_info[email]', '$ims_info[password]', '$ims_info[code]', '$ims_info[first_login]', '$ims_info[payer_paypal_email]', '$ims_info[subscribed]', '$ims_info[fname]', '$ims_info[lname]', '$ims_info[account_active]', '$ims_info[reset]', '$ims_info[new_email_id]', '$ims_info[new_email]', '$ims_info[new_email_time]', '$ims_info[plan]', '$ims_info[price]', '$ims_info[paypal_email]', '$ims_info[signup_date]', '$ims_info[IP]', '$ims_info[last_login]', '$ims_info[ext_list]', '$ims_info[space_avail]', '$ims_info[folders_avail]', '$ims_info[max_filesize]', '$ims_info[bandwidth_used]', '$ims_info[bandwidth_allotted]', '$ims_info[photo_album]', '$ims_info[notes]', '$ims_info[is_approved]', '$ims_info[prefs_newwin]', '$ims_info[prefs_listby]', '$ims_info[prefs_images_per_page]', '$ims_info[albumprefs_on]', '$ims_info[albumprefs_privacy]', '$ims_info[albumprefs_password]', '$ims_info[albumprefs_logo]', '$ims_info[albumprefs_thumbs]', '$ims_info[albumprefs_align]', '$ims_info[albumprefs_width]', '$ims_info[albumprefs_head]', '$ims_info[albumprefs_foot]')\");";
}





$data .= "







// TABLE STRUCTURE FOR IMS_ADMIN
mysql_query(\"
CREATE TABLE ims_admin (
  login_name varchar(150) default NULL,
  password varchar(150) default NULL,
  special_code varchar(200) default NULL,
  email varchar(150) default NULL,
  paypal_email varchar(150) default NULL,
  timezone varchar(150) default NULL,
  notify varchar(150) default NULL,
  welcome varchar(255) default NULL,
  welcome_sub varchar(150) default NULL,
  welcome_note longtext,
  site_name varchar(150) default NULL,
  site_url varchar(150) default NULL,
  users_per_page int(4) default NULL,
  ok_letters varchar(150) default NULL,
  approve_deny varchar(150) default NULL,
  appr_email varchar(150) default NULL,
  appr_sub varchar(150) default NULL,
  appr_message longtext,
  den_email varchar(150) default NULL,
  den_sub varchar(150) default NULL,
  den_message longtext,
  inactivity varchar(150) default NULL,
  ban_ip longtext,
  ban_email longtext,
  rotate_feature varchar(150) default NULL,
  resize_feature varchar(150) default NULL,
  user_head1 longtext,
  user_head2 longtext,
  user_foot longtext,
  demo_feature varchar(150) default NULL,
  demo_email varchar(150) default NULL,
  demo_password varchar(150) default NULL,
  demo_autofill varchar(150) default NULL,
  plan_upgrade varchar(150) default NULL,
  faq_on varchar(5) default NULL,
  debug_mode varchar(150) default NULL
) TYPE=MyISAM
\");

// DATA DUMP FOR IMS_ADMIN TABLE";

$admin_info[welcome_sub] = addslashes($admin_info[welcome_sub]);
$admin_info[welcome_note] = addslashes($admin_info[welcome_note]);
$admin_info[site_name] = addslashes($admin_info[site_name]);
$admin_info[ok_letters] = addslashes($admin_info[ok_letters]);
$admin_info[appr_sub] = addslashes($admin_info[appr_sub]);
$admin_info[appr_message] = addslashes($admin_info[appr_message]);
$admin_info[den_sub] = addslashes($admin_info[den_sub]);
$admin_info[den_message] = addslashes($admin_info[den_message]);
$admin_info[user_head1] = addslashes($admin_info[user_head1]);
$admin_info[user_head2] = addslashes($admin_info[user_head2]);
$admin_info[user_foot] = addslashes($admin_info[user_foot]);
$data .= "
mysql_query(\"INSERT INTO ims_admin VALUES ('$admin_info[login_name]', '$admin_info[password]', '$admin_info[special_code]', '$admin_info[email]', '$admin_info[paypal_email]', '$admin_info[timezone]', '$admin_info[notify]', '$admin_info[welcome]', '$admin_info[welcome_sub]', '$admin_info[welcome_note]', '$admin_info[site_name]', '$admin_info[site_url]', '$admin_info[users_per_page]', '$admin_info[ok_letters]', '$admin_info[approve_deny]', '$admin_info[appr_email]', '$admin_info[appr_sub]', '$admin_info[appr_message]', '$admin_info[den_email]', '$admin_info[den_sub]', '$admin_info[den_message]', '$admin_info[inactivity]', '$admin_info[ban_ip]', '$admin_info[ban_email]', '$admin_info[rotate_feature]', '$admin_info[resize_feature]', '$admin_info[user_head1]', '$admin_info[user_head2]', '$admin_info[foot]', '$admin_info[demo_feature]', '$admin_info[demo_email]', '$admin_info[demo_password]', '$admin_info[demo_autofill]', '$admin_info[plan_upgrade]', '$admin_info[faq_on]', '$admin_info[debug_mode]')\");
";







$max = mysql_fetch_assoc(mysql_query("SELECT max(q_id) AS q_id FROM ims_faq"));
$max_q_id = $max[q_id] + 1;

$data .= "







// TABLE STRUCTURE FOR IMS_FAQ
mysql_query(\"
CREATE TABLE ims_faq (
  q_id int(11) NOT NULL auto_increment,
  c_id varchar(100) NOT NULL default '',
  q_order int(10) NOT NULL default '0',
  question varchar(255) NOT NULL default '',
  answer text NOT NULL,
  PRIMARY KEY  (q_id)
) TYPE=MyISAM AUTO_INCREMENT=$max_q_id 
\");

// DATA DUMP FOR IMS_FAQ TABLE";


$ims_faq = mysql_query("SELECT * FROM ims_faq");
while($ims_faq_info = mysql_fetch_assoc($ims_faq)) {
$ims_faq_info[question] = addslashes($ims_faq_info[question]);
$ims_faq_info[answer] = addslashes($ims_faq_info[answer]);
$data .= "
mysql_query(\"INSERT INTO ims_faq VALUES ('$ims_faq_info[q_id]', '$ims_faq_info[c_id]', '$ims_faq_info[q_order]', '$ims_faq_info[question]', '$ims_faq_info[answer]')\");";
}





$max = mysql_fetch_assoc(mysql_query("SELECT max(c_id) AS c_id FROM ims_faqcat"));
$max_c_id = $max[c_id] + 1;

$data .= "







// TABLE STRUCTURE FOR IMS_FAQCAT
mysql_query(\"
CREATE TABLE ims_faqcat (
  c_id bigint(10) NOT NULL auto_increment,
  c_order int(10) default NULL,
  category varchar(250) default NULL,
  PRIMARY KEY  (c_id)
) TYPE=MyISAM AUTO_INCREMENT=$max_c_id 
\");

// DATA DUMP FOR IMS_FAQCAT TABLE";


$ims_faqcat = mysql_query("SELECT * FROM ims_faqcat");
while($ims_faqcat_info = mysql_fetch_assoc($ims_faqcat)) {
$ims_faqcat_info[category] = addslashes($ims_faqcat_info[category]);
$data .= "
mysql_query(\"INSERT INTO ims_faqcat VALUES ('$ims_faqcat_info[c_id]', '$ims_faqcat_info[c_order]', '$ims_faqcat_info[category]')\");";
}





$max = mysql_fetch_assoc(mysql_query("SELECT max(f_id) AS f_id FROM ims_folders"));
$max_f_id = $max[f_id] + 1;

$data .= "







// TABLE STRUCTURE FOR IMS_FOLDERS
mysql_query(\"
CREATE TABLE ims_folders (
  f_id bigint(10) NOT NULL auto_increment,
  u_id bigint(10) NOT NULL default '0',
  name varchar(255) NOT NULL default '',
  description text NOT NULL,
  in_album varchar(10) NOT NULL default '',
  PRIMARY KEY  (f_id)
) TYPE=MyISAM AUTO_INCREMENT=$max_f_id 
\");

// DATA DUMP FOR IMS_FOLDERS TABLE";


$ims_folders = mysql_query("SELECT * FROM ims_folders");
while($ims_folders_info = mysql_fetch_assoc($ims_folders)) {
$ims_folders_info[name] = addslashes($ims_folders_info[name]);
$ims_folders_info[description] = addslashes($ims_folders_info[description]);
$data .= "
mysql_query(\"INSERT INTO ims_folders VALUES ('$ims_folders_info[f_id]', '$ims_folders_info[u_id]', '$ims_folders_info[name]', '$ims_folders_info[description]', '$ims_folders_info[in_album]')\");";
}





$max = mysql_fetch_assoc(mysql_query("SELECT max(i_id) AS i_id FROM ims_image"));
$max_i_id = $max[i_id] + 1;

$data .= "







// TABLE STRUCTURE FOR IMS_IMAGE
mysql_query(\"
CREATE TABLE ims_image (
  i_id bigint(10) NOT NULL auto_increment,
  u_id bigint(10) NOT NULL default '0',
  f_id bigint(10) NOT NULL default '0',
  title varchar(255) NOT NULL default '',
  description text NOT NULL,
  thumb varchar(255) NOT NULL default '',
  ext varchar(20) NOT NULL default '',
  size varchar(20) NOT NULL default '',
  views varchar(8) NOT NULL default '',
  PRIMARY KEY  (i_id)
) TYPE=MyISAM AUTO_INCREMENT=$max_i_id 
\");

// DATA DUMP FOR IMS_IMAGE TABLE";


$ims_image = mysql_query("SELECT * FROM ims_image");
while($ims_image_info = mysql_fetch_assoc($ims_image)) {
$ims_image_info[title] = addslashes($ims_image_info[title]);
$ims_image_info[description] = addslashes($ims_image_info[description]);
$data .= "
mysql_query(\"INSERT INTO ims_image VALUES ('$ims_image_info[i_id]', '$ims_image_info[u_id]', '$ims_image_info[f_id], '$ims_image_info[title]', '$ims_image_info[description]', '$ims_image_info[thumb]', '$ims_image_info[ext]', '$ims_image_info[size]', '$ims_image_info[views]')\");";
}






$max = mysql_fetch_assoc(mysql_query("SELECT max(p_id) AS p_id FROM ims_plans"));
$max_p_id = $max[p_id] + 1;

$data .= "







// TABLE STRUCTURE FOR IMS_PLANS
mysql_query(\"
CREATE TABLE ims_plans (
  p_id bigint(10) NOT NULL auto_increment,
  plan varchar(255) default NULL,
  price float default NULL,
  status varchar(255) NOT NULL default '',
  plan_description varchar(255) default NULL,
  photo_album varchar(255) default NULL,
  allocated_space varchar(255) default NULL,
  allowed_folders varchar(255) default NULL,
  max_filesize varchar(255) default NULL,
  bandwidth_allotted varchar(255) default NULL,
  ext_list varchar(255) default NULL,
  PRIMARY KEY  (p_id)
) TYPE=MyISAM AUTO_INCREMENT=$max_p_id 
\");

// DATA DUMP FOR IMS_PLANS TABLE";


$ims_plans = mysql_query("SELECT * FROM ims_plans");
while($ims_plans_info = mysql_fetch_assoc($ims_plans)) {
$ims_plans_info[plan] = addslashes($ims_plans_info[plan]);
$ims_plans_info[plan_description] = addslashes($ims_plans_info[plan_description]);
$data .= "
mysql_query(\"INSERT INTO ims_plans VALUES ('$ims_plans_info[p_id]', '$ims_plans_info[plan]', '$ims_plans_info[price]', '$ims_plans_info[status]', '$ims_plans_info[plan_description]', '$ims_plans_info[photo_album]', '$ims_plans_info[allocated_space]', '$ims_plans_info[allowed_folders]', '$ims_plans_info[max_filesize]', '$ims_plans_info[bandwidth_allotted]', '$ims_plans_info[ext_list]')\");";
}



$data .= "
?>";



// OUTPUT MYSQL BACKUP FILE
header("Content-Type: text/plain");
header("Content-Disposition: attachment; filename=ims_tables.txt");
header("Pragma: no-cache");
header("Expires: 0");

echo $data;

?>