by Russ TannerGallery Comment Cruncher

Version 1.00

Running Commands

Comment Cruncher is designed to allow you to invoke commands simply by making a request containing a query string to the Comment Cruncher script. This page shows you how.

topWhy Do This?

Convenience.

By invoking commands directly from your own webpage, you can specify all database credentials and run a command with the single click of a link (or button).

You can also preconfigure searches you perform often enabling you to view search results in a single click.

topHow It Works

You run commands by creating a link to the Comment Cruncher script. This link contains a query string with parameters defined. These parameters tell Comment Cruncher what to do.

This works equally as well if you wish to POST parameters to the script. It makes no different whether parameters are POSTed or GETed (sent in a query string).

To make this work, you need to know what parameters do what. Please see the Commend Reference below for all of the information you need.

topCommand Reference

About Database Credentials

In order for Comment Cruncher to process a request involving the database (like deleting comments), database credentials must be specified.

In the examples provided in this section, we do not show database credentials in order to make examples easier to read. Nevertheless, these credentials must be provided wherever stated below.

Following is list of HTTP parameters that specify database credentials:

  • DBServer - Provides the database server.
  • DBUsername - Provides the database username credential.
  • DBPassword - Provides the database password credential.
  • DBName - Provides the database name.
  • TablePrefix - Provides the table prefix for all tables.
  • ColumnPrefix - Provides the prefix for all columns.

Display A Page

You can link into any available Comment Cruncher page just by GETing or POSTing a few variables.

"do"

To display a page, this should be passed "SayPage". This is the default value of "do" so you can optionally simply skip passing "do" when simply displaying a Comment Cruncher page.

"page"

This is the name of the page you wish to display. Valid values are:

  • "About"
  • "License"
  • "Main"
  • "SysReq"
  • "Usage"

"Usage" is special. If you attempt to open the "Usage" page, a new window will open and be redirected to the website that contains usage information.

Example

?page=Main

This example displays the "Main" page. Remember, "do" defaults to "SayPage" when not specified, so you can simply omit it. This feature is guaranteed to be forward compatible (it will continue to work in future releases).

Restore Defaults

This enables you to set either the database credentials or table/column prefixes to their default values. This is identical to clicking the "Restore Defaults" link in either the "Database Credentials" section or the "Table & Column Prefix" section.

"do"

This should be passed "RestoreDefaults".

"q"

This is used to determine which set of data gets restored. Valid values are:

  • "DBCredentials" - Restores the fields in the "Database Credentials" section.
  • "Prefixes" - Restores the fields in the "Prefixes" section.

Example

?do=RestoreDefaults&q=DBCredentials

Auto Detect Table & Column Prefix

This automatically detects the table and column prefix used in your Gallery database and displays the result in a dialog. This dialog gives you the option to use the detected prefixes or not use them.

Using "AutoDetect" identical to clicking the "Auto Detect" link in the "Table & Column Prefix" section.

"do"

This should be passed "AutoDetect".

"q"

This should be set to "Prefixes". The current version of Comment Cruncher will work without specifying this variable, but this behavior is not guaranteed in future releases. Therefore, to maintain forward compatibility, it is recommended that you set this value to "Prefixes".

<Database Credentials>

All 6 database credentials are required. See "About Database Credentials" at the beginning of this section.

Example

?do=AutoDetect&q=Prefixes

Clear A List

This clears one of the lists (Subject, Body, Author, IP Address). The file associated with the list is cleared and the Main page is displayed. No confirmation page is displayed.

A "Success" page is displayed after the list is cleared.

"do"

This should be passed "ClearList".

"q"

This should contain the standardized name of a list. Valid values are:

  • "SubjectList"
  • "BodyList"
  • "AuthorList"
  • "IPList"

Example

?do=ClearList&q=IPList

This example clears the IP list.

Sort A List

This sorts one of the lists (Subject, Body, Author, IP Address). The file associated with the list is sorted and the Main page is displayed. No confirmation page is displayed.

A "Success" page is displayed after the list is cleared.

"do"

This should be passed "SortList".

"q"

This should contain the standardized name of a list. Valid values are:

  • "SubjectList"
  • "BodyList"
  • "AuthorList"
  • "IPList"

Example

?do=SortList&q=SubjectList

This example sorts the Subject list.

Remove Duplicates From A List

This removes duplicate items from one of the lists (Subject, Body, Author, IP Address). The file associated with the list has duplicates removed and the Main page is displayed. No confirmation page is displayed.

A "Success" page is displayed after the list is purged of duplicates.

"do"

This should be passed "RemoveDuplicates".

"q"

This should contain the standardized name of the list we want to remove duplicates from. Valid values are:

  • "SubjectList"
  • "BodyList"
  • "AuthorList"
  • "IPList"

Example

?do=RemoveDuplicates&q=BodyList

This example removes all duplicates from the Body list.

Save Or Update A List

This saves a list passed as a parameter to a list file. The file is saved with line-endings that are compatible with the operating system Comment Cruncher is running on, regardless of the line endings used in the passed parameter.

This feature essentially allows you to update and manage lists from another webpage.

"do"

This should be passed "SaveList".

"q"

