Only this pageAll pages
Powered by GitBook
1 of 37

v3.9.0

Loading...

Beginners

Loading...

Loading...

Loading...

Configuring Osclass

Loading...

Loading...

Loading...

Loading...

Loading...

Developers

Basic Osclass

Basic osclass development related information.

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Plugins and Themes

Loading...

Loading...

Loading...

Loading...

Loading...

Legacy Installations Pre 3.8.0

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Install

Step By Step Installation Guide

Step 1

Download and unzip the Osclass package.

Step 2

Move the Osclass unzipped files to the desired location on your server.

Step 3

Execute the Osclass installation script by accessing index.php or oc-includes/osclass/install.php from your browser:

Step 4

Follow the installer’s instructions:

  • Step 4.1

    • Make sure the server has the required permissions to write in the files and directories specified. This will allow you to create a basic configuration file as well as upload images, documents, etc.

  • Step 4.2

    • Add your access details to the database. If you haven’t created it yet, the installer will ask for another account with permissions that will allow to do it for you.

  • Step 4.3

    • Add the basic installation details and select your classifieds site’s country.

  • Step 4.4

    • Your installation is finished! Use the automatically-generated password to access your admin panel (/oc-admin).

Increase PHP memory limit

Increasing memory allocated to PHP

Released with version 2.3, the OSC_MEMORY_LIMIT option allows you to specify the maximum amount of memory that can be consumed by PHP. This setting may be necessary when you see a message such as "Allowed memory size of X bytes exhausted".

This setting increase PHP memory for OSClass, so it wouldn't affect other applications. By default, the memory allocated is set to 32MB. If PHP has been allocated 128MB, there is no need to set this value to 128M because OSClass checks if PHP has been allocated more memory than the entered value.

This setting may not work if your host doesn't allow for increasing the PHP memory limit. In that case, contact your host to increase the PHP memory limit.

Increase PHP Memory to 128MB (add this define constant in config.php)

If you’ve installed it in the domain’s root directory, you’ll have to go to: or directly to

If you’ve installed it in a subdirectory inside the domain, classifieds, for example, go to: or directly to

http://example.com/index.php
http://example.com/oc-includes/osclass/install.php
http://example.com/classifieds/index.php
http://example.com/classifieds/oc-includes/osclass/install.php
define('OSC_MEMORY_LIMIT', '128M') ;

Osclass

Get Started with Osclass

Why this new fork?

Since Osclass project was effectively shut down in September 2019, this project's goal is to continue its development, to adapt new features, get rid of deprecated code and set road for new goals.

What is Osclass?

Osclass is a free and open script to create your advertisement or listings site.

Best features: Plugins, themes, multi-language, CAPTCHA, dashboard, SEO friendly.

Clone the repository and the submodules.

$> git clone --recursive git@github.com:mindstellar/Osclass.git

Project info

Source Code:

Support Forum:

Releases:

Osclass Extras:

License:

https://github.com/mindstellar/osclass
https://osclass.discourse.group
https://github.com/mindstellar/Osclass/releases
https://github.com/mindstellar/Osclass-Extras
Apache License V2.0

Osclass Cron

What is Cron?

It's also recommended to use your system's CRON instead of the built-in functionality of Osclass, since you will get better results with the first one. We use this functionality to run a few jobs as sending email alerts or counting number of items per category.

CRON in Osclass

As said before, we need some 'jobs' to be done from time to time, from sending email alerts, to count number of items per category or allow plugins as sitemap perform other actions.

In an ideal world, every server would have CRON enabled, and you would be able to set as many cronjobs as you want. But because we know that it's not always true, we offer this built-in functionality.

Configure CRON with Osclass

Inbuilt Cron

To use the built-in functionality you need to check the Auto-cron option on the admin panel, under Settings Cron.

System Cron

To use your system's CRON functionality you need to uncheck the Auto-cron option on the admin panel, under Settings > Cron settings.

Cron is only available on Unix or Unix-like system (Linux, OSX, Free BSD).

Most of the web servers out there are running a Linux distribution, so it should be no problem at all. Windows systems have several alternatives to CRON which work in different ways. Usually, you need to SSH your server (access via SSH) and type on the command line/terminal this

crontab \-e

You will enter your "cronjob list" on a terminal editor (usually vi, vim, nano or emacs). Then it depends on the editor to save, close, edit the file itself, etc.

Most hosting companies will not offer SSH access, and those who do it, some of them will not offer you the possibility to modify the CRON, but offer you a workaround via admin panel to do it. For example, Dreamhost (under Goodies > Cron) offers you an "easy wizard" to run cronjobs, but limits to one cronjob per user (via terminal/SSH you have no limits).

We can not provide you with more information since it highly depends on your hosting company/server.

A cron job needs a time interval/time and a command to be executed, something like (really, more detailed on the wiki, I will not talk about the different time options)

\* \* \* \* \* command params

In our case, we want to execute a php file, we need to have installed php-cli or php-cgi versions, which are the executables of PHP.

NOTE: Some server will only have the apache mod version of PHP since performance is slower with the mod version and also have a few fewer features, It's strange that some server doesn't have it, but it could happen! ask your hosting company!

Well, we need to run the CLI (command-line interface or executable) version of PHP, we need to use the full path (your phpinfo could help you on this, or ask your hosting provider!) then, we need to pass as a parameter or argument the PHP file, use full path again (NOTE: Usually, shared server use the home directory to hold their users and websites, so your path will be /home/your_username/public_html, again, "public_html" is one of the most used folders, but it could be different, as website, yourdomain.com or anything. Also, if you own a private server, your web path is probably /var/www)

Crontab (if you could access ssh)

Access your server via SSH, type

crontab \-e

The whole cron-job should look like this

0 * * * * usr/local/php5/bin/php /home/your\_username/public\_html/index.php \-p cron \-t hourly
0 0 * * * usr/local/php5/bin/php /home/your\_username/public\_html/index.php \-p cron \-t daily
0 0 * * 0 usr/local/php5/bin/php /home/your\_username/public\_html/index.php \-p cron \-t weekly

