/**
  *
  */
 function output()
 {
     global $application;
     ob_start();
     phpinfo(1);
     $content = ob_get_contents();
     ob_end_clean();
     $flag = true;
     while ($flag) {
         $pos = _ml_strpos($content, "\n");
         $line = _ml_substr($content, 0, $pos);
         $content = _ml_substr($content, $pos + 1);
         if (_ml_strpos($line, "System")) {
             $line = _ml_substr($line, 0, _ml_strrpos($line, "<"));
             $line = _ml_substr($line, 0, _ml_strrpos($line, "<"));
             $line = _ml_substr($line, _ml_strrpos($line, ">") + 1);
             $flag = false;
         }
     }
     $OS = $line;
     $request = new Request();
     $request->setView('PHPInfo');
     $link = $request->getURL();
     global $db_link;
     $template_contents = array("ProductVersion" => PRODUCT_VERSION_NUMBER, "ProductVersionType" => PRODUCT_VERSION_TYPE, "ProductReleaseDate" => PRODUCT_VERSION_DATE, "CoreVersion" => CORE_VERSION, "ModulesList" => $this->outputModules(), "phpVersion" => PHP_VERSION, "MySQLVersion" => mysqli_get_server_info($db_link), "ServerOS" => $OS, "WebServerVersion" => $_SERVER["SERVER_SOFTWARE"], "PHPInfoLink" => $link);
     $this->_Template_Contents = $template_contents;
     $application->registerAttributes($this->_Template_Contents);
     return modApiFunc('TmplFiller', 'fill', "tools/server_info/", "container.tpl.html", array());
 }
 function outputPrevOperand()
 {
     if (!$this->POST['Formula']) {
         return "_";
     }
     $pos = _ml_strrpos($this->POST['Formula'], ' ');
     if ($pos === false) {
         return $this->POST['Formula'];
     } else {
         return _ml_substr($this->POST['Formula'], $pos + 1);
     }
 }
Exemplo n.º 3
0
 /**
  *
  */
 function outputBackupFilesList()
 {
     if (_ml_strtoupper(_ml_substr(PHP_OS, 0, 3)) === 'WIN') {
         $retval = modApiFunc('TmplFiller', 'fill', "tools/backup/", "item_win_os.tpl.html", array());
         return $retval;
     }
     global $application;
     $retval = "";
     $directory = $application->getAppIni('PATH_SYSTEM_DIR') . "backup/";
     $n = 0;
     $backup_list = array();
     if ($dir = dir($directory)) {
         while ($file = $dir->read()) {
             if (_ml_substr($file, _ml_strrpos($file, '.') + 1) == "abi") {
                 $backup_file_name = _ml_substr($file, 0, _ml_strrpos($file, '.'));
                 if (file_exists($directory . $backup_file_name . ".tar.gz")) {
                     $backup_info = _parse_ini_file($directory . $backup_file_name . ".abi");
                     if (isset($backup_info["asc_version"]) && $backup_info["asc_version"] == PRODUCT_VERSION_NUMBER) {
                         $request = new Request();
                         $request->setView('Downdoad');
                         $request->setKey('directory', 'backup');
                         $request->setKey('file', $backup_file_name . ".tar.gz");
                         $DownloadLink = $request->getURL();
                         $request = new Request();
                         $request->setView('AdminBackup');
                         $request->setAction('BackupDeleteAction');
                         $request->setKey('file', $backup_file_name);
                         $DeleteFormAction = $request->getURL();
                         $this->_Template_Contents = array('BackupFileName' => $backup_file_name, 'DownloadLink' => $DownloadLink, 'InfoLink' => "", 'BackupFileDate' => modApiFunc("Localization", "timestamp_date_format", $backup_info['backup_date']) . " " . modApiFunc("Localization", "timestamp_time_format", $backup_info['backup_date']), 'BackupFileSize' => modApiFunc("Localization", "num_format", $backup_info['backup_file_size'] / 1024) . " Kb", 'N' => $n);
                         $backup_list[] = $this->_Template_Contents;
                         $n++;
                     }
                 }
             }
         }
         $dir->close();
     }
     for ($i = sizeof($backup_list) - 1; $i >= 0; $i--) {
         $this->_Template_Contents = $backup_list[$i];
         $application->registerAttributes($this->_Template_Contents);
         $retval .= modApiFunc('TmplFiller', 'fill', "tools/backup/", "item.tpl.html", array());
     }
     if ($n == 0) {
         $retval .= modApiFunc('TmplFiller', 'fill', "tools/backup/", "item_na.tpl.html", array());
     }
     $retval .= modApiFunc('TmplFiller', 'fill', "tools/backup/", "item_empty.tpl.html", array());
     return $retval;
 }
