Beispiel #1
0
/**
 * Text Static Function
 *
 * @param class $siggen
 * @param array $data
 * 		int x
 * 		int y
 * 		string text
 * 		string color
 * 		int alpha
 * 		int size
 * 		string font
 * 		int angle
 * 		array outline
 * 		array shadow
 *
 * @return bool
 */
function text_static($siggen, $data)
{
    // Parse the string for tags
    $data['text'] = $siggen->tag->parse($data['text']);
    // Parse the string for breaks, where our modifiers are placed
    $data['text'] = explode('|b|', $data['text']);
    $x = $data['x'];
    $y = $data['y'];
    $breaks = count($data['text']);
    for ($t = 0; $t < $breaks; $t++) {
        $text = $data['text'][$t];
        // If this break is empty, there is no need to process further
        if ($text == '') {
            continue;
        }
        $color = $data['color'];
        $size = $data['size'];
        // Find color changes embeded inside the string
        if (preg_match('/\\|c([a-f0-9]{6})(.+?)\\|c/i', $text, $info)) {
            $color = $info[1];
            $text = preg_replace('/\\|c[a-f0-9]{6}(.+?)\\|c/i', '$1', $text);
        }
        // Find font size changes embeded inside the string
        if (preg_match('/\\|s(.+?)\\|(.+?)\\|s/i', $text, $info)) {
            $size = $info[1];
            $text = preg_replace('/\\|s(.+?)\\|(.+?)\\|s/i', '$2', $text);
        }
        $coords = $siggen->write_text($size, $data['angle'], $x, $y, $color, $data['alpha'], $data['font'], $text, $data['align'], $data['outline'], $data['shadow']);
        // Adjust the coords a bit
        $x = $coords[2] - 1;
        $y = $coords[8] - 1;
    }
    return TRUE;
}
Beispiel #2
0
 /**
  * プラグインの読み込み
  * @param class $bot Skype_Botクラス
  * @throws Exception ディレクトリのオープンに失敗
  */
 protected function loadPlugin($bot)
 {
     $plugin_path = PLUGIN_DIR;
     if ($handle = opendir($plugin_path)) {
         // プラグインディレクトリの中のファイルを順に読み込み
         while (false !== ($file = readdir($handle))) {
             if (!is_file($plugin_path . $file) or '.php' !== substr($file, -4)) {
                 // 拡張子が.phpのファイルのみを対象とする、それ以外はスキップ
                 continue;
             }
             $basename = basename($file, '.php');
             // プラグインの設定ファイルを読み込み
             $config_value = $this->loadPluginConfig($basename);
             if (isset($config_value['plugin_is_disabled']) and true === $config_value['plugin_is_disabled']) {
                 // 設定で無効されている場合はスキップ
                 if (DEBUG_MODE) {
                     printf("Skip plugin: %s\n", $basename);
                 }
                 continue;
             }
             // プラグインの読み込み
             if (DEBUG_MODE) {
                 printf("Load plugin: %s\n", $basename);
             }
             require_once $plugin_path . $file;
             $bot->loadPlugin($basename, $config_value);
         }
         closedir($handle);
     } else {
         // プラグインディレクトリのオープンに失敗
         throw new Exception('Can not open plugin directory.');
     }
 }
Beispiel #3
0
/**
 * Image Class Function
 *
 * @param class $siggen
 * @param array $data
 *    int x
 *    int y
 *    int width
 *    int height
 *
 * @return bool
 *
 * @uses image_static
 */
function image_class($siggen, $data)
{
    // This has a dependancy
    // Make sure we have it loaded
    $siggen->check_module('image_static');
    $data['file'] = 'class' . DIR_SEP . strtolower($siggen->tag->tags['classEn']['data']) . '.png';
    return image_static($siggen, $data);
}
 /**
  * Create the exception from the action definition.
  *
  * @param class $actionDef The action definition.
  *
  * @todo Get message from properties file? Possibly dangerous in exceptions.
  */
 public function __construct($actionDef)
 {
     global $UBAR_GLOB;
     // assemble message
     $message = "The action class \"" . $actionDef->getClassName() . "\" was not found at \"" . $UBAR_GLOB['BASE_ACTION_PATH'] . $actionDef->getActionLocation() . "\".";
     // make sure everything is assigned properly
     parent::__construct($message, $this->getCodeFromProperties());
 }
 /**
  * @description Initialise and handle admin pagination
  *
  * @author bizmate
  *
  * @param class  $model
  * @param string $criteria
  *
  * @return CPagination
  */
 protected function initPagination($model, $criteria = null)
 {
     $criteria = is_null($criteria) ? new CDbCriteria() : $criteria;
     $itemsCount = $model->count($criteria);
     $pagination = new CPagination($itemsCount);
     $pagination->pageSize = $this->items_per_page;
     $pagination->applyLimit($criteria);
     return $pagination;
 }