Didn't understand crontab expressions?

Set to run at every hour o'clock (path of the PHP executable could be different)

Some hostings don't offer the possibility to set cron tasks manually, instead, they offer their clients a wizard or an option on their admin panel to set up the tasks.

Dreamhost

In your admin panel go to "Goodies > Cron jobs > add new cron job", since Dreamhost only allow you to use one cronjob per user, it's better to use this instead :

wget domain.com/index.php?page\=cron \-O /dev/null

and select "Hourly"

Hostgator

Enter your Cpanel, scroll down to "Advanced", click on "Cron Jobs". If you want to know if there's any error, enter your email.

Enter the following command:

wget domain.com/index.php?page\=cron \-O /dev/null

Select to run "Once an hour (0 * * * *)", and you're done!

Different setups

  • Best case scenario

You are able to run one or many cron-jobs. In that case, execute oc-includes/osclass/cron.php in your cron-job 'each hour.'

Remember to uncheck General Settings > Cron > Auto-cron.

  • Auto-cron

If you are not able to set any cronjob, don't want to or don't know how to set it, just check

General Settings > Cron > Auto-cron and you're done.

Contribute to Osclass

Contributing to Osclass

We are glad to hear you want to contribute to the Osclass project. Osclass is an open source solution for your classifieds site, developed by and for its users, like you. There are several ways to help Osclass grow and improve, even if you don't know to code, you could still help Osclass.

Documentation

Translations

It is work in progress to allow everyone to contribute with translations.

Support Forums

Users' participation and involvement are essential to maintain our support forums.

We will update this list here if we found more places where you can actively seek or give support.

Development

Do you know PHP, JS or MySQL? Get involved in Osclass development. Help us write code, add features and fix bugs!

Testing Osclass

Even if you don’t know to code, you can also contribute to Osclass. You can help us test the previous releases of Osclass as well as our themes and plugins.

Reporting bugs/suggest features

Tell your friends about Osclass

We will be happy if you tell your friends about Osclass, share a link or display a small banner on your site. More users -> stronger community -> better Osclass!

Donations

Osclass is and will always be free,. Sending money to Osclass developers is another way to support the community. If any theme or plugin makes your life a little bit easier, contact the author and show your support. Sometimes developers just need to hear users are happy to use their plugins/themes.

Cron is a time-based job scheduler in Unix-like computer operating systems. Cron enables users to schedule jobs (commands or shell scripts) to run periodically at certain times or dates. It is commonly used to automate system maintenance or administration. Osclass has a built-in functionality in case your system has no cron daemon, you could enable/disable it from the admin panel, general settings > cron. It's recommended to read more about .

600px-Settings_cron_check

Checkout : A easy to use online tool for creating crontab scheduler expressions

Documentation is done by everyone who wants to do it! This documentation is available on our public GitHub Repo

Currently we do not have any official forums but you can get help at which is an active public forum with active community.

Visit our project and check out our repositories. You can sign in and help us improve our core, themes or plugins. The best way to do this is through “Pull request” and help us fixing bugs by applying changes to the code. For any doubt, look up the help section for any doubt.

Want to suggest improvements or new functionalities? . Have you encountered a bug or want to suggest any other improvement? Open an issue on .

CRON on the wikipedia
Crontab Guru
https://github.com/navjottomer/Osclass-Docs
https://forums.osclasscommunity.com/
GitHub
GitHub

Mail Server

Basic Instructions to configure mail server in Osclass

Setting up a mail server

