示例#1
0
     lovd_errorAdd('password', 'Please enter your correct password for authorization.');
 }
 if (!lovd_error()) {
     // OK, uninstall the lot.
     print '      <B>Uninstalling LOVD...</B><BR>' . "\n" . '      <BR>' . "\n\n";
     require ROOT_PATH . 'class/progress_bar.php';
     // This already puts the progress bar on the screen.
     $_BAR = new ProgressBar('', 'Initiating removal of LOVD...');
     $_T->printFooter(false);
     // The false prevents the footer to actually close the <BODY> and <HTML> tags.
     // Now we're still in the <BODY> so the progress bar can add <SCRIPT> tags as much as it wants.
     flush();
     // The reason to invert the tables is to handle all foreign key constraints nicely.
     $aTables = array_reverse($_TABLES);
     $nTables = count($aTables);
     $_BAR->setMessage('Removing data tables...');
     // Actually run the SQL...
     $nSQLDone = 0;
     $nSQLDonePercentage = 0;
     $nSQLDonePercentagePrev = 0;
     foreach ($aTables as $sTable) {
         $sSQL = 'DROP TABLE IF EXISTS ' . $sTable;
         $q = $_DB->query($sSQL, array(), false);
         if (!$q) {
             // Error when running query. We will use the Div for the form now.
             $sMessage = 'Error during uninstallation while running query.<BR>I ran:<DIV class="err">' . str_replace(array("\r\n", "\r", "\n"), '<BR>', $sSQL) . '</DIV><BR>I got:<DIV class="err">' . str_replace(array("\r\n", "\r", "\n"), '<BR>', $_DB->formatError()) . '</DIV><BR><BR>' . 'A failed uninstallation is most likely caused by a bug in LOVD.<BR>' . 'Please <A href="' . $_SETT['upstream_URL'] . 'bugs/" target="_blank">file a bug</A> and include the above messages to help us solve the problem.';
             $_BAR->setMessage($sMessage, 'done');
             $_BAR->setMessageVisibility('done', true);
             $_DB->query('DROP TABLE IF EXISTS ' . implode(', ', $aTables), array(), false);
             // Try again to remove everything.
             print '</BODY>' . "\n" . '</HTML>' . "\n";
示例#2
0
     $_T->printHeader();
     $_T->printTitle();
     require ROOT_PATH . 'class/progress_bar.php';
     require ROOT_PATH . 'inc-lib-form.php';
     // Generate a unique workID, that is sortable.
     $nTime = gettimeofday();
     $_POST['workID'] = $nTime['sec'] . $nTime['usec'];
     $sFormNextPage = '<FORM action="' . $sPath . '" id="createTranscript" method="post">' . "\n" . '          <INPUT type="hidden" name="workID" value="' . $_POST['workID'] . '">' . "\n" . '          <INPUT type="submit" value="Continue &raquo;">' . "\n" . '        </FORM>';
     $_BAR = new ProgressBar('', 'Collecting transcript information...', $sFormNextPage);
     $_T->printFooter(false);
     // The false prevents the footer to actually close the <BODY> and <HTML> tags.
     // Now we're still in the <BODY> so the progress bar can add <SCRIPT> tags as much as it wants.
     flush();
     require ROOT_PATH . 'class/soap_client.php';
     $_Mutalyzer = new LOVD_SoapClient();
     $_BAR->setMessage('Collecting all available transcripts...');
     $_BAR->setProgress(0);
     $aTranscripts = $_DATA->getTranscriptPositions($zGene['refseq_UD'], $zGene['id'], $zGene['name'], $nProgress);
     $_SESSION['work'][$sPathBase][$_POST['workID']]['values'] = array('gene' => $zGene, 'transcripts' => $aTranscripts['id'], 'transcriptMutalyzer' => $aTranscripts['mutalyzer'], 'transcriptsProtein' => $aTranscripts['protein'], 'transcriptNames' => $aTranscripts['name'], 'transcriptPositions' => $aTranscripts['positions'], 'transcriptsAdded' => $aTranscripts['added']);
     $_BAR->setProgress(100);
     $_BAR->setMessage('Information collected, now building form...');
     $_BAR->setMessageVisibility('done', true);
     print '<SCRIPT type="text/javascript">' . "\n" . '  document.forms[\'createTranscript\'].submit();' . "\n" . '</SCRIPT>' . "\n\n";
     print '</BODY>' . "\n" . '</HTML>' . "\n";
     exit;
 }
 // Now make sure we have a valid workID.
 if (!isset($_POST['workID']) || !array_key_exists($_POST['workID'], $_SESSION['work'][$sPathBase])) {
     exit;
 }
 require ROOT_PATH . 'inc-lib-form.php';
示例#3
0
文件: columns.php 项目: LOVDnl/LOVD3
     lovd_showInfoTable('Please note that the time estimated to remove this column from the ' . $aTableInfo['table_name'] . ' data table is <B>' . round($tAlter) . ' seconds</B>.<BR>During this time, no updates to the data table are possible. If other users are trying to update information in the database during this time, they will have to wait a long time, or get an error.', 'warning');
 }
 require ROOT_PATH . 'class/progress_bar.php';
 // This already puts the progress bar on the screen.
 $_BAR = new ProgressBar('', $sMessage);
 $_T->printFooter(false);
 // The false prevents the footer to actually close the <BODY> and <HTML> tags.
 // Now we're still in the <BODY> so the progress bar can add <SCRIPT> tags as much as it wants.
 flush();
 // Now, end with ALTER TABLE if necessary, since that will take the longest time and ends a transaction anyway.
 if (!$aTableInfo['shared']) {
     // Query text; remove column registration first.
     $sQ = 'DELETE FROM ' . TABLE_ACTIVE_COLS . ' WHERE colid = ?';
     $_DB->query($sQ, array($zData['id']));
     $_BAR->setProgress(20);
     $_BAR->setMessage('Removing column...');
     // The whole transaction stuff is useless here; alter table will commit and there's just one query before that.
     // Alter data table.
     $sQ = 'ALTER TABLE ' . $aTableInfo['table_sql'] . ' DROP COLUMN `' . $zData['id'] . '`';
     $_DB->query($sQ);
     $sMessage = 'Removed column ' . $zData['colid'] . ' (' . $zData['head_column'] . ')';
 } else {
     // Query text; remove column registration first.
     $sObject = $aTableInfo['unit'] . 'id';
     $_DB->beginTransaction();
     $sQ = 'DELETE FROM ' . TABLE_SHARED_COLS . ' WHERE ' . $sObject . ' IN (?' . str_repeat(', ?', count($aTargets) - 1) . ') AND colid = ?';
     $aQ = array_merge($aTargets, array($zData['id']));
     $_DB->query($sQ, $aQ);
     $_DB->commit();
     $_BAR->setProgress(10);
     $_BAR->setMessage('Inactivating column...');
示例#4
0
                }
                $row->save();
                $levels[$level + 1][] = $row->id;
                $categories[$table][] = $row->id;
                print ProgressBar::next();
            }
        }
        unset($levels, $date_min, $date_max, $i, $row, $created, $level, $parent_id);
        print ProgressBar::finish();
        print "DONE\r\n\n";
    }
}
// Generate articles.
if ($numbers['articles']) {
    ProgressBar::start($numbers['articles']);
    ProgressBar::setMessage('Adding articles...');
    $date_min = new DateTime('-3 years');
    $date_max = new DateTime();
    for ($i = 0; $i < $numbers['articles']; $i++) {
        $row = Library\ObjectManager::getInstance()->getObject('com:articles.model.articles')->getItem();
        $row->title = $generator->words(pick_random(range(1, 5)));
        $row->introtext = $generator->sentences(pick_random(range(1, 3)));
        $row->fulltext = $generator->sentences(pick_random(range(0, 5)));
        $row->published = (int) (rand(0, 20) > 0);
        $row->categories_category_id = pick_random($categories['articles']);
        $created = new DateTime('@' . rand($date_min->format('U'), $date_max->format('U')));
        $row->created_on = $created->format('Y-m-d H:i:s');
        $row->created_by = pick_random($users);
        $row->save();
        print ProgressBar::next();
    }
示例#5
0
文件: genes.php 项目: LOVDnl/LOVD3
 if (!lovd_error()) {
     // Throwing away full submissions in one go is unfortunately not an option due to the many-to-many connection between screening and variant.
     // Deleting an individual does not delete its variants. Therefore, we might as well approach this the LOVD2 way: delete the variants, then delete the empty screenings, then the empty individuals.
     // Of course we MUST make sure those are at least entries related to the removed variants in question, otherwise we'll be deleting too much data (LOVD2 never allowed orphaned data like we do now).
     require ROOT_PATH . 'class/progress_bar.php';
     $_BAR = new ProgressBar('', 'Gathering data...');
     $aDone = array();
     $nDone = 0;
     $_DB->beginTransaction();
     // Determine which transcripts need their data deleted...
     // We must have transcripts and variants, otherwise we cannot get to this point.
     $aTranscripts = $_DB->query('SELECT id FROM ' . TABLE_TRANSCRIPTS . ' WHERE geneid = ?', array($sID))->fetchAllColumn();
     // Then determine which VOGs need to be deleted, because they will point to nothing else...
     $aVOGs = $_DB->query('SELECT DISTINCT vog.id FROM ' . TABLE_VARIANTS . ' AS vog INNER JOIN ' . TABLE_VARIANTS_ON_TRANSCRIPTS . ' AS vot1 ON (vog.id = vot1.id AND vot1.transcriptid IN (?' . str_repeat(', ?', count($aTranscripts) - 1) . ')) LEFT OUTER JOIN ' . TABLE_VARIANTS_ON_TRANSCRIPTS . ' AS vot2 ON (vog.id = vot2.id AND vot2.transcriptid NOT IN (?' . str_repeat(', ?', count($aTranscripts) - 1) . ')) WHERE vot2.transcriptid IS NULL', array_merge($aTranscripts, $aTranscripts), true)->fetchAllColumn();
     $_BAR->setProgress(10);
     $_BAR->setMessage('Deleting variants...');
     // Delete the VOTs!
     $q = $_DB->query('DELETE FROM ' . TABLE_VARIANTS_ON_TRANSCRIPTS . ' WHERE transcriptid IN (?' . str_repeat(', ?', count($aTranscripts) - 1) . ')', $aTranscripts);
     $aDone['Variants_On_Transcripts'] = $q->rowCount();
     $nDone++;
     unset($aTranscripts);
     // Save some memory.
     $_BAR->setProgress(25);
     // Determine which screenings need to go, based on the VOGs...
     $aScreenings = $_DB->query('SELECT DISTINCT s2v1.screeningid FROM ' . TABLE_SCR2VAR . ' AS s2v1 LEFT OUTER JOIN ' . TABLE_SCR2VAR . ' AS s2v2 ON (s2v1.screeningid = s2v2.screeningid AND s2v2.variantid NOT IN (?' . str_repeat(', ?', count($aVOGs) - 1) . ')) WHERE s2v1.variantid IN (?' . str_repeat(', ?', count($aVOGs) - 1) . ') AND s2v2.variantid IS NULL', array_merge($aVOGs, $aVOGs), true)->fetchAllColumn();
     // Delete the VOGs!
     $q = $_DB->query('DELETE FROM ' . TABLE_VARIANTS . ' WHERE id IN (?' . str_repeat(', ?', count($aVOGs) - 1) . ')', $aVOGs);
     $aDone['Variants_On_Genome'] = $q->rowCount();
     $nDone++;
     unset($aVOGs);
     // Save some memory.
示例#6
0
 // This already puts the progress bar on the screen.
 $_BAR = new ProgressBar('', 'Checking upgrade lock...', $sFormNextPage);
 $_T->printFooter(false);
 // The false prevents the footer to actually close the <BODY> and <HTML> tags.
 // Now we're still in the <BODY> so the progress bar can add <SCRIPT> tags as much as it wants.
 flush();
 // Try to update the upgrade lock.
 $sQ = 'UPDATE ' . TABLE_STATUS . ' SET lock_update = 1 WHERE lock_update = 0';
 $nMax = 30;
 for ($i = 0; $i < $nMax; $i++) {
     $bLocked = !$_DB->exec($sQ);
     if (!$bLocked) {
         break;
     }
     // No update means that someone else is updating the system.
     $_BAR->setMessage('Update lock is in place, so someone else is already upgrading the database.<BR>Waiting for other user to finish... (' . ($nMax - $i) . ')');
     flush();
     sleep(1);
 }
 if ($bLocked) {
     // Other user is taking ages! Or somethings wrong...
     $_BAR->setMessage('Other user upgrading the database is still not finished.<BR>' . (isset($_GET['force_lock']) ? 'Forcing upgrade as requested...' : 'This may indicate something went wrong during upgrade.'));
     if (isset($_GET['force_lock'])) {
         $bLocked = false;
     }
 } else {
     $_BAR->setMessage('Upgrading database backend...');
 }
 flush();
 if (!$bLocked) {
     // There we go...
示例#7
0
}
require ROOT_PATH . 'class/progress_bar.php';
$oPB = new ProgressBar('', 'Fetching frequency data...', '&nbsp;');
$_T->printFooter(false);
@set_time_limit(0);
$sVariants = ' ';
$nDone = 0;
while ($nDone < $nToFetch && $sVariants) {
    $aVariants = $_DB->query('SELECT chromosome, position_g_start, position_g_end, `VariantOnGenome/DNA` AS DNA FROM ' . TABLE_VARIANTS . ' WHERE average_frequency IS NULL AND chromosome IS NOT NULL AND position_g_start IS NOT NULL AND position_g_end IS NOT NULL LIMIT ' . $nLimit)->fetchAllAssoc();
    if ($aVariants === array()) {
        // No results.
        $oPB->setProgress(100);
        // To prevent ending up in a loop because of a programming error, or unexpected results from the database, we'll redirect with a GET variable that we'll check for, here.
        if (ACTION == 'done') {
            // We were supposedly done before. Don't reload.
            $oPB->setMessage('Done.');
        } else {
            $oPB->setMessage('Done, reloading...');
            $oPB->redirectTo(CURRENT_PATH . '?done', 1);
        }
        die('    </BODY>' . "\n" . '</HTML>');
    } elseif (!$aVariants) {
        // Failed query,
        $oPB->setMessage('Error, did not get proper response from database.');
        die('    </BODY>' . "\n" . '</HTML>');
    } else {
        // Proceed.
        $sVariants = json_encode($aVariants);
        $aResponse = lovd_php_file($sURL, false, 'variants=' . $sVariants);
        if ($aResponse) {
            $sResponse = implode($aResponse);
示例#8
0
文件: index.php 项目: LOVDnl/LOVD3
 $aInstallSQL['Creating LOVD custom links...'] = $aLinkSQL;
 $nInstallSQL += $nLinks;
 // (12) Creating LOVD status.
 $aInstallSQL['Registering LOVD system status...'] = array('INSERT INTO ' . TABLE_STATUS . ' VALUES (0, "' . $_SETT['system']['version'] . '", "' . $sSignature . '", NULL, NULL, NULL, NULL, NULL, NOW(), NULL)');
 $nInstallSQL++;
 // (13) Creating standard external sources.
 require 'inc-sql-sources.php';
 $nSources = count($aSourceSQL);
 $aInstallSQL['Creating external sources...'] = $aSourceSQL;
 $nInstallSQL += $nSources;
 // Actually run the SQL...
 $nSQLDone = 0;
 $nSQLDonePercentage = 0;
 $nSQLDonePercentagePrev = 0;
 foreach ($aInstallSQL as $sMessage => $aSQL) {
     $_BAR->setMessage($sMessage);
     foreach ($aSQL as $sSQL) {
         $q = $_DB->query($sSQL, false, false, true);
         // This means that there is no SQL injection check here. But hey - these are our own queries.
         if (!$q) {
             // Error when running query. We will use the Div for the form now.
             $sMessage = 'Error during install while running query.<BR>I ran:<DIV class="err">' . str_replace(array("\r\n", "\r", "\n"), '<BR>', $sSQL) . '</DIV><BR>I got:<DIV class="err">' . str_replace(array("\r\n", "\r", "\n"), '<BR>', '[' . implode('] [', $_DB->errorInfo()) . ']') . '</DIV><BR>' . 'A failed installation is most likely caused by a bug in LOVD.<BR>' . 'Please <A href="' . $_SETT['upstream_BTS_URL_new_ticket'] . '" target="_blank">file a bug</A> and include the above messages to help us solve the problem.';
             $_BAR->setMessage($sMessage, 'done');
             $_BAR->setMessageVisibility('done', true);
             // LOVD 2.0's lovd_rollback() has been replaced by a two-line piece of code...
             $aTable = array_reverse($_TABLES);
             $_DB->query('DROP TABLE IF EXISTS ' . implode(', ', $aTable), false, false);
             print '</BODY>' . "\n" . '</HTML>' . "\n";
             exit;
         }
         $nSQLDone++;
示例#9
0
文件: scan.php 项目: madcsaba/li-de
function checkFiles($task)
{
    global $jlistConfig, $lang;
    $limits = remove_server_limits();
    if (!$limits) {
        echo '<p>';
        echo '*******************************************************';
        echo '<br />Note: The time limit on the server could not be changed/increased!<br />';
        echo '*******************************************************';
        echo '</p>';
    }
    ignore_user_abort(true);
    // ob_flush();
    flush();
    $model_category = JModelLegacy::getInstance('Category', 'jdownloadsModel');
    $model_download = JModelLegacy::getInstance('Download', 'jdownloadsModel');
    jimport('joomla.filesystem.folder');
    jimport('joomla.filesystem.file');
    $db = JFactory::getDBO();
    $lang = JFactory::getLanguage();
    $lang->load('com_jdownloads', JPATH_SITE . DS);
    //check if all files and dirs in the uploaddir directory are listed
    if ($jlistConfig['files.autodetect'] || $task == 'restore.run' || $task == 'scan.files') {
        if (file_exists($jlistConfig['files.uploaddir']) && $jlistConfig['files.uploaddir'] != '') {
            $startdir = $jlistConfig['files.uploaddir'] . '/';
            $dir_len = strlen($startdir);
            // define the params for scan_dir() results
            $dir = $startdir;
            $only = FALSE;
            $type = array();
            if ($jlistConfig['all.files.autodetect']) {
                $allFiles = true;
            } else {
                $allFiles = FALSE;
                $type = explode(',', $jlistConfig['file.types.autodetect']);
            }
            $recursive = TRUE;
            $onlyDir = TRUE;
            $files = array();
            $file = array();
            $dirlist = array();
            $new_files = 0;
            $new_dirs_found = 0;
            $new_dirs_create = 0;
            $new_dirs_errors = 0;
            $new_dirs_exists = 0;
            $new_cats_create = 0;
            $log_message = '';
            $success = FALSE;
            $log_array = array();
            // ********************************************
            // first search new categories
            // ********************************************
            clearstatcache();
            $jd_root = $jlistConfig['files.uploaddir'] . '/';
            $temp_dir = $jd_root . $jlistConfig['tempzipfiles.folder.name'] . '/';
            $uncat_dir = $jd_root . $jlistConfig['uncategorised.files.folder.name'] . '/';
            $preview_dir = $jd_root . $jlistConfig['preview.files.folder.name'] . '/';
            $private_dir = $jd_root . $jlistConfig['private.area.folder.name'] . '/';
            $except_folders = array($temp_dir, $uncat_dir, $preview_dir, $private_dir);
            $searchdirs = array();
            $dirlist = JDownloadsHelper::searchdir($jd_root, -1, 'DIRS', 0, $except_folders);
            $no_writable = 0;
            for ($i = 0; $i < count($dirlist); $i++) {
                // no tempzifiles directory
                if (strpos($dirlist[$i], $jlistConfig['private.area.folder.name'] . '/') === FALSE) {
                    if (!is_writable($dirlist[$i])) {
                        $no_writable++;
                    }
                    $dirlist[$i] = str_replace($jd_root, '', $dirlist[$i]);
                    // delete last slash /
                    if ($pos = strrpos($dirlist[$i], '/')) {
                        $searchdirs[] = substr($dirlist[$i], 0, $pos);
                    }
                }
            }
            unset($dirlist);
            $count_cats = count($searchdirs);
            // first progressbar for cats
            $title1 = JText::_('COM_JDOWNLOADS_RUN_MONITORING_INFO3');
            $bar = new ProgressBar();
            $bar->setMessage($title1);
            $bar->setAutohide(false);
            $bar->setSleepOnFinish(0);
            $bar->setPrecision(100);
            $bar->setForegroundColor('#990000');
            $bar->setBackgroundColor('#CCCCCC');
            $bar->setBarLength(300);
            $bar->initialize($count_cats - 1);
            // print the empty bar
            for ($i = 0; $i < count($searchdirs); $i++) {
                $dirs = explode('/', $searchdirs[$i]);
                $sum = count($dirs);
                // check that folder exist
                if ($sum == 1) {
                    $db->setQuery("SELECT COUNT(*) FROM #__jdownloads_categories WHERE cat_dir = '{$searchdirs[$i]}'");
                    $cat_dir_parent_value = '';
                    $cat_dir_value = $dirs[0];
                } else {
                    $pos = strrpos($searchdirs[$i], '/');
                    $cat_dir_parent_value = substr($searchdirs[$i], 0, $pos);
                    $cat_dir_value = substr($searchdirs[$i], $pos + 1);
                    $db->setQuery("SELECT COUNT(*) FROM #__jdownloads_categories WHERE cat_dir = '{$cat_dir_value}' AND cat_dir_parent = '{$cat_dir_parent_value}'");
                }
                $cat_exist = $db->loadResult();
                // when not exist - add it
                if (!$cat_exist) {
                    $new_dirs_found++;
                    $parent_cat = '';
                    // get the right parent_id value
                    if ($sum == 1) {
                        // we have a new root cat
                        $parent_id = 1;
                    } else {
                        // find the parent category and get the cat ID
                        $pos = strrpos($cat_dir_parent_value, '/');
                        if ($pos) {
                            // we have NOT a first level sub category
                            $cat_dir_parent_value2 = substr($cat_dir_parent_value, 0, $pos);
                            $cat_dir_value2 = substr($cat_dir_parent_value, $pos + 1);
                            $db->setQuery("SELECT * FROM #__jdownloads_categories WHERE cat_dir = '{$cat_dir_value2}' AND cat_dir_parent = '{$cat_dir_parent_value2}'");
                        } else {
                            // we have a first level sub category
                            $cat_dir_parent_value2 = $cat_dir_parent_value;
                            $cat_dir_value2 = $cat_dir_value;
                            $db->setQuery("SELECT * FROM #__jdownloads_categories WHERE cat_dir = '{$cat_dir_parent_value2}' AND cat_dir_parent = ''");
                        }
                        $parent_cat = $db->loadObject();
                        if ($parent_cat) {
                            $parent_id = $parent_cat->id;
                        } else {
                            // can not found the parents category for the new child
                            $log_array[] = JText::_('Abort. Can not find parents category for the new folder: ') . ' <b>' . $searchdirs[$i] . '</b><br />';
                            break;
                        }
                    }
                    $cat_dir_value = utf8_encode($cat_dir_value);
                    // we need the original folder title as category title
                    $original_folder_name = $cat_dir_value;
                    // check the founded folder name
                    $checked_cat_dir = JDownloadsHelper::getCleanFolderFileName($cat_dir_value, true);
                    // check the folder name result
                    if ($cat_dir_value != $checked_cat_dir) {
                        // build path
                        if ($parent_cat) {
                            if ($parent_cat->cat_dir_parent) {
                                $cat_dir_path = $jd_root . $parent_cat->cat_dir_parent . '/' . $parent_cat->cat_dir . '/' . $checked_cat_dir;
                                $new_cat_dir_name = $parent_cat->cat_dir_parent . '/' . $parent_cat->cat_dir . '/' . $checked_cat_dir;
                            } else {
                                $cat_dir_path = $jd_root . $parent_cat->cat_dir . '/' . $checked_cat_dir;
                                $new_cat_dir_name = $parent_cat->cat_dir . '/' . $checked_cat_dir;
                            }
                        } else {
                            $cat_dir_path = $jd_root . $checked_cat_dir;
                            $new_cat_dir_name = $checked_cat_dir;
                        }
                        // rename the folder - when he already exist: make it unique!
                        $num = 1;
                        while (JFolder::exists($cat_dir_path)) {
                            $cat_dir_path = $cat_dir_path . $num;
                            $checked_cat_dir = $checked_cat_dir . $num;
                            $num++;
                        }
                        if (!JFolder::exists($cat_dir_path)) {
                            $copied = JFolder::move($jd_root . $searchdirs[$i], $cat_dir_path);
                            if ($copied !== true) {
                                $log_array[] = JText::_('Error! Can not change folder name: ') . ' <b>' . $searchdirs[$i] . '</b><br />';
                            }
                        } else {
                            $log_array[] = JText::_('Error! A folder with the same (cleaned) name exist already: ') . ' <b>' . $searchdirs[$i] . '</b><br />';
                        }
                        $cat_dir_value = $checked_cat_dir;
                        // update the name in the folder list
                        $searchdirs[$i] = $new_cat_dir_name;
                    }
                    // set access
                    if ($parent_cat) {
                        $access = $parent_cat->access;
                    } else {
                        $access = 1;
                    }
                    // set alias
                    $alias = JApplication::stringURLSafe($cat_dir_value);
                    // set note hint
                    $note = JText::_('COM_JDOWNLOADS_RUN_MONITORING_NOTE_TEXT');
                    // build table array
                    $data = array('id' => 0, 'parent_id' => $parent_id, 'title' => $original_folder_name, 'alias' => $alias, 'notes' => $note, 'description' => '', 'cat_dir' => $cat_dir_value, 'cat_dir_parent' => $cat_dir_parent_value, 'pic' => $jlistConfig['cat.pic.default.filename'], 'published' => (int) $jlistConfig['autopublish.founded.files'], 'access' => $access, 'metadesc' => '', 'metakey' => '', 'created_user_id' => '0', 'language' => '*', 'rules' => array('core.create' => array(), 'core.delete' => array(), 'core.edit' => array(), 'core.edit.state' => array(), 'core.edit.own' => array(), 'download' => array()), 'params' => array());
                    // create new cat in table
                    $create_result = $model_category->createAutoCategory($data);
                    if (!$create_result) {
                        // error message
                        $log_array[] = JText::_('Error! Can not create new category for: ') . ' <b>' . $searchdirs[$i] . '</b><br />';
                    }
                    $new_cats_create++;
                    // copy index.html to the new folder
                    $index_copied = JFile::copy(JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_jdownloads' . DS . 'index.html', $jlistConfig['files.uploaddir'] . DS . $searchdirs[$i] . DS . 'index.html');
                    $log_array[] = JText::_('COM_JDOWNLOADS_AUTO_CAT_CHECK_ADDED') . ' <b>' . $searchdirs[$i] . '</b><br />';
                }
                $bar->increase();
                // calls the bar with every processed element
            }
            echo '<small><br />' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_SUM_FOLDERS') . ' ' . count($searchdirs) . '<br /><br /></small>';
            ob_flush();
            flush();
            unset($dirs);
            unset($searchdirs);
            // ********************************************
            // Exists all published category folders?
            // ********************************************
            $mis_cats = 0;
            // get all published categories but not the root
            $db->setQuery("SELECT * FROM #__jdownloads_categories WHERE published = 1 AND id > 1");
            $cats = $db->loadObjectList();
            $count_cats = count($cats);
            // first progressbar for cats
            $bar = new ProgressBar();
            $title2 = JText::_('COM_JDOWNLOADS_RUN_MONITORING_INFO4');
            $bar->setMessage($title2);
            $bar->setAutohide(false);
            $bar->setSleepOnFinish(0);
            $bar->setPrecision(100);
            $bar->setForegroundColor('#990000');
            $bar->setBarLength(300);
            $bar->initialize($count_cats);
            // print the empty bar
            foreach ($cats as $cat) {
                if ($cat->cat_dir_parent != '') {
                    $cat_dir = $jd_root . $cat->cat_dir_parent . '/' . $cat->cat_dir;
                } else {
                    $cat_dir = $jd_root . $cat->cat_dir;
                }
                // when it not exist, we must unpublish the category
                if (!JFolder::exists($cat_dir)) {
                    $db->setQuery("UPDATE #__jdownloads_categories SET published = 0 WHERE id = '{$cat->id}'");
                    $db->execute();
                    $mis_cats++;
                    $log_array[] = '<font color="red">' . JText::_('COM_JDOWNLOADS_AUTO_CAT_CHECK_DISABLED') . ' <b>' . $cat->cat_dir . '</b></font><br />';
                }
                $bar->increase();
                // calls the bar with every processed element
            }
            echo '<br /><br />';
            unset($cats);
            // *********************************************************
            //  Check all files and create for new founded new Downloads
            // *********************************************************
            unset($except_folders[1]);
            $all_dirs = JDownloadsHelper::scan_dir($dir, $type, $only, $allFiles, $recursive, $onlyDir, $except_folders, $jd_root, $files);
            if ($all_dirs != FALSE) {
                $count_files = count($files);
                // first progressbar for cats
                $bar = new ProgressBar();
                $title3 = JText::_('COM_JDOWNLOADS_RUN_MONITORING_INFO5');
                $bar->setMessage($title3);
                $bar->setAutohide(false);
                $bar->setSleepOnFinish(0);
                $bar->setPrecision(100);
                $bar->setForegroundColor('#990000');
                $bar->setBarLength(300);
                $bar->initialize($count_files);
                // print the empty bar
                reset($files);
                $new_files = 0;
                foreach ($files as $key3 => $array2) {
                    $filename = $files[$key3]['file'];
                    if ($filename != '') {
                        $dir_path_total = $files[$key3]['path'];
                        $restpath = substr($files[$key3]['path'], $dir_len);
                        $only_dirs = substr($restpath, 0, strlen($restpath) - 1);
                        $upload_dir = $jlistConfig['files.uploaddir'] . '/' . $only_dirs . '/';
                        $pos = strrpos($only_dirs, '/');
                        if ($pos) {
                            $cat_dir_parent_value = substr($only_dirs, 0, $pos);
                            $cat_dir_value = substr($only_dirs, $pos + 1);
                        } else {
                            $cat_dir_parent_value = '';
                            $cat_dir_value = $only_dirs;
                        }
                        // exist still a Download with this filename?
                        $exist_file = false;
                        $db->setQuery("SELECT cat_id FROM #__jdownloads_files WHERE url_download = '" . $filename . "'");
                        $row_file_exists = $db->loadObjectList();
                        // when exist, get the category from the Download, when we have really assigned a category (ID > 1)
                        if ($row_file_exists && $row_file_exists[0]->cat_id > 1) {
                            foreach ($row_file_exists as $row_file_exist) {
                                if (!$exist_file) {
                                    $db->setQuery("SELECT COUNT(*) FROM #__jdownloads_categories WHERE id = '{$row_file_exist->cat_id}' AND cat_dir = '{$cat_dir_value}' AND cat_dir_parent = '{$cat_dir_parent_value}'");
                                    $row_cat_find = $db->loadResult();
                                    if ($row_cat_find) {
                                        $exist_file = true;
                                    }
                                }
                            }
                        } else {
                            // it can be an 'uncategorised'
                            if ($row_file_exists && $row_file_exists[0]->cat_id == 1) {
                                $exist_file = true;
                            } else {
                                $exist_file = false;
                            }
                        }
                        // Add the file here in a new Download
                        if (!$exist_file) {
                            // not check the filename when restore backup file
                            if ($task != 'restore.run') {
                                // reset images var
                                $images = '';
                                $only_name = utf8_encode(JFile::stripExt($filename));
                                $file_extension = JFile::getExt($filename);
                                // $title =  JFilterInput::clean($only_name);
                                $title = JFilterInput::getInstance(null, null, 1, 1)->clean($only_name, 'STRING');
                                // check filename
                                $filename_new = JDownloadsHelper::getCleanFolderFileName($only_name, true) . '.' . $file_extension;
                                if ($only_name == '') {
                                    echo "<script> alert('Error: Filename empty after cleaning: " . $dir_path_total . "'); </script>\n";
                                    continue;
                                    // go to next foreach item
                                }
                                if ($filename_new != $filename) {
                                    $source = $startdir . $only_dirs . '/' . $filename;
                                    $target = $startdir . $only_dirs . '/' . $filename_new;
                                    $success = @rename($source, $target);
                                    if ($success === true) {
                                        $filename = $filename_new;
                                    } else {
                                        // could not rename filename
                                        echo "<script> alert('Error: Could not rename {$filename}'); </script>\n";
                                        continue;
                                        // go to next foreach item
                                    }
                                }
                            }
                            $target_path = $upload_dir . $filename;
                            // find the category for the new founded file in this folder
                            $db->setQuery("SELECT * FROM #__jdownloads_categories WHERE cat_dir = '{$cat_dir_value}' AND cat_dir_parent = '{$cat_dir_parent_value}'");
                            $cat = $db->loadObject();
                            if ($cat) {
                                $id = $cat->id;
                                $access = $cat->access;
                            } else {
                                // it seems that we have a new file in 'uncategorised' folder found
                                $id = 1;
                                $access = 1;
                            }
                            $date = JFactory::getDate();
                            $tz = JFactory::getConfig()->get('offset');
                            $date->setTimezone(new DateTimeZone($tz));
                            $file_extension = JFile::getExt($filename);
                            // set file size
                            $file_size = $files[$key3]['size'];
                            // set note hint
                            $note = JText::_('COM_JDOWNLOADS_RUN_MONITORING_NOTE_TEXT');
                            // set creation date
                            $creation_date = JFactory::getDate()->toSql();
                            // set file mime pic
                            $picpath = strtolower(JPATH_SITE . '/images/jdownloads/fileimages/' . $file_extension . '.png');
                            if (file_exists($picpath)) {
                                $file_pic = $file_extension . '.png';
                            } else {
                                $file_pic = $jlistConfig['file.pic.default.filename'];
                            }
                            // create thumbs form pdf
                            if ($jlistConfig['create.pdf.thumbs'] && $jlistConfig['create.pdf.thumbs.by.scan'] && $file_extension == 'pdf') {
                                $thumb_path = JPATH_SITE . '/images/jdownloads/screenshots/thumbnails/';
                                $screenshot_path = JPATH_SITE . '/images/jdownloads/screenshots/';
                                $pdf_thumb_name = jdownloadsHelper::create_new_pdf_thumb($target_path, $only_name, $thumb_path, $screenshot_path);
                                if ($pdf_thumb_name) {
                                    $images = $pdf_thumb_name;
                                }
                            }
                            // create auto thumb when founded file is an image
                            if ($jlistConfig['create.auto.thumbs.from.pics'] && $jlistConfig['create.auto.thumbs.from.pics.by.scan']) {
                                if ($file_is_image = JDownloadsHelper::fileIsPicture($filename)) {
                                    $thumb_created = jdownloadsHelper::create_new_thumb($target_path);
                                    if ($thumb_created) {
                                        $images = $filename;
                                        // create new big image for full view
                                        $image_created = jdownloadsHelper::create_new_image($target_path);
                                    }
                                }
                            }
                            $sha1_value = sha1_file($target_path);
                            $md5_value = md5_file($target_path);
                            // build data array
                            $data = array('file_id' => 0, 'cat_id' => $id, 'file_title' => $title, 'file_alias' => '', 'notes' => $note, 'url_download' => $filename, 'size' => $file_size, 'description' => JDownloadsHelper::getOnlyLanguageSubstring($jlistConfig['autopublish.default.description']), 'file_pic' => $file_pic, 'images' => $images, 'date_added' => $creation_date, 'sha1_value' => $sha1_value, 'md5_value' => $md5_value, 'published' => (int) $jlistConfig['autopublish.founded.files'], 'access' => $access, 'metadesc' => '', 'metakey' => '', 'created_user_id' => '0', 'language' => '*', 'rules' => array('core.create' => array(), 'core.delete' => array(), 'core.edit' => array(), 'core.edit.state' => array(), 'core.edit.own' => array(), 'download' => array()), 'params' => array());
                            // create new download in table
                            $create_result = $model_download->createAutoDownload($data);
                            if (!$create_result) {
                                // error message
                                echo "<script> alert('Error: Could not add download for: {$filename}'); window.history.go(-1); </script>\n";
                                exit;
                            }
                            $new_files++;
                            $log_array[] = JText::_('COM_JDOWNLOADS_AUTO_FILE_CHECK_ADDED') . ' <b>' . $only_dirs . '/' . $filename . '</b><br />';
                        }
                    }
                    $bar->increase();
                    // calls the bar with every processed element
                }
            }
            echo '<small><br />' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_SUM_FILES') . ' ' . count($files) . '<br /><br /></small>';
            unset($files);
            flush();
            // ****************************************************
            // Check whether the assigned files from all published downloads exists
            // - otherwise unpublish this downloads
            // ****************************************************
            $mis_files = 0;
            $db->setQuery("SELECT * FROM #__jdownloads_files WHERE published = 1");
            $files = $db->loadObjectList();
            $count_files = count($files);
            // first progressbar for cats
            $bar = new ProgressBar();
            $title4 = JText::_('COM_JDOWNLOADS_RUN_MONITORING_INFO6');
            $bar->setMessage($title4);
            $bar->setAutohide(false);
            $bar->setSleepOnFinish(0);
            $bar->setPrecision(100);
            $bar->setForegroundColor('#990000');
            $bar->setBarLength(300);
            $bar->initialize($count_files);
            // print the empty bar
            foreach ($files as $file) {
                // we checked only intern stored files
                if ($file->url_download != '') {
                    // get the category path only, when we have not an 'uncategorised' Download
                    if ($file->cat_id > 1) {
                        $db->setQuery("SELECT cat_dir, cat_dir_parent FROM #__jdownloads_categories WHERE id = '{$file->cat_id}'");
                        $cat = $db->loadObject();
                        if ($cat->cat_dir_parent != '') {
                            $cat_dir_path = $cat->cat_dir_parent . '/' . $cat->cat_dir;
                        } else {
                            $cat_dir_path = $cat->cat_dir;
                        }
                        $file_path = $jd_root . $cat_dir_path . '/' . $file->url_download;
                        $cat_dir = $cat->cat_dir . '/' . $file->url_download;
                    } else {
                        // file in 'uncategorised' folder
                        $file_path = $uncat_dir . $file->url_download;
                        $cat_dir = $file_path;
                    }
                    if (!file_exists($file_path)) {
                        $db->setQuery("UPDATE #__jdownloads_files SET published = 0 WHERE file_id = '{$file->file_id}'");
                        $db->execute();
                        $mis_files++;
                        $log_array[] = '<font color="red">' . JText::_('COM_JDOWNLOADS_AUTO_FILE_CHECK_DISABLED') . ' <b>' . $cat_dir . '</b></font><br />';
                    }
                }
                $bar->increase();
                // calls the bar with every processed element
            }
            echo '<br /><br />';
            echo '<div style="font-family:Verdana; font-size:10"><b>' . JText::_('COM_JDOWNLOADS_RUN_MONITORING_INFO7') . '</b><br /><br /></div>';
            flush();
            // build log message
            if (count($log_array) > 0) {
                array_unshift($log_array, date(JText::_('DATE_FORMAT_LC2')) . ':<br />');
            }
            foreach ($log_array as $log) {
                $log_message .= $log;
            }
            // when we have changed anything, we store it in the config
            if ($log_message != '') {
                $db->setQuery("UPDATE #__jdownloads_config SET setting_value = '{$log_message}' WHERE setting_name = 'last.log.message'");
                $db->execute();
            }
            if ($task == 'scan.files') {
                echo '<table width="100%"><tr><td><font size="1" face="Verdana">' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_TITLE') . '</font><br />';
                if ($new_cats_create > 0) {
                    echo '<font color="#FF6600" size="1" face="Verdana"><b>' . $new_cats_create . ' ' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_NEW_CATS') . '</b></font><br />';
                } else {
                    echo '<font color="green" size="1" face="Verdana"><b>' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_NO_NEW_CATS') . '</b></font><br />';
                }
                if ($new_files > 0) {
                    echo '<font color="#FF6600" size="1" face="Verdana"><b>' . $new_files . ' ' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_NEW_FILES') . '</b></font><br />';
                } else {
                    echo '<font color="green" size="1" face="Verdana"><b>' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_NO_NEW_FILES') . '</b></font><br />';
                }
                if ($mis_cats > 0) {
                    echo '<font color="#990000" size="1" face="Verdana"><b>' . $mis_cats . ' ' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_MISSING_CATS') . '</b></font><br />';
                } else {
                    echo '<font color="green" size="1" face="Verdana"><b>' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_NO_MISSING_CATS') . '</b></font><br />';
                }
                if ($mis_files > 0) {
                    echo '<font color="#990000"  size="1" face="Verdana"><b>' . $mis_files . ' ' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_MISSING_FILES') . '</b><br /></td></tr></table>';
                } else {
                    echo '<font color="green" size="1" face="Verdana"><b>' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_NO_MISSING_FILES') . '</b><br /></td></tr></table>';
                }
                if ($log_message) {
                    echo '<table width="100%"><tr><td><font size="1" face="Verdana">' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_LOG_TITLE') . '<br />' . $log_message . '</font></td></tr></table>';
                }
            }
        } else {
            // error upload dir not exists
            echo '<font color="red"><b>' . JText::sprintf('COM_JDOWNLOADS_AUTOCHECK_DIR_NOT_EXIST', $jlistConfig['files.uploaddir']) . '<br /><br />' . JText::_('COM_JDOWNLOADS_AUTOCHECK_DIR_NOT_EXIST_2') . '</b></font>';
        }
    }
}
示例#10
0
文件: variants.php 项目: LOVDnl/LOVD3
 $qInsertScr2Var = $_DB->prepare('INSERT INTO ' . TABLE_SCR2VAR . ' (screeningid, variantid) VALUES (?, ?)');
 // When doing slow things, we can provide a more detailed status message in the 'done' message box.
 $_BAR->setMessageVisibility('done', true);
 // Start parsing variants.
 $aUnsupportedLines = array();
 while ($aVariant = lovd_getVariantFromSeattleSeq($fInput)) {
     // Empty the arrays that will hold the variant data to be inserted into the database.
     $aFieldsVariantOnGenome = array();
     // [0] is the first variant, [1] is filled in case of compound heterozygosity.
     $aFieldsVariantOnTranscript = array();
     // lovd_fetchDBID wants to have some additional data in the variant's array which we need to store separately for now.
     $aTranscriptDataForDBID = array();
     // And we use this just to be able to cache the numberConversion calls.
     $aNumberConversion = array();
     if ($nCount % 10 == 0) {
         $_BAR->setMessage('Processed ' . $nCount . ' variants<BR>' . 'Time working: ' . gmdate('H:i:s', time() - $tStart));
     }
     $nCount++;
     // Prepare genomic variant.
     $aFieldsVariantOnGenome[0] = array('effectid' => $_SETT['var_effect_default'], 'chromosome' => !isset($aVariant['chromosome']) ? '' : $aVariant['chromosome'], 'owned_by' => $_POST['owned_by'], 'statusid' => $_POST['statusid'], 'created_by' => $_AUTH['id'], 'created_date' => $aUploadData['upload_date']);
     if (in_array('VariantOnGenome/Conservation_score/GERP', $aVOGColumnsAvailable) && !in_array($aVariant['consScoreGERP'], array('NA', 'unknown', 'none'))) {
         $aFieldsVariantOnGenome[0]['VariantOnGenome/Conservation_score/GERP'] = $aVariant['consScoreGERP'];
     }
     if ($_POST['dbSNP_column'] > 0 && preg_match('/\\d+/', $aVariant['rsID'], $aDbSNP) && $aDbSNP[0] != '0') {
         // Include custom link to dbSNP if the user wants that and we have an rsID for this variant.
         if ($aDbSNPColumns[$_POST['dbSNP_column']] == 'VariantOnGenome/dbSNP') {
             $aFieldsVariantOnGenome[0][$aDbSNPColumns[$_POST['dbSNP_column']]] = 'rs' . $aDbSNP[0];
         } else {
             $aFieldsVariantOnGenome[0][$aDbSNPColumns[$_POST['dbSNP_column']]] = '{dbSNP:rs' . $aDbSNP[0] . '}';
         }
     }
示例#11
0
文件: index.php 项目: ragchuck/pv
}
?>
<p>
ProgressBar.class.php is an easy to use solution for time consuming operations and loops in PHP.
</p>
<p>
The class increases the timelimit for script-execution (if safe-mode is turned off), prevents a browser-timeout by sending pieces auf the progressbar to the browser and gives the user live-feedback on the progress of the running operation.
</p>
<p>
As of version 1.2 you can use setter-methods to change the appeareance of the bar at runtime. Have a look at the source of this demo to see how it works!
</p>

<?php 
$bar1 = new ProgressBar('End of simulation: 0%');
$bar1->setForegroundColor('#FFA200');
$elements1 = 3;
//total number of elements to process
$bar1->initialize($elements1);
//print the empty bar
for ($i = 0; $i < $elements1; $i++) {
    sleep(1);
    // simulate a time consuming process
    $bar1->increase();
    //calls the bar with every processed element
    $bar1->setMessage('End of simulation: ' . ($i + 1) * 33 . '%');
}
$bar1->setMessage('End of simulation: 100%');
?>
</body>
</html>
示例#12
0
文件: data_load.php 项目: ragchuck/pv
sort($arFiles);
$anzFiles = count($arFiles);
$aktFile = 1;
$put = array();
?>
<h2>Es sind <?php 
echo $anzFiles;
?>
 Dateien vorhanden</h2>
<?php 
if ($anzFiles == 0) {
    die("<p>keine neuen Dateien vorhanden</p></body></html>");
}
require_once './ProgressBar/ProgressBar.class.php';
$bar = new ProgressBar();
$bar->setMessage('loading ...');
$bar->setAutohide(true);
$bar->setSleepOnFinish(0);
$bar->setForegroundColor('#3F41FF');
$bar->initialize($anzFiles);
//print the empty bar
foreach ($arFiles as $ZipFile) {
    include "./load_zipfile.php";
    $bar->increase();
    //calls the bar with every processed element
    $bar->setMessage("File {$aktFile}/{$anzFiles}: {$ZipFile}");
    $aktFile++;
}
print $put["message"];
?>
</body>