Beispiel #6
0
 /**
  * Execute the action.
  *
  * @param array $args command line parameters specific for this command
  */
 public function actionGenerate($args)
 {
     //TODO: make available via param --xdebug-trace
     //xdebug_start_trace('giic');
     if (!$this->confirm("\nAttention! The command may overwrite exisiting files wihtout further notice.\n\nEnable overwrite all existing files?")) {
         define('GIIC_ALL_CONFIRMED', false);
     } else {
         define('GIIC_ALL_CONFIRMED', true);
     }
     // fake input params
     $_SERVER['REQUEST_URI'] = "console://index.php";
     $_SERVER['SCRIPT_FILENAME'] = $_SERVER['SCRIPT_NAME'] = "index.php";
     $_POST['generate'] = true;
     $_POST['answers'] = true;
     // create gii module for controller
     Yii::import('system.gii.*');
     $module = Yii::createComponent('system.gii.GiiModule', 'gii', null);
     $module->password = false;
     // load config
     $path = Yii::getPathOfAlias($args[0]) . "/giic-config.php";
     if (!is_file($path)) {
         echo $this->_shellAlert->getColoredString("File in {$path} not exist!", "white", "red") . "\n";
         exit;
     }
     $config = (require $path);
     // execute actions (run gii controller action multiple times)
     foreach ($config['actions'] as $action) {
         // fake input param
         $_POST[$action['codeModel']] = $action['model'];
         // create generator
         $controller = Yii::createComponent($action['generator'], lcfirst($action['codeModel']), $module);
         // assign template
         $controller->templates = $action['templates'];
         // message
         echo $action['codeModel'] . "\n" . substr(CJSON::encode($action['model']), 0, 160);
         echo "\n\n";
         // assign controller to application
         Yii::app()->controller = $controller;
         // capture output from controller
         ob_start();
         $controller->run('index');
         $html = ob_get_clean();
         // TODO: tidy
         // sanitize, XSLT hotfix
         $html = str_replace("&nbsp;", "", $html);
         $html = str_replace('png">', 'png"/>', $html);
         // parse for console output
         $xslt = new XSLTProcessor();
         $xslt->importStylesheet(new SimpleXMLElement(file_get_contents(dirname(__FILE__) . '/giic.xsl')));
         file_put_contents(dirname(__FILE__) . '/giic.html.log', $html);
         echo $xslt->transformToXml(new SimpleXMLElement($html));
         // TODO: add $html output with --verbose
     }
 }
Beispiel #7
0
 function SetContents($blob)
 {
     $recno = 0;
     foreach (explode("\n", $blob) as $line) {
         if (!$line) {
             continue;
         }
         $csv = str_getcsv($line);
         $recno++;
         if (!$this->columns) {
             // Not seen any column information yet
             foreach ($csv as $bit) {
                 foreach ($this->columnDefs as $field => $possibles) {
                     foreach ($possibles as $possible) {
                         if (preg_match("/{$possible}/i", $bit)) {
                             $found = $field;
                             $this->columns[] = $field;
                             continue 3;
                         }
                     }
                 }
                 $this->columns[] = null;
             }
         } else {
             // Have got column setup - process data line
             $ref = array();
             foreach ($this->columns as $offset => $field) {
                 if ($field) {
                     $ref[$field] = $csv[$offset];
                 }
             }
             if (isset($ref['authors'])) {
                 $ref['authors'] = $this->parent->ReJoin($ref['authors']);
             }
             // Append to $this->parent->refs {{{
             if (!$this->parent->refId) {
                 // Use indexed array
                 $this->parent->refs[] = $ref;
             } elseif (is_string($this->parent->refId)) {
                 // Use assoc array
                 if ($this->parent->refId == 'rec-number') {
                     $this->parent->{$refs}[$recno] = $ref;
                 } elseif (!isset($ref[$this->parent->refId])) {
                     trigger_error("No ID found in reference to use as key");
                 } else {
                     $this->parent->refs[$ref[$this->parent->refId]] = $ref;
                 }
             }
             // }}}
         }
     }
 }