Exemplo n.º 4
0
/**
 * Read recursively stated directory and include all files
 * with specified extension form it.
 *
 * @ Check file errors, we have to use IO class
 * @access  private
 * @param string $directory The path to directory which will be read
 * @param string $file_extension The file extension which will be included
 * @return array List of included files
 */
function DirRead($directory, $file_extension)
{
    $insertions_list = array();
    if ($dir = @dir($directory)) {
        while ($file = $dir->read()) {
            if (!is_dir($directory . $file)) {
                if (_ml_substr($file, _ml_strrpos($file, '.')) == $file_extension) {
                    _use($directory . $file);
                    array_push($insertions_list, _ml_substr($file, 0, _ml_strrpos($file, '.')));
                }
            } elseif ($file != '..' && $file != '.') {
                $insertions_list = array_merge($insertions_list, DirRead($directory . $file . '/', $file_extension));
            }
        }
        $dir->close();
    }
    return $insertions_list;
}
Exemplo n.º 5
0
 function createXML($tagID, $parentXML = '')
 {
     // Creates XML string for a tag object
     // Specify parent XML to insert new string into parent XML
     $final = '';
     // Get Reference to tag object
     $tag =& $this->xml_index[$tagID];
     $name = $tag->name;
     $contents = $tag->contents;
     $attr_count = count($tag->attributes);
     $child_count = count($tag->tags);
     $empty_tag = $tag->contents == '' ? true : false;
     // Create intial tag
     if ($attr_count == 0) {
         // No attributes
         if ($empty_tag === true) {
             $final = "<{$name} />";
         } else {
             $final = "<{$name}>{$contents}</{$name}>";
         }
     } else {
         // Attributes present
         $attribs = '';
         foreach ($tag->attributes as $key => $value) {
             $attribs .= ' ' . $key . "=\"{$value}\"";
         }
         if ($empty_tag === true) {
             $final = "<{$name}{$attribs} />";
         } else {
             $final = "<{$name}{$attribs}>{$contents}</{$name}>";
         }
     }
     // Search for children
     if ($child_count > 0) {
         foreach ($tag->tags as $childID) {
             $final = $this->createXML($childID, $final);
         }
     }
     if ($parentXML != '') {
         // Add tag XML to parent XML
         $stop1 = _ml_strrpos($parentXML, '</');
         $stop2 = _ml_strrpos($parentXML, ' />');
         if ($stop1 > $stop2) {
             // Parent already has children
             $begin_chunk = _ml_substr($parentXML, 0, $stop1);
             $end_chunk = _ml_substr($parentXML, $stop1, _ml_strlen($parentXML) - $stop1 + 1);
             $final = $begin_chunk . $final . $end_chunk;
         } elseif ($stop2 > $stop1) {
             // No previous children
             $spc = _ml_strpos($parentXML, ' ', 0);
             $parent_name = _ml_substr($parentXML, 1, $spc - 1);
             if ($spc != $stop2) {
                 // Attributes present
                 $parent_attribs = _ml_substr($parentXML, $spc, $stop2 - $spc);
             } else {
                 // No attributes
                 $parent_attribs = '';
             }
             $final = "<{$parent_name}{$parent_attribs}>{$final}</{$parent_name}>";
         }
     }
     return $final;
 }
 /**
  * Returns a "clear" visible name for the Person Info variant.
  *
  * @author Oleg Vlasenko
  * @param string $variant_name - vsible variant name. For default variants
  *               a visible name begins with substring "[default]"
  * @return string a visible name without substring "[default]"
  */
 function getClearVariantName($variant_name)
 {
     $pos = _ml_strrpos($variant_name, "]");
     if ($pos != false) {
         $tail = _ml_substr($variant_name, $pos + 1);
         return $tail;
     } else {
         return $variant_name;
     }
 }
 /**
  *            CZ layout config     .                                   .
  */
 function static_parse_layout_config_file($layout_file_path)
 {
     global $zone;
     global $application;
     $app_root_path = $application->getAppIni("PATH_ASC_ROOT");
     $config = array();
     $error = array();
     # Use $layout_file_path If it exists and readable
     if (file_exists($layout_file_path) && is_readable($layout_file_path) && is_file($layout_file_path)) {
         $config['PATH_LAYOUTS_CONFIG_FILE'] = $layout_file_path;
         $config['PATH_LAYOUTS_CONFIG_FILE'] = strtr($config['PATH_LAYOUTS_CONFIG_FILE'], '\\', '/');
         $isDefaultLayoutFileUsed = false;
         # Defining layout.ini directory location
         $config['DIR_LAYOUTS_CONFIG_FILE'] = dirname($config['PATH_LAYOUTS_CONFIG_FILE']) . '/';
         $config['DIR_LAYOUTS_CONFIG_FILE'] = strtr($config['DIR_LAYOUTS_CONFIG_FILE'], '\\', '/');
     } else {
         if ($zone != 'AdminZone') {
             $error = array("MAIN_ERROR_PARAMETERS" => array("CODE" => "CORE_056"));
             return $error;
         }
     }
     if (isset($config['DIR_LAYOUTS_CONFIG_FILE'])) {
         # Defining SITE_URL and SITE_PATH
         $layout_array = @_parse_cz_layout_ini_file($config['PATH_LAYOUTS_CONFIG_FILE'], true);
         # convert all array keys to upper case
         $layout_array = array_change_key_case($layout_array, CASE_UPPER);
         foreach ($layout_array as $layout_section => $layout_value) {
             $layout_array[$layout_section] = array_change_key_case($layout_value, CASE_UPPER);
         }
         # Read [Site] section from layout.ini
         if (isset($layout_array['SITE'])) {
             if (isset($layout_array['SITE']['SITEURL'])) {
                 # Defining SITE_URL
                 $config['SITE_URL'] = $layout_array['SITE']['SITEURL'];
                 # check if SITE_URL is empty or ./ then set to current
                 if ($config['SITE_URL'] == '' || $config['SITE_URL'] == './') {
                     $config['SITE_URL'] = "http://" . $_SERVER['SERVER_NAME'] . _ml_substr($_SERVER['PHP_SELF'], 0, _ml_strrpos($_SERVER['PHP_SELF'], '/') + 1);
                 }
             } else {
                 $error = array("MAIN_ERROR_PARAMETERS" => array("CODE" => "CORE_032", "FILE" => $config['PATH_LAYOUTS_CONFIG_FILE'], "SECTION" => 'Site', "DIRECTIVE" => "SiteURL"));
                 return $error;
             }
             if (isset($layout_array['SITE']['SITEPATH'])) {
                 # Defining SITE_PATH
                 $config['SITE_PATH'] = $layout_array['SITE']['SITEPATH'];
                 $config['SITE_PATH'] = strtr($config['SITE_PATH'], '\\', '/');
             } elseif (isset($application->appIni["PATH_ASC_ROOT"])) {
                 # Defining SITE_PATH
                 $config['SITE_PATH'] = $application->appIni["PATH_ASC_ROOT"];
                 $config['SITE_PATH'] = strtr($config['SITE_PATH'], '\\', '/');
             } else {
                 $error = array("MAIN_ERROR_PARAMETERS" => array("CODE" => "CORE_033", "FILE" => $config['PATH_LAYOUTS_CONFIG_FILE'], "SECTION" => 'Site', "DIRECTIVE" => "SitePATH"));
                 return $error;
             }
             if (isset($layout_array['SITE']['SITEHTTPSURL'])) {
                 $config['SITE_HTTPS_URL'] = $layout_array['SITE']['SITEHTTPSURL'];
                 if ($config['SITE_HTTPS_URL'] == "" || $config['SITE_HTTPS_URL'] == "./") {
                     $config['SITE_HTTPS_URL'] = "https://" . $_SERVER['SERVER_NAME'] . _ml_substr($_SERVER['PHP_SELF'], 0, _ml_strrpos($_SERVER['PHP_SELF'], '/') + 1);
                 }
                 $config['SITE_HTTPS_URL'] .= $config['SITE_HTTPS_URL'][_byte_strlen($config['SITE_HTTPS_URL']) - 1] != "/" ? "/" : "";
             }
             /*
             else
             {
                 $config['SITE_HTTPS_URL'] = $config['SITE_URL'];
             }
             */
         } else {
             $error = array("MAIN_ERROR_PARAMETERS" => array("CODE" => "CORE_034", "FILE" => $config['PATH_LAYOUTS_CONFIG_FILE'], "SECTION" => 'Site'));
             return $error;
         }
         # Check if SITE_PATH and SITE_URL have '/' in the line end
         $config['SITE_PATH'] = _ml_substr($config['SITE_PATH'], -1, 1) != '/' ? $config['SITE_PATH'] . '/' : $config['SITE_PATH'];
         $config['SITE_URL'] = _ml_substr($config['SITE_URL'], -1, 1) != '/' ? $config['SITE_URL'] . '/' : $config['SITE_URL'];
         # Check if SITE_PATH exists
         if (!file_exists($config['SITE_PATH'])) {
             $error = array("MAIN_ERROR_PARAMETERS" => array("CODE" => "CORE_038", "FILE" => $config['PATH_LAYOUTS_CONFIG_FILE'], "SECTION" => 'Site', "DIRECTIVE" => "SitePath = " . $config['SITE_PATH']));
             return $error;
         }
         # Define LAYOUT_TEMPLATE from layout.ini
         if (isset($layout_array['TEMPLATES']) && isset($layout_array['TEMPLATES']['TEMPLATEDIRECTORY'])) {
             # Defining LAYOUT_TEMPLATE
             $config['TEMPLATE_DIRECTORY_NAME'] = $layout_array['TEMPLATES']['TEMPLATEDIRECTORY'];
             # Check if there is '/' at the end of TEMPLATE_DIRECTORY_NAME path
             $config['TEMPLATE_DIRECTORY_NAME'] = _ml_substr($config['TEMPLATE_DIRECTORY_NAME'], -1, 1) != '/' ? $config['TEMPLATE_DIRECTORY_NAME'] . '/' : $config['TEMPLATE_DIRECTORY_NAME'];
             # Check template directory exists relative to SitePath directive
             if (file_exists($config['SITE_PATH'] . $config['TEMPLATE_DIRECTORY_NAME'])) {
                 # Path to current templates directory, based on layout.ini directive
                 $config['PATH_TEMPLATES'] = $config['SITE_PATH'] . $config['TEMPLATE_DIRECTORY_NAME'];
                 $config['URL_TEMPLATES'] = $config['SITE_URL'] . $config['TEMPLATE_DIRECTORY_NAME'];
                 $config['PATH_USERS_RESOURCES'] = $config['PATH_TEMPLATES'] . 'resources/';
                 if (isset($config['SITE_HTTPS_URL'])) {
                     $config['HTTPS_URL_TEMPLATES'] = $config['SITE_HTTPS_URL'] . $config['TEMPLATE_DIRECTORY_NAME'];
                 }
             } else {
                 $error = array("MAIN_ERROR_PARAMETERS" => array("CODE" => "CORE_035", "FILE" => $config['PATH_LAYOUTS_CONFIG_FILE'], "SECTION" => 'Templates', "DIRECTIVE" => "TemplateDirectory = " . $config['TEMPLATE_DIRECTORY_NAME']), $config['TEMPLATE_DIRECTORY_NAME'], $config['SITE_PATH']);
                 return $error;
             }
         } else {
             # If TEMPLATEDIRECTORY directive is undefined then use system templates
             $config['TEMPLATE_DIRECTORY_NAME'] = 'avactis-themes/system';
             $config['PATH_TEMPLATES'] = $app_root_path . '/' . $config['TEMPLATE_DIRECTORY_NAME'] . '/';
             $config['URL_TEMPLATES'] = $application->getAppIni('HTTP_URL') . $config['TEMPLATE_DIRECTORY_NAME'] . '/';
             $config['PATH_USERS_RESOURCES'] = $config['PATH_TEMPLATES'] . 'resources/';
             if (isset($config['SITE_HTTPS_URL'])) {
                 $config['HTTPS_URL_TEMPLATES'] = $application->getAppIni('HTTPS_URL') . $config['TEMPLATE_DIRECTORY_NAME'] . '/';
             }
         }
         # Hard-coding system templates
         $config['SYSTEM_TEMPLATE_DIRECTORY_NAME'] = 'avactis-themes/system';
         $config['SYSTEM_PATH_TEMPLATES'] = str_replace('//', '/', $app_root_path . '/' . $config['SYSTEM_TEMPLATE_DIRECTORY_NAME'] . '/');
         $config['SYSTEM_URL_TEMPLATES'] = $application->getAppIni('HTTP_URL') . $config['SYSTEM_TEMPLATE_DIRECTORY_NAME'] . '/';
         $config['SYSTEM_PATH_USERS_RESOURCES'] = $config['SYSTEM_PATH_TEMPLATES'] . 'resources/';
         if (isset($config['SITE_HTTPS_URL'])) {
             $config['SYSTEM_HTTPS_URL_TEMPLATES'] = $application->getAppIni('HTTPS_URL') . $config['SYSTEM_TEMPLATE_DIRECTORY_NAME'] . '/';
         }
     }
     return $config;
 }
