Loading
  • EN
  • RU
Nodes Studio

Functions


The library is loaded from the file /engine/nodes/autoload.php and contains all framework classes, located in files of /engine/core/ directory.
The directories /engine/core/../ contains secondary engine functions, available for execution as engine::function_name($args[0], $args[1], ...);

 

The file /engine/core/engine.php contains the primary engine library of framework, comprising the following functions:

 

engine::__callStatic($name, $args - Includes engine/core/../function_name.php and execute a function_name($args[0], $args[1], ...);
string $name - function_name
array $arguments - Array of arguments.
Returns result of targeted function or die with error.
engine::print_paypal_form($site, 10, "/account/finance");


engine::error($error_code='0') - Register error in a DB and print error page.
string $error_code - HTTP code of error.
engine::error(401);


engine::mysql($query) - Sends a query to the currently active MySQL DB.
string $query - MySQL request.
Returns a resource on success, or die with error.
engine::mysql($query);


engine::send_mail($email, $header, $theme, $message) - Sends a mail.
string $email - Receiver, or receivers of the mail.
string $header - Sender of the mail.
string $theme - Subject of the email to be sent.
string $message - Text of the email to be sent.
Returns TRUE on success, FALSE on failure.
engine::send_mail("dev@null.com", "admin@server.com", "Hello", "Text");


engine::url_translit($str) - Convert a string to URL-compatible format.
string $str - The input string.
Returns the convetrted string.
engine::url_translit("Hello world!");


engine::curl_get_query($url, $format=0) - Send GET request using CURL Library.
string $url - Request URL.
bool $format - Remove all non-text chars from string if TRUE.
Returns result of request.
engine::curl_get_query("http://google.com");


engine::curl_post_query($url, $query, $format=0) - Send POST request using CURL Library.
string $url - Formated POST data.
bool $format - Remove all non-text chars from string if TRUE.
Returns result of request.
engine::curl_post_query("http://google.com", 'foo=1&bar=2');


engine::timezone_list() - Gets the timezone list used by all date/time functions.
Returns array with timezones.
engine::timezone_list();


 

In addition, the directory /engine/core/ contains several functional libraries, comprising the following classes and methods:

 

cache::update_cache($url, $jQuery = 0, $lang="en") - Update a cache data in DB.
string $url - Page URL.
bool $jQuery - jQuery mode.
string $lang - Request language.
Returns HTML contents of page.
cache::update_cache("/", TRUE);


cache() - Output requested page from cache DB.
Returns HTML contents of requested page.
$cache = new cache();


cache()->page_id() - Gets current page ID.
Returns id of page in MySQL DB.
$cache = new cache();
$cache_id = $cache->page_id();


image::resize_image($src, $dest, $width, $height, $rgb, $quality, $proportions) - Copies and resize an image
string $src - Source image path.
string $dest -Destination image path.
int $width - Destination image width.
int $height - Destination image height.
hex $rgb - Destination image background color.
int $quality - Destination image quality.
bool $proportions - Save image proportions while resizing.
Returns TRUE on success, FALSE on failure
image::resize_image('img/1.jpg', 'img/2.jpg', 800, 600);


image($file) - Class constructor.
string $url - Image URL.
$img = new image("/img/1.jpg");


image()->resize($width = false, $height = false) - Resizes an image.
int $width - Destination image width.
int $height - Destination image height.
$img = new image("/img/1.jpg");
$img->resize(800, 600);


image()->crop($x0 = 0, $y0 = 0, $w = false, $h = false) - Crops an image.
int $x0 - Crop left coordinate.
int $y0 - Crop top coordinate.
int $w - Crop width.
int $h - Crop height.
$img = new image("/img/1.jpg");
$img->crop(0, 0, 800, 600);


image()->cropSave($x0, $y0, $w, $h) - Crops an image and returs canvas.
int $x0 - Crop left coordinate.
int $y0 - Crop top coordinate.
int $w - Crop width.
int $h - Crop height.
$img = new image("/img/1.jpg");
$img->cropSave(0, 0, 800, 600);


image()->save($path = '', $fileName, $type, $rewrite, $quality) - Saves image to file.
string $path - Destination image directory.
string $fileName - Destination image name.
string $type - Image type.
string $rewrite - Rewrite file is exist.
string $quality - Destination image quality.
$img = new image("/img/1.jpg");
$img->save("/img/", "2", "jpg", true, 100);


file::copy($source, $dest, $permissions = 0755) - Backup a file, or recursively copy a folder and its contents.
string $source - Source path.
string $dest - Destination path.
int $permissions - New folder creation permissions.
Returns TRUE on success, FALSE on failure.
file::copy("/img", "/temp");


file::delete($dir) - Recursively delete a directory.
string $dir - Destination path.
Returns TRUE on success, FALSE on failure.
file::delete("/temp");


file::upload($filename, $path, $md5=0) - Uploading file from FILES request data to server.
string $filename - Source input name.
string $path - Destination path.
bool $md5 - MD5 name modification.
Returns filename on success, 'error' on failure.
file::upload("new_image", "/img", true);


file::zip($sourcePath, $outZipPath) - Zip a folder (include itself).
string $sourcePath - Path of directory to be zip.
string $outZipPath - Path of output zip file.
Returns TRUE on success, FALSE on failure.
file::zip('/img', '/backup/img.zip');


dump($db=null, $filepath='dump.sql', $compress=false, $hexValue=false) - Class constructor.
string $db -The database name.
string $filepath - The file where the dump will be written.
bool $compress - It defines if the output file is compress (gzip) or not.
bool $hexValue - It defines if the outup values are base-16 or not.
new dump($dbname, 'filename.sql', false, false);


dump()->doDump($params=array(), $close_file=true) - Writes to file the selected database dump.
string $params -The database name.
string $close_file - The file where the dump will be written.
$dumper = new dump($dbname, 'filename.sql', false, false);
$dumper->doDump();


email::email_template($text) - Generates HTML template for a message.
string $text - Text of message.
Returns generated HTML of message to email.
$body = email::email_template($text);


email::bulk_mail($text) - Sends a message to specified user.
array $data - @mysql[nodes_user_outbox].
email::bulk_mail($text);


email::daily_report() - Sends a message with daily report to admin.
email::daily_report();


email::registration($email, $name) - Sends a message after registration.
string $email - User email.
string $name - User name.
email::registration("dev@null.com", "user_name");


email::restore_password($email, $new_pass, $code) - Sends a message after request to restore password.
string $email - User email.
string $new_pass - New password.
string $code - Confirmation code.
email::restore_password("dev@null.com", "12345", "9876");


email::new_comment($user_id, $url) - Sends a message to admin when new comment is submited.
int $user_id - @mysql[nodes_user]->id.
string $url - Page URL.
email::new_comment("1", "/");


email::new_transaction($user_id, $amount) - Sends a message to user when account balance updated.
int $user_id - @mysql[nodes_user]->id.
double $amount - Transaction sum.
email::new_transaction(1, 100.00);


email::new_message($user_id, $sender_id) - Sends a message to user when new message in chat.
int $user_id - To @mysql[nodes_user]->id.
double $sender_id - From @mysql[nodes_user]->id.
email::new_message(1, 2);


email::new_withdrawal($user_id, $amount, $paypal) - Sends a message to user and admin when new withdrawal request is created.
int $user_id - @mysql[nodes_user]->id.
double $amount - Widthdrawal sum.
string $paypal - Receiver PayPal ID.
email::new_withdrawal("1", 100.00, "dev@null.com");


email::finish_withdrawal($user_id) - Sends a message to user when withdrawal is comlplete.
int $user_id - @mysql[nodes_user]->id.
email::finish_withdrawal(1);


email::new_purchase($id) - Sends a message to user and admin when new order is created.
int $id - @mysql[nodes_order]->id.
email::new_purchase(1);


email::shipping_confirmation($id) - Sends a message to user when order is shipped.
int $id - @mysql[nodes_order]->id.
email::shipping_confirmation(1);


email::delivery_confirmation($id) - Sends a message to user and admin when order delivery is done.
int $id - @mysql[nodes_order]->id.
email::delivery_confirmation(1);