Beispiel #8
0
 /**
  * Construct the action definition from the contents of the ubar.xml file.
  *
  * @param class $xmlDef - XML representation of an template definition.
  *
  * @see ActionMapper::getTemplate()
  */
 public function __construct($xmlDef)
 {
     if (!is_null($xmlDef->attributes()->path)) {
         $pathString = (string) $xmlDef->attributes()->path;
         $this->path = FileUtils::dotToPath($pathString);
     }
     foreach ($xmlDef->param as $param) {
         $attribs = $param->attributes();
         $name = (string) $attribs->name;
         $value = (string) $attribs->value;
         $this->addParam($name, $value);
     }
 }
 /**
  * Gets the current worksheets and processes the desired ones into specific file outputs
  * @param array $workSheets The list of worksheets to process. The names must match exactly.
  * @param class $transformer
  * @param class $writer
  * @throws ExporterException
  */
 public function processWorksheets($workSheets, $transformer, $writer)
 {
     foreach ($workSheets as $workSheetName) {
         $worksheet = $this->worksheetFeed->getByTitle($workSheetName);
         if (is_null($worksheet)) {
             throw new ExporterException("No worksheet called '{$workSheetName}' was found!");
         }
         $listFeed = $worksheet->getListFeed();
         $dataRows = $this->getRows($listFeed);
         $transformedDataRow = $transformer->transform($dataRows);
         $writer->write($transformedDataRow);
     }
 }
Beispiel #10
0
/**
 * Image Static Function
 *
 * @param class $siggen
 * @param array $data
 * 		int x
 * 		int y
 * 		int width
 * 		int height
 * 		string file
 *
 * @return bool
 */
function image_static($siggen, $data)
{
    // Parse the string for tags
    $file = $siggen->theme['dir'] . $siggen->tag->parse($data['file']);
    $default = $siggen->theme['default_dir'] . $siggen->tag->parse($data['file']);
    if (file_exists($file)) {
        $siggen->combine_image($file, $data['x'], $data['y'], 0, 0, $data['width'], $data['height']);
        return TRUE;
    } elseif (file_exists($default)) {
        $siggen->combine_image($default, $data['x'], $data['y'], 0, 0, $data['width'], $data['height']);
        return TRUE;
    } else {
        return FALSE;
    }
}
 /**
  * This function returns the structure of the page recursively beginnig at $TopNode
  * @author ComaWStefan
  * @access private
  * @param integer TopNode This is the id of the toppage
  * @return string The complete structure beginning at the toppage
  */
 function _ShowStructure($TopNode = 0)
 {
     $pages = $this->_Pagestructure->RemoveAcessDeletedPages();
     $out = '';
     if (!array_key_exists($TopNode, $pages)) {
         return;
     }
     if (empty($pages[$TopNode])) {
         return;
     }
     $out .= "\r\n\t\t\t<ul>";
     // TODO: make this configureabele by the module-call
     $showLanguage = $this->_Config->Get('sitemap_show_language', '1');
     foreach ($pages[$TopNode] as $page) {
         if ($page['access'] == 'public') {
             // blockelements
             $out .= "\r\n\t\t\t\t<li class=\"page_type_" . $page['type'] . "\"><span class=\"structure_row\">";
             // show language of the page if activated
             if ($showLanguage) {
                 $out .= "<span class=\"page_lang\">[" . $this->_Translation->GetTranslation($page['lang']) . "]</span>";
             }
             // show pagename with link to index.php and pagetitle
             $out .= "<strong><a href=\"index.php?page={$page['name']}\">{$page['title']}</a></strong></span>";
             // show all subpages
             $out .= $this->_ShowStructure($page['id']);
             // blockelement endings
             $out .= "\r\n\t\t\t\t</li>";
         }
     }
     $out .= "\r\n\t\t\t</ul>";
     return $out;
 }
Beispiel #12
0
 /**
  * 清空缓存
  * @author 欧远宁
  */
 public function clear()
 {
     $this->buf = array();
     $this->incList = array();
     $this->open();
     $this->mem_cls->flush();
 }
Beispiel #13
0
        /**
         * setDefinition
         *
         * @param string $name
         * @param array $def
         * @return bool
         */
        public function setDefinition($name,$def){
                $this->Out->debug(__METHOD__,func_get_args());

                if(!isset($def['key']) || !is_string($def['key'])) {
                        $this->Out->error("Package definition missing 'key' in: ".$name);
                        return false;
                }

                if(strlen($def['key']) < 16) {
                        $this->Out->error("Package 'key' must be 16 characters or more in: ".$name);
                        return false;
                }

                if(!isset($def['source_path']) || !is_string($def['source_path'])) {
                        $this->Out->error("Package definition missing 'source_path' in: ".$name);
                        return false;
                }

                if(!isset($def['install_path']) || !is_string($def['install_path'])) {
                        $this->Out->error("Package definition missing 'install_path' in: ".$name);
                        return false;
                }

                $this->definition[str_replace('package_','',$name)] = $def;
                return true;
        }