Exemplo n.º 8
0
 /**
 * Function for extracting images from
 * html source. This function will look
 * through the html code supplied by add_html()
 * and find any file that ends in one of the
 * extensions defined in $obj->image_types.
 * If the file exists it will read it in and
 * embed it, (not an attachment).
 *
 * @author Dan Allen
 */
 function _findHtmlImages($images_dir)
 {
     // Build the list of image extensions
     while (list($key, ) = each($this->image_types)) {
         $extensions[] = $key;
     }
     preg_match_all('/(?:"|\')([^"\']+\\.(' . implode('|', $extensions) . '))(?:"|\')/Ui', $this->html, $images);
     for ($i = 0; $i < count($images[1]); $i++) {
         if (file_exists($images_dir . $images[1][$i])) {
             $html_images[] = $images[1][$i];
             $this->html = str_replace($images[1][$i], basename($images[1][$i]), $this->html);
         }
     }
     if (!empty($html_images)) {
         // If duplicate images are embedded, they may show up as attachments, so remove them.
         $html_images = array_unique($html_images);
         sort($html_images);
         for ($i = 0; $i < count($html_images); $i++) {
             $file = new CFile($images_dir . $html_images[$i]);
             if ($image = $file->getContent()) {
                 $ext = _ml_substr($html_images[$i], _ml_strrpos($html_images[$i], '.') + 1);
                 $content_type = $this->image_types[_ml_strtolower($ext)];
                 $this->addHtmlImage($image, basename($html_images[$i]), $content_type);
             }
         }
     }
 }
