Пример #1
0
function checkPrereqs()
{
    if (file_exists(INSTALLDIR.'/config.php')) {
         ?><p class="error">Config file &quot;config.php&quot; already exists.</p>
         <?
        return false;
    }

    if (version_compare(PHP_VERSION, '5.0.0', '<')) {
            ?><p class="error">Require PHP version 5 or greater.</p><?
		    return false;
    }

    $reqs = array('gd', 'mysql', 'curl',
                  'xmlwriter', 'mbstring',
                  'gettext');

    foreach ($reqs as $req) {
        if (!checkExtension($req)) {
            ?><p class="error">Cannot load required extension &quot;<?php 
echo $req;
?>
&quot;.</p><?
		    return false;
        }
    }

	if (!is_writable(INSTALLDIR)) {
         ?><p class="error">Cannot write config file to &quot;<?php 
echo INSTALLDIR;
?>
&quot;.</p>
	       <p>On your server, try this command:</p>
	       <blockquote>chmod a+w <?php 
echo INSTALLDIR;
?>
</blockquote>
         <?
	     return false;
	}

	if (!is_writable(INSTALLDIR.'/avatar/')) {
         ?><p class="error">Cannot write avatar directory &quot;<?php 
echo INSTALLDIR;
?>
/avatar/&quot;.</p>
	       <p>On your server, try this command:</p>
	       <blockquote>chmod a+w <?php 
echo INSTALLDIR;
?>
/avatar/</blockquote>
         <?
	     return false;
	}

	return true;
}
Пример #2
0
            </div>
            <!-- /.navbar-static-side -->
        </nav>

        <!-- Page Content -->
        <div id="page-wrapper">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <h1 class="page-header">Forms</h1>                                               
                        <?php 
