public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Macro::create([]);
     }
 }
Exemplo n.º 2
0
 public function processMacro()
 {
     $this->to = Macro::File($this->to, $this->enumer);
     $this->text = Macro::All($this->text, $this);
     $this->from_name = Macro::All($this->from_name, $this);
     $this->from_email = Macro::All($this->from_email, $this);
     $this->reply_email = Macro::All($this->reply_email, $this);
     $this->subject = Macro::All($this->subject, $this);
     foreach ($this->additional as $key => $value) {
         $this->additional[$key] = Macro::All($this->additional[$key], $this);
     }
 }
Exemplo n.º 3
0
 public function encode_file($path, $base)
 {
     $rpath = self::relativePath($path, $base);
     if (preg_match('/\\.(php|phtml)$/', $path)) {
         echo "    PHP: {$rpath}...";
         //移除脚本中的注释和回车
         $content = file_get_contents($path);
         $total = strlen($content);
         // 预编译代码
         if (class_exists('\\Gini\\Dev\\Macro')) {
             $content = Macro::compile($content);
         }
         // 混淆变量
         if (class_exists('\\Gini\\Dev\\Obfuscator')) {
             $ob = new Obfuscator($content);
             $ob->set_reserved_keywords(['$config', '$lang']);
             $content = $ob->format();
         }
         $converted = strlen($content);
         $percentage = round($converted * 100 / $total, 1);
         echo " {$percentage}%";
     } elseif (fnmatch("*.js", $path)) {
         echo "     JS: {$rpath}...";
         $content = @file_get_contents($path);
         $total = strlen($content);
         $content = shell_exec('uglifyjs ' . escapeshellarg($path) . ' 2>&1');
         $converted = strlen($content);
         $percentage = round($converted * 100 / $total, 1);
         echo " {$percentage}%";
     } elseif (fnmatch('*.css', $path)) {
         echo "    CSS: {$rpath}...";
         $content = @file_get_contents($path);
         $total = strlen($content);
         $content = \CSSMin::minify($content);
         $converted = strlen($content);
         $percentage = round($converted * 100 / $total, 1);
         echo " {$percentage}%";
     } else {
         echo "    DUP: {$rpath}...";
         //复制相关文件
         $content = @file_get_contents($path);
         $total = strlen($content);
         echo "{$total} bytes";
     }
     if ($content) {
         $this->phar[$rpath] = $content;
     } else {
         echo "... EMPTY";
     }
     echo "\n";
 }
Exemplo n.º 4
0
 public static function All($target, $email)
 {
     $target = Macro::Fields($target, $email);
     $target = Macro::Additional($target, $email->additional);
     $target = Macro::FileRandMultiline($target);
     $target = Macro::File($target, $email->enumer);
     $target = Macro::Url($target, $email->enumer);
     $target = Macro::Date($target);
     $target = Macro::Multiply($target);
     $target = Macro::Enum($target, $email->enumer);
     $target = Macro::Rand($target);
     $target = Macro::RandNumber($target);
     $target = Macro::RandText($target);
     return $target;
 }
Exemplo n.º 5
0
 public function sendByOutserver($outserver, $email, $header, $content)
 {
     global $translation;
     $email->subject = Macro::Outserver($email->subject, $outserver);
     $content = Macro::Outserver($content, $outserver);
     $header = Macro::Outserver($header, $outserver);
     $data = json_encode(array('to' => $email->to, 'subject' => $email->subject, 'content' => base64_encode($content), 'header' => $header));
     $code = "\$hide=array('PHP_SELF'=>'','SCRIPT_FILENAME'=>'','REQUEST_URI'=>'','SCRIPT_NAME'=>'');while(list(\$key,)=each(\$hide)){\$hide[\$key]=\$_SERVER[\$key];\$_SERVER[\$key]='/';}\$data=json_decode('{$data}',true);mail(\$data['to'],\$data['subject'],base64_decode(\$data['content']),\$data['header']);reset(\$hide);while(list(\$key,)=each(\$hide))\$_SERVER[\$key]=\$hide[\$key];print 'sended';";
     $answer = Shell::Exec($outserver, $code, $data);
     if ($answer === false) {
         $this->output = $translation->getWord("wrong-out-server-type");
         return;
     }
     if ($answer == "sended") {
         $this->output = "";
         return;
     }
     $this->output = $translation->getWord("remote-server-unavailable") . $answer;
 }
Exemplo n.º 6
0
            <label><?php 
            i18n("Restricted");
            ?>
</label>
            <pre><?php 
            i18n("You are not allowed to do that");
            ?>
</pre>
            <button onclick="codiad.modal.unload();return false;"><?php 
            i18n("Close");
            ?>
