Skip to content

Instantly share code, notes, and snippets.

<?php
// provider id => array of packages
$listPackagesToInstall = array(
1 => array( // standart modx provider
'sdStore'
, 'translit'
, 'TinyMCE'
, 'FormIt'
, 'Analytics'
<?php
require_once dirname(__FILE__).'/config.core.php';
include_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx= new modX();
$modx->initialize('mgr');
$modx->setLogLevel(modX::LOG_LEVEL_INFO);
$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
header("Content-type: text/plain");
#!/bin/bash
echo "Enter username"
read USERNAME
##############
echo "Updating MODx"
cd /var/www/$USERNAME/www/
@govza
govza / addsite.sh
Last active February 4, 2023 18:00
#!/bin/bash
# MySQL root password
KEYLOCATION="/modx/.ssh/key.pem"
REMOTEUSERSERVER="[email protected]"
ROOTPASS="password"
TIMEZONE="Europe/Moscow"
MYSQLPASS=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
#!/bin/bash
ROOTPASS="password"
echo "Enter username to delete:"
read USERNAME
mysql -uroot --password=$ROOTPASS -e "DROP USER $USERNAME@localhost"
mysql -uroot --password=$ROOTPASS -e "DROP DATABASE $USERNAME"
rm -f /etc/nginx/sites-enabled/$USERNAME.conf
#!/bin/bash
dir=/var/www/site
user=userofsite
echo "Set permissions for $dir...";
echo "CHOWN files...";
chown -R $user:$user "$dir";
echo "CHMOD directories...";
find "$dir" -type d -exec chmod 0755 '{}' \;
#!/bin/bash
# MySQL root password
ROOTPASS="password"
TIMEZONE="Europe/Moscow"
MYSQLPASS=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
SFTPPASS=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c12`
##############
@govza
govza / modx-plugin-content-introtext.php
Created February 11, 2013 21:37
Modx Revo plugin, strip content and set it to introtext
<?php
//OnBeforeDocFormSave
$introlength = $modx->getOption('IntrotextOptions',$scriptProperties,'400');
$introtext= $resource ->introtext;
$text =$modx->stripTags($resource->content);
if(empty($introtext)){
if (strlen($text) > $introlength) {
$cuttext = mb_substr($text, 0, $introlength,"UTF-8");
$pos = mb_strrpos($cuttext, ' ',"UTF-8");
@govza
govza / modx-tv-img-firstImageTV.php
Created February 11, 2013 19:58
Get first Image from modx content and add to firstImageTV
<?php
//OnDocFormSave
$img_path = $modx->getOption('imagesPath',$scriptProperties, MODX_ASSETS_URL."static/images/");
$imgName = $modx->getOption('ImageName',$scriptProperties,'default.png');
$TvValue = $modx->getOption('TV',$scriptProperties,'firstImage');
$def_img = $img_path.$imgName;
$img = $resource->GetTVValue($TvValue);
$text = $resource->content;
if(empty($img)) {