### Dockerfile Example Source: https://github.com/vtecrm/vtenext/blob/main/include/js/codemirror/mode/dockerfile/index.html A sample Dockerfile demonstrating the installation of the Ghost blogging platform and the setup of a development environment. This snippet illustrates common Dockerfile instructions. ```dockerfile # Install Ghost blogging platform and run development environment # # VERSION 1.0.0 FROM ubuntu:12.10 MAINTAINER Amer Grgic "amer@livebyt.es" WORKDIR /data/ghost # Install dependencies for nginx installation RUN apt-get update RUN apt-get install -y python g++ make software-properties-common --force-yes RUN add-apt-repository ppa:chris-lea/node.js RUN apt-get update # Install unzip RUN apt-get install -y unzip # Install curl RUN apt-get install -y curl # Install nodejs & npm RUN apt-get install -y rlwrap RUN apt-get install -y nodejs # Download Ghost v0.4.1 RUN curl -L https://ghost.org/zip/ghost-latest.zip -o /tmp/ghost.zip # Unzip Ghost zip to /data/ghost RUN unzip -uo /tmp/ghost.zip -d /data/ghost # Add custom config js to /data/ghost ADD ./config.example.js /data/ghost/config.js # Install Ghost with NPM RUN cd /data/ghost/ && npm install --production # Expose port 2368 EXPOSE 2368 # Run Ghost CMD ["npm","start"] ``` -------------------------------- ### Configure and Start ADODB Session with Non-Persistent Connection Source: https://github.com/vtecrm/vtenext/blob/main/adodb/docs/docs-session.htm Use this example to configure ADODB session handling and start a session with non-persistent connections. Ensure the session handler file is included before configuration. ```php include_once("adodb/session/adodb-session2.php"); $driver = 'mysql'; $host = 'localhost'; $user = 'auser'; $pwd = 'secret'; $database = 'sessiondb'; ADOdb_Session::config($driver, $host, $user, $password, $database, $options=false); ADOdb_session::Persist($connectMode=false); session_start(); ``` -------------------------------- ### getinfo Method Example Request Source: https://github.com/vtecrm/vtenext/blob/main/include/ckeditor/filemanager/ReadMe.txt An example HTTP GET request to the connector for the 'getinfo' mode, specifying the file path and requesting file size. ```http [path to connector]?mode=getinfo&path=/UserFiles/Image/logo.png&getsize=true ``` -------------------------------- ### Shell Script Example Source: https://github.com/vtecrm/vtenext/blob/main/include/js/codemirror/mode/shell/index.html This snippet demonstrates a typical shell script for cloning a repository, generating HTTPS credentials, and starting a server. It also includes commands to stop the server. ```shell #!/bin/bash # clone the repository git clone http://github.com/garden/tree # generate HTTPS credentials cd tree openssl genrsa -aes256 -out https.key 1024 openssl req -new -nodes -key https.key -out https.csr openssl x509 -req -days 365 -in https.csr -signkey https.key -out https.crt cp https.key{,.orig} openssl rsa -in https.key.orig -out https.key # start the server in HTTPS mode cd web sudo node ../server.js 443 'yes' >> ../node.log & # here is how to stop the server for pid in `ps aux | grep 'node ../server.js' | awk '{print $2}'` ; do sudo kill -9 $pid 2> /dev/null done exit 0 ``` -------------------------------- ### Global Cron Setup Example Source: https://github.com/vtecrm/vtenext/blob/main/cron/README-NewCronServiceSetup.txt Example of how to add the VTE cron script to the system's crontab file. Ensure the paths and user are correct for your system. ```bash */1 * * * * root /var/www/vte_root/cron/RunCron.sh >> /var/www/vte_root/logs/cron.log 2>&1 ``` -------------------------------- ### Puppet Module Example Source: https://github.com/vtecrm/vtenext/blob/main/include/js/codemirror/mode/puppet/index.html An example of a Puppet module for installing and configuring AutoMySQLBackup. This demonstrates class definition, parameter inheritance, and resource declaration within Puppet. ```puppet # == Class: automysqlbackup # # Puppet module to install AutoMySQLBackup for periodic MySQL backups. # # class { # 'automysqlbackup': # backup_dir => '/mnt/backups', # } # class automysqlbackup ( $bin_dir = $automysqlbackup::params::bin_dir, $etc_dir = $automysqlbackup::params::etc_dir, $backup_dir = $automysqlbackup::params::backup_dir, $install_multicore = undef, $config = {}, $config_defaults = {}, ) inherits automysqlbackup::params { # Ensure valid paths are assigned validate_absolute_path($bin_dir) validate_absolute_path($etc_dir) validate_absolute_path($backup_dir) # Create a subdirectory in /etc for config files file { $etc_dir: ensure => directory, owner => 'root', group => 'root', mode => '0750', } # Create an example backup file, useful for reference file { "${etc_dir}/automysqlbackup.conf.example": ensure => file, owner => 'root', group => 'root', mode => '0660', source => 'puppet:///modules/automysqlbackup/automysqlbackup.conf', } # Add files from the developer file { "${etc_dir}/AMB_README": source => 'puppet:///modules/automysqlbackup/AMB_README', } file { "${etc_dir}/AMB_LICENSE": source => 'puppet:///modules/automysqlbackup/AMB_LICENSE', } # Install the actual binary file file { "${bin_dir}/automysqlbackup": ensure => file, owner => 'root', group => 'root', mode => '0755', source => 'puppet:///modules/automysqlbackup/automysqlbackup', } # Create the base backup directory file { $backup_dir: ensure => directory, owner => 'root', group => 'root', mode => '0755', } # If you'd like to keep your config in hiera and pass it to this class if !empty($config) { create_resources('automysqlbackup::backup', $config, $config_defaults) } # If using RedHat family, must have the RPMforge repo's enabled if $install_multicore { package { ['pigz', 'pbzip2']: ensure => installed } } } ``` -------------------------------- ### Install php-amqplib with Composer Source: https://github.com/vtecrm/vtenext/blob/main/vendor/videlalvaro/php-amqplib/README.md Install the library using Composer. This command fetches the library and its dependencies. ```bash $ composer require php-amqplib/php-amqplib ``` -------------------------------- ### Default Session Setup Source: https://github.com/vtecrm/vtenext/blob/main/adodb/docs/docs-session.old.htm Basic setup for default ADODB session management. Ensure adodb.inc.php and adodb-session.php are included and session variables are started. ```php include('adodb/adodb.inc.php'); $ADODB_SESSION_DRIVER='mysql'; $ADODB_SESSION_CONNECT='localhost'; $ADODB_SESSION_USER ='scott'; $ADODB_SESSION_PWD ='tiger'; $ADODB_SESSION_DB ='sessiondb'; include('adodb/session/adodb-session.php'); session_start(); # # Test session vars, the following should increment on refresh # $_SESSION['AVAR'] += 1; print "
\$\_SESSION['AVAR']={\$\_SESSION['AVAR']}
"; ``` -------------------------------- ### Install league/oauth2-client via Composer Source: https://github.com/vtecrm/vtenext/blob/main/vendor/league/oauth2-client/README.md This command installs the league/oauth2-client library using Composer. Ensure you have Composer installed and configured in your project. ```bash $composer require league/oauth2-client ``` -------------------------------- ### Start Transaction and Complete Source: https://github.com/vtecrm/vtenext/blob/main/adodb/docs/docs-adodb.htm Shows how to start a transaction and then complete it, implying a commit if no errors occur. ```php $db->StartTrans(); $db->Execute(...); $db->Execute(...); $db->CompleteTrans(); ``` -------------------------------- ### Get Folder Response Example Source: https://github.com/vtecrm/vtenext/blob/main/include/ckeditor/filemanager/ReadMe.txt Example response structure for the getfolder method, showing file properties. ```JSON [ "/UserFiles/Image/logo.png" = { Path: "/UserFiles/Image/logo.png", Filename: "logo.png", File Type: "png", Preview: "/UserFiles/Image/logo.png", Properties: { Date Created: null, Date Modified: "02/09/2007 14:01:06", Height: 14, Width: 14, Size: 384 }, Error: "", Code: 0 }, "/UserFiles/Image/icon.png" = { Path: "/UserFiles/Image/icon.png", Filename: "icon.png", File Type: "png", Preview: "/UserFiles/Image/icon.png", Properties: { Date Created: null, Date Modified: "02/09/2007 14:01:06", Height: 14, Width: 14, Size: 384 }, Error: "", Code: 0 } ] ``` -------------------------------- ### Install HubSpot PHP Client Source: https://github.com/vtecrm/vtenext/blob/main/modules/VteSync/vendor/hubspot/hubspot-php/README.md Install the HubSpot PHP client library using Composer. ```bash composer require "hubspot/hubspot-php" ``` -------------------------------- ### Install Dependencies Source: https://github.com/vtecrm/vtenext/blob/main/modules/VteSync/vendor/hubspot/hubspot-php/CONTRIBUTING.md Install project dependencies using Composer. ```bash composer install ``` -------------------------------- ### Basic ADOdb Connection Example Source: https://github.com/vtecrm/vtenext/blob/main/adodb/docs/docs-datadict.htm A simplified example of creating an ADOdb connection with specific host, user, password, and database. ```php $db = ADONewConnection( 'mysql' ); $db->Connect( 'host', 'user', 'password', 'database' ); ``` -------------------------------- ### Install getallheaders for PHP < 5.6 Source: https://github.com/vtecrm/vtenext/blob/main/vendor/ralouphie/getallheaders/README.md Use this command to install the library for PHP versions older than 5.6. ```bash composer require ralouphie/getallheaders "^2" ``` -------------------------------- ### Install Salesforce OAuth2 Provider Source: https://github.com/vtecrm/vtenext/blob/main/modules/VteSync/vendor/stevenmaguire/oauth2-salesforce/README.md Install the package using Composer. ```bash composer require stevenmaguire/oauth2-salesforce ``` -------------------------------- ### Install phpseclib 1.0 via PEAR Source: https://github.com/vtecrm/vtenext/blob/main/vendor/phpseclib/phpseclib/README.md Instructions for installing phpseclib version 1.0 using the PEAR package manager. ```sh See phpseclib PEAR Channel Documentation ``` -------------------------------- ### Gas Mode Syntax Example Source: https://github.com/vtecrm/vtenext/blob/main/include/js/codemirror/mode/gas/index.html An example demonstrating the syntax highlighting for Gas mode, including multi-line and single-line comments, directives, labels, and string literals. This example showcases the basic structure and elements recognized by the Gas mode. ```gas .syntax unified .global main /* * A * multi-line * comment. */ @ A single line comment. main: push {sp, lr} ldr r0, =message bl puts mov r0, #0 pop {sp, pc} message: .asciz "Hello world!Output of getAttributeNames: "; var_dump($person->getAttributeNames()); $person = new person(); $person->name_first = 'Andi'; $person->name_last = 'Gutmans'; $person->save(); // this save() will fail on INSERT as favorite_color is a must fill... $person = new person(); $person->name_first = 'Andi'; $person->name_last = 'Gutmans'; $person->favorite_color = 'blue'; $person->save(); // this save will perform an INSERT successfully echo "
The Insert ID generated:"; print_r($person->id); $person->favorite_color = 'red'; $person->save(); // this save() will perform an UPDATE $person = new person(); $person->name_first = 'John'; $person->name_last = 'Lim'; $person->favorite_color = 'lavender'; $person->save(); // this save will perform an INSERT successfully // load record where id=2 into a new ADOdb_Active_Record $person2 = new person(); $person2->Load('id=2'); var_dump($person2); // retrieve an array of records $activeArr = $db->GetActiveRecordsClass($class = "person",$table = "persons","id=".$db->Param(0),array(2)); $person2 = $activeArr[0]; echo "
Name first (should be John): ",$person->name_first, "
Class = ",get_class($person2);
```
--------------------------------
### Set up Materialize Documentation Locally
Source: https://github.com/vtecrm/vtenext/blob/main/themes/next/scss/materialize/README.md
Commands to clone the Materialize repository, install dependencies, and prepare the documentation for local viewing.
```bash
git clone https://github.com/Dogfalo/materialize
cd materialize
npm install
```
--------------------------------
### CreateSequence Example
Source: https://github.com/vtecrm/vtenext/blob/main/adodb/docs/docs-adodb.htm
Creates a database sequence with a specified name and starting ID. The next call to GenID() will use this starting ID.
```php
$conn->CreateSequence('my_sequence', 100);
```
--------------------------------
### ADOdb StartTrans Example
Source: https://github.com/vtecrm/vtenext/blob/main/adodb/docs/docs-adodb.htm
Demonstrates the initiation of a monitored transaction in ADOdb.
```php
$db->StartTrans();
```
--------------------------------
### Connect to Database and Fetch Rows
Source: https://github.com/vtecrm/vtenext/blob/main/adodb/docs/readme.htm
Demonstrates how to establish a database connection using ADONewConnection, set debug mode, connect to the server, execute a query, and retrieve all rows from the result set. Customize connection settings and driver as needed.
```php
debug = true;
$db->**Connect**($server, $user, $password, $database);
$rs = $db->**Execute**('select * from some_small_table');
print "
"; print_r($rs->**GetRows**()); print ""; ?> ``` -------------------------------- ### Get All Contacts Endpoint Source: https://github.com/vtecrm/vtenext/blob/main/modules/VteSync/vendor/hubspot/hubspot-php/CONTRIBUTING.md Example of a method to retrieve all contacts for a portal. It handles pagination using 'vid-offset' and 'has-more' fields. ```php /** * For a given portal, return all contacts that have been created in the portal. * * A paginated list of contacts will be returned to you, with a maximum of 100 contacts per page. * * Please Note: There are 2 fields here to pay close attention to: the "has-more" field that will let you know * whether there are more contacts that you can pull from this portal, and the "vid-offset" field which will let * you know where you are in the list of contacts. You can then use the "vid-offset" field in the "vidOffset" * parameter described below. * * @see http://developers.hubspot.com/docs/methods/contacts/get_contacts * * @param array $params Array of optional parameters ['count', 'property', 'vidOffset'] * @return \SevenShores\Hubspot\Http\Response */ function all($params = []) { $endpoint = "https://api.hubapi.com/contacts/v1/lists/all/contacts/all"; $queryString = build_query_string($params); return $this->client->request('get', $endpoint, [], $queryString); } ``` -------------------------------- ### Stylus Syntax Example Source: https://github.com/vtecrm/vtenext/blob/main/include/js/codemirror/mode/stylus/index.html Demonstrates basic Stylus syntax including selectors, properties, variables, and mixins. ```stylus /* Stylus mode */ #id .class article font-family: Arial, sans-serif #id, .class, article { font-family: Arial, sans-serif } // Variables font-size-base = 16px line-height-base = 1.5 font-family-base = "Helvetica Neue", Helvetica, Arial, sans-serif text-color = lighten(#000, 20%) body { font: 400 16px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif color: #333 } // Variables link-color = darken(#428bca, 6.5%) link-hover-color = darken(link-color, 15%) link-decoration = none link-hover-decoration = false // Mixin tab-focus() { outline: thin dotted outline: 5px auto -webkit-focus-ring-color outline-offset: -2px } a { color: link-color if link-decoration { text-decoration: link-decoration } &:hover, &:focus { color: link-hover-color } &:focus { tab-focus() } } a:hover, a:focus { color: #2f6ea7 } a:focus { outline: thin dotted outline: 5px auto -webkit-focus-ring-color outline-offset: -2px } ``` -------------------------------- ### Get Jira Issue Worklogs Source: https://github.com/vtecrm/vtenext/blob/main/modules/VteSync/VteSyncLib/src/Connector/Jira/vendor/lesstif/php-jira-rest-client/README.md Provides examples for retrieving all worklogs associated with a Jira issue and for fetching a specific worklog by its ID. ```php getWorklog($issueKey)->getWorklogs(); var_dump($worklogs); // get worklog by id $wlId = 12345; $wl = $issueService->getWorklogById($issueKey, $wlId); var_dump($wl); } catch (JiraException $e) { $this->assertTrue(false, 'testSearch Failed : '.$e->getMessage()); } ``` -------------------------------- ### Basic Database Connection and Query Source: https://github.com/vtecrm/vtenext/blob/main/adodb/docs/docs-adodb.htm Demonstrates how to connect to a database, set debugging, execute a query, and fetch results. Ensure PHP 4.0.5 or later is installed and connection settings are customized. ```php debug = true; $db->Connect($server, $user, $password, $database); $rs = $db->Execute('select * from some_small_table'); print "
"; print_r($rs->GetRows()); print ""; ?> ``` -------------------------------- ### SelectLimit with offset to get last rows Source: https://github.com/vtecrm/vtenext/blob/main/adodb/docs/docs-adodb.htm Retrieves rows starting from a specific offset to the end of the result set. Useful for pagination. ```php $connection->SelectLimit('SELECT * FROM TABLE',-1,10) ``` -------------------------------- ### Add Worklog to Jira Issue (API V2) Source: https://github.com/vtecrm/vtenext/blob/main/modules/VteSync/VteSyncLib/src/Connector/Jira/vendor/lesstif/php-jira-rest-client/README.md Example of adding a worklog entry to a Jira issue using the V2 API. Requires setting comment, start date, and time spent. ```php setComment('I did some work here.') ->setStarted("2016-05-28 12:35:54") ->setTimeSpent('1d 2h 3m'); $issueService = new IssueService(); $ret = $issueService->addWorklog($issueKey, $workLog); $workLogid = $ret->{'idържа'; var_dump($ret); } catch (JiraException $e) { $this->assertTrue(false, 'Create Failed : '.$e->getMessage()); } ``` -------------------------------- ### Paginate Through All Contacts Source: https://github.com/vtecrm/vtenext/blob/main/modules/VteSync/vendor/hubspot/hubspot-php/README.md Retrieve a paginated list of contacts, specifying the number of results, desired properties, and an offset. This example retrieves 10 contacts, only their first and last names, starting from a specific offset. ```php $response = $hubspot->contacts()->all([ 'count' => 10, 'property' => ['firstname', 'lastname'], 'vidOffset' => 123456, ]); ``` -------------------------------- ### Basic Prepared Statement Execution Source: https://github.com/vtecrm/vtenext/blob/main/adodb/docs/docs-adodb.htm Demonstrates preparing and executing a simple SQL statement with parameter binding. ```php $sql = "insert into table (col1,col2) values (:a,:b)"; $stmt = $DB->Prepare($sql); $stmt = $DB->Execute($stmt,array('one','two')); ``` -------------------------------- ### Composer Install Command Source: https://github.com/vtecrm/vtenext/blob/main/modules/VteSync/VteSyncLib/src/Connector/Jira/vendor/lesstif/php-jira-rest-client/README.md Runs Composer's install command to finalize the installation. ```sh php composer.phar install ``` -------------------------------- ### Install Smarty Development Wrapper Source: https://github.com/vtecrm/vtenext/blob/main/gdpr/include/smarty/README.md Install a wrapper package that installs all three Smarty development packages (core, phpunit, lexer/parser) for version 3.1.19. ```json "require": { "smarty/smarty-dev": "3.1.19" } ``` -------------------------------- ### Module Installation Logic Source: https://github.com/vtecrm/vtenext/blob/main/modules/Settings/ModuleMaker/templates/install.php.txt Core logic for installing a new module, including saving, event triggering, webservice initialization, and default sharing. ```PHP $tabid = $newModule->save(); if (empty($tabid)) throw new InstallException("Unable to install the module properly"); // trigger events Vtecrm_Module::fireEvent($newModule->name, Vtecrm_Module::EVENT_MODULE_POSTINSTALL); // initialize webservice Vtecrm_Webservice::initialize($newModule); // set Default sharing $newModule->setDefaultSharing($module_default_sharing ?: 'Private'); // add it to the menu $menuInstance = Vtecrm_Menu::getInstance('Tools'); $menuInstance->addModule($newModule); ``` -------------------------------- ### Basic Table and Index Creation Source: https://github.com/vtecrm/vtenext/blob/main/adodb/docs/docs-datadict.htm Demonstrates creating a table with three fields and then creating indexes on those fields using ADOdb's Data Dictionary. ```php include_once('adodb.inc.php'); # First create a normal connection $db = NewADOConnection('mysql'); $db->Connect(...); # Then create a data dictionary object, using this connection $dict = NewDataDictionary($db); # We have a portable declarative data dictionary format in ADOdb, similar to SQL. # Field types use 1 character codes, and fields are separated by commas. # The following example creates three fields: "col1", "col2" and "col3": $flds = " col1 C(32) NOTNULL DEFAULT 'abc', col2 I DEFAULT 0, col3 N(12.2) "; # We demonstrate creating tables and indexes $sqlarray = $dict->CreateTableSQL($tabname, $flds, $taboptarray); $dict->ExecuteSQLArray($sqlarray); $idxflds = 'co11, col2'; $sqlarray = $dict->CreateIndexSQL($idxname, $tabname, $idxflds); $dict->ExecuteSQLArray($sqlarray); ``` -------------------------------- ### LiveScript Prelude Installation Source: https://github.com/vtecrm/vtenext/blob/main/include/js/codemirror/mode/livescript/index.html A meta-function to install the LiveScript prelude onto a target object if it doesn't already have one. It checks for `target.prelude.isInstalled` before proceeding. ```livescript export installPrelude = !(target) -> unless target.prelude?isInstalled target <<< out$ # using out$ generated by livescript target <<< target.prelude.isInstalled = true export prelude = out$ ``` -------------------------------- ### XML Service Description Example Source: https://github.com/vtecrm/vtenext/blob/main/modules/VteSync/vendor/guzzlehttp/guzzle/UPGRADING.md This is an example of an XML service description before conversion. ```xml
";
print_r( $ldap->ServerInfo() );
$ldap->SetFetchMode(ADODB_FETCH_ASSOC);
$userName = 'eldridge';
$filter="(|(CN=$userName")(sn=$userName")(givenname=$userName")(uid=$userName*))";
$rs = $ldap->Execute( $filter );
if ($rs)
while ($arr = $rs->FetchRow()) {
print_r($arr);
}
$rs = $ldap->Execute( $filter );
if ($rs)
while (!$rs->EOF) {
print_r($rs->fields);
$rs->MoveNext();
}
print_r( $ldap->GetArray( $filter ) );
print_r( $ldap->GetRow( $filter ) );
$ldap->Close();
echo "";
```
--------------------------------
### Install PSR Log via Composer
Source: https://github.com/vtecrm/vtenext/blob/main/modules/VteSync/VteSyncLib/src/Connector/Jira/vendor/psr/log/README.md
Install the PSR log package using Composer.
```bash
composer require psr/log
```
--------------------------------
### getinfo Method Example Response
Source: https://github.com/vtecrm/vtenext/blob/main/include/ckeditor/filemanager/ReadMe.txt
An example JSON response for the 'getinfo' method, providing details about a file including its path, type, preview, and properties like creation date, modification date, height, width, and size.
```json
{
Path: "/UserFiles/Image/logo.png",
Filename: "logo.png",
"File Type": "png",
Preview: "/UserFiles/Image/logo.png",
Properties: {
"Date Created": null,
"Date Modified": "02/09/2007 14:01:06",
Height: 14,
Width: 14,
Size: 384
},
Error: "",
Code: 0
}
```
--------------------------------
### Install Smarty Lexer/Parser Generator
Source: https://github.com/vtecrm/vtenext/blob/main/gdpr/include/smarty/README.md
Install the Smarty 3.1.19 lexer/parser generator via Composer.
```json
"require": {
"smarty/smarty-lexer": "3.1.19"
}
```
--------------------------------
### XQuery Basic Syntax and Comments
Source: https://github.com/vtecrm/vtenext/blob/main/include/js/codemirror/mode/xquery/index.html
Demonstrates basic XQuery syntax, including version declaration, comments, let bindings, and element construction.
```xquery
xquery version "1.0-ml"; (: this is : a "comment" :)
let $let :=