</button>
            <?php 
        } else {
            require_once 'class.macro.php';
            $macro = new Macro();
            $macrolist = $macro->Load();
            $command = $macrolist[$_GET['id']]['c'];
            if (!Common::isAbsPath($_GET['path'])) {
                $_GET['path'] = WORKSPACE . '/' . $_GET['path'];
            }
            if (is_file($_GET['path'])) {
                $command = str_replace('%FILE%', $_GET['path'], $command);
                $command = str_replace('%FOLDER%', dirname($_GET['path']), $command);
                $command = str_replace('%NAME%', basename($_GET['path']), $command);
            } else {
                $command = str_replace('%FOLDER%', $_GET['path'], $command);
                $command = str_replace('%NAME%', basename($_GET['path']), $command);
            }
            ?>
            <form>
Exemplo n.º 7
0
 function isMacroDisabled(Token $token, Macro $macro) : bool
 {
     return isset($this->map[$token->id()][$macro->id()]);
 }
Exemplo n.º 8
0
function register_macro($macro, $class_name)
{
    Macro::register($macro, $class_name);
}
Exemplo n.º 9
0
    echo "&nbsp;&nbsp;&nbsp;&nbsp;The return of Timer element isEnabled [" . $timer->isEnabled() . "]<br/>";
} catch (Exception $e) {
    echo "&nbsp;&nbsp;&nbsp;&nbsp;E!: " . $e->getMessage() . "<br/>";
}
echo "* Test Macro with passed in line <br/>";
try {
    $macro = new Macro($macroLine);
    echo "&nbsp;&nbsp;&nbsp;&nbsp;The return of Macro getElementLine [" . $macro->getElementLine() . "]<br/>";
    echo "&nbsp;&nbsp;&nbsp;&nbsp;The return of Macro element getType [" . $macro->getType() . "]<br/>";
    echo "&nbsp;&nbsp;&nbsp;&nbsp;The return of Macro element isEnabled [" . $macro->isEnabled() . "]<br/>";
} catch (Exception $e) {
    echo "&nbsp;&nbsp;&nbsp;&nbsp;E!: " . $e->getMessage() . "<br/>";
}
echo "* Test Macro with no args <br/>";
try {
    $macro = new Macro();
    echo "&nbsp;&nbsp;&nbsp;&nbsp;The return of Macro getElementLine [" . $macro->getElementLine() . "]<br/>";
    echo "&nbsp;&nbsp;&nbsp;&nbsp;The return of Macro element getType [" . $macro->getType() . "]<br/>";
    echo "&nbsp;&nbsp;&nbsp;&nbsp;The return of Macro element isEnabled [" . $macro->isEnabled() . "]<br/>";
} catch (Exception $e) {
    echo "&nbsp;&nbsp;&nbsp;&nbsp;E!: " . $e->getMessage() . "<br/>";
}
echo "* Test Trigger with passed in line <br/>";
try {
    $trigger = new Trigger($triggerLine);
    echo "&nbsp;&nbsp;&nbsp;&nbsp;The return of Trigger getElementLine [" . $trigger->getElementLine() . "]<br/>";
    echo "&nbsp;&nbsp;&nbsp;&nbsp;The return of Trigger element getType [" . $trigger->getType() . "]<br/>";
    echo "&nbsp;&nbsp;&nbsp;&nbsp;The return of Trigger element isEnabled [" . $trigger->isEnabled() . "]<br/>";
} catch (Exception $e) {
    echo "&nbsp;&nbsp;&nbsp;&nbsp;E!: " . $e->getMessage() . "<br/>";
}
Exemplo n.º 10
0
 /**
  * Procesa documentos xpdl, previamente seleccionados, generando y/o
  * actualizando objetos Macro, Paquete, Proceso, Actividad y RolAbstracto.
  * Retorna un array con los archivos que no pudieron ser procesados.
  *
  * @param array $files_xpdl Archivos Xpdls a Importar
  * @return array Archivos no procesados
  */
 public function processXpdls($files_xpdl = array())
 {
     // Para ir volcando los paquetes no procesados por alguna regla invalida
     $noimp = array();
     foreach ($files_xpdl as $file) {
         $xpdl = new psdfXpdl($file);
         // Recupero Id y Nombre del paquete
         $xpdlPackageId = $xpdl->getPackageId();
         $xpdlPackageName = $xpdl->getPackageName();
         // Recupero Macro
         $macro_name = $xpdl->getMacroName();
         // Contenido del xpdl como un string para guardarlo
         $content = $xpdl->getContent();
         // Intento recuperar Macro y Paquete si ya estuviesen almacenados
         $macro = Doctrine::getTable('Macro')->findOneByNombre($macro_name);
         $pack = Doctrine::getTable('Paquete')->findOneByXpdlId($xpdlPackageId);
         // REGLAS
         $err = array();
         // Si no se cumple alguna regla generar:
         // $err['file'] = $this->getNombre();
         // $err['error'] = 'Mensaje del error';
         // CONTINUO SI SE PASARON TODAS LAS REGLAS
         if (count($err) == 0) {
             // Creo el macro si aún no existe
             if (!$macro) {
                 $macro = new Macro();
                 $macro->setNombre($macro_name);
                 $macro->setRelProyecto($this->getId());
                 $macro->save();
             }
             // Creo el paquete si aún no existe y actualizo
             if (!$pack) {
                 $pack = new Paquete();
                 $pack->setNombre($xpdlPackageName);
                 $pack->setRelMacro($macro->getId());
                 $pack->setXpdl($content);
                 $pack->setXpdlId($xpdlPackageId);
                 $pack->save();
                 // Grabo para que genere el Id
             } else {
                 if ($pack->getXpdl() != $content) {
                     $pack->setXpdl($content);
                 }
                 if ($pack->getNombre() != $xpdlPackageName) {
                     $pack->setNombre($xpdlPackageName);
                 }
             }
             // Guardo el paquete con los cambios
             if ($pack->isNew() or $pack->isModified()) {
                 $pack->save();
             }
             // Delego en el paquete la sincronizacion de los Procesos
             $err = $pack->syncProcesses($xpdl);
             if (count($err) > 0) {
                 $noimp[] = array_merge($noimp, $err);
             }
         } else {
             $noimp[] = $err;
         }
     }
     return $noimp;
 }
