Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Run SQL Script from Admin


surfalot

Recommended Posts

The purpose of this contribution is simply to upload and

process a SQL script text file. I wrote this script since

I have found a couple hosts that don't provide a SQL tool

like phpMyAdmin.

 

The code allows you to restrict the commands that can

be processed so allow some additional script safety.

 

This script processes the SQL script file and provides

feedback if errors occur. This script should only be used

in a password protected area of your site. If others get

access to this script, you could have serious problems.

But I guess it is just as dangerous as the file manager

that is already distributed with osCommerce.

 

Get it here

Edited by surfalot
Link to comment
Share on other sites

  • 2 months later...

Todd, I am installing your contribution. When I try to execute a sql file I am receiving an error

Error: Destination not writeable.

Did I miss something?

Also, what would be the simplest way to disable this contribution betweeen uses?

-Dave

Link to comment
Share on other sites

Todd, I am installing your contribution. When I try to execute a sql file I am receiving an error

Error: Destination not writeable.

Did I miss something?

Also, what would be the simplest way to disable this contribution betweeen uses?

I should have thought over the upload destination for the SQL file a little better.

 

find this setting is in /catalog/admin/run_sql.php

 

about line 31:

 

	$attachment_upload_location = DIR_FS_ADMIN;

change to:

 

	$attachment_upload_location = DIR_FS_BACKUP;

then make sure the directory has write permissions. by default it is defined as:

 

/catalog/admin/backups/

 

on your server. as installed, this directory should have write permissions. if it doesn't you may have to set it to 777 permissions. some FTP programs let you change permissions. FileZilla is one of them filezilla.sourceforge.net. in FileZilla, on your site, just right-click the folder and select "file attributes", check them all.

 

to disable the file between uses, add this to the top of the file, anywhere after the comments section:

 

exit;

 

a couple of excellent questions to start this thread off! :thumbsup:

Link to comment
Share on other sites

  • 2 months later...

When I installed R SQL I can see in Panel Administration>Tools>Run SQL Script , but I cant run it because

"no access"(I changed string $attachment_upload_location = DIR_FS_BACKUP;). In Administrators>Groups menu there isn't "run_sql.php" item (see below)

 

 

Tools

 

backup.php

banner_manager.php

banner_statistics.php

cache.php

define_language.php

file_manager.php

mail.php

newsletters.php

server_info.php

whos_online.php

 

Perhaps problem is in "tools.php". My contrib osC included, (when I added string with Run_SQL thre isnt

"Run SQL Sript" item in Tools Menu) :

 

"

'link' => tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('selected_box')) . 'selected_box=tools'));

 

if ($selected_box == 'tools') {

$contents[] = array('text' => tep_admin_files_boxes(FILENAME_BACKUP, BOX_TOOLS_BACKUP) .

tep_admin_files_boxes(FILENAME_BANNER_MANAGER, BOX_TOOLS_BANNER_MANAGER) .

tep_admin_files_boxes(FILENAME_CACHE, BOX_TOOLS_CACHE) .

tep_admin_files_boxes(FILENAME_DEFINE_LANGUAGE, BOX_TOOLS_DEFINE_LANGUAGE) .

tep_admin_files_boxes(FILENAME_FILE_MANAGER, BOX_TOOLS_FILE_MANAGER) .

 

// BOC: Run SQL contribution

tep_admin_files_boxes(FILENAME_RUN_SQL, BOX_TOOLS_RUN_SQL) .

// EOC: Run SQL contribution

 

tep_admin_files_boxes(FILENAME_MAIL, BOX_TOOLS_MAIL) .

tep_admin_files_boxes(FILENAME_NEWSLETTERS, BOX_TOOLS_NEWSLETTER_MANAGER) .

// tep_admin_files_boxes(FILENAME_SERVER_INFO, BOX_TOOLS_SERVER_INFO) .

tep_admin_files_boxes(FILENAME_WHOS_ONLINE, BOX_TOOLS_WHOS_ONLINE));

}

Link to comment
Share on other sites

  • 3 weeks later...
When I installed R SQL I can see in Panel Administration>Tools>Run SQL Script , but I cant run it because

"no access"(I changed string $attachment_upload_location = DIR_FS_BACKUP;). In Administrators>Groups menu there isn't "run_sql.php" item (see below)