Exemplo n.º 9
0
 /**
  * Returns the directory part of the path (path may include query)
  *
  * @param string $path
  * @return string
  */
 function dirname($path)
 {
     if (!$path) {
         return false;
     }
     $i = _ml_strpos($path, '?');
     $dir = $i ? _ml_substr($path, 0, $i) : $path;
     $i = _ml_strrpos($dir, '/');
     $dir = $i ? _ml_substr($dir, 0, $i) : '/';
     $dir[0] == '/' || ($dir = '/' . $dir);
     return $dir;
 }
Exemplo n.º 10
0
 /**
  * Gets database data dump, including the database structure.
  *
  * @return array data array
  */
 function getDataDump($tables, $currentTable, $currentLimit, $recordsExported, $fp, $link = 'db_link')
 {
     global ${$link};
     global $application;
     $table_engine = CConf::get('mysql_table_engine');
     $data = "";
     if ($currentTable == 0) {
         fwrite($fp, "-- --------------------------------------------------------\n-- Avactis Shopping Cart Software\n-- Database Backup\n-- Generation Time: " . date("M d, Y at h:i A", time()) . "\n-- --------------------------------------------------------\n");
     }
     $start_time = time();
     while (isset($tables[$currentTable])) {
         $query = new DB_MYSQL_Lock_Tables();
         $query->addTableToLock($tables[$currentTable]['table_name'], DB_LOCK_MODE_WRITE);
         $this->DB_Exec($query);
         if (!(time() - $start_time >= 2)) {
             if ($currentLimit == 0) {
                 $query = " SHOW CREATE TABLE " . $tables[$currentTable]['table_name'];
                 $query_result = $this->DB_Query($query);
                 $result = $this->DB_Fetch_Array($query_result, QUERY_RESULT_NUM);
                 $create_table_query = _ml_substr($result[1], 0, _ml_strrpos($result[1], "\n") + 1) . ") ENGINE={$table_engine};";
                 $data = "\n\n-- \n-- Table structure for table `" . $tables[$currentTable]['table_name'] . "`\n-- \n\nDROP TABLE IF EXISTS `" . $tables[$currentTable]['table_name'] . "`;\n";
                 $data .= $create_table_query;
                 $data .= "\n\n-- \n-- Dumping data for table `" . $tables[$currentTable]['table_name'] . "`\n-- \n\n";
                 fwrite($fp, $data);
             }
             $query = " SHOW COLUMNS FROM " . $tables[$currentTable]['table_name'];
             $query = $this->DB_Query($query);
             $columns = array();
             while ($table_column = $this->DB_Fetch_Array($query, QUERY_RESULT_ASSOC)) {
                 $columns[] = $table_column["Field"];
             }
             $query = " SELECT * FROM " . $tables[$currentTable]['table_name'] . " LIMIT " . 100 * $currentLimit . ", 100";
             $query = $this->DB_Query($query);
             $insert = true;
             $data = "";
             while ($row_data = $this->DB_Fetch_Array($query, QUERY_RESULT_ASSOC)) {
                 if ($insert) {
                     $table_name = $tables[$currentTable]['table_name'];
                     $data .= "LOCK TABLES `{$table_name}` WRITE;\nINSERT INTO `{$table_name}` (`" . implode("`, `", $columns) . "`) VALUES \n";
                     $insert = false;
                 }
                 $row = array();
                 foreach ($row_data as $key => $value) {
                     if (!is_int($key)) {
                         $row[] = "'" . addcslashes(addslashes($value), "..") . "'";
                     }
                 }
                 $data .= "(" . implode(", ", $row) . "),\n";
                 $recordsExported++;
             }
             if ($data && $data[_byte_strlen($data) - 2] == ",") {
                 $data[_byte_strlen($data) - 2] = ";";
                 fwrite($fp, $data . "UNLOCK TABLES;\n");
             }
             $currentLimit++;
             if ($currentLimit * 100 >= $tables[$currentTable]['records_count']) {
                 $currentLimit = 0;
                 $currentTable++;
             }
         } else {
             $query = new DB_MYSQL_Unlock_Tables();
             $this->DB_Exec($query);
             break;
         }
     }
     $retval = array("currentTable" => $currentTable, "currentLimit" => $currentLimit, "recordsExported" => $recordsExported);
     return $retval;
 }