Sindbad~EG File Manager

Current Path : /home/copmadinaarea/public_html/wp-content__80fcb17/plugins/mozable/
Upload File :
Current File : /home/copmadinaarea/public_html/wp-content__80fcb17/plugins/mozable/status.php

<?php
global $wpdb;
$table_name = $wpdb->prefix . "moz_apps";

$apps = $wpdb->get_results("SELECT * FROM $table_name ORDER BY time DESC LIMIT 50", ARRAY_A);

$status_class = array(
    "Submitted" => 'fa fa-upload',
    "Rejected" => 'fa fa-exclamation',
    "Build in progress" => 'fa fa-clock',
    "Generated" => 'fa fa-check-circle',
    "Error" => 'fa fa-exclamation-triangle',
    "Deleted" => 'fa fa-calendar-times',
);

$build_in_progress = false;
$table_name = $wpdb->prefix . "moz_apps";
if ($apps) {
    $x = 0;
    foreach ($apps as $app) {
        if (in_array($app['status'], array('Deleted', 'Error', 'Generated'))) {
            continue;
        }
        //$result = file_get_contents("https://mozable.com/administrator/mozable/get_status/" . $app['server_id']);
        $request = wp_remote_get("https://mozable.com/administrator/mozable/get_status/" . $app['server_id']);
        $result = wp_remote_retrieve_body( $request );

        $app_server = json_decode($result, true);

        if ($app_server['data']['apps_request_status_value'] != $app['status']) {
            if ($app_server['data']['apps_request_status_value'] != $app['status']) {
                $apps[$x]['status'] = $app_server['data']['apps_request_status_value'];
                $apps[$x]['download_link'] = $app_server['data']['apps_download_link'];
                $apps[$x]['error_message'] = $app_server['data']['apps_error_message'];
                //$wpdb->query("UPDATE $table_name SET `status` = '" . $apps[$x]['status'] . "', `download_link` = '" . $apps[$x]['download_link'] . "', `error_message` = '" . $apps[$x]['error_message'] . "' WHERE server_id = '" . $app['server_id'] . "'");
                $wpdb->update($table_name, array("status" => $apps[$x]['status'],
                    "download_link" => $apps[$x]['download_link'],
                    "error_message" => $apps[$x]['error_message']
                ),
                    array("server_id" => $app['server_id'])
                );
                //wp_die($wpdb->last_query);
            }

            if ($app_server['data']['apps_request_status_value'] == "Build in progress" || $app_server['data']['apps_request_status_value'] == "Submitted") {
                $build_in_progress = true;
            }
        }

        $x++;
    }
}
?>
<?php if ($build_in_progress): ?>
    <script>
        setTimeout("location.reload(true);", 25000);
    </script>
    <center><p style="margin-top:20px">You have apps in Submitted or Generation in progress status... <br />Automatic refresh page every 30 seconds...</p></center>
<?php endif; ?>
<script>
    var url_form_ajax = '<?php echo plugins_url('ajax.php', __FILE__); ?>';
</script>

<style>
    .actions a {
        margin:0 5px 0 5px;
    }
</style>
<div class="row" style="margin-top:20px;">

    <div class="col-md-12">

        <h4>Your apps</h4>

        <table class="table">
            <tr>
                <th>Server ID</th>
                <th>App Name</th>
                <th>Package</th>
                <th>Platform</th>
                <th>Version</th>
                <th>Time</th>
                <th>Status</th>
                <th>Actions</th>
            </tr>
            <?php if ($apps): ?>
                <?php foreach ($apps as $app): ?>
                    <tr>
                        <td><?php echo $app['server_id']; ?></td>
                        <td><?php echo $app['name']; ?></td>
                        <td><?php echo $app['packagename']; ?></td>
                        <td><?php echo ($app['platform'] == "1") ? "Android": "iOS"; ?></td>
                        <td><?php echo $app['version']; ?></td>
                        <td><?php echo $app['time']; ?></td>
                        <td>
                            <i class="fas <?php echo $status_class[$app['status']]; ?>"></i> <?php echo $app['status']; ?>
                        </td>
                        <td class="actions">
                            <?php if ($app['download_link']): ?>
                                <a href="<?php echo $app['download_link']; ?>"><i class="fas fa-download"></i></a>

                                <?php if ($app['platform']=="1"): ?>
                                    <a href="#" OnClick="jQuery('.modal_download_<?php echo $app['server_id']; ?>').modal();"><i class="fa fa-qrcode"></i></a>
                                    <div class="modal fade modal_download_<?php echo $app['server_id']; ?>" role="dialog">
                                        <div class="modal-dialog">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <h4 class="modal-title">Install by QR Code</h4>
                                                </div>
                                                <div class="modal-body">
                                                    <img src="https://api.qrserver.com/v1/create-qr-code/?size=150x150&data=<?php echo $app['download_link']; ?>" width="100"/>
                                                    <p>If your reader can not install the app, copy and paste the link on your browser or download apk and install it manually.</p>
                                                </div>
                                            </div>

                                        </div>
                                    </div>
                                <?php endif; ?>
                            <?php endif; ?>

                            <a href="<?php echo plugins_url('ajax.php', __FILE__); ?>?type=delete_app&server_id=<?php echo $app['server_id']; ?>"><i class="fas fa-trash"></i></a>
                            
                            <?php if ($app['status'] == "Submitted" || empty($app['status'])):?>
                                <a href="<?php echo plugins_url('ajax.php', __FILE__); ?>?type=delete_app&server_id=<?php echo $app['server_id']; ?>"><i class="fas fa-delete"></i></a>
                            <?php endif; ?>

                            <?php if ($app['error_message']): ?>
                                <button OnClick="jQuery('.modal_error_<?php echo $app['server_id']; ?>').modal();">Show
                                    error
                                </button>
                                <div class="modal fade modal_error_<?php echo $app['server_id']; ?>" role="dialog">
                                    <div class="modal-dialog">
                                        <div class="modal-content">
                                            <div class="modal-header">
                                                <h4 class="modal-title">Errors reporting</h4>
                                            </div>
                                            <div class="modal-body">ddd
                                                <?php echo $app['error_message']; ?>
                                            </div>
                                        </div>

                                    </div>
                                </div>
                            <?php endif; ?>
                        </td>
                    </tr>
                <?php endforeach; ?>
            <?php else: ?>
                <tr>
                    <td colspan="7">You have not generated apps yet</td>
                </tr>
            <?php endif; ?>
        </table>

    </div>
</div>

<div class="row" style="margin-top:10px;">
    <div class="col-md-12">
        <h3>Status legend</h3>
        <ul>
            <li><strong>Submitted</strong> <br />Your app is submitted to server, it will be processed within 10 minutes, depending on the server load.</li>
            <li><strong>Rejected</strong> <br /> Your apps is rejected, check the attached errors to understand the reason.</li>
            <li><strong>Build in progress</strong> <br /> This operation may take 4-5 minutes, after this your app should be ready.</li>
            <li><strong>Generated</strong> <br /> You can download your app*! Enjoy it!</li>
            <li><strong>Error</strong> <br /> Generation process has stalled, check the attached errors to understand the reason.</li>
            <li><strong>Deleted</strong> <br /> Your app is deleted from server, you can't download it again.</li>
        </ul>
        * When the app is generated, it will be available for download maximum 5 days.
    </div>
</div>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists