function getFilesFromDir($dir, $isFirst = true)
{
    $dir = trim($dir);
    $arrfiles = array();
    if (is_dir($dir)) {
        if ($handle = opendir($dir)) {
            chdir($dir);
            while (false !== ($file = readdir($handle))) {
                if ($file != "." && $file != "..") {
                    if (is_dir($file)) {
                        $arr = getFilesFromDir($file, false);
                        foreach ($arr as $key => $value) {
                            $fullName = $dir . "/" . $key;
                            if ($isFirst) {
                                $arrfiles[$fullName] = md5_file($fullName);
                            } else {
                                $arrfiles[$fullName] = "";
                            }
                        }
                    } else {
                        $fullName = $dir . "/" . $file;
                        if ($isFirst) {
                            $arrfiles[$fullName] = md5_file($fullName);
                        } else {
                            $arrfiles[$fullName] = "";
                        }
                    }
                }
            }
            chdir("../");
        }
        closedir($handle);
    }
    return $arrfiles;
}
Exemple #2
0
function getFilesFromDir($dir)
{
    $dir = trim($dir);
    $arrfiles = array();
    if (is_dir($dir)) {
        if ($handle = opendir($dir)) {
            chdir($dir);
            while (false !== ($file = readdir($handle))) {
                if ($file != "." && $file != "..") {
                    if (is_dir($file)) {
                        $arr = getFilesFromDir($file, false);
                        foreach ($arr as $value) {
                            $arrfiles[] = $dir . "/" . $value;
                        }
                    } else {
                        $arrfiles[] = $dir . "/" . $file;
                    }
                }
            }
            chdir("../");
        }
        closedir($handle);
    }
    return $arrfiles;
}
function getFilesFromDir($dir, $exclude)
{
    $files = array();
    if ($handle = opendir($dir)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                if (is_dir($dir . '/' . $file)) {
                    $dir2 = $dir . '/' . $file;
                    $files[] = getFilesFromDir($dir2, $exclude);
                } else {
                    if (!is_excluded($dir, $file, $exclude)) {
                        $GLOBALS["fileTxt"] .= $dir . '/' . $file;
                        if ($GLOBALS["readContent"] == true) {
                            $cont = file($dir . "/" . $file);
                            $GLOBALS["fileContents"] .= implode("\n", $cont);
                            $GLOBALS["md5s"][$dir . "/" . $file] = md5(implode("\n", $cont));
                        }
                        $files[] = $dir . '/' . $file;
                    }
                }
            }
        }
        closedir($handle);
    }
    return $files;
}
Exemple #4
0
 function returnDir($dir)
 {
     $files = array();
     if ($handle = opendir($dir)) {
         while (false !== ($file = readdir($handle))) {
             if ($file != "." && $file != "..") {
                 if (is_dir($dir . '/' . $file)) {
                     $dir2 = $dir . '/' . $file;
                     $files[] = getFilesFromDir($dir2);
                 } else {
                     $files[] = $dir . '/' . $file;
                 }
             }
         }
         closedir($handle);
     }
     return array_flat($files);
 }
Exemple #5
0
 /**
  * Gets the files from a directory
  *
  * @param $dir
  * @return array
  */
 public static function getFilesFromDir($dir)
 {
     $files = array();
     if ($handle = opendir($dir)) {
         while (false !== ($file = readdir($handle))) {
             if ($file != "." && $file != ".." && $file != "Thumbs.db") {
                 if (is_dir($dir . '/' . $file)) {
                     $dir2 = $dir . '/' . $file;
                     $files[] = getFilesFromDir($dir2);
                 } else {
                     $files[] = $dir . '/' . $file;
                 }
             }
         }
         closedir($handle);
     }
     return Minotar::array_flat($files);
 }