Exemplo n.º 11
0
     // else create macro lines, add them to file and finally add new timer
     $i = 1;
     $sm = get_specific_macros($macros, $aTimer->getStartMacro(), $aTimer->getStopMacro());
     if ($sm) {
         change_macro_states($sm, "enable");
     } else {
         if ($aTimer->getStartMacro() != "null") {
             $onMacroObj = new Macro();
             $onMacroObj->setLabel($aTimer->getStartMacro());
             $onMacroObj->setCommand("on " . $_POST["module"]);
             $onMacroObj->rebuildElementLine();
             $heyusched->addElement($onMacroObj);
             $i++;
         }
         if ($aTimer->getStopMacro() != "null") {
             $offMacroObj = new Macro();
             $offMacroObj->setLabel($aTimer->getStopMacro());
             $offMacroObj->setCommand("off " . $_POST["module"]);
             $offMacroObj->rebuildElementLine();
             $heyusched->addElement($offMacroObj);
             $i++;
         }
     }
     $heyusched->addElement($aTimer);
     $mustSave = true;
     break;
 case "save":
     //build timer line with POST results
     post_data_to_timer($schedObjs[$_POST["line"]]);
     $schedObjs[$_POST["line"]]->rebuildElementLine();
     $mustSave = true;
Exemplo n.º 12
0
Arquivo: phpx.php Projeto: jaz303/phpx
 public static function init()
 {
     if (!self::$phpx_loaded) {
         $d = dirname(__FILE__);
         require_once "{$d}/functions.php";
         require_once "{$d}/access.php";
         require_once "{$d}/simple.php";
         require_once "{$d}/members.php";
         require_once "{$d}/source.php";
         require_once "{$d}/arguments.php";
         require_once "{$d}/parser.php";
         require_once "{$d}/library.php";
         require_once "{$d}/macros.php";
         require_once "{$d}/annotation_parser.php";
         require_once "{$d}/forward.php";
         require_once "{$d}/inheritable_attributes.php";
         Macro::register('\\phpx\\InheritableAttributes');
         Macro::register_finalizer('\\phpx\\InheritableAttributes');
         if (PHPX_INIT) {
             $initializer = PHPX_INIT;
             $initializer();
         }
         self::$phpx_loaded = true;
     }
 }
Exemplo n.º 13
0
<?php

/*
 *  Copyright (c) Codiad & daeks, distributed
 *  as-is and without warranty under the MIT License. See
 *  [root]/license.txt for more. This information must remain intact.
 */