Beispiel #14
0
 /**
  * 实例化controller
  * @param  class $router 路由
  * @return void
  */
 public static function dispatch($router)
 {
     //得到的controller类似: App\Controller\BaseController,而不是: Base
     $controller = $router->getController();
     $action = $router->getAction();
     $params = $router->getParams();
     $controllerfile = str_replace('\\', '/', $controller) . '.class.php';
     if (file_exists($controllerfile)) {
         require_once $controllerfile;
         $app = new $controller();
         $app->setParams($params);
         $app->{$action}();
     } else {
         throw new \Exception("找不到controller,请检查{$controllerfile}是否存在");
     }
 }
Beispiel #15
0
 /**
  * Updates the record in the specified table
  * 
  * The record should be an array with the column names as keys and the 
  * column values as values.
  * 
  * @author Schmalls / Joshua Thompson <*****@*****.**>
  * @version 0.0.0
  * @since 0.0.0
  * @access public
  * @param string $table the table to insert into
  * @param array $record the record to insert
  * @param string $prefix_placeholder the table prefix placeholder
  */
 public function update($table, $record, $where = false, $prefix_placeholder = '#__')
 {
     // change table prefix
     $table = str_replace($prefix_placeholder, $this->_table_prefix, $table);
     // insert
     $this->_db->AutoExecute($table, $record, 'UPDATE', $where);
 }
 /**
  * Setea o actualiza la variable de sesión con el zonal actualmente
  * seleccionado por el usuario, y retorna mensaje de confirmación.
  * Este mètodo debe ser utilizado en operaciones tipo ajax.
  */
 function setZonalAjax()
 {
     $zname = JRequest::getVar('zname', NULL, 'post', 'string');
     $sesid = JRequest::getVar('PHPSESSID', NULL, 'post', 'string');
     $usemap = JRequest::getVar('usemap', true, 'post', 'string');
     if ($sesid) {
         session_id($sesid);
     }
     $result = "failure";
     $message = "Zonal desconocido";
     if ($zname) {
         $zonal = $this->_zonalesHelper->getZonal($zname);
         if ($zonal) {
             $session = JFactory::getSession();
             $session->set('zonales_zonal_name', $zonal->name);
             $session->set('zonales_zonal_label', $zonal->label);
             $result = "success";
             $message = $zonal->label;
         } else {
             $session->set('zonales_zonal_name', NULL);
             $session->set('zonales_zonal_label', NULL);
         }
     }
     if ($usemap) {
         echo "result={$result}&message={$message}";
     }
     return;
 }
Beispiel #17
0
        /**
         * decrypt()
         *
         * @param string $filename
         * @param string $key
         */
        function decrypt($filename,$key) {
                //$this->out(__METHOD__,'debug');

                if(empty($key) || !is_string($key)) {
                        throw new Exception('No key provided to decrypt file against.');
                }

                // Check the source file exists
                if(!is_file($filename)) {
                        throw new Exception('Unable to locate file: '.$filename.' to decrypt.');
                }

                // Create a tempfile name
                $tempfile_filename = tempnam(sys_get_temp_dir(),'decrypt_').'.gz.nc';
                $target_filename = str_replace('.gz.nc','',$tempfile_filename);
                unlink($target_filename);

                // Copy the file to the temp
                copy($filename,$tempfile_filename);

                // Decrypt the file
                $cmd = $this->mcrypt_exec.' --decrypt --quiet --force --key "'.$key.'" --gzip '.$tempfile_filename;

                if(false === $this->SystemCommand->exec($cmd)) {
                        throw new Exception('Failed while calling mcrypt to decrypt: '.$filename);
                }
                unlink($tempfile_filename);

                // Check the decrypted file exists
                if(!is_file($target_filename)) {
                        throw new Exception('Could not locate decrypted file at: '.$target_filename);
                }

                return $target_filename;
        }