include "../../databaseInfo.php";
define("TARGET_DIR", "../../forms/");
if (!empty($_POST["formName"]) && !empty($_FILES["fileUpload"]["name"])) {
    if (!file_exists(TARGET_DIR . $_FILES["fileUpload"]["name"])) {
        if (checkExtension(pathinfo($_FILES["fileUpload"]["name"], PATHINFO_EXTENSION))) {
            if (move_uploaded_file($_FILES["fileUpload"]["tmp_name"], TARGET_DIR . $_FILES["fileUpload"]["name"])) {
                if (submitInformation(trim($_POST["formName"]), $_FILES["fileUpload"]["name"])) {
                    displayForm("success", "");
                } else {
                    unlink(TARGET_DIR . basename($_FILES["fileUpload"]["name"]));
                    displayForm("fail_submit", $_POST["formName"]);
                }
            } else {
                displayForm("fail_upload", $_POST["formName"]);
            }
        } else {
            displayForm("fail_file_ext", $_POST["formName"]);
        }
    } else {
        displayForm("fail_file_exist", $_POST["formName"]);
Пример #3
0
function asterisk_handleResponse3($mainresponse, $adb, $asterisk)
{
    $uid = false;
    $receiver_callerinfo = false;
    // Asterisk 1.4 (Event: Link), Asterisk 1.6 (Event: Bride, Bridgestate: Link)
    if ($mainresponse['Event'] == 'Link' || $mainresponse['Event'] == 'Bridge' && $mainresponse['Bridgestate'] == 'Link') {
        $uid = $mainresponse['Uniqueid1'];
        $uid2 = $mainresponse['Uniqueid2'];
        $callerNumber = $mainresponse['CallerID1'];
        $extensionCalled = $mainresponse['CallerID2'];
        // Ignore the case wheren CallerIDs are same!
        if ($callerNumber == $extensionCalled) {
            // case handled but we ignored.
            return false;
        }
        $callerType = '';
        $status = "received";
        $sourceChannel = $mainresponse['Channel1'];
        // Check if Popup has already been shown to user?
        // Due to (asterisk 1.4 bug: https://issues.asterisk.org/view.php?id=11757)
        // Popup display for Call made to queue is defered and will be handled below
        // So we need to pick up events with (flag = 0, asterisk 1.6) or (flag = -1, asterisk 1.4)
        // asterisk 1.4 - from_number is NULL,
        // TODO check the state of from_number in asterisk 1.6
        $checkres = $adb->pquery("SELECT * FROM vtiger_asteriskincomingevents WHERE uid=? and (flag = 0 or flag = -1) and (from_number is NULL or from_number = 0)", array($uid));
        if ($adb->num_rows($checkres) > 0) {
            if (empty($checkresrow['from_name'])) {
                $checkresrow['from_name'] = "Unknown";
            }
            $checkresrow = $adb->fetch_array($checkres);
            $sql = "UPDATE vtiger_asteriskincomingevents SET from_number=?, to_number=?, timer=?, flag=? WHERE uid=?";
            $adb->pquery($sql, array($callerNumber, $extensionCalled, time(), 0, $uid));
            // Check if the user has checked Incoming Calls in My Preferences
            if (checkExtension($extensionCalled, $adb)) {
                $query = "INSERT INTO vtiger_asteriskincomingcalls (refuid, from_number, from_name, to_number, callertype, flag, timer) VALUES(?,?,?,?,?,?,?)";
                $adb->pquery($query, array($uid, $callerNumber, $checkresrow['from_name'], $extensionCalled, '', 0, time()));
            }
        }
        // END
    } else {
        if ($mainresponse['Event'] == 'Newexten' && $mainresponse['AppData'] == "DIALSTATUS=CONGESTION" || $mainresponse['Event'] == 'Hangup') {
            $status = "missed";
            $uid = $mainresponse['Uniqueid'];
            $extensionCalled = false;
        }
    }
    // TODO Need to detect the caller number using the Event Information
    $callerNumberInfo = $adb->pquery("SELECT from_number, callertype FROM vtiger_asteriskincomingevents WHERE uid=? AND from_number is not NULL LIMIT 1", array($uid));
    if ($callerNumberInfo && $adb->num_rows($callerNumberInfo)) {
        $callerNumber = $adb->query_result($callerNumberInfo, 0, 'from_number');
        $receiver_callerinfo = getCallerInfo($callerNumber);
    }
    if ($uid !== false) {
        // Create Record if not yet done and link to the event for further use
        $eventResult = $adb->pquery("SELECT * FROM vtiger_asteriskincomingevents WHERE uid = ? and pbxrecordid is NULL AND flag =0", array($uid));
        if ($adb->num_rows($eventResult)) {
            $eventResultRow = $adb->fetch_array($eventResult);
            $callerNumber = $eventResultRow['from_number'];
            if ($extensionCalled === false) {
                $extensionCalled = $eventResultRow['to_number'];
            }
            // If we are not knowing the caller informatio (Asterisk 1.4, Event: Link not yet called)
            if ($callerNumber != 'Unknown' && $callerNumber != '0') {
                $pbxrecordid = addToCallHistory($extensionCalled, $callerNumber, $extensionCalled, "incoming-{$status}", $adb, $receiver_callerinfo);
                $adb->pquery("UPDATE vtiger_asteriskincomingevents SET pbxrecordid = ? WHERE uid = ?", array($pbxrecordid, $uid));
                if (!empty($receiver_callerinfo['id'])) {
                    $adb->pquery("UPDATE vtiger_asteriskincomingevents SET relcrmid = ? WHERE uid = ?", array($receiver_callerinfo['id'], $uid));
                }
            }
            return false;
        }
    }
    return true;
}
Пример #4
0
/**
 * This function displays the requirements for installing Chamilo.
 *
 * @param string $installType
 * @param boolean $badUpdatePath
 * @param boolean $badUpdatePath
 * @param string $updatePath The updatePath given (if given)
 * @param array $update_from_version_8 The different subversions from version 1.9
 *
 * @author unknow
 * @author Patrick Cool <*****@*****.**>, Ghent University
 */
function display_requirements($installType, $badUpdatePath, $updatePath = '', $update_from_version_8 = array())
{
    global $_setting;
    echo '<div class="RequirementHeading"><h2>' . display_step_sequence() . get_lang('Requirements') . "</h2></div>";
    echo '<div class="RequirementText">';
    echo '<strong>' . get_lang('ReadThoroughly') . '</strong><br />';
    echo get_lang('MoreDetails') . ' <a href="../../documentation/installation_guide.html" target="_blank">' . get_lang('ReadTheInstallationGuide') . '</a>.<br />' . "\n";
    if ($installType == 'update') {
        echo get_lang('IfYouPlanToUpgradeFromOlderVersionYouMightWantToHaveAlookAtTheChangelog') . '<br />';
    }
    echo '</div>';
    //  SERVER REQUIREMENTS
    echo '<div class="RequirementHeading"><h4>' . get_lang('ServerRequirements') . '</h4>';
    $timezone = checkPhpSettingExists("date.timezone");
    if (!$timezone) {
        echo "<div class='warning-message'>" . Display::return_icon('warning.png', get_lang('Warning'), '', ICON_SIZE_MEDIUM) . get_lang("DateTimezoneSettingNotSet") . "</div>";
    }
    echo '<div class="RequirementText">' . get_lang('ServerRequirementsInfo') . '</div>';
    echo '<div class="RequirementContent">';
    echo '<table class="table">
            <tr>
                <td class="requirements-item">' . get_lang('PHPVersion') . ' >= ' . REQUIRED_PHP_VERSION . '</td>
                <td class="requirements-value">';
    if (phpversion() < REQUIRED_PHP_VERSION) {
        echo '<strong><font color="red">' . get_lang('PHPVersionError') . '</font></strong>';
    } else {
        echo '<strong><font color="green">' . get_lang('PHPVersionOK') . ' ' . phpversion() . '</font></strong>';
    }
    echo '</td>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://php.net/manual/en/book.session.php" target="_blank">Session</a> ' . get_lang('support') . '</td>
                <td class="requirements-value">' . checkExtension('session', get_lang('Yes'), get_lang('ExtensionSessionsNotAvailable')) . '</td>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://php.net/manual/en/book.mysql.php" target="_blank">MySQL</a> ' . get_lang('support') . '</td>
                <td class="requirements-value">' . checkExtension('mysql', get_lang('Yes'), get_lang('ExtensionMySQLNotAvailable')) . '</td>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://php.net/manual/en/book.zlib.php" target="_blank">Zlib</a> ' . get_lang('support') . '</td>
                <td class="requirements-value">' . checkExtension('zlib', get_lang('Yes'), get_lang('ExtensionZlibNotAvailable')) . '</td>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://php.net/manual/en/book.pcre.php" target="_blank">Perl-compatible regular expressions</a> ' . get_lang('support') . '</td>
                <td class="requirements-value">' . checkExtension('pcre', get_lang('Yes'), get_lang('ExtensionPCRENotAvailable')) . '</td>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://php.net/manual/en/book.xml.php" target="_blank">XML</a> ' . get_lang('support') . '</td>
                <td class="requirements-value">' . checkExtension('xml', get_lang('Yes'), get_lang('No')) . '</td>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://php.net/manual/en/book.intl.php" target="_blank">Internationalization</a> ' . get_lang('support') . '</td>
                <td class="requirements-value">' . checkExtension('intl', get_lang('Yes'), get_lang('No')) . '</td>
            </tr>
               <tr>
                <td class="requirements-item"><a href="http://php.net/manual/en/book.json.php" target="_blank">JSON</a> ' . get_lang('support') . '</td>
                <td class="requirements-value">' . checkExtension('json', get_lang('Yes'), get_lang('No')) . '</td>
            </tr>

             <tr>
                <td class="requirements-item"><a href="http://php.net/manual/en/book.image.php" target="_blank">GD</a> ' . get_lang('support') . '</td>
                <td class="requirements-value">' . checkExtension('gd', get_lang('Yes'), get_lang('ExtensionGDNotAvailable')) . '</td>
            </tr>

            <tr>
                <td class="requirements-item"><a href="http://php.net/manual/en/book.mbstring.php" target="_blank">Multibyte string</a> ' . get_lang('support') . ' (' . get_lang('Optional') . ')</td>
                <td class="requirements-value">' . checkExtension('mbstring', get_lang('Yes'), get_lang('ExtensionMBStringNotAvailable'), true) . '</td>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://php.net/manual/en/book.iconv.php" target="_blank">Iconv</a> ' . get_lang('support') . ' (' . get_lang('Optional') . ')</td>
                <td class="requirements-value">' . checkExtension('iconv', get_lang('Yes'), get_lang('No'), true) . '</td>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://php.net/manual/en/book.ldap.php" target="_blank">LDAP</a> ' . get_lang('support') . ' (' . get_lang('Optional') . ')</td>
                <td class="requirements-value">' . checkExtension('ldap', get_lang('Yes'), get_lang('ExtensionLDAPNotAvailable'), true) . '</td>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://xapian.org/" target="_blank">Xapian</a> ' . get_lang('support') . ' (' . get_lang('Optional') . ')</td>
                <td class="requirements-value">' . checkExtension('xapian', get_lang('Yes'), get_lang('No'), true) . '</td>
            </tr>

            <tr>
                <td class="requirements-item"><a href="http://php.net/manual/en/book.curl.php" target="_blank">cURL</a> ' . get_lang('support') . ' (' . get_lang('Optional') . ')</td>
                <td class="requirements-value">' . checkExtension('curl', get_lang('Yes'), get_lang('No'), true) . '</td>
            </tr>

          </table>';
    echo '  </div>';
    echo '</div>';
    // RECOMMENDED SETTINGS
    // Note: these are the settings for Joomla, does this also apply for Chamilo?
    // Note: also add upload_max_filesize here so that large uploads are possible
    echo '<div class="RequirementHeading"><h4>' . get_lang('RecommendedSettings') . '</h4>';
    echo '<div class="RequirementText">' . get_lang('RecommendedSettingsInfo') . '</div>';
    echo '<div class="RequirementContent">';
    echo '<table class="table">
            <tr>
                <th>' . get_lang('Setting') . '</th>
                <th>' . get_lang('Recommended') . '</th>
                <th>' . get_lang('Actual') . '</th>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://php.net/manual/features.safe-mode.php">Safe Mode</a></td>
                <td class="requirements-recommended">' . Display::label('OFF', 'success') . '</td>
                <td class="requirements-value">' . checkPhpSetting('safe_mode', 'OFF') . '</td>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://php.net/manual/ref.errorfunc.php#ini.display-errors">Display Errors</a></td>
                <td class="requirements-recommended">' . Display::label('OFF', 'success') . '</td>
                <td class="requirements-value">' . checkPhpSetting('display_errors', 'OFF') . '</td>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.file-uploads">File Uploads</a></td>
                <td class="requirements-recommended">' . Display::label('ON', 'success') . '</td>
                <td class="requirements-value">' . checkPhpSetting('file_uploads', 'ON') . '</td>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://php.net/manual/ref.info.php#ini.magic-quotes-gpc">Magic Quotes GPC</a></td>
                <td class="requirements-recommended">' . Display::label('OFF', 'success') . '</td>
                <td class="requirements-value">' . checkPhpSetting('magic_quotes_gpc', 'OFF') . '</td>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://php.net/manual/ref.info.php#ini.magic-quotes-runtime">Magic Quotes Runtime</a></td>
                <td class="requirements-recommended">' . Display::label('OFF', 'success') . '</td>
                <td class="requirements-value">' . checkPhpSetting('magic_quotes_runtime', 'OFF') . '</td>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://php.net/manual/security.globals.php">Register Globals</a></td>
                <td class="requirements-recommended">' . Display::label('OFF', 'success') . '</td>
                <td class="requirements-value">' . checkPhpSetting('register_globals', 'OFF') . '</td>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://php.net/manual/ref.session.php#ini.session.auto-start">Session auto start</a></td>
                <td class="requirements-recommended">' . Display::label('OFF', 'success') . '</td>
                <td class="requirements-value">' . checkPhpSetting('session.auto_start', 'OFF') . '</td>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.short-open-tag">Short Open Tag</a></td>
                <td class="requirements-recommended">' . Display::label('OFF', 'success') . '</td>
                <td class="requirements-value">' . checkPhpSetting('short_open_tag', 'OFF') . '</td>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-httponly">Cookie HTTP Only</a></td>
                <td class="requirements-recommended">' . Display::label('ON', 'success') . '</td>
                <td class="requirements-value">' . checkPhpSetting('session.cookie_httponly', 'ON') . '</td>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.upload-max-filesize">Maximum upload file size</a></td>
                <td class="requirements-recommended">' . Display::label('>= ' . REQUIRED_MIN_UPLOAD_MAX_FILESIZE . 'M', 'success') . '</td>
                <td class="requirements-value">' . compare_setting_values(ini_get('upload_max_filesize'), REQUIRED_MIN_UPLOAD_MAX_FILESIZE) . '</td>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://php.net/manual/ini.core.php#ini.post-max-size">Maximum post size</a></td>
                <td class="requirements-recommended">' . Display::label('>= ' . REQUIRED_MIN_POST_MAX_SIZE . 'M', 'success') . '</td>
                <td class="requirements-value">' . compare_setting_values(ini_get('post_max_size'), REQUIRED_MIN_POST_MAX_SIZE) . '</td>
            </tr>
            <tr>
                <td class="requirements-item"><a href="http://www.php.net/manual/en/ini.core.php#ini.memory-limit">Memory Limit</a></td>
                <td class="requirements-recommended">' . Display::label('>= ' . REQUIRED_MIN_MEMORY_LIMIT . 'M', 'success') . '</td>
                <td class="requirements-value">' . compare_setting_values(ini_get('memory_limit'), REQUIRED_MIN_MEMORY_LIMIT) . '</td>
            </tr>
          </table>';
    echo '  </div>';
    echo '</div>';
    // DIRECTORY AND FILE PERMISSIONS
    echo '<div class="RequirementHeading"><h4>' . get_lang('DirectoryAndFilePermissions') . '</h4>';
    echo '<div class="RequirementText">' . get_lang('DirectoryAndFilePermissionsInfo') . '</div>';
    echo '<div class="RequirementContent">';
    $course_attempt_name = '__XxTestxX__';
    $course_dir = api_get_path(SYS_COURSE_PATH) . $course_attempt_name;
    //Just in case
    @unlink($course_dir . '/test.php');
    @rmdir($course_dir);
    $perms_dir = array(0777, 0755, 0775, 0770, 0750, 0700);
    $perms_fil = array(0666, 0644, 0664, 0660, 0640, 0600);
    $course_test_was_created = false;
    $dir_perm_verified = 0777;
    foreach ($perms_dir as $perm) {
        $r = @mkdir($course_dir, $perm);
        if ($r === true) {
            $dir_perm_verified = $perm;
            $course_test_was_created = true;
            break;
        }
    }
    $fil_perm_verified = 0666;
    $file_course_test_was_created = false;
    if (is_dir($course_dir)) {
        foreach ($perms_fil as $perm) {
            if ($file_course_test_was_created == true) {
                break;
            }
            $r = @touch($course_dir . '/test.php', $perm);
            if ($r === true) {
                $fil_perm_verified = $perm;
                if (check_course_script_interpretation($course_dir, $course_attempt_name, 'test.php')) {
                    $file_course_test_was_created = true;
                }
            }
        }
    }
    @unlink($course_dir . '/test.php');
    @rmdir($course_dir);
    $_SESSION['permissions_for_new_directories'] = $_setting['permissions_for_new_directories'] = $dir_perm_verified;
    $_SESSION['permissions_for_new_files'] = $_setting['permissions_for_new_files'] = $fil_perm_verified;
    $dir_perm = Display::label('0' . decoct($dir_perm_verified), 'info');
    $file_perm = Display::label('0' . decoct($fil_perm_verified), 'info');
    $courseTestLabel = Display::label(get_lang('No'), 'important');
    if ($course_test_was_created && $file_course_test_was_created) {
        $courseTestLabel = Display::label(get_lang('Yes'), 'success');
    }
    if ($course_test_was_created && !$file_course_test_was_created) {
        $courseTestLabel = Display::label(sprintf(get_lang('InstallWarningCouldNotInterpretPHP'), api_get_path(WEB_COURSE_PATH) . $course_attempt_name . '/test.php'), 'warning');
    }
    if (!$course_test_was_created && !$file_course_test_was_created) {
        $courseTestLabel = Display::label(get_lang('No'), 'important');
    }
    $oldConf = '';
    if (file_exists(api_get_path(SYS_CODE_PATH) . 'inc/conf/configuration.php')) {
        $oldConf = '<tr>
            <td class="requirements-item">' . api_get_path(SYS_CODE_PATH) . 'inc/conf</td>
            <td class="requirements-value">' . check_writable(api_get_path(SYS_CODE_PATH) . 'inc/conf') . '</td>
        </tr>';
    }
    echo '<table class="table">
            ' . $oldConf . '
            <tr>
                <td class="requirements-item">' . api_get_path(SYS_APP_PATH) . '</td>
                <td class="requirements-value">' . check_writable(api_get_path(SYS_APP_PATH)) . '</td>
            </tr>
            <tr>
                <td class="requirements-item">' . api_get_path(SYS_CODE_PATH) . 'default_course_document/images/</td>
                <td class="requirements-value">' . check_writable(api_get_path(SYS_CODE_PATH) . 'default_course_document/images/') . '</td>
            </tr>
            <tr>
                <td class="requirements-item">' . api_get_path(SYS_CODE_PATH) . 'lang/</td>
                <td class="requirements-value">' . check_writable(api_get_path(SYS_CODE_PATH) . 'lang/', true) . ' <br />(' . get_lang('SuggestionOnlyToEnableSubLanguageFeature') . ')</td>
            </tr>
            <tr>
                <td class="requirements-item">' . api_get_path(SYS_PATH) . 'vendor/</td>
                <td class="requirements-value">' . checkReadable(api_get_path(SYS_PATH) . 'vendor') . '</td>
            </tr>
            <tr>
                <td class="requirements-item">' . api_get_path(SYS_PUBLIC_PATH) . '</td>
                <td class="requirements-value">' . check_writable(api_get_path(SYS_PUBLIC_PATH)) . '</td>
            </tr>
            <tr>
                <td class="requirements-item">' . get_lang('CourseTestWasCreated') . '</td>
                <td class="requirements-value">' . $courseTestLabel . ' </td>
            </tr>
            <tr>
                <td class="requirements-item">' . get_lang('PermissionsForNewDirs') . '</td>
                <td class="requirements-value">' . $dir_perm . ' </td>
            </tr>
            <tr>
                <td class="requirements-item">' . get_lang('PermissionsForNewFiles') . '</td>
                <td class="requirements-value">' . $file_perm . ' </td>
            </tr>
            ';
    echo '    </table>';
    echo '  </div>';
    echo '</div>';
    if ($installType == 'update' && (empty($updatePath) || $badUpdatePath)) {
        if ($badUpdatePath) {
            ?>
            <div class="alert alert-warning">
                <?php 
            echo get_lang('Error');
            ?>
!<br />
                Chamilo <?php 
            echo implode('|', $update_from_version_8) . ' ' . get_lang('HasNotBeenFoundInThatDir');
            ?>
.
            </div>
        <?php 
        } else {
            echo '<br />';
        }
        ?>
            <div class="row">
                <div class="col-md-12">
                    <p><?php 
        echo get_lang('OldVersionRootPath');
        ?>
:
                        <input type="text" name="updatePath" size="50" value="<?php 
        echo $badUpdatePath && !empty($updatePath) ? htmlentities($updatePath) : api_get_path(SYS_SERVER_ROOT_PATH) . 'old_version/';
        ?>
" />
                    </p>
                    <p>
                        <button type="submit" class="btn btn-default" name="step1" value="<?php 
        echo get_lang('Back');
        ?>
" >
                            <i class="fa fa-backward"> <?php 
        echo get_lang('Back');
        ?>
</i>
                        </button>
                        <input type="hidden" name="is_executable" id="is_executable" value="-" />
                        <button type="submit" class="btn btn-success" name="<?php 
        echo isset($_POST['step2_update_6']) ? 'step2_update_6' : 'step2_update_8';
        ?>
" value="<?php 
        echo get_lang('Next');
        ?>
 &gt;" >
                            <i class="fa fa-forward"> </i> <?php 
        echo get_lang('Next');
        ?>
                        </button>
                    </p>
                </div>
            </div>

        <?php 
    } else {
        $error = false;
        // First, attempt to set writing permissions if we don't have them yet
        $perm = api_get_permissions_for_new_directories();
        $perm_file = api_get_permissions_for_new_files();
        $notWritable = array();
        $checked_writable = api_get_path(SYS_APP_PATH);
        if (!is_writable($checked_writable)) {
            $notWritable[] = $checked_writable;
            @chmod($checked_writable, $perm);
        }
        $checked_writable = api_get_path(SYS_PUBLIC_PATH);
        if (!is_writable($checked_writable)) {
            $notWritable[] = $checked_writable;
            @chmod($checked_writable, $perm);
        }
        $checked_writable = api_get_path(SYS_CODE_PATH) . 'default_course_document/images/';
        if (!is_writable($checked_writable)) {
            $notWritable[] = $checked_writable;
            @chmod($checked_writable, $perm);
        }
        if ($course_test_was_created == false) {
            $error = true;
        }
        $checked_writable = api_get_path(CONFIGURATION_PATH) . 'configuration.php';
        if (file_exists($checked_writable) && !is_writable($checked_writable)) {
            $notWritable[] = $checked_writable;
            @chmod($checked_writable, $perm_file);
        }
        // Second, if this fails, report an error
        //--> The user would have to adjust the permissions manually
        if (count($notWritable) > 0) {
            $error = true;
            echo '<div class="error-message">';
            echo '<center><h3>' . get_lang('Warning') . '</h3></center>';
            printf(get_lang('NoWritePermissionPleaseReadInstallGuide'), '</font>
                <a href="../../documentation/installation_guide.html" target="blank">', '</a> <font color="red">');
            echo '</div>';
            echo '<ul>';
            foreach ($notWritable as $value) {
                echo '<li>' . $value . '</li>';
            }
            echo '</ul>';
        } elseif (file_exists(api_get_path(CONFIGURATION_PATH) . 'configuration.php')) {
            // Check wether a Chamilo configuration file already exists.
            echo '<div class="alert alert-warning"><h4><center>';
            echo get_lang('WarningExistingLMSInstallationDetected');
            echo '</center></h4></div>';
        }
        // And now display the choice buttons (go back or install)
        ?>
        <p align="center" style="padding-top:15px">
        <button type="submit" name="step1" class="btn btn-default" onclick="javascript: window.location='index.php'; return false;" value="<?php 
        echo get_lang('Previous');
        ?>
" >
            <i class="fa fa-backward"> </i> <?php 
        echo get_lang('Previous');
        ?>
        </button>
        <button type="submit" name="step2_install" class="btn btn-success" value="<?php 
        echo get_lang("NewInstallation");
        ?>
" <?php 
        if ($error) {
            echo 'disabled="disabled"';
        }
        ?>
 >
            <i class="fa fa-forward"> </i> <?php 
        echo get_lang('NewInstallation');
        ?>
        </button>
        <input type="hidden" name="is_executable" id="is_executable" value="-" />
        <?php 
        // Real code
        echo '<button type="submit" class="btn btn-default" name="step2_update_8" value="Upgrade from Chamilo 1.9.x"';
        if ($error) {
            echo ' disabled="disabled"';
        }
        echo ' ><i class="fa fa-forward"> </i> ' . get_lang('UpgradeFromLMS19x') . '</button>';
        echo '</p>';
    }
}
/**
 * this function checks if there are any incoming calls for the current user
 * if any call is found, it just inserts the values into the vtiger_asteriskincomingcalls table
 * 
 * @param $asterisk - the asterisk object
 * @param $adb - the peardatabase type object
 * @return	incoming call information if successful
 * 			false if unsuccessful
 */
function handleIncomingCalls($asterisk, $adb, $version = "1.4")
{
    $response = $asterisk->getAsteriskResponse();
    if (empty($response)) {
        return false;
    }
    $callerNumber = "Unknown";
    $callerName = "Unknown";
    //event can be both newstate and newchannel :: this is an asterisk bug and can be found at
    //http://lists.digium.com/pipermail/asterisk-dev/2006-July/021565.html
    if ($version == "1.6") {
        $state = "ChannelStateDesc";
    } else {
        $state = "State";
    }
    if (($response['Event'] == 'Newstate' || $response['Event'] == 'Newchannel') && ($response[$state] == 'Ring' || $response[$state] == 'Ringing')) {
        //get the caller information
        if (!empty($response['CallerID'])) {
            $callerNumber = $response['CallerID'];
        } elseif (!empty($response['CallerIDNum'])) {
            $callerNumber = $response['CallerIDNum'];
        }
        if (!empty($response['CallerIDName'])) {
            $callerName = $response['CallerIDName'];
        }
        while (true) {
            $response = $asterisk->getAsteriskResponse();
            if ($response['Event'] == 'Newexten' && (strstr($response['AppData'], "__DIALED_NUMBER") || strstr($response['AppData'], "EXTTOCALL"))) {
                $temp = array();
                if (strstr($response['Channel'], $callerNumber)) {
                    $temp = explode("/", $response['Channel']);
                    $callerType = $temp[0];
                }
                $temp = explode("=", $response['AppData']);
                $extension = $temp[1];
                if (checkExtension($extension, $adb)) {
                    //insert into database
                    $sql = "insert into vtiger_asteriskincomingcalls values (?,?,?,?,?,?)";
                    $flag = 0;
                    $timer = time();
                    $params = array($callerNumber, $callerName, $extension, $callerType, $flag, $timer);
                    $adb->pquery($sql, $params);
                    addToCallHistory($extension, $callerType . ":" . $callerNumber, $extension, "incoming", $adb);
                    break;
                    //break the while loop
                }
            }
        }
    } else {
        return false;
    }
}
Пример #6
0
function fileupload()
{
    global $modx, $_lang, $startpath, $filemanager_path, $uploadablefiles, $new_file_permissions;
    $msg = '';
    if (!empty($_FILES['userfile']['tmp_name'])) {
        $userfile['tmp_name'] = $_FILES['userfile']['tmp_name'];
        $userfile['error'] = $_FILES['userfile']['error'];
        $name = $_FILES['userfile']['name'];
        if ($modx->config['clean_uploaded_filename'] == 1) {
            $nameparts = explode('.', $name);
            $nameparts = array_map(array($modx, 'stripAlias'), $nameparts, array('file_manager'));
            $name = implode('.', $nameparts);
        }
        $userfile['name'] = $name;
        $userfile['type'] = $_FILES['userfile']['type'];
    }
    // this seems to be an upload action.
    $path = $modx->config['site_url'] . substr($startpath, strlen($filemanager_path), strlen($startpath));
    $path = rtrim($path, '/') . '/' . $userfile['name'];
    $msg .= $path;
    if ($userfile['error'] == 0) {
        $img = strpos($userfile['type'], 'image') !== false ? '<br /><img src="' . $path . '" height="75" />' : '';
        $msg .= "<p>" . $_lang['files_file_type'] . $userfile['type'] . ", " . $modx->nicesize(filesize($userfile['tmp_name'])) . $img . '</p>';
    }
    $userfilename = $userfile['tmp_name'];
    if (is_uploaded_file($userfilename)) {
        // file is uploaded file, process it!
        if (!checkExtension($userfile['name'])) {
            $msg .= '<p><span class="warning">' . $_lang['files_filetype_notok'] . '</span></p>';
        } else {
            if (@move_uploaded_file($userfile['tmp_name'], $_POST['path'] . '/' . $userfile['name'])) {
                // Ryan: Repair broken permissions issue with file manager
                if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
                    @chmod($_POST['path'] . "/" . $userfile['name'], $new_file_permissions);
                }
                // Ryan: End
                $msg .= '<p><span class="success">' . $_lang['files_upload_ok'] . '</span></p>';
                // invoke OnFileManagerUpload event
                $modx->invokeEvent('OnFileManagerUpload', array('filepath' => $_POST['path'], 'filename' => $userfile['name']));
                // Log the change
                logFileChange('upload', $_POST['path'] . '/' . $userfile['name']);
            } else {
                $msg .= '<p><span class="warning">' . $_lang['files_upload_copyfailed'] . '</span> ' . $_lang["files_upload_permissions_error"] . '</p>';
            }
        }
    } else {
        $msg .= '<br /><span class="warning"><b>' . $_lang['files_upload_error'] . ':</b>';
        switch ($userfile['error']) {
            case 0:
                //no error; possible file attack!
                $msg .= $_lang['files_upload_error0'];
                break;
            case 1:
                //uploaded file exceeds the upload_max_filesize directive in php.ini
                $msg .= $_lang['files_upload_error1'];
                break;
            case 2:
                //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
                $msg .= $_lang['files_upload_error2'];
                break;
            case 3:
                //uploaded file was only partially uploaded
                $msg .= $_lang['files_upload_error3'];
                break;
            case 4:
                //no file was uploaded
                $msg .= $_lang['files_upload_error4'];
                break;
            default:
                //a default error, just in case!  :)
                $msg .= $_lang['files_upload_error5'];
                break;
        }
        $msg .= '</span><br />';
    }
    return $msg;
}
Пример #7
0
function doSBONUpload()
{
    global $tablePrefix;
    $cap_sbonToVoting = getDbText("sbon_toVoting");
    $allowedExtensions = array(".gif", ".jpg", ".jpeg");
    $errMessages = array("Upload war erfolgreich!", "Die Dateigr&ouml;sse &uuml;berschreitet die Servereinstellungen!", "Die Dateigr&ouml;sse &uuml;berschreitet die Formulareinstellungen!", "Die Datei wurde nur teilweise geladen!", "Es wurde keine Datei geladen!", "Es sind nur folgende Dateitypen erlaubt: ");
    foreach ($allowedExtensions as $curExt) {
        $errMessages[5] .= "{$curExt}, ";
    }
    $errMessages[5] = substr($errMessages[5], 0, -2);
    echo <<<EOT
  <p>
  <img src="images/ico_pfeillinks.gif" width="13" height="13" border="0" alt="" align="absmiddle">&nbsp;
  <a href="sbon-bewertung.php"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">{$cap_sbonToVoting}</font></a>
  </p>
EOT;
    $newLocationDir = "images/sbon/";
    $uploadFileExtension = checkExtension($_FILES['userfile']['name'], $allowedExtensions);
    if (!$uploadFileExtension) {
        $curError = 5;
    } else {
        $curError = $_FILES['userfile']['error'];
    }
    if ($curError == 0) {
        $msgColor = "#000000";
    } else {
        $msgColor = "#FF0000";
    }
    echo "<font size=\"3\" color=\"{$msgColor}\"><b>{$errMessages[$curError]}</b></font><br>\n";
    $info .= "<br>";
    $info .= "name=" . $_FILES['userfile']['name'] . "<br>";
    $info .= "type=" . $_FILES['userfile']['type'] . "<br>";
    $info .= "size=" . $_FILES['userfile']['size'] . "<br>";
    $info .= "tmp_name=" . $_FILES['userfile']['tmp_name'] . "<br>";
    $info .= "error=" . $_FILES['userfile']['error'] . "<br>\n";
    if ($curError == 0) {
        mysql_query("INSERT INTO {$tablePrefix}sbonImage VALUES ('', '', NOW(), '', '')") or die("itemView.php;doSBONUpload(.): Database error (" . mysql_error() . ")");
        $newSBONImageID = mysql_insert_id();
        $newFilename = "upload{$newSBONImageID}{$uploadFileExtension}";
        $newLocation = "{$newLocationDir}{$newFilename}";
        $info .= "newLocation={$newLocation}<br>\n";
        // this would also overwrite an existing file
        if (move_uploaded_file($_FILES['userfile']['tmp_name'], $newLocation)) {
            $info .= "moving OK<br>";
            chmod($newLocation, 0644);
            echo "<br><a href=\"sbon-bewertung.php?sbonID={$newSBONImageID}\"><img src=\"{$newLocation}\" border=\"0\"></a><br>\n";
            echo "Bild gleich bewerten, einfach auf's Bild klicken!";
            mysql_query("UPDATE {$tablePrefix}sbonImage SET url='{$newFilename}' WHERE sbon_id={$newSBONImageID}") or die("itemView.php;doSBONUpload(.): Database error (" . mysql_error() . ")");
        } else {
            $info .= "moving NOTOK<br>";
            mysql_query("REMOVE FROM {$tablePrefix}sbonImage WHERE sbon_id={$newSBONImageID}") or die("itemView.php;doSBONUpload(.): Database error (" . mysql_error() . ")");
        }
    }
    //	 echo $info;
}
Пример #8
0
function delete($setup)
{
    //Get the image ID
    $id = htmlentities($setup['imageId']);
    //Check the file extension to make sure that it's valid
    checkExtension($id);
    //Get the directory to get the images from
    $dir = getDir($setup);
    //Make sure that it is actually a directory
    checkImageDirectoryExists($dir);
    //Check to make sure that the image actually exists
    if (imageExists($dir . '/' . $id)) {
        //Delete the file
        unlink($dir . '/' . $id);
        echo json_encode(['success' => true, 'message' => 'Image successfully deleted.']);
        exit;
    } else {
        echo json_encode(['success' => false, 'message' => 'That image could not be found.']);
        exit;
    }
}
Пример #9
0
}
if (!empty($time)) {
    echo "Photo already uploaded for that show";
    exit;
}
if (!empty($_FILES["up_file"]) && $_FILES['up_file']['error'] == 0) {
    echo "found a file!";
    //echo "dirname:".dirname(__FILE__);
    //  exit();
    //Check if the file is JPEG image and it's size is less than 500Kb
    $filename = basename($_FILES['up_file']['name']);
    $ext = substr($filename, strrpos($filename, '.') + 1);
    // allow other extensions: png, gif, jpeg
    //  if (($ext == "jpg") && ($_FILES["up_file"]["type"] == "image/jpeg") &&
    //    ($_FILES["up_file"]["size"] < 500000)) {
    if (checkExtension($ext) && checkFileSize()) {
        $fname = $sdate . "_" . $u . "." . $ext;
        $newname = dirname(__FILE__) . '/tmp/' . $fname;
        echo $newname;
        //Check if the file with the same name is already exists on the server
        if (!file_exists($newname)) {
            //Attempt to move the uploaded file to it's new place
            if (move_uploaded_file($_FILES['up_file']['tmp_name'], $newname)) {
                echo "File has been submitted!";
            } else {
                echo "Error: A problem occurred during file upload!";
                exit;
            }
        } else {
            echo "Error: Photo from user " . $u . " from the show on " . $sdate . " already exists";
            exit;
Пример #10
0
function importFile()
{
    $strInitialPosition = stripos($_SERVER["SERVER_SOFTWARE"], "Win32");
    $serverOS = substr($_SERVER["SERVER_SOFTWARE"], $strInitialPosition, "5");
    if ($serverOS == "Win32") {
        //Variaveis para Windows
        $pathMX = BVS_DIR . "\\cgi-bin\\mx";
        $uploaddir = BVS_DIR . "\\temp\\secs-web\\importedFiles\\";
    } else {
        //Variaveis para Linux
        $pathMX = BVS_DIR . "/cgi-bin/mx";
        $uploaddir = BVS_DIR . "/temp/secs-web/importedFiles/";
    }
    $uploadfile = $uploaddir . $_FILES['importFile']['name'];
    $extension = end(explode(".", $_FILES['importFile']['name']));
    $filesize = $_FILES['importFile']['size'];
    try {
        checkExtension($extension);
        checkFilesize($filesize);
    } catch (Exception $error) {
        print $error->getMessage();
        die;
    }
    if (move_uploaded_file($_FILES['importFile']['tmp_name'], $uploaddir . $_FILES['importFile']['name'])) {
        $importedFile = file($uploadfile);
        for ($i = 0; $i < count($importedFile); $i++) {
            $dataModel = new facicOperations();
            $temporaryArray = explode('|', $importedFile[$i]);
            $array_content = array("database" => "FACIC", "centerCode" => $temporaryArray[0], "titleCode" => $temporaryArray[1], "codeNameMask" => $temporaryArray[2], "year" => $temporaryArray[3], "volume" => $temporaryArray[4], "issue" => $temporaryArray[5], "number" => $temporaryArray[6], "creationDate" => date('Ymd'), "changeDate" => date('Ymd'), "documentalistCreation" => $_SESSION["logged"], "documentalistChange" => $_SESSION["logged"]);
            print "Registro #" . $i . " incluido com sucesso<br/>";
            $dataModel->createRecord($array_content);
            $dataModel->saveRecord("New");
        }
    } else {
        //user_error($BVS_LANG["errorImport"],E_USER_ERROR);
        print "error: ";
        print_r($_FILES);
    }
}
Пример #11
0
$email = $_POST['email'];
//$image = $_POST['image'];
$image = $_FILES['image']['tmp_name'];
$result = mysqli_query($con, "SELECT * FROM user WHERE uUser='******'") or die("Problemas enla consulta: " . mysqli_error($con));
$total = mysqli_num_rows($result);
if ($total == 0) {
    //valida que El usuario no exista
    $nuevodirectorio = "../img/pic/";
    $archivo_subir_1 = $nuevodirectorio . $_FILES['image']['name'];
    //separamos los trozos del archivo, nombre extension
    $trozos = explode(".", $_FILES['image']['name']);
    //obtenemos la extension
    $extension = end($trozos);
    //Inicia inserccion de portada++++++++++++++++++++++++++++++++++++++++++++++++++
    //si la extensión es una de las permitidas
    if (checkExtension($extension) === TRUE) {
        if (move_uploaded_file($image, $archivo_subir_1)) {
            $resultado = substr($archivo_subir_1, 3);
            //elimina el ../ de la ruta
            $query1 = "INSERT INTO user(uUser,uPassword,uName,uLastname,uTitle,uMail,uPhone,uAddress,uStatus,uImg,uHide) VALUES ('{$username}','{$password}','{$firstname}','{$lastname}','{$title}','{$phone}','{$address}','{$email}','1','{$resultado}','1')";
            $result = mysqli_query($con, $query1);
            if (!$result) {
                echo 'La consulta SQL contiene errores.' . mysqli_error($con) . "\n";
            } else {
                echo "DATOS INSERTADOS CORRECTAMENTE\n";
            }
        } else {
            echo "error al subir archivo";
        }
    } else {
        echo 'Incorrect file type, Try Again';