public static function setCredentials($client, $user, $pass) { $return = false; $client = strtolower($client); // Test if the given credentials are valid switch ($client) { case 'ftp': $config = MFactory::getConfig(); $options = array('enabled' => $config->get('ftp_enable'), 'host' => $config->get('ftp_host'), 'port' => $config->get('ftp_port')); if ($options['enabled']) { mimport('framework.client.ftp'); $ftp = MFTP::getInstance($options['host'], $options['port']); // Test the connection and try to log in if ($ftp->isConnected()) { if ($ftp->login($user, $pass)) { $return = true; } $ftp->quit(); } } break; default: break; } if ($return) { // Save valid credentials to the session $session = MFactory::getSession(); $session->set($client . '.user', $user, 'MClientHelper'); $session->set($client . '.pass', $pass, 'MClientHelper'); // Force re-creation of the data saved within MClientHelper::getCredentials() MClientHelper::getCredentials($client, true); } return $return; }
public static function getInstance($type, $prefix = 'MTable', $config = array()) { // Sanitize and prepare the table class name. $type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type); $tableClass = $prefix . ucfirst($type); // Only try to load the class if it doesn't already exist. if (!class_exists($tableClass)) { // Search for the class file in the MTable include paths. mimport('framework.filesystem.path'); MTable::addIncludePath(MPATH_MIWI . '/proxy/database/table'); if ($path = MPath::find(MTable::addIncludePath(), strtolower($type) . '.php')) { // Import the class file. include_once $path; // If we were unable to load the proper class, raise a warning and return false. if (!class_exists($tableClass)) { MError::raiseWarning(0, MText::sprintf('MLIB_DATABASE_ERROR_CLASS_NOT_FOUND_IN_FILE', $tableClass)); return false; } } else { // If we were unable to find the class file in the MTable include paths, raise a warning and return false. MError::raiseWarning(0, MText::sprintf('MLIB_DATABASE_ERROR_NOT_SUPPORTED_FILE_NOT_FOUND', $type)); return false; } } // If a database object was passed in the configuration array use it, otherwise get the global one from MFactory. $db = isset($config['dbo']) ? $config['dbo'] : MFactory::getDbo(); // Instantiate a new table class and return it. return new $tableClass($db); }
function getPagination() { if (empty($this->_pagination)) { mimport('framework.html.pagination'); $this->_pagination = new MPagination($this->getTotal(), $this->getState($this->option . '.queries.limitstart'), $this->getState($this->option . '.queries.limit')); } return $this->_pagination; }
protected function _getCommand($ref, $com, $override, $component) { // Get Help URL mimport('framework.language.help'); $url = MHelp::createURL($ref, $com, $override, $component); $url = htmlspecialchars($url, ENT_QUOTES); $cmd = "Miwi.popupWindow('{$url}', '" . MText::_('MHELP', true) . "', 700, 500, 1)"; return $cmd; }
public static function raise($level, $code, $msg, $info = null, $backtrace = false) { // Deprecation warning. MLog::add('MError::raise() is deprecated.', MLog::WARNING, 'deprecated'); mimport('framework.error.exception'); // Build error object $exception = new MException($msg, $code, $level, $info, $backtrace); return MError::throwError($exception); }
public static function cleanUrl($url) { $url = self::cleanText($url); $bad_chars = array('#', '>', '<', '\\', '="', 'px;', 'onmouseover='); $url = trim(str_replace($bad_chars, '', $url)); mimport('framework.filter.input'); MFilterInput::getInstance(array('br', 'i', 'em', 'b', 'strong'), array(), 0, 0, 1)->clean($url); return $url; }
public static function addIncludePath($path = '') { static $paths; if (!isset($paths)) { $paths = array(); } if (!empty($path) && !in_array($path, $paths)) { mimport('framework.filesystem.path'); array_unshift($paths, MPath::clean($path)); } return $paths; }
public function __construct($context) { $this->context = $context; $this->constants(); $miwi = MPATH_WP_CNT . '/miwi/initialise.php'; if (!file_exists($miwi)) { return false; } require_once $miwi; $this->app = MFactory::getApplication(); $this->app->initialise(); mimport('framework.filesystem.file'); }
public static function images($name, $active = null, $javascript = null, $directory = null, $extensions = "bmp|gif|jpg|png") { if (!$directory) { $directory = '/images/'; } if (!$javascript) { $javascript = "onchange=\"if (document.forms.adminForm." . $name . ".options[selectedIndex].value!='') {document.imagelib.src='..{$directory}' + document.forms.adminForm." . $name . ".options[selectedIndex].value} else {document.imagelib.src='media/system/images/blank.png'}\""; } mimport('framework.filesystem.folder'); $imageFiles = MFolder::files(MPATH_SITE . '/' . $directory); $images = array(MHtml::_('select.option', '', MText::_('MOPTION_SELECT_IMAGE'))); foreach ($imageFiles as $file) { if (preg_match('#(' . $extensions . ')$#', $file)) { $images[] = MHtml::_('select.option', $file); } } $images = MHtml::_('select.genericlist', $images, $name, array('list.attr' => 'class="inputbox" size="1" ' . $javascript, 'list.select' => $active)); return $images; }
public function __construct($options = array()) { // If default transfer type is not set, set it to autoascii detect if (!isset($options['type'])) { $options['type'] = FTP_BINARY; } $this->setOptions($options); if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $this->_OS = 'WIN'; } elseif (strtoupper(substr(PHP_OS, 0, 3)) === 'MAC') { $this->_OS = 'MAC'; } else { $this->_OS = 'UNIX'; } if (FTP_NATIVE) { // Import the generic buffer stream handler mimport('framework.utilities.buffer'); // Autoloading fails for MBuffer as the class is used as a stream handler MLoader::load('MBuffer'); } }
public static function getInstance($type, $prefix = '', $config = array()) { $type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type); $modelClass = $prefix . ucfirst($type); if (!class_exists($modelClass)) { mimport('framework.filesystem.path'); $path = MPath::find(self::addIncludePath(null, $prefix), self::_createFileName('model', array('name' => $type))); if (!$path) { $path = MPath::find(self::addIncludePath(null, ''), self::_createFileName('model', array('name' => $type))); } if ($path) { require_once $path; if (!class_exists($modelClass)) { MError::raiseWarning(0, MText::sprintf('MLIB_APPLICATION_ERROR_MODELCLASS_NOT_FOUND', $modelClass)); return false; } } else { return false; } } return new $modelClass($config); }
<?php /* * @package Miwi Framework * @copyright Copyright (C) 2009-2014 Miwisoft, LLC. All rights reserved. * @copyright Copyright (C) 2005-2012 Open Source Matters, Inc. All rights reserved. * @license GNU/GPL based on Moomla www.joomla.org */ defined('MIWI') or die('MIWI'); mimport('framework.filesystem.helper'); //mimport('framework.utilities.utility'); kullanılan fonction göremedim class MStream extends MObject { protected $filemode = 0644; protected $dirmode = 0755; protected $chunksize = 8192; protected $filename; protected $writeprefix; protected $readprefix; protected $processingmethod = 'f'; protected $filters = array(); protected $_fh; protected $_filesize; protected $_context = null; protected $_contextOptions; protected $_openmode; public function __construct($writeprefix = '', $readprefix = '', $context = array()) { $this->writeprefix = $writeprefix; $this->readprefix = $readprefix; $this->_contextOptions = $context;
<?php /* * @package MiwoSQL * @copyright 2009-2012 Mijosoft LLC, www.mijosoft.com * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html */ // No Permission defined('MIWI') or die('Restricted access'); mimport('framework.filesystem.file'); mimport('framework.filesystem.folder'); class com_MiwosqlInstallerScript { public function postflight($type, $parent) { if (MFolder::copy(MPath::clean(MPATH_WP_PLG . '/miwosql/languages'), MPath::clean(MPATH_WP_CNT . '/miwi/languages'), null, true)) { MFolder::delete(MPath::clean(MPATH_WP_PLG . '/miwosql/languages')); } } }
public static function getStream($use_prefix = true, $use_network = true, $ua = null, $uamask = false) { mimport('framework.filesystem.stream'); // Setup the context; $context = array(); $version = new MVersion(); // set the UA for HTTP and overwrite for FTP $context['http']['user_agent'] = $version->getUserAgent($ua, $uamask); $context['ftp']['overwrite'] = true; if ($use_prefix) { $FTPOptions = MClientHelper::getCredentials('ftp'); $SCPOptions = MClientHelper::getCredentials('scp'); if ($FTPOptions['enabled'] == 1 && $use_network) { $prefix = 'ftp://' . $FTPOptions['user'] . ':' . $FTPOptions['pass'] . '@' . $FTPOptions['host']; $prefix .= $FTPOptions['port'] ? ':' . $FTPOptions['port'] : ''; $prefix .= $FTPOptions['root']; } elseif ($SCPOptions['enabled'] == 1 && $use_network) { $prefix = 'ssh2.sftp://' . $SCPOptions['user'] . ':' . $SCPOptions['pass'] . '@' . $SCPOptions['host']; $prefix .= $SCPOptions['port'] ? ':' . $SCPOptions['port'] : ''; $prefix .= $SCPOptions['root']; } else { $prefix = MPATH_ROOT . '/'; } $retval = new MStream($prefix, MPATH_ROOT, $context); } else { $retval = new MStream('', '', $context); } return $retval; }
if (!defined('_MREQUEST_NO_CLEAN') && (bool) ini_get('register_globals')) { //MRequest::clean(); // miwisoft ticket 110 } } MLoader::import('framework.object.object'); MLoader::import('framework.text.text'); MLoader::import('framework.route.route'); // Register the library base path for CMS libraries. MLoader::registerPrefix('M', MPATH_MIWI . '/framework'); // Define the Miwi version if not already defined. if (!defined('MVERSION')) { $Mversion = new MVersion(); define('MVERSION', $Mversion->getShortVersion()); } mimport('framework.application.menu'); mimport('framework.environment.uri'); mimport('framework.utilities.utility'); mimport('framework.event.dispatcher'); mimport('framework.utilities.arrayhelper'); mimport('framework.access.access'); mimport('framework.user.user'); mimport('framework.document.document'); mimport('phputf8.utf8'); mimport('framework.database.table'); if (is_admin()) { mimport('framework.html.toolbar'); mimport('framework.html.toolbar.helper'); } mimport('framework.application.component.helper'); // Base.css file MFactory::getDocument()->addStyleSheet(MURL_WP_CNT . '/miwi/media/system/css/base.css');
<?php /* * @package Miwi Framework * @copyright Copyright (C) 2009-2014 Miwisoft, LLC. All rights reserved. * @license GNU General Public License version 2 or later */ defined('MIWI') or die('MIWI'); mimport('framework.widget.widget'); mimport('framework.application.module.helper'); class MWidgetHelper extends MObject { public static function startWidgets($option) { $modules = MModuleHelper::getModules(); foreach ($modules as $module) { if (!is_object($module)) { continue; } if (!strpos($module->module, $option)) { continue; } $class_name = $module->module . '_widget'; if (!defined($class_name)) { define($class_name, $class_name); } eval('class ' . $class_name . ' extends MWidget {public $class_name = ' . $class_name . ';};'); add_action('widgets_init', create_function('', 'return register_widget(' . $class_name . ');')); } } }
public function getMenu($name = null, $options = array()) { if (!isset($name)) { $name = $this->_name; } mimport('framework.application.menu'); $menu = MMenu::getInstance($name, $options); if ($menu instanceof Exception) { return null; } return $menu; }
<?php /* * @package Miwi Framework * @copyright Copyright (C) 2009-2014 Miwisoft, LLC. All rights reserved. * @copyright Copyright (C) 2005-2012 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later */ defined('MIWI') or die('MIWI'); mimport('framework.filesystem.path'); mimport('framework.utilities.arrayhelper'); class MForm { protected $data; protected $errors = array(); protected $name; protected $options = array(); protected $xml; protected static $forms = array(); public function __construct($name, array $options = array()) { // Set the name for the form. $this->name = $name; // Initialise the MRegistry data. $this->data = new MRegistry(); // Set the options if specified. $this->options['control'] = isset($options['control']) ? $options['control'] : false; } public function bind($data) { // Make sure there is a valid MForm XML document.
<?php /* * @package MiwoSQL * @copyright 2009-2012 Mijosoft LLC, mijosoft.com * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html */ // No Permission defined('MIWI') or die('Restricted access'); mimport('framework.application.component.model'); class MiwosqlModel extends MModel { public function __construct() { parent::__construct(); } }
<?php /* * @package Miwi Framework * @copyright Copyright (C) 2009-2014 Miwisoft, LLC. All rights reserved. * @copyright Copyright (C) 2005-2012 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later */ defined('MIWI') or die('MIWI'); mimport('framework.event.dispatcher'); define('MAUTHENTICATE_STATUS_SUCCESS', 1); define('MAUTHENTICATE_STATUS_CANCEL', 2); define('MAUTHENTICATE_STATUS_FAILURE', 4); class MAuthentication extends MObject { const STATUS_SUCCESS = 1; const STATUS_CANCEL = 2; const STATUS_FAILURE = 4; const STATUS_EXPIRED = 8; const STATUS_DENIED = 16; const STATUS_UNKNOWN = 32; protected $_observers = array(); protected $_state = null; protected $_methods = array(); protected static $instance; public function __construct() { $isLoaded = MPluginHelper::importPlugin('authentication'); if (!$isLoaded) { MError::raiseWarning('SOME_ERROR_CODE', MText::_('MLIB_USER_ERROR_AUTHENTICATION_LIBRARIES')); }
public function widgets() { mimport('framework.widget.helper'); MWidgetHelper::startWidgets($this->context); }
public static function ucwords($str) { mimport('phputf8.ucwords'); return utf8_ucwords($str); }
protected static function _load($option) { if (isset(self::$components[$option]) and self::$components[$option] !== null) { return true; } mimport('framework.filesystem.folder'); $folders = MFolder::folders(MPATH_WP_PLG); if (empty($folders)) { self::$components[$option] = new stdClass(); return false; } self::$components = array(); $n = count($folders); for ($i = 0; $i < $n; $i++) { $folder = @$folders[$i]; if (empty($folder)) { continue; } if (substr($folder, 0, 4) != 'miwo') { continue; } $com = new stdClass(); $com->id = $i; $com->option = 'com_' . $folder; $com->params = MFactory::getWOption($folder); $com->enabled = 1; // Convert the params to an object. if (is_string($com->params)) { $temp = new MRegistry(); $temp->loadString($com->params); $com->params = $temp; } self::$components[$com->option] = $com; } return true; }
<?php /* * @package MiwoSQL * @copyright 2009-2012 Mijosoft LLC, mijosoft.com * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html */ // No Permission defined('MIWI') or die('Restricted access'); mimport('framework.application.component.controller'); class MiwosqlController extends MController { public function __construct($default = array()) { parent::__construct($default); $this->_db = MFactory::getDBO(); $this->_table = MiwosqlHelper::getVar('tbl'); $this->_query = MiwosqlHelper::getVar('qry'); $this->registerTask('add', 'edit'); $this->registerTask('new', 'edit'); } public function display($cachable = false, $urlparams = false) { $controller = MRequest::getWord('controller', 'miwosql'); MRequest::setVar('view', $controller); parent::display($cachable, $urlparams); } public function edit() { MRequest::setVar('hidemainmenu', 1); MRequest::setVar('view', 'edit');
<?php /* * @package Miwi Framework * @copyright Copyright (C) 2009-2014 Miwisoft, LLC. All rights reserved. * @copyright Copyright (C) 2005-2012 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later */ defined('MIWI') or die('MIWI'); mimport('framework.html.editor'); class MFormFieldEditor extends MFormField { public $type = 'Editor'; protected $editor; protected function getInput() { // Initialize some field attributes. $rows = (int) $this->element['rows']; $cols = (int) $this->element['cols']; $height = (string) $this->element['height'] ? (string) $this->element['height'] : '250'; $width = (string) $this->element['width'] ? (string) $this->element['width'] : '100%'; $assetField = $this->element['asset_field'] ? (string) $this->element['asset_field'] : 'asset_id'; $authorField = $this->element['created_by_field'] ? (string) $this->element['created_by_field'] : 'created_by'; $asset = $this->form->getValue($assetField) ? $this->form->getValue($assetField) : (string) $this->element['asset_id']; // Build the buttons array. $buttons = (string) $this->element['buttons']; if ($buttons == 'true' || $buttons == 'yes' || $buttons == '1') { $buttons = true; } elseif ($buttons == 'false' || $buttons == 'no' || $buttons == '0') { $buttons = false; } else {
protected static function _load() { if (self::$plugins !== null) { return self::$plugins; } mimport('framework.filesystem.folder'); if (!MFolder::exists(MPATH_PLUGINS)) { self::$plugins = array(); return self::$plugins; } $folders = MFolder::folders(MPATH_PLUGINS); if (empty($folders)) { self::$plugins = array(); return self::$plugins; } self::$plugins = array(); foreach ($folders as $folder) { $folder = str_replace('plg_', '', $folder); list($type, $name) = explode('_', $folder); $plg = new stdClass(); $plg->type = $type; $plg->name = $name; $plg->params = null; $xml_file = MPATH_MIWI . '/plugins/plg_' . $type . '_' . $name . '/' . $name . '.xml'; if (file_exists($xml_file)) { $form = MForm::getInstance($folder . '_form', $xml_file, array(), false, 'config'); $field_sets = $form->getFieldsets(); if (!empty($field_sets)) { $params = array(); foreach ($field_sets as $name => $field_set) { foreach ($form->getFieldset($name) as $field) { $field_name = $field->get('fieldname'); $field_value = $field->get('value'); $params[$field_name] = $field_value; } } $plg->params = json_encode($params); } } self::$plugins[] = $plg; } return self::$plugins; }
function modChrome_outline($module, &$params, &$attribs) { static $css = false; if (!$css) { $css = true; mimport('framework.environment.browser'); $doc = MFactory::getDocument(); $browser = MBrowser::getInstance(); $doc->addStyleDeclaration(".mod-preview-info { padding: 2px 4px 2px 4px; border: 1px solid black; position: absolute; background-color: white; color: red;}"); $doc->addStyleDeclaration(".mod-preview-wrapper { background-color:#eee; border: 1px dotted black; color:#700;}"); if ($browser->getBrowser() == 'msie') { if ($browser->getMajor() <= 7) { $doc->addStyleDeclaration(".mod-preview-info {filter: alpha(opacity=80);}"); $doc->addStyleDeclaration(".mod-preview-wrapper {filter: alpha(opacity=50);}"); } else { $doc->addStyleDeclaration(".mod-preview-info {-ms-filter: alpha(opacity=80);}"); $doc->addStyleDeclaration(".mod-preview-wrapper {-ms-filter: alpha(opacity=50);}"); } } else { $doc->addStyleDeclaration(".mod-preview-info {opacity: 0.8;}"); $doc->addStyleDeclaration(".mod-preview-wrapper {opacity: 0.5;}"); } } ?> <div class="mod-preview"> <div class="mod-preview-info"><?php echo $module->position . "[" . $module->style . "]"; ?> </div> <div class="mod-preview-wrapper"> <?php echo $module->content; ?> </div> </div> <?php }
<?php /* * @package Miwi Framework * @copyright Copyright (C) 2009-2014 Miwisoft, LLC. All rights reserved. * @copyright Copyright (C) 2005-2012 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later */ defined('MIWI') or die('MIWI'); mimport('framework.filesystem.path'); class MFormHelper { protected static $paths; protected static $entities = array(); public static function loadFieldType($type, $new = true) { return self::loadType('field', $type, $new); } public static function loadRuleType($type, $new = true) { return self::loadType('rule', $type, $new); } protected static function loadType($entity, $type, $new = true) { // Reference to an array with current entity's type instances $types =& self::$entities[$entity]; // Initialize variables. $key = md5($type); $class = ''; // Return an entity object if it already exists and we don't need a new one. if (isset($types[$key]) && $new === false) {
public function loadHelper($hlp = null) { // Clean the file name $file = preg_replace('/[^A-Z0-9_\\.-]/i', '', $hlp); // Load the template script mimport('framework.filesystem.path'); $helper = MPath::find($this->_path['helper'], $this->_createFileName('helper', array('name' => $file))); if ($helper != false) { // Include the requested template filename in the local scope include_once $helper; } }
<?php /* * @package Miwi Framework * @copyright Copyright (C) 2009-2014 Miwisoft, LLC. All rights reserved. * @copyright Copyright (C) 2005-2012 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later */ defined('MIWI') or die('MIWI'); mimport('frameowrk.html.toolbar'); abstract class MToolBarHelper { public static function title($title, $icon = 'generic.png') { $bar = MToolBar::getInstance('toolbar'); $bar->set('_title', $title); } public static function spacer($width = '') { $bar = MToolBar::getInstance('toolbar'); // Add a spacer. $bar->appendButton('Separator', 'spacer', $width); } public static function divider() { $bar = MToolBar::getInstance('toolbar'); // Add a divider. $bar->appendButton('Separator', 'divider'); } public static function custom($task = '', $icon = '', $iconOver = '', $alt = '', $listSelect = true) {