Beispiel #18
0
 /**
  *
  * Get mail contents
  *
  * @access 	public
  * @return 	Content
  */
 public function getContents()
 {
     $out = new StdClass();
     $out->body = $this->view->fetch($this->getConfig('template'));
     $out->subject = $this->view->getCapture('subject');
     $out->altbody = $this->view->getCapture('altbody');
     return $out;
 }
 /**
  * Real escape, using mysql_real_escape_string() or addslashes()
  *
  * @see addslashes()
  * @since 0.1
  * @access private
  *
  * @param  string $string to escape
  * @return string escaped
  */
 public function _real_escape($string)
 {
     if ($this->real_escape) {
         return $this->mysqli->real_escape_string($string);
     } else {
         return addslashes($string);
     }
 }
Beispiel #20
0
/**
 * GD Progress Bar Function
 *
 * @param class $siggen
 * @param array $data
 *		string value
 *		string max
 *		int x
 *		int y
 *		int x2
 *		int y2
 *		string color
 *		int alpha
 *		bool filled
 *		bool radius
 * 		string direction
 * 		bool border
 *		string border_color
 *		int border_alpha
 * 		bool background
 *		string background_color
 *		int background_alpha
 *
 * @return bool
 *
 * @uses gd_rectangle
 */
function gd_progress($siggen, $data)
{
    // This has a dependancy
    // Make sure we have it loaded
    $siggen->check_module('gd_rectangle');
    // Are we using a border?
    if ($data['border']) {
        $border = array('color' => $data['border_color'], 'alpha' => $data['border_alpha'], 'x' => $data['x'] - 1, 'y' => $data['y'] - 1, 'x2' => $data['x2'] + 1, 'y2' => $data['y2'] + 1, 'radius' => $data['radius'], 'filled' => 0);
        gd_rectangle($siggen, $border);
    }
    // Are we filling the background?
    if ($data['background']) {
        $background = array('color' => $data['background_color'], 'alpha' => $data['background_alpha'], 'x' => $data['x'], 'y' => $data['y'], 'x2' => $data['x2'], 'y2' => $data['y2'], 'radius' => $data['radius'], 'filled' => 1);
        gd_rectangle($siggen, $background);
    }
    // Draw the actual progress bar
    switch ($data['direction']) {
        case 'up':
            $length = $data['y2'] - $data['y'];
            $location = $data['value'] > 0 ? round($data['value'] / $data['max'] * $length - $data['y2'], 0) : $data['y2'];
            $bar = array('color' => $data['color'], 'alpha' => $data['alpha'], 'x' => $data['x'], 'y' => $location, 'x2' => $data['x2'], 'y2' => $data['y2'], 'radius' => $data['radius'], 'filled' => $data['filled']);
            gd_rectangle($siggen, $bar);
            break;
        case 'down':
            $length = $data['y2'] - $data['y'];
            $location = $data['value'] > 0 ? round($data['value'] / $data['max'] * $length + $data['y'], 0) : 0;
            $bar = array('color' => $data['color'], 'alpha' => $data['alpha'], 'x' => $data['x'], 'y' => $data['y'], 'x2' => $data['x2'], 'y2' => $location, 'radius' => $data['radius'], 'filled' => $data['filled']);
            gd_rectangle($siggen, $bar);
            break;
        case 'right':
            $length = $data['x2'] - $data['x'];
            $location = $data['value'] > 0 ? round($data['value'] / $data['max'] * $length + $data['x'], 0) : 0;
            $bar = array('color' => $data['color'], 'alpha' => $data['alpha'], 'x' => $location, 'y' => $data['y'], 'x2' => $data['x2'], 'y2' => $data['y2'], 'radius' => $data['radius'], 'filled' => $data['filled']);
            gd_rectangle($siggen, $bar);
            break;
        case 'left':
        default:
            $length = $data['x2'] - $data['x'];
            $location = $data['value'] > 0 ? round($data['value'] / $data['max'] * $length - $data['x2'], 0) : 0;
            $bar = array('color' => $data['color'], 'alpha' => $data['alpha'], 'x' => $data['x'], 'y' => $data['y'], 'x2' => $location, 'y2' => $data['y2'], 'radius' => $data['radius'], 'filled' => $data['filled']);
            gd_rectangle($siggen, $bar);
            break;
    }
    return TRUE;
}
Beispiel #21
0
        /**
         * setDefinition
         *
         * @param string $name
         * @param array $def
         * @return bool
         */
        public function setDefinition($name,$def){
                $this->Out->debug(__METHOD__,func_get_args());

                if(!isset($def['volume_id']) || !is_string($def['volume_id'])) {
                        $this->Out->error("Volume definition missing 'volume_id' in: ".$name);
                        return false;
                }

                if(!isset($def['device']) || !is_string($def['device'])) {
                        $this->Out->error("Volume definition missing 'device' in: ".$name);
                        return false;
                }

                if(!isset($def['mount']) || !is_string($def['mount'])) {
                        $this->Out->error("Volume definition missing 'mount' in: ".$name);
                        return false;
                }

                if(!isset($def['availability_zone']) || !is_string($def['availability_zone'])) {
                        $this->Out->error("Volume definition missing 'availability_zone' in: ".$name);
                        return false;
                }

                if(isset($def['command_before_snap'])) {

                        // Convert $def['command_before'] into an array
                        if(is_string($def['command_before_snap'])) {
                                $def['command_before_snap'] = split(',',$def['command_before_snap']);
                        }

                        foreach($def['command_before_snap'] as $command) {
                                if(!empty($command) && !in_array($command,$this->Cloud->Command->getNames())) {
                                        $this->Out->error("Volume definition 'command_before_snap' references command '".$command."' which could not be found in: ".$name);
                                        return false;
                                }
                        }
                }

                if(isset($def['command_after_snap'])) {

                        // Convert $def['command_before'] into an array
                        if(is_string($def['command_after_snap'])) {
                                $def['command_after_snap'] = split(',',$def['command_after_snap']);
                        }

                        foreach($def['command_after_snap'] as $command) {
                                if(!empty($command) && !in_array($command,$this->Cloud->Command->getNames())) {
                                        $this->Out->error("Volume definition 'command_after_snap' references command '".$command."' which could not be found in: ".$name);
                                        return false;
                                }
                        }
                }

                $this->definition[str_replace('volume_','',$name)] = $def;
                return true;
        }
 /**
  * Do the actual notification
  *
  * @param class $from reminderer
  * @param class $to reminderee
  *
  * @return nothing
  */
 function notify($from, $to)
 {
     if ($to->id != $from->id) {
         if ($to->email) {
             // TODO
             common_switch_locale($to->language);
             // TRANS: Subject for 'reminder' notification email.
             // TRANS: %s is the sender.
             $subject = sprintf(_('%s would like to see you post on GNU social'), $from->nickname);
             $from_profile = $from->getProfile();
             // TRANS: Body for 'reminder' notification email.
             // TRANS: %1$s is the sender's long name, $2$s is the receiver's nickname,
             // TRANS: %3$s is a URL to post notices at.
             $body = sprintf(_("%1\$s (%2\$s) is wondering what you are up to " . "these days and is inviting you to post some news.\n\n" . "So let's hear from you :)\n\n" . "%3\$s\n\n" . "Don't reply to this email; it won't get to them."), $from_profile->getBestName(), $from->nickname, common_local_url('all', array('nickname' => $to->nickname))) . mail_footer_block();
             common_switch_locale();
             $headers = $this->mail_prepare_headers('nudge', $to->nickname, $from->nickname);
             return mail_to_user($to, $subject, $body, $headers);
         }
     }
 }