Tools

 

backup.php

banner_manager.php

banner_statistics.php

cache.php

define_language.php

file_manager.php

mail.php

newsletters.php

server_info.php

whos_online.php

 

Perhaps problem is in "tools.php". My contrib osC included, (when I added string with Run_SQL thre isnt

"Run SQL Sript" item in Tools Menu) :

 

"

'link' => tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('selected_box')) . 'selected_box=tools'));

 

if ($selected_box == 'tools') {

$contents[] = array('text' => tep_admin_files_boxes(FILENAME_BACKUP, BOX_TOOLS_BACKUP) .

tep_admin_files_boxes(FILENAME_BANNER_MANAGER, BOX_TOOLS_BANNER_MANAGER) .

tep_admin_files_boxes(FILENAME_CACHE, BOX_TOOLS_CACHE) .

tep_admin_files_boxes(FILENAME_DEFINE_LANGUAGE, BOX_TOOLS_DEFINE_LANGUAGE) .

tep_admin_files_boxes(FILENAME_FILE_MANAGER, BOX_TOOLS_FILE_MANAGER) .

 

// BOC: Run SQL contribution

tep_admin_files_boxes(FILENAME_RUN_SQL, BOX_TOOLS_RUN_SQL) .

// EOC: Run SQL contribution

 

tep_admin_files_boxes(FILENAME_MAIL, BOX_TOOLS_MAIL) .

tep_admin_files_boxes(FILENAME_NEWSLETTERS, BOX_TOOLS_NEWSLETTER_MANAGER) .

// tep_admin_files_boxes(FILENAME_SERVER_INFO, BOX_TOOLS_SERVER_INFO) .

tep_admin_files_boxes(FILENAME_WHOS_ONLINE, BOX_TOOLS_WHOS_ONLINE));

}

you need to add it to your Admin Access contribution. See that contribution for more help with that.

Link to comment
Share on other sites

  • 3 months later...
In the ZenCart version of this kind of contrib called "sqlpatch.php" there is a text field along with the file upload box. How hard would it be to add this box for paste-able sql statements :)

 

been thinking about. next version.

Link to comment
Share on other sites

  • 1 year later...

I installed your contrib and now I cant see right window in admin.

 

How I did what:

1. Installed 3 files

2. Manually edited (using find and pasting after) filenames, tools, and english.php

 

I have triple checked my copying and pasting to make sure its perfect

 

File names changes -

define('FILENAME_REVIEWS', 'reviews.php');

// BOC: Run SQL contribution

define('FILENAME_RUN_SQL', 'run_sql.php');

// EOC: Run SQL contribution

define('FILENAME_SERVER_INFO', 'server_info.php');

 

Tools changes -

'<a href="' . tep_href_link(FILENAME_DEFINE_LANGUAGE) . '" class="menuBoxContentLink">' . BOX_TOOLS_DEFINE_LANGUAGE . '</a><br>' .

'<a href="' . tep_href_link(FILENAME_FILE_MANAGER) . '" class="menuBoxContentLink">' . BOX_TOOLS_FILE_MANAGER . '</a><br>' .

// BOC: Run SQL contribution

'<a href="' . tep_href_link(FILENAME_RUN_SQL) . '" class="menuBoxContentLink">' . BOX_TOOLS_RUN_SQL . '</a><br>' .

// EOC: Run SQL contribution

class="menuBoxContentLink">' . BOX_TOOLS_FILE_MANAGER . '</a><br>' .

'<a href="' . tep_href_link(FILENAME_MAIL) . '" class="menuBoxContentLink">' . BOX_TOOLS_MAIL . '</a><br>' .

 

English Changes -

define('BOX_TOOLS_FILE_MANAGER', 'File Manager');

// BOC: Run SQL contribution

define('BOX_TOOLS_RUN_SQL', 'Run SQL Script');

// EOC: Run SQL contribution

define('BOX_TOOLS_MAIL', 'Send Email');

 

Do you see something I am missing? What happened?

 

Help, D

Link to comment
Share on other sites

  • 5 years later...

yup buttons where for the new shop.  v1.2.1 Update is old style buttons. [reboot]  thanks for the heads-up

Edited by surfalot
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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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...