With Osclass you could configure your email server. Some shared hosting has limited mail servers, you should always check with your hosting company about it before. If you own your own dedicated server you probably know how to set up one, if not, you should perform some searches on the internet (on a linux machine it's enough to install postfix and courier packages).

Configuring Osclass to use your mail server is very easy, we also offer a pre-filled configuration to use with Google mail servers, you should notice Google offers a limited service and your emails could get marked as spam.

Want to see it in action? Check out our video tutorial on How to set up your mail server.

Mail server settings are located on Mail server option, under General Settings

Custom mail server

  • Hostname: usually smtp.yourdomain.com but it could be any domain or IP (localhost by default)

  • Server port: This is the port where is your mail server (it depends on the protocol: POP3 - port 110, IMAP - port 143, SMTP - port 25, HTTP - port 80, Secure SMTP (SSMTP) - port 465, Secure IMAP (IMAP4-SSL) - port 585, IMAP4 over SSL (IMAPS) - port 993, Secure POP3 (SSL-POP) - port 995)

  • Username: This is optional, only in case your server need authentication

  • Password: Same as Username

  • Encryption: ssl, tls or left blank as possible values

  • Check box for SMTP authentication check only if you're sure what you're doing

Google mail server

You need a Google Mail account, assume yours' myname@gmail.com

  • Hostname: smtp.gmail.com

  • Server port: 465

  • Username: your username before the @ ( "myname" )

  • Password: your password

  • Encryption: ssl

  • Check box for SMTP authentication checked

Troubleshooting

I'm not receiving any emails

Check your configuration on the Osclass admin panel. Maybe you have misspelled some detail. If everything looks correct, then check your mail server is working properly. Contact you hosting company or check the mail server's log to know what is happening.

It was working correctly but suddenly it stopped and I don't receive anything

Your mail server has stopped for some reason or you're getting your emails marked as spam. Check your mail server is running and revise its log. If they are being marked as spam, you probably have sent too many emails in a very short time interval.

I have other problems not listed here

Feel free to contact us on our support forums. We will be glad to help you. When posting your question, please, give us as much information as you can, so we could offer you a solution soon.

Installing Locations

Installing new locations

Via Admin panel

Under General Settings > Locations you could install new locations (countries, regions and cities).

Manually

Installing new locations could be a very-long process due to the big amount of data being transferred. You could raise your max_execution_limit on the PHP.ini file or install new locations manually.

  • Change /*TABLE_PREFIX*/ for whatever your prefix is. (If using the OSClass' import functionality it's not needed to modify anything)

  • Import it to your database (via OSClass' import system -Admin panel > Tools > Import-, phpMyAdmin, command line,... )

Note: If you already installed a country or a region you should not installed it again.

Download the .sql you want to from our

GitHub Repository

Configure Cache

NOTE: before enabling cache make sure you have installed and enabled the cache extension.

APC / APCu

You need to edit your config.php file and the following line

   define('OSC_CACHE', 'apc');

MEMCACHE

You need to know ip and port of the machine/s where memcached service is installed and then add the following lines to the file config.php

   define('OSC_CACHE', 'memcache');
   $_cache_config[] = array(
       'default_host'      => '127.0.0.1',
       'default_port'      => 11211,
       'default_weight'    => 1
   );

Debug PHP Errors

The OSC_DEBUG constant, added in version 2.3, controls the display of php errors and warnings. If this setting is not defined in config.php, the default value is false.

When the OSC_DEBUG is false, the error reporting level is E_ALL ^ E_NOTICE ^ E_USER_NOTICE. In that case, we're not showing notice and strict php errors. However, if we set the constant to true, the error reporting level is E_ALL | E_STRICT and display_error value is 1.

The OSC_DEBUG_LOG constant, added in version 2.3, logs these errors to a file called debug.log in oc-content. If Apache doesn't have write permissions, you may need to create the file first and set the appropriate permissions (i.e. use 666).

/**
 * Copy this code to config.php file
 * This will disable notice and strict errors
 */
define('OSC_DEBUG', false) ;
/**
 * Copy this code to config.php file
 * This will show all error notices and warnings on the site
 */
define('OSC_DEBUG', true) ;
/**
 * Copy this code to config.php file
 * This will log all error notices and warnings to a file called debug.log in oc-content
 */
define('OSC_DEBUG', true) ;
define('OSC_DEBUG_LOG', true) ;

Coding Style

Basic Introduction to Osclass coding style

Coding Style

PHP Code Demarcation

PHP code must always be delimited by the full-form, standard PHP tags:

<?php
 
?>

Short tags are never allowed. For files containing only PHP code, the closing tag must always be omitted (See General standards).

Variables

$iThisIsAnInteger = 42;
$sSomeText = 'This is some text';
$aVariable = array(1, 2, 3, 4 , 5);
...

Note: SQL column's names should follow a similar notation, but the first character should follow an underscore. Words are separated by an underscore, all in lowercase. If the column is a primary key, it should be preceded by "pk_" if it's a foreign key by "fk_"

i_integer_variable
s_some_text
dt_registration_date
pk_i_id // this is a primary key
fk_i_category_id // this is a foreign key
...

Classes

Class Declaration

The brace should always be written on the line underneath the class name.

Every class must have a documentation block that conforms to the PHPDocumentor standard. The following is an example of an acceptable class declaration:

/**
* Documentation Block Here
*/
class Foo
{
    /**
     * Documentation Block Here
     */
    public function bar()
    {
        // all contents of function
        // must be indented four spaces
    }
}

Control Statements

If/Else/Elseif

Control statements based on the if and elseif constructs must have a single space before the opening parenthesis of the conditional and a single space after the closing parenthesis.

The opening brace is written on the same line as the conditional statement.

The closing brace is always written on its own line. Any content within the braces must be indented using four spaces.

if ($a != 2) {
    $a = 2;
} else {
    $a = 7;
}
 
if ($a != 2) {
    $a = 2;
} elseif ($a == 3) {
    $a = 4;
} else {
    $a = 7;
}

It's required ALWAYS to put the braces.

The following if statements is not valid

if($a != 2)
    $a = 2;

Switch

Control statements written with the "switch" statement must have a single space before the opening parenthesis of the conditional statement and after the closing parenthesis.

All content within the "switch" statement must be indented using four spaces. Content under each "case" statement must be indented using an additional four spaces.

switch ($numPeople) {
    case 1:
        break;
 
    case 2:
        break;
 
    default:
        break;
}

The construct default should never be omitted from a switch statement.

Documentation Format

More information

This small guide is partly based in the coding style guide of Zend Framework :

Variables should follow the Hungarian Notation ( ), that means they should start with a character indicating the type of variable, for example i for integer, a for arrays, o for objects, s for strings ... Also, each first character of a word should be uppercase.

All documentation blocks ("docblocks") must be compatible with the phpDocumentor format. Describing the phpDocumentor format is beyond the scope of this document. For more information, visit: »

This small guide is partly based in the coding style guide of Zend Framework :

http://framework.zend.com/manual/1.12/en/coding-standard.coding-style.html
https://en.wikipedia.org/wiki/Hungarian_notation
http://phpdoc.org/
http://framework.zend.com/manual/1.12/en/coding-standard.coding-style.html

Administrator Menus

Usually plugin and themes needs to add menus in the Administrator panel for provide access to screens. The best way is adding a menu section in the Administration menu that allows the user to access the screens.

There are some functions for manipulate the Administration Menu.

hAdminMenu helper

Add menu page to Administration Menu.

 osc_add_admin_menu_page( 
   $menu_title, 
   $url,
   $menu_id,
   $icon_url = null, 
   $capability = null,
   $position = null )

Add submenu page to Administration Menu page given a menu parent identifier.

 osc_add_admin_submenu_page( 
   $menu_id, 
   $submenu_title, 
   $url, 
   $submenu_id, 
   $capability = null, 
   $icon_url = null )

Remove menu page from Administrator Menu.

 osc_remove_admin_menu_page($id_menu);

Remove submenu page given parent menu page identifier.

 osc_remove_admin_submenu_page( $menu_id, $submenu_id )

Adding submenus to existings menus

Helpers can add submenus to existing menus, like:Submenu Listings

Helpers are available for these pages:

  • Listings

  • Categories

  • Pages

  • Appearance

  • Plugins

  • Settings

  • Tools

  • Users

  • Statistics

 osc_admin_menu_items( 
   $submenu_title, $url, $submenu_id, $capability = null, $icon_url = null )
 osc_admin_menu_categories( 
   $submenu_title, $url, $submenu_id, $capability = null, $icon_url = null )
 osc_admin_menu_pages( 
   $submenu_title, $url, $submenu_id, $capability = null, $icon_url= null)
 osc_admin_menu_appearance( 
   $submenu_title, $url, $submenu_id, $capability = null, $icon_url = null )
 osc_admin_menu_plugins( 
   $submenu_title, $url, $submenu_id, $capability = null, $icon_url = null )
 osc_admin_menu_settings( 
   $submenu_title, $url, $submenu_id, $capability = null, $icon_url = null )
 osc_admin_menu_tools( 
   $submenu_title, $url, $submenu_id,$capability = null, $icon_url = null )
 osc_admin_menu_users( 
   $submenu_title, $url, $submenu_id, $capability = null, $icon_url = null )
 osc_admin_menu_stats( 
   $submenu_title, $url, $submenu_id, $capability = null, $icon_url = null )

Examples:

 osc_add_admin_menu_page( 
   __('Listing'),                                             // menu title
   osc_admin_base_url(true).'?page=items',                    // menu url
   'items',                                                   // menu id
   'moderator'                                                // capability
 ) ; 
 osc_add_admin_submenu_page( 
   'items',                                 // menu id
   __('Manage listings'),                   // submenu title   
   osc_admin_base_url(true).'?page=items',  // submenu url
   'items_manage',                          // submenu id
   'moderator'                              // capability
 ) ;
   ...

How to write a bug report

Here’s a great rule: If we can’t reproduce the bug, we can’t fix the bug.

When you report a bug to us, here’s what happens:

  • We read the bug report

  • One of us tries to reproduce the bug

  • If we can reproduce it, we investigate what’s broken and fix it

  • But if we can’t reproduce the bug…

  • Often bug reports don’t include enough information. Meaning we have go back and ask for details so we can investigate. If you want to increase the odds we fix an issue, and fix it fast, help us out.

A great bug report includes the following:

  1. What were you trying to do?

  2. What did you click on or do last?

  3. What happened / what did you see?

  4. What browser are you using?

  5. What version of OSClass?

  6. What hosting provider? (And if you know, what version of PHP do they use?)

  7. The bug is reported to the right place:

    1. Plugins: Specify the plugin and the version

    2. Themes: Specify the theme and the version

Bonus points for reviewing known issues before submitting, as your problem might already have been reported and have a patch or a workaround.

We work hard to have you deal with as few issues as possible, but if you want to improve the odds we can fix your issue fast, please take a extra minute to write a bug report that’s easier for us to use. Thanks.

Debug SQL Queries

Note: This will have a performance impact on your site, so make sure to turn this off in your production site.

The OSC_DEBUG_DB constant, added in version 2.3, saves the database queries to an array and at the end of the execution the queries are displayed at the end the page. The information saves each query: the sql string, how long that query took to execute, the sql number error and string if there has been some sql error.

The OSC_DEBUG_DB_LOG constant, added in version 2.3, logs the sql queries to a file called queries.log in oc-content. If you want to debug the sql queries of the AJAX calls or cron, you must use OSC_DEBUG_DB_LOG because we can't print these at the end of the page. If Apache doesn't have write permissions, you may need to create the file first and set the appropriate permissions (i.e. use 666).

The OSC_DEBUG_DB_EXPLAIN constant, added in version 2.3, run an EXPLAIN query for each select query and logs the result to a file called explain_queries.log queries. It should be used only during the development of OSClass, themes or plugins to see the performance of the queries. Remember, if Apache doesn't have write permissions, you may need to create the file first and set the appropriate permissions (i.e. use 666).

We don’t like bugs, neither you do. I’ve seen a post in talking about this and I’ve found really interesting. I’m going to reproduce it here:

Bug reports that for #3 are incredibly useful, as we can see exactly what you saw.

Source:

jetpack blog
OSClass
show screenshots
How to write a great bug report
/**
 * Copy this code to config.php file
 *
 * This will show SQL queries at the bottom of the site
 */
define('OSC_DEBUG_DB', true) ;
/**
 * Copy this code to config.php file
 *
 * This will log all sql to a file called queries.log in oc-content.
 * 
 * If Apache doesn't have write permissions, you may need to create the file first 
 * and set the appropriate permissions (i.e. use 666).
 */
define('OSC_DEBUG_DB', true) ;
define('OSC_DEBUG_DB_LOG', true) ;
/**
 * Copy this code to config.php file
 *
 * This will run a EXPLAIN sql query for each SELECT sql statement.
 * The results will be logged to a file called explain_queries.log in oc-content.
 * 
 * If Apache doesn't have write permissions, you may need to create the file first 
 * and set the appropriate permissions (i.e. use 666).
 */
define('OSC_DEBUG_DB_EXPLAIN', true) ;

Improving Search

Improving search

MySQL's full-text search capability has few user-tunable parameters.

NOTE:Note that full-text search is carefully tuned for the most effectiveness. Modifying the default behavior in most cases can actually decrease effectiveness. Do not alter the MySQL sources unless you know what you are doing.

For Osclass users, item title and item description have a fulltext index, that do search more effective and speed up.

The minimum and maximum lengths of words to be indexed by default is 4 (4 characters), that means, only words more or equal than 4 will be indexed.

Changing the maximum, minimum limit

If you like to change the minimum and maximum lengths of words to be indexed, you need update your mysql config file.

[mysqld]
ft_min_word_len=3
[mysqld]
ft_max_word_len=10

Rebuilding FULL-Text Index

After this, if you modify full-text variables that affect indexing (ft_min_word_len, ft_max_word_len, or ft_stopword_file), you must rebuild your FULL-TEXT indexes after making the changes and restarting the server. To rebuild the indexes in this case, it is sufficient to do a QUICK repair operation:

REPAIR TABLE tbl_name QUICK;

Replace tbl_name with your table name. e.g oc_t_item_description.

Updating Osclass

Osclass update instructions.

Automatic Update

N/A

Work in progress

Manual Update

For these instructions, it is assumed that your Osclass URL is http://example.com/.

Step 1: Take a backup

You should take a backup of your database and files. All your data is held in the database, so you will need to have a copy just in case you change your mind after upgrading and need to go back. The same reasons are sustained to make a backup of oc-content folder.

Step 2: Replace Osclass files

  • Unpack the zip file that you've downloaded.

  • Using FTP or you SSH, upload the new files. You should replace all the old Osclass files with the new ones: oc-admin and oc-includes directories and sub-directories, and in the root directory (ajax.php, contact.php, index.php, item.php and so on). Do NOT delete config.php file.

  • Be careful when copying the oc-content directory. You should make sure that you only copy the files from inside this directory, rather than replacing your entire oc-content directory. If you have customized the default theme without renaming it, make sure not to overwrite those files, otherwise you will lose your changes. (Though you might want to compare them for new features or fixes...)

Step 3: Update your installation

If you have permalinks enabled, you should disable them before updating Osclass. Then, update your installation. Just enter to the oc-admin (http://www.example.com/oc-admin/) and it will appear a button to update your database if it's necessary.

Visit http://www.example.com/oc-admin/index.php?page=upgrade&action=upgrade-funcs. If a database upgrade is necessary, Osclass will update your database to be compatible with the last code. If some new values in t_preference are necessary, it will update too.

Final steps

Your update is complete. Remember to activate permalinks if you have disabled before. It wasn't too difficult, was it? If anything goes wrong, you should let us know.

Source: Fine-Tuning MySQL Full-Text Search

These are short instructions, we're going to extend them in the future. If you experience problems you should report them on .

Get the . (zip or tar.gz)

[1]
Osclass forums
latest Osclass

Database model and diagram

  • Install it and open it

  • Select Create EER Model From SQL Script

  • Look for your file 'struct.sql (your_osclass_folder/oc-includes/osclass/installer/struct.sql)

  • Check Place imported object on a diagram

  • Click on Execute, Next, Finish

  • Re-arrange the boxes (tables) as you wish

Relations will highlight if you place your mouse over the tables or the relations.

This diagram could be a bit difficult to understand at first and follow all the relations. To be able to use an interactive version of the same diagram, please use the and follow these steps.

Download (it's free and cross-platform!)

MySQL Workbench
MySQL Workbench

Introduction

If you don't want to upgrade to new Osclass 3.9.0, you can use use this guide to remove Osclass Market from your current installation.

About the guide.

This guide covers most, if not all, changes required to un-tie your site from Osclass Market

If you know some changes that we forgot, post it on our forums or contact us via the links above.

Verifying that this works.

As a test if this mods were successful, we put error_log('cURL:'.$url); in osc_file_get_contents() function.

We visited admin homepage, plugins, themes and language pages, settings page, we checked for updates, we ran cron, etc.

There wasn't a single cURL log that says that a request has been made to Osclass.

Also, all this changes were made on a live site as the guide was written. There were no problems, errors and warnings.

This guide was made by and was originally posted on docs.osclasscommunity.com which is now moved here.

webmods-croatia

Auto-update themes and plugins

In version 3.0, we introduced an auto-upgrade system for plugins and themes, along with some neat features. To make your plugins and themes able to use this new feature, you need to use the Update URI param on the description of your creations. The Update URI should be unique per theme/plugin and reply a JSON response with the following format:

{
dt_mod_date: "YYYY-MM-DD HH:MM:SS",
dt_pub_date: "YYYY-MM-DD HH:MM:SS",
e_type: "{TYPE}",
i_total_downloads: "XYZ",
s_banner: "banner.jpg",
s_banner_path: "http://www.domain.tld/path/to/banner/",
s_compatible: "2.3,2.4,3.0,3.1,3.1.1,3.1.2",
s_contact_name: "My name",
s_description: "My description, HTML accepted",
s_source_file: "http://www.domain.tld/path/to/my_plugin.zip",
s_title: "Title",
s_update_url: "http://www.domain.tld/path/to/update/cheker.php",
s_version: "A.B.C",
}

s_version: Any alphanumeric string is ok, but we encourage only-numeric ones to be able to check is a version is greater or not than the installed one, preferred A.B.C style, as "1.0.2" or "2.1.0"

e_type: e_type has to be one of these options THEME or PLUGIN or "LANGUAGE"

Admin Menu

Routes

What are the routes for?

You could extend Osclass with plugins, and sometimes you need to create a special page, for example to show more options to your users.

In previous versions, the url will look like:

domain.tld/index.php?page=custom&file=your_plugin/page.php

Which isn't the prettiest url you could see, and also the file path are visible which is not a problem, but it's not good. In 3.2 we added "routes" that will transform that ugly url into a more beauty one, like:

domain.tld/your_plugin_page

They even works with regular expressions to accept variables on the url.

The route functions

To make routes works, we first need to create them:

/**
* $id - Shortname of the route
* $regexp - Regular expression of the url
* $url - Required to be able to create the nice-looking url
* $file - file that will be loaded
*/
osc_add_route($id, $regexp, $url, $file)

Later we just need to get the url:

Later we just need to get the url:

/**
* $id - Shortname of the previously created route
* $args - Optional, only required if your url accept parameters
*/
//For public routes
osc_route_url($id, [$args])

//For routes in the admin panel
osc_route_admin_url($id, [$args])

Examples

Here is an example

// Create route
osc_add_route(
     'dynamic-route',
     'dynamic-route/([0-9]+)/(.+)',
     'dynamic-route/{my-numeric-param}/{my-own-param}',
     osc_plugin_folder(__FILE__).'mydynamicroute.php'
   );
// Show link to it
echo osc_route_url(
         'dynamic-route', 
         array(
               'my-numeric-param' => '12345', 
               'my-own-param' => 
               'my-own-value'
               )
    );

Notes

  • Parameters in the $url should be enclosed between "{" and "}", example "{parameter}"

  • Parameters should have the same name (case sensitive) in both, osc_add_route and osc_route_url

  • Additionally, any file located in a folder called "admin" will be opened in admin panel, but show a 404 error in the public site

Remember that regular expressions could be tricky, make them truly unique so they will not collide with any other rule.

Example plugin

Admin Toolbar

At admin panel since osclass version 3.0, there is a toolbar which is visible around the admin panel, can have shortcuts to actions like: add a new listing, show pending updates, ...

Developers can add to the toolbar whatever they want, with hooks, and calling AdminToolbar functions like add_menu($array)

Example, adding link to frontend

An example plugin could be found in github :

https://github.com/osclass/osclass-plugins/tree/routes_example
 AdminToolbar::newInstance()->add_menu( array(...) );
 /**
   * Add a node to the menu.
   *   
   * @todo implement parent nodes
   *
   * @param array $args - The arguments for each node.
   * - id         - string    - The ID of the item.
   * - title      - string    - The title of the node.
   * - href       - string    - The link for the item. Optional.
   * - meta       - array     - Meta data including the following keys: html, class, 
   *                                 onclick, target, title, tabindex.
 */
 function add_menu( $array ) 
 /**
  * Add webtitle with link to frontend 
  */
 function osc_admin_toolbar_menu()
 {
     AdminToolbar::newInstance()->add_menu( array(
                 'id'        => 'home',
                 'title'     => ''.  osc_page_title() .'',
                 'href'      => osc_base_url(),
                 'meta'      => array('class' => 'user-profile'),
                 'target'    => '_blank'
             ) );
 }
 osc_add_hook( 'add_admin_toolbar_menus', 'osc_admin_toolbar_menu'    , 0 );

Remove calls to Osclass

This part of the guide helps you remove all calls and requests to Osclass and Osclass Market.

This is the first and most important part of "Removing Market" guide.

Unlike the second part ("Remove Market from admin frontend"), this one is a must, as it will stop your site from requesting data from Osclass Market.

Delete featured products from Admin.

You may think this change fits better in "Remove Market from admin frontend." section, but featured products make a call to Osclass to get the product list.

Open the following file:

Locate and remove this code:

$aFeatured = array();
$out_featured = osc_file_get_contents(osc_market_featured_url('plugins', 3));
$array_featured_plugins = (array) json_decode($out_featured, true);​
$out_featured = osc_file_get_contents(osc_market_featured_url('themes', 3));
$array_featured_themes = (array) json_decode($out_featured, true);​​
$this->_exportVariableToView("aFeatured", 
array_merge($array_featured_plugins, $array_featured_themes));

​

Open the following file:

oc-admin/themes/modern/main/index.php

Remove each one of this blocks of code:

$aFeatured            = __get('aFeatured');
osc_register_script('market-js', 
osc_current_admin_theme_js_url('market.js'), array('jquery', 'jquery-ui'));
osc_enqueue_script('market-js');​
osc_add_hook('admin_header','add_market_jsvariables');
<style>    
.mk-item {
          width: 90%;
          margin:5%;        
          margin-top: 3%;    
        }    
.mk-item-plugin {        
                  height: 225px;    
                }    
.mk-item .mk-info {
        width:auto;    
        }
 .mk-item-plugin .banner , .mk-item-theme .banner {
         width: 90%;        
         height: 155px;        
         border-radius: 5px 5px 0 0;        
         -webkit-border-radius: 5px 5px 0 0;        
         -moz-border-radius: 5px 5px 0 0;    
         }​    
 .mk-item-plugin .mk-info {        
         height: 40px;
         padding: 170px 15px 15px;
         }
 ​</style>
<div class="grid-row grid-first-row grid-50">
    <div class="row-wrapper">
        <div class="widget-box  widget-box-project">
            <div class="widget-box-title"><h3><?php _e('Featured products'); ?></h3></div>
            <div class="widget-box-content widget-box-content-no-wrapp">
                <?php foreach($aFeatured['themes'] as $p) {
                    drawMarketItem($p);
                } ?>
                <?php foreach($aFeatured['plugins'] as $p) {
                    drawMarketItem($p);
                } ?>
            </div>
        </div>
    </div>
</div>
<div class="grid-row grid-50">
    <div class="row-wrapper">
        <div class="widget-box">
            <div class="widget-box-title"><h3><?php _e('Market'); ?></h3></div>
            <div class="widget-box-content widget-box-content-no-wrapp">
                <div id="banner_market"></div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function(){
        $.getJSON(
            '<?php echo osc_admin_base_url(true); ?>?page=ajax&action=dashboardbox_market',
            function(data){
                if(data.error===0) {
                    $('<a href="'+oscEscapeHTML(data.url)+'" target="_blank"><div style="height: 100%; width: 100%; background: url('+oscEscapeHTML(data.banner)+') no-repeat;"></div></a>').insertAfter('#banner_market');
                }else {
                    $('<p style="text-align:center; padding-top:15px;"><?php _e('Has been a problem loading the contents, sorry for the inconvenience'); ?></p>').insertAfter('#banner_market');
                }
            });
        });
</script>

Remove Market from admin frontend

Here you will learn how to remove Market related stuff on your admin frontend.

This is the second and last part of "Removing Market" guide.

It's not mandatory, but it's recommended, as it will remove any "Market" links, menus and such from your Osclass Admin.

Admin Toolbar

Style and scripts enqueue functions

Using the Enqueue functions

Why use them?

The enqueue functions are used for loading your javascript and css files. The reason they were added is because many plugins make use of javascript frameworks such as JQuery, JQuery-ui, and fancybox just to name a few. There is a high chance that these javascript files could be loaded multiple times and that is where the enqueue functions come into play. The enqueue functions help to reduce the chances of the same file getting loaded more than once.

The Enqueue functions

javascript related functions

osc_enqueue_script($id) - Enqueue script

osc_remove_script($id) - Remove script from the queue, so it will not be loaded

osc_register_script($id, $url, $dependencies = null) - Add script to be loaded

osc_unregister_script($id) - Remove script from the queue, so it will not be loaded

osc_load_scripts() - Print the HTML tags to make the script load

css related functions

osc_enqueue_style($id, $url) - Add style to be loaded

osc_remove_style($id) - Remove style from the queue, so it will not be loaded

osc_load_styles() - Print the HTML tags to make the style load

Good naming practices

If you're going to use another js library/file which is not in oc-load (for example fancybox, or any other jquery plugin) please, use a "good" name.

If you're going to use "Jquery My plugin", do not register it as "my_extrange_name", because if someone else could be registering it with a different name and then it would be loaded twice.

Examples

registering a javascript file

osc_register_script('jCarouselLite', osc_base_url() . 'oc-content/plugins/carousel_for_osclass/js/jCarouselLite.js', 'jquery');

Enqueueing the script

osc_enqueue_script('jCarouselLite');

Enqueueing a style

osc_enqueue_style(
    'carouselCss',
    osc_base_url() . 'oc-content/plugins/carousel_for_osclass/css/slideshow.css')
 );

You may have noticed that i did not register the style and that is because it is not required and there is no function to do so.

Ok now onto a real life example.

To use these functions you will want to create a function for this example I am going to use ex_load_scripts() please use a unique function name in your plugin if you are planning on releasing it otherwise we could end up with conflicting function names.

   function ex_load_scripts() {
       osc_register_script('jCarouselLite', osc_base_url() . 'oc-content/plugins/carousel_for_osclass/js/jCarouselLite.js', 'jquery');
       osc_enqueue_script('jCarouselLite');
       osc_enqueue_style('carouselCss', osc_base_url() . 'oc-content/plugins/carousel_for_osclass/css/slideshow.css');
   }

Once you add that code you will then need to add the following hook to your index.php file of your plugin.

   osc_add_hook('init', 'ex_load_scripts');

To load the script on the admin side you would use this hook

   osc_add_hook('init_admin', 'ex_load_scripts');

That is all that you have to do to get your javascript and css files working in 3.1.+

For theme developers a good example can be found in the head.php file of the modern theme.

Pre registered scripts

Osclass pre registers some of the more common javascript files.

Here is the list of pre registered javascript files.

osc_register_script('jquery', osc_assets_url('js/jquery.min.js'));
osc_register_script('jquery-ui', osc_assets_url('js/jquery-ui.min.js'), 'jquery');
osc_register_script('jquery-json', osc_assets_url('js/jquery.json.js'), 'jquery');
osc_register_script('jquery-treeview', osc_assets_url('js/jquery.treeview.js'), 'jquery');
osc_register_script('jquery-nested', osc_assets_url('js/jquery.ui.nestedSortable.js'), 'jquery');
osc_register_script('jquery-validate', osc_assets_url('js/jquery.validate.min.js'), 'jquery'); 
osc_register_script('tabber', osc_assets_url('js/tabber-minimized.js'), 'jquery');
osc_register_script('tiny_mce', osc_assets_url('js/tiny_mce/tiny_mce.js'));
osc_register_script('colorpicker', osc_assets_url('js/colorpicker/js/colorpicker.js'));

Stop checking for updates from Osclass.

Updated 16/09/2019 to fix auto update for older plugins (Google Maps and Google Analytics).

Scroll down to see updated part (between warning messages).

Open the following file:

oc-includes/osclass/utils.php

Locate this code:

$uri = osc_market_url($type, $update_uri);

Replace it with this code:

Locate this code:

$url = osc_market_url($section, $element);$data = json_decode(osc_file_get_contents($url, array('api_key' => osc_market_api_connect())), true);

Replace it with this code:

Locate this code:

$download_post_data = array('api_key' => osc_market_api_connect());

Replace it with this code:

$download_post_data = array();

Locate this code:

$url = osc_market_url($section, $code);$data = osc_file_get_contents($url, array('api_key' => osc_market_api_connect()));$data = json_decode(osc_file_get_contents($url, array('api_key' => osc_market_api_connect())), true);

Replace it with this code:

return array('error' => 2, 'message' => __('Market updating not available.'), 'data' => $data);

Locate this code:

if(osc_market_external_sources())

Replace it with this code:

if(osc_market_external_sources() && strpos($update_uri, 'osclass.org') === false)

Note! The upper replacement must be done on all occurrences of the code (it appears 2 times).

Locate this code:

if(!osc_market_external_sources()

Replace it with this code:

if(!osc_market_external_sources() || strpos($update_uri, 'osclass.org') !== false)

​

Open the following file:

Locate this code:

$data = json_decode(osc_file_get_contents(osc_market_url($section, $code), array('api_key' => osc_market_api_connect())), true);

Replace it with this code:

echo json_encode(array('error' => 3, 'error_msg' => __('Market updating not available.')));

Locate this code:

$data = osc_file_get_contents('https://osclass.org/latest_version_v1.php?callback=?');

Replace it with this code:

echo json_encode(array('error' => 1, 'msg' => __('Version could not be checked')));

Disable Upgrade page

oc-admin/themes/modern/tools/upgrade.php
function customHead(){    ?>    <script type="text/javascript">        $(document).ready(function() {            $("#steps_div").hide();        });    <?php    $perms = osc_save_permissions();    $ok    = osc_change_permissions();    foreach($perms as $k => $v) {        @chmod($k, $v);    }    if( $ok ) {    ?>        $(function() {            var steps_div = document.getElementById('steps_div');            steps_div.style.display = '';            var steps = document.getElementById('steps');            var version = <?php echo osc_version(); ?>;            var fileToUnzip = '';            steps.innerHTML += '<?php echo osc_esc_js( sprintf( __('Checking for updates (Current version %s)'), osc_version() )); ?> ';​            $.getJSON("https://osclass.org/latest_version_v1.php?callback=?", function(data) {                if(data.version <= version) {                    steps.innerHTML += '<?php echo osc_esc_js( __('Congratulations! Your Osclass installation is up to date!')); ?>';                } else {                    steps.innerHTML += '<?php echo osc_esc_js( __('New version to update:')); ?> ' + oscEscapeHTML(data.version); + "<br />";                    <?php if(Params::getParam('confirm')=='true') {?>                        steps.innerHTML += '<img id="loading_image" src="<?php echo osc_current_admin_theme_url('images/loading.gif'); ?>" /><?php echo osc_esc_js(__('Upgrading your Osclass installation (this could take a while):')); ?>';​                        var tempAr = data.url.split('/');                        fileToUnzip = tempAr.pop();                        $.getJSON('<?php echo osc_admin_base_url(true); ?>?page=ajax&action=upgrade&<?php echo osc_csrf_token_url(); ?>' , function(data) {                            if(data.error==0 || data.error==6) {                                window.location = "<?php echo osc_admin_base_url(true); ?>?page=tools&action=version";                            }                            var loading_image = document.getElementById('loading_image');                            loading_image.style.display = "none";                            steps.innerHTML += $("<div>").text(data.message).html();+"<br />";                        });                    <?php } else { ?>                        steps.innerHTML += '<input type="button" value="<?php echo osc_esc_html( __('Upgrade')); ?>" onclick="window.location.href=\'<?php echo osc_admin_base_url(true); ?>?page=tools&action=upgrade&confirm=true\';" />';                    <?php } ?>                }            });        });    <?php } ?>    </script>    <?php}osc_add_hook('admin_header','customHead', 10);
<?php if( $ok ) { ?>    <p class="text">        <?php printf( __('Your Osclass installation can be auto-upgraded. Please, back up your database and the folder oc-content before attempting to upgrade your Osclass installation. You can also upgrade Osclass manually, more information in the %s'), '<a href="http://doc.osclass.org/">Wiki</a>'); ?>    </p><?php } else { ?>    <p class="text">        <?php _e("Your Osclass installation can't be auto-upgraded. Files and folders need to be writable. You can apply write permissions via SSH with the command \"chmod -R a+w *\" (without quotes) or via an FTP client, it depends on the program so we can not provide more information. You can also upgrade Osclass by downloading the upgrade package, unzipping it and replacing the files on your server with the ones in the package."); ?>    </p><?php } ?>
<p class="text">    <?php _e('Congratulations! Your Osclass installation is up to date!'); ?></p>

Stop auto upgrading.

This will stop automatic upgrading of Osclass, plugins, themes, and languages as the auto-upgrade function makes a call to osclass.org.

Open the following file:

oc-includes/osclass/cron.php

Locate this code:

Replace it with this code:

// osc_do_auto_upgrade();

This function ("osc_do_auto_upgrade();") first checks for the latest version of Osclass by making a request to osclass.org. After that it updates the plugins, themes and languages.

We commented this function instead of removing as you may wish to modify it to update your plugins, themes and languages without updating Osclass.

osc_do_auto_upgrade() is located in utils.php.

Delete Market from Appearance (themes).

Open the following file:

Locate and remove this code:

Locate this code:

Replace it with this:

Open the following file:

Locate and remove this code:

oc-admin/themes/modern/appearance/index.php
<li><a href="#market" onclick="window.location = '<?php echo osc_admin_base_url(true) . '?page=market&action=themes'; ?>'; return false; "><?php _e('Market'); ?></a></li>
echo '<p>' . sprintf(__("Change your site's look and feel by activating a 
theme among those available. You can download new themes from the <a href=\"%s\">market</a>. <strong>Be careful</strong>: if your theme has been customized, you'll lose all changes if you change to a new theme."), osc_admin_base_url(true) . '?page=market&action=themes') . '</p>'
echo '<p
>' . __("Change your site's look and feel by activating a theme among those available. You can download new themes from the <a href=\"%s\">market</a>. <strong>Be careful</strong>: if your theme has been customized, you'll lose all changes if you change to a new theme."). '</p>';
oc-admin/themes/modern/appearance/add.php
<div class="flashmessage flashmessage-info flashmessage-inline" style="display: block;">    <p class="info"><?php printf( __('Download more themes at %s'), '<a href="'.osc_admin_base_url(true) . '?page=market&action=themes">Market</a>'); ?></p></div>

Delete Market from Admin menu.

oc-includes/osclass/classes/AdminMenu.php
$this->add_menu( __('Market'), osc_admin_base_url(true) .'?page=market', 'market', 'administrator');if( !osc_is_moderator() ) {    $connected = osc_check_market_connect();    if(!$connected) {        $this->add_submenu( 'market', __('Connect Market'), osc_admin_base_url(true) . "?page=market&open_market_connect=true", 'market_connect', 'administrator');    }}$this->add_submenu( 'market', __('Themes'), osc_admin_base_url(true) .'?page=market&action=themes', 'market_view_themes', 'administrator');$this->add_submenu( 'market', __('Plugins'), osc_admin_base_url(true).'?page=market&action=plugins', 'market_view_plugins', 'administrator');$this->add_submenu( 'market', __('Languages'), osc_admin_base_url(true).'?page=market&action=languages', 'market_view_languages', 'administrator');
$this->add_submenu( 'appearance', __('Market'), osc_admin_base_url(true).'?page=market&action=themes', 'appearance_market', 'administrator');
$this->add_submenu( 'plugins', __('Market'), osc_admin_base_url(true).'?page=market&action=plugins', 'plugins_market', 'administrator');

Delete Market from Plugins.

Open the following file:

oc-admin/themes/modern/plugins/index.php

Locate and remove this code:

<li><a href="#market" onclick="window.location = '<?php echo osc_admin_base_url(true) . '?page=market&action=plugins'; ?>'; return false; "><?php _e('Market'); ?></a></li>

​

Open the following file:

oc-admin/themes/modern/plugins/add.php

Locate and remove this code:

<div class="flashmessage flashmessage-info flashmessage-inline" style="display:block;">    <p class="info"><?php printf( __('Download more plugins at %s'), '<a href="'.osc_admin_base_url(true) . '?page=market&action=plugins">Market</a>'); ?></p></div>

Delete Connect Market from Admin toolbar.

Delete Connect Market from Admin toolbar.

Removing the line of code listed below will remove "Connect Market" from your Admin toolbar (header part).

Open the following file:

oc-includes/osclass/classes/AdminToolbar.php

Locate and remove this code:

osc_add_hook( 'add_admin_toolbar_menus', 'osc_admin_toolbar_market_connect'     , 0 );