Beispiel #23
0
        /**
         * parseConfig
         * @param string $filename
         */
        protected function parseConfig($filename) {
			$this->Out->debug(__METHOD__);

			// Make sure the file is there
			if(!is_file($filename)) {
				$this->Out->error('Unable to locate configuration file: '.$filename);
				exit(1);
			}

			// Parse the config file
			$config = parse_ini_file($filename,true);

			// Check required config sections are present
			$missing = null;

			// credentials
			if(!isset($config['aws']['access_key'])) { $missing = '[aws] access_key'; }
			if(!isset($config['aws']['secret_key'])) { $missing = '[aws] secret_key'; }

			// ec2
			if(!isset($config['ec2']['region'])) { $missing = '[ec2] region'; }
			if(isset($config['ec2']['region']) && isset($config['ec2']['hostname'])) {
				trigger_error('Must only set region -or- hostname in config [ec2]');
				exit(1);
			}

			// s3
			if(!isset($config['s3']['region'])) { $missing = '[s3] region'; }
			if(!isset($config['s3']['bucket_name'])) { $missing = '[s3] bucket_name'; }
			if(isset($config['s3']['region']) && isset($config['s3']['hostname'])) {
				trigger_error('Must only set region -or- hostname in config [s3]');
				exit(1);
			}

			// Check $config['s3']['package_bucket_name'] name is valid
			if(strlen(preg_replace("/[a-zA-Z0-9]|-/",'',$config['s3']['bucket_name']))) {
				trigger_error('Invalid S3 bucket name in [s3] bucket_name');
				exit(1);
			}

			if($missing) {
				trigger_error('Missing required configuration item: '.$missing);
				exit(1);
			}

			// Set debug mode if set in config file
			if(isset($config['core']['debug']) && 1 == $config['core']['debug']) {
				$this->debug = true;
			} else {
				$this->debug = false;
			}

			return $config;
        }