function getFilesFromDir($dir, array &$files)
{
    if ($handle = opendir($dir)) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                if (is_dir($dir . '/' . $file)) {
                    $dir2 = $dir . '/' . $file;
                    getFilesFromDir($dir2, $files);
                } else {
                    if (endsWith(strtoupper($file), '.H')) {
                        $files[] = $dir . '/' . $file;
                    }
                }
            }
        }
        closedir($handle);
    }
    return $files;
}
Exemple #7
0
 public static function check_for_upgrades($requested_plugin = '', $get_file_contents = 0)
 {
     // compile a list of current plugins
     // along with the users installation code
     // send it to our server and get a response with a list of available updates for this user.
     $current_plugins = array();
     $current_files = array();
     global $plugins;
     if (_DEBUG_MODE) {
         module_debug::log(array('title' => 'Checking for upgrades:', 'data' => 'start'));
     }
     foreach ($plugins as $plugin_name => $p) {
         if ($requested_plugin && $requested_plugin != $plugin_name) {
             continue;
         }
         if (!$p->is_plugin_enabled()) {
             $p->init();
         }
         $current_plugins[$plugin_name] = $p->get_plugin_version();
         // find all the files related to this plugin.
         if (function_exists('getFilesFromDir') && module_config::c('upgrade_post_file_list', 1)) {
             $directory = 'includes/plugin_' . $plugin_name . '/';
             $files = getFilesFromDir($directory);
             $files = array_flip($files);
             foreach ($files as $file => $tf) {
                 // ignore certain files.
                 if (strpos($file, 'plugin_file/upload') !== false || strpos($file, 'plugin_data/upload') !== false || strpos($file, '/cache/') !== false || strpos($file, '/html2ps/') !== false || strpos($file, 'backup/backups/backup_') !== false || strpos($file, '/attachments/') !== false || strpos($file, '/temp/') !== false || strpos($file, '/tmp/') !== false) {
                     unset($files[$file]);
                 } else {
                     $d = preg_replace('#Envato:[^\\r\\n]*#', '', preg_replace('#Package Date:[^\\r\\n]*#', '', preg_replace('#IP Address:[^\\r\\n]*#', '', preg_replace('#Licence:[^\\r\\n]*#', '', file_get_contents($file)))));
                     $files[$file] = md5(base64_encode($d));
                 }
             }
             $current_files[$plugin_name] = $files;
         }
         if (_DEBUG_MODE) {
             module_debug::log(array('title' => 'Checking for upgrades:', 'data' => $plugin_name . ' done'));
         }
     }
     //print_r($current_files);exit;
     $available_updates = array();
     $post_fields = array('application' => _APPLICATION_ID, 'installation_code' => module_config::c('_installation_code'), 'current_version' => module_config::c('_admin_system_version', 2.1), 'current_plugins' => json_encode($current_plugins), 'current_files' => json_encode($current_files), 'client_ip' => $_SERVER['REMOTE_ADDR'], 'installation_location' => full_link('/'), 'requested_plugin' => $requested_plugin, 'get_file_contents' => $get_file_contents);
     $url = module_config::c('ucm_upgrade_url', 'http://api.ultimateclientmanager.com/upgrade.php');
     if ($url == 'http://ultimateclientmanager.com/api/upgrade.php') {
         $url = 'http://api.ultimateclientmanager.com/upgrade.php';
         // hack to use new update subdomain
     }
     if ($url != 'http://ultimateclientmanager.com/api/upgrade.php' && $url != 'http://api.ultimateclientmanager.com/upgrade.php') {
         set_error('Incorrect API url');
         redirect_browser(_BASE_HREF);
     }
     if (_DEBUG_MODE) {
         module_debug::log(array('title' => 'Checking for upgrades:', 'data' => 'Posting to API'));
     }
     if (!function_exists('curl_init')) {
         $postdata = http_build_query($post_fields);
         $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
         $context = stream_context_create($opts);
         $result = file_get_contents($url, false, $context);
     } else {
         //$url = 'http://localhost/ucm/web/api/upgrade.php';
         $ch = curl_init($url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_HEADER, false);
         curl_setopt($ch, CURLOPT_POST, true);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
         curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
         // fixes netregistr, may break others?
         $result = curl_exec($ch);
     }
     $data = json_decode($result, true);
     if (_DEBUG_MODE) {
         module_debug::log(array('title' => 'Checking for upgrades:', 'data' => 'Received response from API'));
     }
     if ($data && isset($data['available_updates']) && is_array($data['available_updates'])) {
         $available_updates = $data['available_updates'];
     }
     if ($data && isset($data['licence_codes']) && is_array($data['licence_codes'])) {
         // find out what the licence codes  are (url / name) so we can dispaly this under each code nicely.
         foreach ($data['licence_codes'] as $code => $foo) {
             if (strlen($code) > 10 && strlen($foo) > 10) {
                 module_config::save_config('_licence_code_' . $code, $foo);
                 // this might not be working
             }
         }
     }
     if (!$data) {
         echo $result;
     }
     //echo '<pre>';print_r($current_plugins);print_r($result);echo '</pre>';
     return $available_updates;
 }
Exemple #8
0
 function listContent()
 {
     if ($this->development == true) {
         $files = getFilesFromDir(realpath(dirname(realpath($this->_tarname)) . '/'));
         // remove absolute prefix
         $currDir = realpath(dirname(realpath($this->_tarname)) . '/');
         foreach ($files as $tmp_item) {
             $tmp[] = substr($tmp_item, strlen($currDir) + 1);
         }
         $finalArray = array();
         foreach ($tmp as $tmp_item) {
             $statInfo = stat($currDir . '/' . $tmp_item);
             $finalArray[] = array('filename' => $tmp_item, 'size' => $statInfo['size'], 'mtime' => $statInfo['mtime'], 'mode' => $statInfo['mode'], 'uid' => $statInfo['uid'], 'gid' => $statInfo['gid'], 'typeflag' => NULL);
         }
         return $finalArray;
     } else {
         return parent::listContent();
     }
 }