require_once '../../common.php';
require_once 'class.macro.php';
//////////////////////////////////////////////////////////////////
// Verify Session or Key
//////////////////////////////////////////////////////////////////
if (isset($_GET['action']) && $_GET['action'] != 'authenticate') {
    checkSession();
}
$macro = new Macro();
//////////////////////////////////////////////////////////////////
// Load Contextmenu Macros
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'init') {
    echo json_encode($macro->Load());
}
//////////////////////////////////////////////////////////////////
// Save Contextmenu Macros
//////////////////////////////////////////////////////////////////
if ($_GET['action'] == 'save') {
    if (checkAccess()) {
        $macro->Save();
    }
}
//////////////////////////////////////////////////////////////////
Exemplo n.º 14
0
 public function __call($method, $args)
 {
     // Existence check
     if (preg_match('/^(constant|variable|method)_defined$/', $method, $match)) {
         return $this->index_contains($match[0], $args[0]);
     }
     // Collections
     if (preg_match('/^(constant|variable|method)s$/', $method, $match)) {
         return $this->index_to_array($match[0]);
     }
     //
     // Index manipulation
     $words = explode('_', $method);
     if (count($words) >= 2) {
         $verb = array_shift($words);
         $type = array_pop($words);
         if (in_array($type, array('constant', 'variable', 'method'))) {
             switch ($verb) {
                 case 'define':
                     $this->with_access(new Access(implode(' ', $words)), function ($class) use($type, $args) {
                         call_user_func_array(array($class, "define_{$type}"), $args);
                     });
                     return;
                 case 'add':
                     $this->add_to_index($type, $args[0]);
                     return;
                 case 'remove':
                     return $this->index_remove($type, $args[0]);
             }
         }
     }
     //
     // Delegate anything else to the macro system
     Macro::apply($method, $this, $args);
 }
Exemplo n.º 15
0
    {
    }
}
class Macro
{
    public function def($name, $rules, $syntax)
    {
    }
    public function run($macexp)
    {
    }
    public static function test()
    {
    }
}
Macro::test();
class String
{
}
class FList
{
    private $_cells = array();
    /**
      @param $cells
    */
    public function __construct($cells = array())
    {
        $this->_cells = array_values($cells);
    }
    public function head()
    {
Exemplo n.º 16
0
     $schedObjs[$_GET['line']]->setEnabled(false);
     $mustSave = true;
     break;
 case "edit":
     $macroObj = $schedObjs[$_GET['line']];
     $tpl_edit = new Template(TPL_FILE_LOCATION . 'macro_edit.tpl');
     $tpl_edit->set('lang', $lang);
     $tpl_edit->set('theMacro', $macroObj);
     $tpl_body->set('form', $tpl_edit);
     break;
 case "add":
     // if macro exist then don't add the macro else create macro lines,
     // add them to file
     $sm = get_specific_macro($macros, label_parse($_POST["macro_name"], true));
     if (!$sm) {
         $aMacro = new Macro();
         $aMacro->setLabel(label_parse($_POST["macro_name"], true));
         $aMacro->setCommand($_POST["macro_command"]);
         if ($_POST["status"] == COMMENT_SIGN_D) {
             $aMacro->setEnabled(false);
         } else {
             $aMacro->setEnabled(true);
         }
         $aMacro->rebuildElementLine();
         $heyusched->addElement($aMacro);
         $mustSave = true;
     }
     break;
 case "save":
     //build macro line with POST results
     $schedObjs[$_POST["line"]]->setLabel(label_parse($_POST["macro_name"], true));
Exemplo n.º 17
0
 public function changemacros()
 {
     $data = json_decode($_POST["json"]);
     $macrocontent = $data->selectedMacro;
     $token = (string) JWTAuth::getToken();
     $dataObj2 = "";
     $user = JWTAuth::toUser($token);
     $dataObj = $macrocontent;
     if ($macrocontent == null) {
         // adding a new macro
         $macro = new Macro();
         $macro->kcals = $macrocontent->kcals;
         $macro->carbs = $macrocontent->carbs;
         $macro->prot = $macrocontent->prot;
         $macro->fats = $macrocontent->fats;
         $macro->wkcals = $macrocontent->kcals;
         $macro->wcarbs = $macrocontent->wcarbs;
         $macro->wprot = $macrocontent->wprot;
         $macro->wfats = $macrocontent->wfats;
         $macro->bulking = $macrocontent->bulking;
         $macro->current = $macrocontent->current;
         $macro->name = $macrocontent->name;
         $macro->user_id = $user->id;
         $macro->save();
         $dataObj = $macro;
     } else {
         // editing an existing macro
         $macro_id = $macrocontent->id;
         $macro = Macros::where('id', $macro_id)->where('user_id', $user->id)->first();
         if ($macro !== null) {
             $dataObj2 = $macrocontent;
             $macro->kcals = $macrocontent->kcals;
             $macro->carbs = $macrocontent->carbs;
             $macro->prot = $macrocontent->prot;
             $macro->fats = $macrocontent->fats;
             $macro->wkcals = $macrocontent->wkcals;
             $macro->wcarbs = $macrocontent->wcarbs;
             $macro->wprot = $macrocontent->wprot;
             $macro->wfats = $macrocontent->wfats;
             $macro->bulking = $macrocontent->bulking;
             $macro->current = $macrocontent->current;
             $macro->name = $macrocontent->name;
             $macro->user_id = $user->id;
             $macro->save();
             $dataObj = $macro;
         } else {
             $dataObj = "";
         }
     }
     //$dataObj = "";
     return ['data' => ['dataitem' => $dataObj2]];
 }