Beispiel #24
0
		/**
		 * __mapAwsRegion
		 * 
		 * provided to implement backward compatibility with previous AWSSDK versions
		 * @param string $region_name 
		 */
		private function __mapAwsRegion($region_name) {
			
			switch($region_name) {
				
				case 'ap-northeast-1':
					return AmazonEC2::REGION_APAC_NE1;
				break;
				
				case 'ap-southeast-1':
					return AmazonEC2::REGION_APAC_SE1;
				break;
			
                case 'ap-southeast-2':
                        return AmazonEC2::REGION_APAC_SE2;
                break;

				case 'eu-west-1':
					return AmazonEC2::REGION_EU_W1;
				break;
			
				case 'sa-east-1':
					return AmazonEC2::REGION_SA_E1;
				break;
			
				case 'sa-east-1':
					return AmazonEC2::REGION_SA_E1;
				break;
				
				case 'us-east-1':
					return AmazonEC2::REGION_US_E1;
				break;
			
				case 'us-west-1':
					return AmazonEC2::REGION_US_W1;
				break;
			
				case 'us-west-2':
					return AmazonEC2::REGION_US_W2;
				break;
			
				case 'us-gov-west-1':
					return AmazonEC2::REGION_US_GOV1;
				break;
			}
			
			// catch situations where the full aws hostname was passed through
			if(strstr($region_name,'.amazonaws.com') && strstr($region_name,'ec2.')) {
				return $region_name;
			}

			$this->Out->error('Unknown AWS region "'.$region_name.'"');
			exit(1);
		}
Beispiel #25
0
 /**
  * 移除对象缓存
  * @author 欧远宁
  * @param string $id 对象缓存的ID
  */
 private function mv_obj_cache($id)
 {
     try {
         if ($this->schema['cache'] > -1) {
             //改变查询缓存的流水号
             $this->cache->inc('qc.' . $this->mdl . '.' . $this->tbl);
             //移除对象缓存
             $this->cache->del($this->ver . $this->mdl . $this->tbl . $id);
         }
     } catch (Exception $e) {
         throw new err($e->getMessage(), 100);
     }
 }
Beispiel #26
0
 /**
  *
  * Function which creates a new User, uses the validation class to make sure all values match the requirements.
  *      this function also uses the database class for database and Convert class to convert the date to an mysql date.
  *
  * @param string $username Username is a string
  * @param string $password1 first password for validation
  * @param string $password2 2nd password for validation
  * @throws Exception
  *
  * @return boolean
  */
 public function newUser($username, $password1, $password2)
 {
     if ($this->loggedin || isset($_SESSION['loggedin'])) {
         throw new Exception("U bent al ingelogd");
         $this->loggedin = true;
     }
     $this->validation->checkIfSame($password1, $password2, 'wachtwoorden');
     $this->validation->checkStringLength($password1, 'wachtwoord', 6, 255);
     $this->sql = "INSERT INTO\n\t\t\t\t\tusers(\n\t\t\t\t\t\t username,\n\t\t\t\t\t\t password)\n\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t(:username,\n\t\t\t\t\t\t\t\t :password)";
     $query = database::singleton()->prepare($this->sql);
     $query->bindParam(':username', $username, PDO::PARAM_STR);
     $password1 = sha1($password2 . ZOUT);
     $query->bindParam(':password', $password1, PDO::PARAM_STR);
     $query->execute();
     $this->sql = "SELECT\n\t\t\t\t\t\tuser_id\n\t\t\t\t\t  FROM\n\t\t\t\t\t\tusers\n\t\t\t\t\t  WHERE\n\t\t\t\t\t\tusername = '******'";
     $query = database::singleton()->prepare($this->sql);
     $query->execute();
     $_SESSION['user_id'] = $query->fetchColumn(0);
     $_SESSION['loggedin'] = true;
     $this->loggedin = true;
     echo 'success';
 }
 /**
  * Adds theme options to the Customizer screen
  *
  * This function is attached to the 'customize_register' action hook.
  *
  * @param	class $wp_customize
  *
  * @since 1.0.0
  */
 public function customize_register($wp_customize)
 {
     $bavotasan_default_theme_options = bavotasan_default_theme_options();
     // Layout section panel
     $wp_customize->add_section('bavotasan_layout', array('title' => __('Layout', 'destin-basic'), 'priority' => 35));
     $wp_customize->add_setting('width', array('default' => $bavotasan_default_theme_options['width'], 'sanitize_callback' => 'absint'));
     $wp_customize->add_control('width', array('label' => __('Site Width', 'destin-basic'), 'section' => 'bavotasan_layout', 'priority' => 10, 'type' => 'select', 'choices' => array('1170' => __('1200px', 'destin-basic'), '992' => __('992px', 'destin-basic'))));
     $choices = array('col-md-2' => '17%', 'col-md-3' => '25%', 'col-md-4' => '34%', 'col-md-5' => '42%', 'col-md-6' => '50%', 'col-md-7' => '58%', 'col-md-8' => '66%', 'col-md-9' => '75%', 'col-md-10' => '83%');
     $wp_customize->add_setting('primary', array('default' => $bavotasan_default_theme_options['primary'], 'sanitize_callback' => 'esc_attr'));
     $wp_customize->add_control('primary', array('label' => __('Main Content Width', 'destin-basic'), 'section' => 'bavotasan_layout', 'priority' => 15, 'type' => 'select', 'choices' => $choices));
     $wp_customize->add_setting('layout', array('default' => $bavotasan_default_theme_options['layout'], 'sanitize_callback' => 'esc_attr'));
     $layout_choices = array('left' => __('Left', 'destin-basic'), 'right' => __('Right', 'destin-basic'));
     $wp_customize->add_control(new Bavotasan_Post_Layout_Control($wp_customize, 'layout', array('label' => __('Sidebar Layout', 'destin-basic'), 'section' => 'bavotasan_layout', 'priority' => 25, 'choices' => $layout_choices)));
 }