This should contain the standardized name of the list we want to save. Valid values are:

  • "SubjectList"
  • "BodyList"
  • "AuthorList"
  • "IPList"

<List Name>

The name of this variable must match the name specified in "q".

This parameter contains the actual contents of the list we wish to save. This will normally be a list of items delimited by some type of EOL (end-of-line) sequence. The type of EOL sequence used can be any of the following: \r\n, \n, or \r.

Example

?do=SaveList&q=AuthorList&AuthorList=Bob%0ALisa%0ADebbie

This example saves three items to the Author list: "Bob", "List", and "Debbie". Any existing items in the list are discarded.

Delete Comments

This deletes all comments in the Gallery database that match any item in the specified list. This also saves the specified list.

"do"

This should be passed "DeleteComments".

"q"

This should contain the standardized name of the list we're using to delete comments. Valid values are:

  • "SubjectList"
  • "BodyList"
  • "AuthorList"
  • "IPList"

Note that there is an assumed association between the list used and the field of the Comment table that is used to find matches. Below is a table the shows the association between the specified list and the column used:

  • SubjectList -> subject
  • BodyList -> comment
  • AuthorList -> author
  • IPList -> host

<List Name>

The name of this variable must match the name specified in "q".

This parameter contains the actual contents of the list we wish to use (it will be saved as well). This will normally be a list of items delimited by some type of EOL (end-of-line) sequence. The type of EOL sequence used can be any of the following: \r\n, \n, or \r.

<Database Credentials>

All 6 database credentials are required. See "About Database Credentials" at the beginning of this section.

Example

?do=DeleteComments&q=AuthorList&AuthorList=free+airline+tickets

This example deletes all comments that have an author that is contained in the Author list.

Delete Comments In Batch Mode

This deletes all comments in the Gallery database that match any item in the specified list. Comments are deleted in "batch mode", meaning that separate page request is made for each item in the specified list. This is very useful in preventing PHP from timing out while processing long lists.

This also saves the specified list.

"do"

This should be passed "DeleteBatch".

"q"

This should contain the standardized name of the list we're using to delete comments. Valid values are:

  • "SubjectList"
  • "BodyList"
  • "AuthorList"
  • "IPList"

Note that there is an assumed association between the list used and the field of the Comment table that is used to find matches. Below is a table the shows the association between the specified list and the column used:

  • SubjectList -> subject
  • BodyList -> comment
  • AuthorList -> author
  • IPList -> host

<List Name>

The name of this variable must match the name specified in "q".

This parameter contains the actual contents of the list we wish to use (it will be saved as well). This will normally be a list of items delimited by some type of EOL (end-of-line) sequence. The type of EOL sequence used can be any of the following: \r\n, \n, or \r.

<Database Credentials>

All 6 database credentials are required. See "About Database Credentials" at the beginning of this section.

Example

?do=DeleteBatch&q=IPList&IPList=84.12.45.6

This example deletes (in batch mode) all comments with an IP address that is contained in the IP list.

Delete All Comments

This deletes all comments in the Gallery.

"do"

This should be passed "DeleteCommentsAll".

"confirmed"

If you want to delete all comments without displaying a confirmation page, this parameter must be set to "yes".

If you want to display a confirmation page first before deleting all comment (recommended), this parameter should be omitted.

<Database Credentials>

All 6 database credentials are required. See "About Database Credentials" at the beginning of this section.

Example

?do=DeleteCommentsAll&confirmed=yes

This example deletes all comments in the database without first displaying a confirmation page.

Find Comments

This finds all comments in the Gallery database that match the specified parameters.

"do"

This should be passed "FindComments".

"column"

This is the actual name of the column we're searching (from the Comment) table. Valid values are:

  • "subject"
  • "comment"
  • "author"
  • "host"

"value"

This is the value we're searching for. This value is use in a SQL LIKE statement so wildcards are allowed: "%", "_".

"max"

This is the maximum number of rows we will return in the result list. This must be numeric and between 1 and 2,000,000 inclusive.

<Database Credentials>

All 6 database credentials are required. See "About Database Credentials" at the beginning of this section.

Example

?do=FindComments&column=subject&value=%25airline+tickets%25&max=100

This example returns a list of a maximum of 100 comments having a subject that contains the phrase "airline tickets".

Find Duplicates

This finds all comments in the Gallery database that have an attribute (subject, body, author, host) that is identical to other comments.

"do"

This should be passed "FindDuplicates".

"column"

This is the actual name of the column we're searching (from the Comment) table. Valid values are:

  • "subject"
  • "comment"
  • "author"
  • "host"

"value"

This is the value we're searching for. This value is use in a SQL LIKE statement so wildcards are allowed: "%", "_".

"count"

This is the number of duplicates that must be found (based on the specified column) in order for the comment to be displayed in the result list. This is normally a number greater-than or equal-to 1.

"max"

This is the maximum number of rows we will return in the result list. This must be numeric and between 1 and 2,000,000 inclusive.

<Database Credentials>

All 6 database credentials are required. See "About Database Credentials" at the beginning of this section.

Example

?do=FindDuplicates&column=subject&value=%25airline+tickets%25&count=2&max=100

This example returns a list of a maximum of 100 comments having a subject that contains the phrase "airline tickets".

top