/** * This function is executed during the 'plugins_boot' event, before most plugins are initialized * * @return void */ function translation_editor_plugins_boot_event() { // add the custom_keys_locations to language paths $custom_keys_path = elgg_get_data_path() . 'translation_editor' . DIRECTORY_SEPARATOR . 'custom_keys' . DIRECTORY_SEPARATOR; if (is_dir($custom_keys_path)) { register_translations($custom_keys_path); } // force creation of static to prevent reload of unwanted translations reload_all_translations(); if (elgg_in_context('translation_editor') || elgg_in_context('settings') || elgg_in_context('admin')) { translation_editor_reload_all_translations(); } translation_editor_load_custom_languages(); if (!elgg_in_context('translation_editor')) { // remove disabled languages translation_editor_unregister_translations(); } // load custom translations $user_language = get_current_language(); $elgg_default_language = 'en'; $load_languages = [$user_language, $elgg_default_language]; $load_languages = array_unique($load_languages); $disabled_languages = translation_editor_get_disabled_languages(); foreach ($load_languages as $language) { if (empty($disabled_languages) || !in_array($language, $disabled_languages)) { // add custom translations translation_editor_load_translations($language); } } }
/** * Cleanup the cached inline images * * @param string $hook the name of the hook * @param string $type the type of the hook * @param mixed $return current return value * @param array $params supplied params * * @return void */ public static function imageCacheCleanup($hook, $type, $return, $params) { if (empty($params) || !is_array($params)) { return; } $cache_dir = elgg_get_data_path() . 'html_email_handler/image_cache/'; if (!is_dir($cache_dir)) { return; } $dh = opendir($cache_dir); if (empty($dh)) { return; } $max_lifetime = elgg_extract('time', $params, time()) - 24 * 60 * 60; while (($filename = readdir($dh)) !== false) { // make sure we have a file if (!is_file($cache_dir . $filename)) { continue; } $modified_time = filemtime($cache_dir . $filename); if ($modified_time > $max_lifetime) { continue; } // file is past lifetime, so cleanup unlink($cache_dir . $filename); } closedir($dh); }
/** * Add a menu item to the user hover dropdown * * @param string $hook the name of the hook * @param string $type the type of the hook * @param \ElggMenuItem[] $return_value current menu items * @param array $params supplied params * * @return void|\ElggMenuItem[] */ public static function register($hook, $type, $return_value, $params) { static $user_dirs; if (!elgg_is_admin_logged_in()) { return; } if (empty($params) || !is_array($params)) { return; } $user = elgg_extract('entity', $params); if (!$user instanceof \ElggUser) { return; } if (!isset($user_dirs)) { $user_dirs = []; } // save in a static for performance when viewing user listings if (!isset($user_dirs[$user->getGUID()])) { $user_dirs[$user->getGUID()] = false; $edl = new \Elgg\EntityDirLocator($user->getGUID()); $path = $edl->getPath(); if (is_dir(elgg_get_data_path() . $path)) { $path = substr($path, 0, -1); $user_dirs[$user->getGUID()] = \ElggMenuItem::factory(['name' => 'dataroot-browser', 'text' => elgg_echo('dataroot_browser:menu:user_hover'), 'href' => elgg_http_add_url_query_elements('admin/administer_utilities/dataroot_browser', ['dir' => $path]), 'is_trusted' => true, 'section' => 'admin']); } } if (empty($user_dirs[$user->getGUID()])) { return; } $return_value[] = $user_dirs[$user->getGUID()]; return $return_value; }
/** * Returns upload path for a given user * * @param int $user_guid guid of the user * * @return string */ function ckeditor_extended_get_upload_path($user_guid) { $bucket_size = 500; if (empty($user_guid)) { $user_guid = elgg_get_logged_in_user_guid(); } if (empty($user_guid)) { return false; } $site_guid = elgg_get_site_entity()->getGUID(); $lower_bound = (int) max(floor($user_guid / $bucket_size) * $bucket_size, 1); return elgg_get_data_path() . "ckeditor_upload/" . $site_guid . "/" . $lower_bound . "/" . $user_guid . "/"; }
function elggpg_get_gpg_home() { // try to find location of settings from environment file, // which means the gpg directory goes at the same level. $elgg_config = getenv("elgg_config"); if ($elgg_config && is_dir(dirname($elgg_config) . "/gpg")) { return dirname($elgg_config) . "/gpg"; } // otherwise create a gpg folder at the data folder // and store the keys there $gpg_path = elgg_get_data_path() . "gpg/"; if (!file_exists($gpg_path)) { mkdir($gpg_path); } return $gpg_path; }
function widget_rss_init() { elgg_register_widget_type("rss", elgg_echo("widgets:rss:title"), elgg_echo("widgets:rss:description"), "groups,index,profile,dashboard", true); // extend CSS elgg_extend_view("css/elgg", "widgets/rss/css"); // make cache directory if (!is_dir(elgg_get_data_path() . "/widgets/")) { mkdir(elgg_get_data_path() . "/widgets/"); } if (!is_dir(elgg_get_data_path() . "/widgets/rss/")) { mkdir(elgg_get_data_path() . "/widgets/rss/"); } elgg_register_library("simplepie", elgg_get_plugins_path() . "widget_manager/widgets/rss/vendors/simplepie/simplepie.inc"); // set cache settings define("WIDGETS_RSS_CACHE_LOCATION", elgg_get_data_path() . "widgets/rss/"); define("WIDGETS_RSS_CACHE_DURATION", 600); }
/** * Download the Archive ZIP to computer */ function page_handler_file_takeout_download($page) { $file_guid = $page[0]; $file_name = $file_guid . '.zip'; $file_path = elgg_get_data_path(); if (file_exists($file_path . $file_name)) { $mime = "application/octet-stream"; header("Pragma: public"); header("Content-type: {$mime}"); header("Content-Disposition: attachment; filename=\"{$file_name}\""); ob_clean(); flush(); readfile($file_path . $file_name); exit; } else { register_error(elgg_echo("file:downloadfailed")); forward('/file_takeout'); } }
/** * @param string $name The logging channel * @param HandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, etc. * @param callable[] $processors Optional array of processors */ public function __construct($name, array $handlers = array(), array $processors = array()) { parent::__construct($name, $handlers, $processors); // set handler $elgg_log_level = _elgg_services()->logger->getLevel(); if ($elgg_log_level == \Elgg\Logger::OFF) { // always log errors $elgg_log_level = \Elgg\Logger::ERROR; } $handler = new RotatingFileHandler(elgg_get_data_path() . 'elasticsearch/client.log', 0, $elgg_log_level); // create correct folder structure $date = date('Y/m/'); $path = elgg_get_data_path() . "elasticsearch/{$date}"; if (!is_dir($path)) { mkdir($path, 0755, true); } $handler->setFilenameFormat('{date}_{filename}', 'Y/m/d'); $this->pushHandler($handler); // set logging processor $processor = new IntrospectionProcessor(); $this->pushProcessor($processor); }
register_error(elgg_echo('translation_editor:action:add_custom_key:invalid_chars')); forward(REFERER); } if (elgg_language_key_exists($key, 'en')) { register_error(elgg_echo('translation_editor:action:add_custom_key:exists')); forward(REFERER); } // save $custom_translations = translation_editor_get_plugin('en', 'custom_keys'); if (!empty($custom_translations)) { $custom_translations = $custom_translations['en']; } else { $custom_translations = array(); } $custom_translations[$key] = $translation; $base_dir = elgg_get_data_path() . 'translation_editor' . DIRECTORY_SEPARATOR; if (!file_exists($base_dir)) { mkdir($base_dir, 0755, true); } $location = $base_dir . 'custom_keys' . DIRECTORY_SEPARATOR; if (!file_exists($location)) { mkdir($location, 0755, true); } $file_contents = '<?php' . PHP_EOL; $file_contents .= 'return '; $file_contents .= var_export($custom_translations, true); $file_contents .= ';' . PHP_EOL; if (file_put_contents($location . 'en.php', $file_contents)) { // invalidate cache elgg_flush_caches(); system_message(elgg_echo('translation_editor:action:add_custom_key:success'));
if (empty($vars['entity']->etfootlink)) { $vars['entity']->etfootlink = "#ccc"; } echo elgg_view('input/text', array('name' => 'params[etfootlink]', 'value' => $vars['entity']->etfootlink, 'class' => 'easytheme')); echo "<br /><br /><p>[15] Footer :: link hover colour <em>(Theme default = #666)</em></p> "; if (empty($vars['entity']->etfoothov)) { $vars['entity']->etfoothov = "#666"; } echo elgg_view('input/text', array('name' => 'params[etfoothov]', 'value' => $vars['entity']->etfoothov, 'class' => 'easytheme')); echo "<br /><br /><p>[16] Text & Buttons Colour (1) <em>(Theme default = #2f5980)</em></p> "; if (empty($vars['entity']->etcolor1)) { $vars['entity']->etcolor1 = "#2f5980"; } echo elgg_view('input/text', array('name' => 'params[etcolor1]', 'value' => $vars['entity']->etcolor1, 'class' => 'easytheme')); echo "<br /><br /><p>[17] Text & Buttons Colour (2) <em>(Theme default = #a95e27)</em></p> "; if (empty($vars['entity']->etcolor2)) { $vars['entity']->etcolor2 = "#a95e27"; } echo elgg_view('input/text', array('name' => 'params[etcolor2]', 'value' => $vars['entity']->etcolor2, 'class' => 'easytheme')); echo "<br /><br /><p>[18] Custom Index :: Module top bar colour <em>(Theme default = #181a2f)</em></p> "; if (empty($vars['entity']->etmod)) { $vars['entity']->etmod = "#181a2f"; } echo elgg_view('input/text', array('name' => 'params[etmod]', 'value' => $vars['entity']->etmod, 'class' => 'easytheme')); echo "<br /><br /><p>[19] <strong> To Replace the site name with a Logo image</strong> <em>(optional)</em>:<br />~ Save your logo in 'mod/easytheme/graphics' <br /> ~ Open the file 'mod/easytheme/views/default/page/elements/header_logo.php'<br /> ~ Remove the 'h1' tags, and everything in between.<br /> ~ Replace with the code for your logo image.<br /> ~ Save the file.</p><br /><p>[20] <strong>To change the Favicon icon</strong> <em>(optional)</em>: Swap your sites icon with the elgg favicon icon in <strong>'mod/easytheme/graphics'</strong></p><br /><br /><p>[21] <strong>Site Introduction</strong> Write a short introduction to your site - <em>(This will appear at the top of the custom index page. Be careful to copy/paste from a text file - otherwise it's easy to paste unwanted mark-up into the box.)</em></p>"; $myFile = elgg_get_data_path() . "easytheme/intro.php"; $fh = fopen($myFile, 'r'); $etintrofile = fread($fh, filesize($myFile)); fclose($fh); echo elgg_view('input/longtext', array('name' => 'params[etintro]', 'value' => $etintrofile, 'class' => 'easytheme')); echo "<br /><p class='et-admin-red'><strong>Now save your settings.</strong></p>";
$etfootlink = elgg_get_plugin_setting('etfootlink', 'easytheme'); $etfoothov = elgg_get_plugin_setting('etfoothov', 'easytheme'); $etfoottext = elgg_get_plugin_setting('etfoottext', 'easytheme'); $etsearch = elgg_get_plugin_setting('etsearch', 'easytheme'); $etheadh = elgg_get_plugin_setting('etheadh', 'easytheme'); $etmenu = elgg_get_plugin_setting('etmenu', 'easytheme'); $etintro = elgg_get_plugin_setting('etintro', 'easytheme'); $etborder = elgg_get_plugin_setting('etborder', 'easytheme'); $etborderwidth = elgg_get_plugin_setting('etborderwidth', 'easytheme'); $etshadow = elgg_get_plugin_setting('etshadow', 'easytheme'); //this bit writes the file... $file = elgg_get_data_path() . "easytheme/cssinc.php"; $fileHandle = fopen($file, 'w') or die("Error opening file"); $data = "body {background: {$et_bkimg};}\n\n.elgg-button-submit {\n\tcolor: white;\n\ttext-shadow: 1px 1px 0px black;\n\ttext-decoration: none;\n\tborder: 1px solid #000;\n\tbackground: {$etcolor2} url(<?php echo elgg_get_site_url(); ?>_graphics/button_graduation.png) repeat-x left 10px;\n}\n\n.elgg-button-submit:hover {\n\tborder-color: #000;\n\ttext-decoration: none;\n\tcolor: white;\n\tbackground: {$etcolor1} url(<?php echo elgg_get_site_url(); ?>_graphics/button_graduation.png) repeat-x left 10px;\n}\n\n.elgg-breadcrumbs > li > a:hover {\n\tcolor: {$etcolor1};\n\ttext-decoration: underline;\n}\n\n.elgg-menu-site-more > li > a:hover {\n\tbackground: {$etcolor1}; \n\tcolor: white;\n}\n\n.elgg-menu-page a:hover {\n\tbackground-color: {$etcolor1}; \n\tcolor: white;\n\ttext-decoration: none;\n}\n\n.elgg-menu-owner-block li a:hover {\n\tbackground-color: {$etcolor1}; \n\tcolor: white;\n\ttext-decoration: none;\n}\n\na {\n\tcolor: {$etcolor2};\n}\n\nh1, h2, h3, h4, h5, h6 {\n\tfont-weight: bold;\n\tcolor: {$etcolor1}; \n}\n\n.elgg-heading-basic {\n\tcolor: {$etcolor1};\n\tfont-size: 1.2em;\n\tfont-weight: bold;\n}\n\n.elgg-loud {\n\tcolor: {$etcolor1}; \n}\n\n\n\n.elgg-menu-page li.elgg-state-selected > a {\n\tbackground-color: {$etcolor1}; \n\tcolor: white;\n}\n\n.elgg-heading-site, .elgg-heading-site:hover {\n\tfont-size: 2em;\n\tline-height: 1.4em;\n\tcolor: #000;\n\tfont-style: italic;\n\tfont-family: Georgia, times, serif;\n\ttext-shadow: 1px 2px 4px #333333;\n\ttext-decoration: none;\n background: #fff;\n\tpadding: 20px;\n\tpadding-left: 15px;\n}\n\n.elgg-page-default .elgg-page-header .elgg-inner {\n\twidth: {$etpgwidth};\n\theight: {$etheadh};\n background: {$et_headimg};\n}\n\n.elgg-page-default {\n\twidth: {$etpgwidth};\n\tmargin: 0px auto; \n\tborder-right: {$etborderwidth} solid {$etborder};\n background: #ffffff;\n border-left: {$etborderwidth} solid {$etborder};\n\t-moz-box-shadow: 0 0 {$etshadow} #888;\n\t-webkit-box-shadow: 0 0 {$etshadow} #888;\n\tbox-shadow: 0 0 {$etshadow} #181a2f;\n}\n\n.elgg-heading-site, .elgg-heading-site:hover {\n\t-webkit-border-bottom-right-radius: 24px;\n\t-moz-border-bottom-right-radius: 24px;\n\tborder-bottom-right-radius: 24px;\n\topacity: 0.6;\n\t-ms-filter:\"progid:DXImageTransform.Microsoft.Alpha(Opacity=60)\";\n filter: alpha(opacity=60);\n}\n\n.elgg-page-footer {\n\theight: {$etfooth};\n}\n\n.elgg-page-footer {\n color: {$etfoottext}; \n background: {$etfootbk}; \n}\n.elgg-page-footer a:link {\n\tcolor: {$etfootlink};\n}\n \n.elgg-page-footer a:hover {\n\tcolor: {$etfoothov};\n}\n#login-dropdown {\n\tdisplay:none;\n\tposition: absolute;\n\ttop: 10px;\n\tright: 0;\n\tz-index: 100; \n\tmargin-right: 10px; \n}\n\n\n.elgg-menu-item-report-this{\n margin-left: 10px;\n\tmargin-top: 5px;\n}\n\n\n\n\n.elgg-page-default {\n\tmin-width: {$etpgwidth};\n}\n\n.elgg-page-default .elgg-page-body > .elgg-inner {\n\twidth: {$etpgwidth};\n\tmargin: 0 auto; \n\t\n}\n\n.elgg-page-default .elgg-page-footer > .elgg-inner {\n\twidth: {$etpgwidth}; \n\tmargin: 0 auto;\n\tpadding: 5px 0;\n\tborder-top: 1px solid #DEDEDE;\n\t\n}\n\n.elgg-page-header .elgg-search {\n margin-top: {$etsearch};\n\tmargin-bottom: 2px;\n margin-right: 5px;\n\theight: 23px;\n\tposition: absolute;\n\tright: 0;\n \n}\n\n.elgg-menu-footer-default {\n\tfloat: right;\n\tpadding-right: 10px;\n}\n\n.elgg-menu-site-default{\n\tbackground: {$etmenu}; \n\tpadding-top: 5px; \n\twidth: 100%;\n}"; fwrite($fileHandle, $data); fclose($fileHandle); // close the file since we're done if (empty($etintro)) { } else { //this bit writes the file... $file2 = elgg_get_data_path() . "easytheme/intro.php"; $fileHandle = fopen($file2, 'w') or die("Error opening file"); $data = $etintro; fwrite($fileHandle, $data); fclose($fileHandle); elgg_unset_plugin_setting('etintro', 'easytheme'); } elgg_invalidate_simplecache(); elgg_reset_system_cache(); system_message(elgg_echo('plugins:settings:save:ok', array($plugin_name))); forward(REFERER);
<?php $file = get_input('file'); $file = sanitise_filepath($file, false); // no file if (empty($file)) { forward(REFERER); } $file_path = elgg_get_data_path() . $file; // file doesn't exist or is directory if (!file_exists($file_path) || is_dir($file_path)) { forward(REFERER); } $contents = file_get_contents($file_path); // empty file if (empty($contents)) { forward(REFERER); } $filename = basename($file_path); $mimetype = 'application/octet-stream'; if (is_callable('finfo_open')) { $finfo = finfo_open(FILEINFO_MIME_TYPE); $mimetype = finfo_file($finfo, $file_path); } header("Pragma: public"); header("Content-type: {$mimetype}"); header("Content-Disposition: attachment; filename=\"{$filename}\""); header("Content-Length: " . strlen($contents)); echo $contents; exit;
if (empty($icontime)) { return; } $user_guid = $user->getGUID(); $filehandler = new ElggFile(); $filehandler->owner_guid = $user_guid; $filehandler->setFilename("profile/{$user_guid}master.jpg"); if ($filehandler->exists()) { $image_data = $filehandler->grabFile(); } if (empty($image_data)) { return; } $x1 = $user->x1; $x2 = $user->x2; $y1 = $user->y1; $y2 = $user->y2; if ($x1 === null) { return $image_data; } // apply user cropping config // create temp file for resizing $tmpfname = tempnam(elgg_get_data_path(), 'elgg_avatar_service'); $handle = fopen($tmpfname, 'w'); fwrite($handle, $image_data); fclose($handle); // apply resizing $result = get_resized_image_from_existing_file($tmpfname, 2048, 2048, true, $x1, $y1, $x2, $y2, false); // remove temp file unlink($tmpfname); echo $result;
function translation_editor_delete_translation($current_language, $plugin) { $result = false; if (!empty($current_language) && !empty($plugin)) { $filename = elgg_get_data_path() . "translation_editor" . DIRECTORY_SEPARATOR . $current_language . DIRECTORY_SEPARATOR . $plugin . ".json"; if (file_exists($filename)) { $result = unlink($filename); } } return $result; }
/** * Disables the simple cache. * * @warning Simplecache is also purged when disabled. * * @see elgg_register_simplecache_view() * @return void * @since 1.8.0 */ function elgg_disable_simplecache() { if (elgg_get_config('simplecache_enabled')) { datalist_set('simplecache_enabled', 0); elgg_set_config('simplecache_enabled', 0); // purge simple cache _elgg_rmdir(elgg_get_data_path() . "views_simplecache"); } }
/** * Log to file * * @param type $msg * @return type */ function registration_randomizer_log($msg, $all = true) { if (elgg_get_config('rr_debug') !== true) { return; } if (!$all) { file_put_contents(elgg_get_data_path() . 'rr_log.log', $msg . "\n", FILE_APPEND); return; } $data = $_REQUEST; $data['referrer'] = filter_input(INPUT_SERVER, 'HTTP_REFERER'); $data['remote_ip'] = filter_input(INPUT_SERVER, 'REMOTE_ADDR'); $data['remote_ua'] = filter_input(INPUT_SERVER, 'HTTP_USER_AGENT'); $data['time'] = date("r"); $data['error'] = $msg; file_put_contents(elgg_get_data_path() . 'rr_log.log', print_r($data, true), FILE_APPEND); }
/** * Get the different instances of the H5P core. * * @param string $type * @return \H5PElgg|\H5PCore|\H5PContentValidator|\H5PExport|\H5PStorage|\H5PValidator */ function h5p_get_instance($type) { static $interface, $core; if ($interface === null) { $interface = new \H5P\Elgg(); $language = get_current_language(); $path = elgg_get_data_path() . '/h5p'; $url = elgg_get_site_url() . 'serve-file/'; $core = new H5PCore($interface, $path, $url, $language); } switch ($type) { case 'validator': return new H5PValidator($interface, $core); case 'storage': return new H5PStorage($interface, $core); case 'contentvalidator': return new H5PContentValidator($interface, $core); case 'export': return new H5PExport($interface, $core); case 'interface': return $interface; case 'core': return $core; } }
/** * Returns an array of documents to be deleted from the elastic index * * @return array */ function elasticsearch_get_documents_for_deletion() { $plugin = elgg_get_plugin_from_id('elasticsearch'); $locator = new \Elgg\EntityDirLocator($plugin->getGUID()); $documents_path = elgg_get_data_path() . $locator->getPath() . 'documents_for_deletion/'; $dir = @opendir($documents_path); if (!$dir) { return []; } $documents = []; while (($file = readdir($dir)) !== false) { if (is_dir($file)) { continue; } $contents = unserialize(file_get_contents($documents_path . $file)); if (!is_array($contents)) { continue; } $documents[$file] = $contents; } return $documents; }
} // groups if (elgg_is_active_plugin('groups')) { echo elgg_view_module('featured', elgg_echo("custom:groups"), $vars['groups'], $mod_params); } ?> </div> </div> <div class="elgg-col elgg-col-1of2"> <div class="elgg-inner pvm"> <div class="et-module-message"> <?php include elgg_get_data_path() . "easytheme/intro.php"; ?> </div> <?php // a view for plugins to extend echo elgg_view("index/righthandside"); // files echo elgg_view_module('featured', elgg_echo("custom:members"), $vars['members'], $mod_params); // bookmarks if (elgg_is_active_plugin('bookmarks')) { echo elgg_view_module('featured', elgg_echo("custom:bookmarks"), $vars['bookmarks'], $mod_params); } ?>
<?php /** * EasyTheme * * Contains CSS for EasyTheme * */ include_once elgg_get_data_path() . "easytheme/cssinc.php";
function backup_tool_restore_backup($options = array()) { global $CONFIG; $dbuser = $CONFIG->dbuser; //get database user $dbpass = $CONFIG->dbpass; //get database password $dbname = $CONFIG->dbname; //get database name $dbhost = $CONFIG->dbhost; //get path to default backup dir specified in plugin settings $backup_dir = elgg_get_plugin_setting('backup_dir', 'backup-tool'); $backip_file_name = $options['file_name']; $backup_data_dir = $backup_dir . str_replace(".tar.gz", "", $backip_file_name) . "/"; $backup_file_path = $backup_dir . $backip_file_name; mkdir($backup_data_dir); //extract files from backup file into the new backup's dir $cmd = "cd {$backup_data_dir} && tar xfz {$backup_file_path}"; exec($cmd); //restore dump $dump_dir = $backup_data_dir . "dump/"; $dump_file_path = $dump_dir . $dbname . ".sql"; $cmd = "mysql --user={$dbuser} --password={$dbpass} --host={$dbhost} {$dbname} < {$dump_file_path}"; exec($cmd); //restore data folder $data_dir = $backup_data_dir . "dataroot/"; if (is_dir($data_dir)) { $datafolder = elgg_get_data_path(); $cmd = "cd {$data_dir} && cp -R . {$datafolder}"; exec($cmd); } //restore site folder $site_dir = $backup_data_dir . "siteroot/"; if (is_dir($site_dir)) { $sitefolder = elgg_get_root_path(); $cmd = "cd {$site_dir} && cp -R . {$sitefolder}"; exec($cmd); } //remove backup's dir $cmd = "rm {$backup_data_dir} -R"; exec($cmd); return true; }
/** * Returns the image for the given set of parameters * * @param array $params parameters for fetching the image * * @return string */ function avatar_service_get_image($params) { $user = elgg_extract('user', $params); $size = elgg_extract('size', $params); $image_data = ''; // retrieve image data // views need to profile the largest quality square image if ($user) { $image_data = elgg_view('avatar_service/icon/profile', $params); } if (empty($image_data)) { $image_data = elgg_view('avatar_service/icon/default', $params); } // create temp file for resizing $tmpfname = tempnam(elgg_get_data_path(), 'elgg_avatar_service'); $handle = fopen($tmpfname, 'w'); fwrite($handle, $image_data); fclose($handle); // apply resizing $result = get_resized_image_from_existing_file($tmpfname, $size, $size, true, 0, 0, 0, 0, true); // remove temp file unlink($tmpfname); return $result; }
/** * Used to Pull in the latest avatar from facebook. * * @access public * @param array $user * @param string $file_location * @return void */ function facebook_connect_update_user_avatar($user, $file_location) { $path = elgg_get_data_path(); $tempfile = $path . $user->getGUID() . 'img.jpg'; $imgContent = file_get_contents($file_location); $fp = fopen($tempfile, "w"); fwrite($fp, $imgContent); fclose($fp); $sizes = array('topbar' => array(16, 16, TRUE), 'tiny' => array(25, 25, TRUE), 'small' => array(40, 40, TRUE), 'medium' => array(100, 100, TRUE), 'large' => array(200, 200, FALSE), 'master' => array(550, 550, FALSE)); $filehandler = new ElggFile(); $filehandler->owner_guid = $user->getGUID(); foreach ($sizes as $size => $dimensions) { $image = get_resized_image_from_existing_file($tempfile, $dimensions[0], $dimensions[1], $dimensions[2]); $filehandler->setFilename("profile/{$user->guid}{$size}.jpg"); $filehandler->open('write'); $filehandler->write($image); $filehandler->close(); } // update user's icontime $user->icontime = time(); return TRUE; }
<?php $current_dir = elgg_extract('current_dir', $vars); $current_dir = sanitise_filepath($current_dir); $root_dir = elgg_get_data_path() . $current_dir; if (!is_dir($root_dir)) { echo elgg_format_element('div', [], elgg_echo('dataroot_browser:list:invalid_dir')); return; } $dir_data = scandir($root_dir); // breadcrumb echo elgg_view('dataroot_browser/breadcrumb', ['current_dir' => $current_dir]); // go through all folders/file in this dir $dir_items = []; $file_items = []; $dir_classes = ['dataroot_browser_name', 'dataroot_browser_folder']; $file_classes = ['dataroot_browser_name', 'dataroot_browser_file']; $posix_getpwuid = is_callable('posix_getpwuid'); $base_url = 'admin/administer_utilities/dataroot_browser'; $download_url = 'action/dataroot_browser/download'; $delete_url = 'action/dataroot_browser/delete_file'; $dh = new DirectoryIterator($root_dir); foreach ($dh as $file) { $cells = []; if ($file->isDot()) { continue; } $last_modified = date('Y/m/d H:i:s', $file->getMTime()); if ($posix_getpwuid) { $owner = posix_getpwuid($file->getOwner()); $owner = elgg_extract('name', $owner, $file->getOwner());
/** * Clears tree html cache * * @param ElggEntity $entity the root entity to flush the cache for * * @return void */ function pages_tools_flush_tree_html_cache(ElggEntity $entity) { if (!$entity instanceof ElggEntity) { return; } $locator = new Elgg_EntityDirLocator($entity->getGUID()); $cache_dir = elgg_get_data_path() . $locator->getPath() . 'tree_cache/'; $dh = opendir($cache_dir); if (empty($dh)) { return; } while (($filename = readdir($dh)) !== false) { // make sure we have a file if (!is_file($cache_dir . $filename)) { continue; } unlink($cache_dir . $filename); } }
<?php /** * Show a notification to the editor that some custom translations were cleaned */ $current_translation = elgg_extract('current_language', $vars); $file_name = elgg_get_data_path() . 'translation_editor' . DIRECTORY_SEPARATOR . $current_translation . DIRECTORY_SEPARATOR . 'translation_editor_cleanup.json'; if (!file_exists($file_name)) { // nothing was cleaned up return; } $content = file_get_contents($file_name); $cleaned = json_decode($content, true); $count = 0; foreach ($cleaned as $plugin_id => $removed_translations) { $count += count($removed_translations); } $download = elgg_view('output/url', ['text' => elgg_echo('download'), 'href' => "action/translation_editor/download_cleanup?language={$current_translation}", 'is_action' => true, 'class' => 'elgg-button elgg-button-action float-alt']); $remove = elgg_view('output/url', ['text' => strtolower(elgg_echo('delete')), 'href' => "action/translation_editor/remove_cleanup?language={$current_translation}", 'is_action' => true, 'confirm' => elgg_echo('deleteconfirm')]); $content = elgg_format_element('div', ['class' => 'elgg-output mtn'], elgg_echo('translation_editor:cleanup:description', [$count, $remove])); echo elgg_format_element('div', ['class' => 'elgg-message elgg-state-notice mbm ptm pbl translation-editor-cleanup'], $download . $content);
<?php $path = get_input('path'); $path = sanitise_filepath($path, false); if (empty($path)) { register_error(elgg_echo('error:missing_data')); forward(REFERER); } $logging_base_dir = elgg_get_data_path() . 'elasticsearch/'; // check if the requested file exists $filename = $logging_base_dir . $path; if (!file_exists($filename)) { register_error(elgg_echo('error:404:content')); forward(REFERER); } // get contents $contents = file_get_contents($filename); // begin download header('Pragma: public'); header('Content-Type: text/plain'); header('Content-Disposition: Attachment; filename=' . basename($filename)); header('Content-Length: ' . strlen($contents)); echo $contents; exit;
echo elgg_view("index/lefthandside"); ?> <div class="et-module-text-left"> <?php include elgg_get_data_path() . "teranga_theme/textleft.php"; ?> </div> </div> </div> <div class="elgg-col elgg-col-1of2"> <div class="elgg-inner pvm"> <?php // a view for plugins to extend echo elgg_view("index/righthandside"); ?> <div class="et-module-text-right"> <?php include elgg_get_data_path() . "teranga_theme/textright.php"; ?> </div> </div> </div> </div> </div> </body> </html>
if ($file->getError() !== 0) { register_error(elgg_get_friendly_upload_error($file->getError())); forward(REFERER); } $site = elgg_get_site_entity(); $validator = h5p_get_instance('validator'); $interface = h5p_get_instance('interface'); /* echo "<pre>"; var_dump($file); var_dump($file->getPathName()); var_dump(file_exists($file->getPathName())); var_dump(elgg_get_data_path() . "h5p/{$file->getClientOriginalName()}"); die; */ $h5p_dir = elgg_get_data_path() . "h5p/"; if (!file_exists($h5p_dir)) { mkdir($h5p_dir); } // Move so core can validate the file extension. //rename($file->getPathName(), $interface->getUploadedH5pPath()); rename($file->getPathName(), "{$h5p_dir}{$file->getClientOriginalName()}"); if ($validator->isValidPackage()) { $storage = h5p_get_instance('storage'); //$storage->savePackage(); //return $storage->contentId; } // Parse and save the libraries included in the package //$library_parser = new \H5P\Library\LibrarySaver(new \Elgg\Database\EntityTable()); //$library_parser->setPackage($file); /*
/** * Remove the custom translations for a plugin * * @param string $current_language the language to remove * @param string $plugin the plugin to remove * * @return bool */ function translation_editor_delete_translation($current_language, $plugin) { if (empty($current_language) || empty($plugin)) { return false; } $filename = elgg_get_data_path() . 'translation_editor' . DIRECTORY_SEPARATOR . $current_language . DIRECTORY_SEPARATOR . $plugin . '.json'; if (file_exists($filename)) { return unlink($filename); } return true; }