Beispiel #28
0
 function GetContents()
 {
     $out = '';
     foreach ($this->parent->refs as $refraw) {
         $ref = $refraw;
         $out .= "TY  - " . (isset($ref['type']) ? strtoupper($ref['type']) : 'ELEC') . "\n";
         foreach ($this->_mapHashArray as $k => $v) {
             if (isset($ref[$v])) {
                 foreach ((array) $ref[$v] as $val) {
                     $out .= "{$k}  - " . $this->Escape($val) . "\n";
                 }
                 unset($ref[$v]);
                 // Remove it from the reference copy so we dont process it twice
             }
         }
         foreach ($this->_mapHash as $k => $v) {
             if (isset($ref[$v])) {
                 $out .= "{$k}  - " . $this->Escape($ref[$v]) . "\n";
                 unset($ref[$v]);
                 // Remove it from the reference copy so we dont process it twice
             }
         }
         if (isset($ref['pages'])) {
             if (preg_match('!(.*?)-(.*)$!', $ref['pages'], $pages)) {
                 $out .= "SP  - {$pages[1]}\n";
                 $out .= "EP  - {$pages[2]}\n";
             } else {
                 $out .= "SP  - " . $this->Escape($ref['pages']) . "\n";
             }
         }
         if (isset($ref['date']) && ($date = $this->parent->ToDate($ref['date'], '/', true))) {
             $out .= "PY  - {$date}/\n";
         }
         $out .= "ER  - \n";
     }
     return $out;
 }
Beispiel #29
0
 /**
  * 执行一条sql操作,并返回操作成功数
  * @author 欧远宁
  * @param string $sql 含参数的sql
  * @param array $para 参数及其对应的值
  * @return int        操作成功数
  */
 public function execute($sql, $para = null)
 {
     $this->open();
     $re = 0;
     $this->log_sql($sql, $para);
     try {
         $this->begin_trans();
         $smt = $this->link->prepare($sql);
         $smt->execute($para);
         $re = $smt->rowCount();
         $smt = null;
     } catch (Exception $e) {
         throw new err('sql error=' . $e->getMessage() . '. sql=' . $sql, 100);
     }
     return $re;
 }
Beispiel #30
0
        /**
         * setDefinition
         *
         * @param string $name
         * @param array $def
         * @return bool
         */
        public function setDefinition($name,$def){
                $this->Out->debug(__METHOD__,func_get_args());

                if(!isset($def['address']) || !is_string($def['address'])) {
                        $this->Out->error("Address 'address' definition missing in: ".$name);
                        return false;
                }

                if(!isset($def['region']) || !is_string($def['region'])) {
                        $this->Out->error("Address 'region' definition missing in: ".$name);
                        return false;
                }

                $this->definition[str_replace('address_','',$name)] = $def;
                return true;
        }