Exemplo n.º 1
0
function simpleSelect($select, $tableNames, $joinTypes, $joins, $where, $having, $order, $conn)
{
    if (!checkConnection($conn)) {
        return NULL;
    }
    if (!empty($joins) and (count($tableNames) != count($joins) + 1 or count($joins) != count($joinTypes))) {
        debugMessages("Incorrect sql query parameters." . mysqli_error($conn), "debugSQL");
        return NULL;
    }
    $tableName = $tableNames[0];
    $sqlQuery = "SELECT " . arrToQueryString($select, false) . " FROM " . $tableName;
    if (count($joins)) {
        for ($i = 0; $i < count($joins); $i++) {
            $sqlQuery .= " " . $joinTypes[$i] . " " . $tableNames[$i + 1] . " ON " . $joins[$i];
        }
    }
    if (!empty($where)) {
        $sqlQuery .= " WHERE " . $where;
    }
    if (!empty($having)) {
        $sqlQuery .= " HAVING " . $having;
    }
    if (!empty($order)) {
        $sqlQuery .= " ORDER BY" . $order;
    }
    $sqlQuery .= ";";
    $conn->real_escape_string($sqlQuery);
    debugMessages($sqlQuery, "debugSQL");
    $res = $conn->query($sqlQuery);
    if (!empty(mysqli_error($conn))) {
        debugMessages(mysqli_error($conn), "debugSQL");
    }
    return $res;
}
Exemplo n.º 2
0
function getManifest()
{
    global $bundle;
    if (checkConnection() === FALSE) {
        return FALSE;
    }
    $dir = exec('echo $HOME') . "/Library/Application Support/Alfred 2/Workflow Data/{$bundle}" . "/manifest.xml";
    file_put_contents("{$dir}", file_get_contents('https://raw.github.com/packal/repository/master/manifest.xml'));
    return TRUE;
}
Exemplo n.º 3
0
function sqlConnectDB($dbname)
{
    $servername = "localhost";
    $username = "******";
    $password = "******";
    $conn = new mysqli($servername, $username, $password, $dbname);
    if (checkConnection($conn)) {
        return $conn;
    }
}
Exemplo n.º 4
0
        $sth = dbQuery($sql, ':id', $auth_session->domain_id) or die(htmlsafe(end($dbh->errorInfo())));
        while ($this_extension = $sth->fetch()) {
            $DB_extensions[$this_extension['name']] = $this_extension;
        }
        $config->extension = $DB_extensions;
    }
}
// If no extension loaded, load Core
if (!$config->extension) {
    $extension_core = new Zend_Config(array('core' => array('id' => 1, 'domain_id' => 1, 'name' => 'core', 'description' => 'Core part of Simple Invoices - always enabled', 'enabled' => 1)));
    $config->extension = $extension_core;
}
include_once './include/language.php';
include_once './include/functions.php';
//add class files for extensions
checkConnection();
include './include/include_auth.php';
include_once './include/manageCustomFields.php';
include_once "./include/validation.php";
//if authentication enabled then do acl check etc..
if ($config->authentication->enabled == 1) {
    include_once "./include/acl.php";
    include_once "./include/check_permission.php";
}
/*
Array: Early_exit
- Pages that don't need header or exit prior to adding the template add in here
*/
$early_exit = array();
$early_exit[] = "auth_login";
$early_exit[] = "api_cron";
Exemplo n.º 5
0
<!DOCTYPE html>
<?php 
$error = false;
$dbhost = "";
$dbuser = "";
$dbpass = "";
$db = "";
if (file_exists("../../config.php")) {
    die("<meta http-equiv=\"refresh\" content=\"0; url=../../\" />");
}
if (isset($_REQUEST['dbhost'])) {
    if (checkConnection()) {
        writeConfig();
        die("<meta http-equiv=\"refresh\" content=\"0; url=../create/\" />");
    } else {
        $error = true;
    }
}
function checkConnection()
{
    global $db, $dbuser, $dbpass, $dbhost;
    $db = $_REQUEST['db'];
    $dbuser = $_REQUEST['dbuser'];
    $dbpass = $_REQUEST['dbpass'];
    $dbhost = $_REQUEST['dbhost'];
    $connection = mysqli_connect($dbhost, $dbuser, $dbpass, $db);
    if (!$connection) {
        return false;
    }
    return true;
}
 /**
  * Function for parsing XML file of repository
  * 
  * This function parses XML file and creates initial database used for searching. 
  * It may work on both online and offline modes. If internet connection is not
  * available then XML file attached in the module is used.
  *
  */
 function parse()
 {
     //create object of class XMLReader for reading XML file
     $xml = new XMLReader();
     //Parsing may take a few minutes because OL repository is quite large.
     @set_time_limit(0);
     global $db;
     $connS = false;
     //Find internet connection's status
     $conn = checkConnection();
     $op = '';
     if ($conn) {
         //internet connection is available so we can directly parse using URL
         $connS = true;
         $xml->open("http://openlearn.open.ac.uk/local/oai/oai2.php?verb=ListRecords&metadataPrefix=oai_ilox");
         $op = '1';
     } else {
         $connS = false;
         //internet connection is unavailable so we need to use repository's offline version
         $xml->open("../../ol_search_open_learn/oai2.php.xml");
         $op = '2';
     }
     $members = array();
     //main array which will contain all entries of repo.
     $flag = false;
     $resumption = 'dummy';
     //resumption token of repository
     //parse while resumption token is not null.
     while ($resumption != '') {
         if ($resumption == 'dummy' && $connS) {
             //if this is first iteration then use following URL
             $xml->open('http://openlearn.open.ac.uk/local/oai/oai2.php?verb=ListRecords&metadataPrefix=oai_ilox');
             $resumption = '';
         } else {
             if ($connS) {
                 //if this is not first URL then use resumption token of last page
                 $xml->open('http://openlearn.open.ac.uk/local/oai/oai2.php?verb=ListRecords&resumptionToken=' . $resumption);
             }
         }
         //main logic of parsing
         while ($xml->read()) {
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'record') {
                 //starting of a new record
                 $member = array();
                 $flag = false;
                 //$member['uni']='';
             }
             //starting tag of identifier
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'identifier' && !isset($member['identifier'])) {
                 $member['identifier'] = addslashes(trim($xml->readString()));
             }
             //starting tag of datestamp
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'datestamp' && !isset($member['datestamp'])) {
                 $member['datestamp'] = addslashes(trim($xml->readString()));
             }
             //starting tag of entry
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'entry' && !isset($member['entry'])) {
                 $member['entry'] = trim($xml->readString());
             }
             //starting tag of catalog
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'catalog' && !isset($member['catalog'])) {
                 $member['catalog'] = addslashes(trim($xml->readString()));
             }
             //starting tag of description
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'description' && !isset($member['description'])) {
                 $tag1 = '';
                 while ($tag1 != 'title') {
                     $xml->read();
                     $tag1 = $xml->localName;
                 }
                 $member['title'] = addslashes(trim($xml->readString()));
                 while ($tag1 != 'description') {
                     $xml->read();
                     $tag1 = $xml->localName;
                 }
                 $member['description'] = addslashes(trim($xml->readString()));
                 $member['keywords'] = '';
             }
             //starting tag of keywords
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'keyword' && !$flag) {
                 $member['keywords'] .= addslashes(trim($xml->readString())) . ", ";
             }
             if ($xml->nodeType == XMLReader::END_ELEMENT && $xml->localName == 'general') {
                 $flag = true;
                 rtrim($member['keywords']);
                 $member['keywords'] = substr($member['keywords'], 0, strlen($member['keywords']) - 2);
             }
             if ($xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'manifestation') {
                 $data = $xml->readString();
                 $tag = '';
                 if (strpos($data, 'web site') > 0) {
                     //echo 'case 1<br/>';
                     while ($tag != 'location') {
                         $xml->read();
                         $tag = $xml->localName;
                     }
                     $member['website'] = trim($xml->readString());
                 } else {
                     if (strpos($data, 'Common Cartridge') > 0) {
                         //echo 'case 2<br/>';
                         while ($tag != 'location') {
                             $xml->read();
                             $tag = $xml->localName;
                         }
                         $member['common'] = trim($xml->readString());
                     } else {
                         if (strpos($data, 'Content Package') > 0) {
                             //echo 'case 3<br/>';
                             while ($tag != 'location') {
                                 $xml->read();
                                 $tag = $xml->localName;
                             }
                             $member['package'] = trim($xml->readString());
                         }
                     }
                 }
             }
             //record ends insert record to the main array
             if ($xml->nodeType == XMLReader::END_ELEMENT && $xml->localName == 'record') {
                 $members[] = $member;
             }
             //read resumption token
             if ($connS && $xml->nodeType == XMLReader::ELEMENT && $xml->localName == 'resumptionToken') {
                 $resumption = $xml->readString();
             }
         }
         if (!$connS) {
             //if in offline mode then only one iteration is needed
             break;
         }
     }
     $res = '';
     $index = 1;
     //enter records in database
     if (count($members) > 0) {
         foreach ($members as $member) {
             $qry = 'INSERT INTO ' . TABLE_PREFIX . 'ol_search_open_learn VALUES (' . $index . ',"' . $member['identifier'] . '","' . $member['datestamp'] . '","' . $member['catalog'] . '","' . $member['entry'] . '","' . $member['title'] . '","' . $member['description'] . '","' . $member['keywords'] . '","' . $member['website'] . '","' . $member['common'] . '","' . $member['package'] . '")';
             $index++;
             if (mysql_query($qry, $db)) {
                 $tmp = "Success";
             } else {
                 $tmp = "Failed";
             }
         }
     }
     //enter date when database last updated in config table which will be used by admin later on
     if ($connS) {
         //online mode
         $qry = "UPDATE " . TABLE_PREFIX . "config SET value=CURDATE() WHERE name='ol_last_updation'";
     } else {
         //offline mode
         $qry = "UPDATE " . TABLE_PREFIX . "config SET value='2011-06-28' WHERE name='ol_last_updation'";
     }
     mysql_query($qry, $db);
     //insert current time of installation in database
     $qry = "INSERT INTO " . TABLE_PREFIX . "config VALUES ('ol_last_time','" . time() . "')";
     mysql_query($qry, $db);
 }
Exemplo n.º 7
0
// If the data directory doesn't exist, then we'll just wait for another time.
if (!file_exists($data)) {
    die;
}
// If the config file doesn't exist, then we'll just wait for another time.
if (!file_exists("{$data}/config/config.xml")) {
    die;
}
// Load the config
$config = simplexml_load_file("{$data}/config/config.xml");
// Check if workflow reporting is enabled. If not. Die.
if (!(isset($config->workflowReporting) && (string) $config->workflowReporting == '1')) {
    die;
}
// Make sure that we have an Internet connection before continuing.
if (checkConnection() == FALSE) {
    die;
}
// Check if the usage directory exists; make it if it doesn't.
if (!file_exists("{$data}/usage")) {
    mkdir("{$data}/usage");
}
// This is your unique identifier. If you're reading this, just run the command and see what's up.
$unique = hash("sha256", exec('ioreg -rd1 -c IOPlatformExpertDevice | awk \'/IOPlatformUUID/ { split($0, line, "\\""); printf("%s\\n", line[4]); }\''));
$unique = utf8_encode($unique);
// Create the filename
$date = date('Y-W', time());
$file = $data . '/usage/' . $date . "-data-{$unique}.json";
// This means that we've already generated and sent the file. So, let's just stop now.
if (file_exists($file)) {
    echo "Already submitted this week.";
Exemplo n.º 8
0
<?php

session_start();
require_once 'src/includes/config.php';
require_once 'src/includes/functions.php';
$return = '';
if (!empty($_POST)) {
    $return = checkConnection($_POST);
}
if (!empty($_SESSION['login'])) {
    header('Location:chat.php');
}
?>
<!doctype html>
<html lang="fr-FR">
<head>
    <meta charset="UTF-8">
    <title>Miaou</title>
    <link rel="stylesheet" type="text/css" href="src/css/reset.css">
    <link rel="stylesheet" type="text/css" href="src/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="src/css/custom.css">
</head>
<body>
	<div class="container">
		<div>
			<?php 
if (!empty($return)) {
    ?>
				<div class="return">
					<?php 
    echo $return;
Exemplo n.º 9
0
function installData()
{
    global $connection;
    $db = $_POST['database'];
    $prefix = $_POST['prefix'];
    $sql = <<<SQL

USE {$db};

INSERT INTO {$prefix}settings (`variable`, `value`) VALUES ('showPgaeLoadTime', '0');
INSERT INTO {$prefix}settings (`variable`, `value`) VALUES ('maxSubmitWithOutApproval', '10');
INSERT INTO {$prefix}settings (`variable`, `value`) VALUES ('imgurUploadOn', '1');
INSERT INTO {$prefix}settings (`variable`, `value`) VALUES ('imgurClientID', '7f0764588452050');
INSERT INTO {$prefix}settings (`variable`, `value`) VALUES ('imgurClientSecret', '0061179a2f436175dc84e83deabc23aa12ef255a');
INSERT INTO {$prefix}settings (`variable`, `value`) VALUES ('addonSubmissionOn', '1');
INSERT INTO {$prefix}settings (`variable`, `value`) VALUES ('paypalDonationLink', 'http://paypal.com');
INSERT INTO {$prefix}settings (`variable`, `value`) VALUES ('twitterLink', 'http://twitter.com/musicbeeplayer');
INSERT INTO {$prefix}settings (`variable`, `value`) VALUES ('wikiaLink', 'http://musicbee.wikia.com');
INSERT INTO {$prefix}settings (`variable`, `value`) VALUES ('wishlistLink', '');
INSERT INTO {$prefix}settings (`variable`, `value`) VALUES ('websiteBugLink', '');
INSERT INTO {$prefix}settings (`variable`, `value`) VALUES ('musicbeeBugLink', '');
INSERT INTO {$prefix}settings (`variable`, `value`) VALUES ('eliteRequirement', '8');
INSERT INTO {$prefix}settings (`variable`, `value`) VALUES ('selfApprovalRequirement', '3');
INSERT INTO {$prefix}settings (`variable`, `value`) VALUES ('maximumAddonSubmissionPerDay', '20');

INSERT INTO {$prefix}help (`variable`, `data_type`, `data`) VALUES ('help_links', 'json', '');
INSERT INTO {$prefix}help (`variable`, `data_type`, `data`) VALUES ('help_api_link', 'link', 'http://musicbee.wikia.com/index.php?action=render&title=FAQ');
INSERT INTO {$prefix}help (`variable`, `data_type`, `data`) VALUES ('api_md', 'markdown', '');
INSERT INTO {$prefix}help (`variable`, `data_type`, `data`) VALUES ('api_html', 'html', '');
INSERT INTO {$prefix}help (`variable`, `data_type`, `data`) VALUES ('press_md', 'markdown', '');
INSERT INTO {$prefix}help (`variable`, `data_type`, `data`) VALUES ('press_html', 'html', '');

SQL;
    if (checkConnection()) {
        try {
            $statement = $connection->prepare($sql);
            $statement->execute();
            return true;
        } catch (Exception $e) {
            return false;
        }
    }
    return false;
}
Exemplo n.º 10
0
    ini_set('date.timezone', $tz);
}
// Get the version of OSX; if we aren't using Mavericks, then they don't get access to the GUI.
$osx = exec("sw_vers | grep 'ProductVersion:' | grep -o '10\\.[0-9]*'");
// So, they can use the GUI if they're using Mavericks or Yosemite.
if ($osx == '10.9' || $osx == '10.10') {
    $gui = TRUE;
}
firstRun();
$bundle = 'com.packal';
$q = $argv;
$w = new Workflows();
$HOME = exec('echo $HOME');
$data = "{$HOME}/Library/Application Support/Alfred 2/Workflow Data/{$bundle}";
$cache = "{$HOME}/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/{$bundle}";
$connection = checkConnection();
if ($connection === FALSE) {
    $w->result('', '', 'Warning: no viable Internet connection', 'Some features of this workflow will be unavailable without a solid Internet connection', 'assets/icons/task-attention.png', 'no', '');
}
if (!file_exists($data)) {
    mkdir("{$data}");
}
if (!file_exists($cache)) {
    mkdir("{$cache}");
}
if (!file_exists("{$data}/config")) {
    mkdir("{$data}/config");
}
if (!file_exists("{$data}/endpoints")) {
    mkdir("{$data}/endpoints");
}
Exemplo n.º 11
0
<?php

require_once __DIR__ . "/../utils.php";
$endpoint = "http://localhost/repo/learninglocker/public/data/xAPI/";
$username = "******";
$password = "******";
$res = checkConnection($endpoint, $username, $password);
print_r($res);
// testing
/*if (array_key_exists("statements",$decoded))
	echo "works...";

else
	echo "fails..";*/
Exemplo n.º 12
0
     $newGroups = array();
     foreach (explode(',', $_POST['icn_active']) as $icon) {
         if (is_numeric($icon)) {
             $newGroups[] = $icon;
         }
     }
     if (!writeConfig(IP, QUERYPORT, SERVERPORT, QUERYUSER, QUERYPASS, QUERYDISPLAYNAME, ADMINPANEL_PASS, MAXGROUPS, RULESACCEPTGROUP, GROUPSDISALLOW, RULES, RULESACTIVATE, json_encode($newGroups))) {
         $error[] = array('danger', 'Error while writing Config File! Check Write Permissions!');
     } else {
         header("Refresh:0");
         die;
     }
     break;
 case 'editTS3Config':
     if (!empty($_POST['ts_ip']) and !empty($_POST['ts_qport']) and !empty($_POST['ts_sport']) and !empty($_POST['ts_user']) and !empty($_POST['ts_pass'])) {
         $ts3_conn_status = checkConnection($_POST['ts_ip'], $_POST['ts_qport'], $_POST['ts_sport'], $_POST['ts_user'], $_POST['ts_pass'], $_POST['ts_displayname']);
         if ($ts3_conn_status === TRUE) {
             if (!writeConfig(IP, QUERYPORT, SERVERPORT, QUERYUSER, QUERYPASS, QUERYDISPLAYNAME, ADMINPANEL_PASS, MAXGROUPS, RULESACCEPTGROUP, GROUPSDISALLOW, RULES, RULESACTIVATE, GROUPS)) {
                 $error[] = array('danger', 'Error while writing Config File! Check Write Permissions!');
             } else {
                 header("Refresh:0");
                 die;
             }
         } else {
             $error[] = array('danger', $ts3_conn_status);
         }
     } else {
         $error[] = array('info', 'Please Fill out all required Fields!');
     }
     break;
 case 'addrule':
Exemplo n.º 13
0
function status()
{
    global $wf, $config, $workflows, $blacklist, $manifestBundles, $me, $data, $workflowsDir;
    $endpoints = json_decode(file_get_contents("{$data}/endpoints/endpoints.json"), TRUE);
    $updates = FALSE;
    foreach ($endpoints as $k => $v) {
        if (file_exists("{$v}/packal/package.xml")) {
            $w = simplexml_load_file("{$v}/packal/package.xml");
            if (in_array($k, $manifestBundles)) {
                if ($wf["{$k}"]['version'] != (string) $w->version) {
                    if (!in_array($k, $blacklist)) {
                        $updates = TRUE;
                        break;
                    }
                }
            }
        }
    }
    $meta = array();
    $meta['mineOnPackal'] = array();
    $meta['myWorkflows'] = array();
    if (isset($config->username) && $config->username) {
        foreach ($wf as $bundle => $value) {
            if ($value['author'] == "{$config->username}") {
                $meta['mineOnPackal'][] = $bundle;
            }
        }
    }
    foreach ($workflows as $bundle => $dir) {
        $dir = substr($dir, strrpos($dir, '/') + 1);
        $workflows[$bundle] = $dir;
        // Installed workflows
        $meta['installedWorkflows'][] = $bundle;
        if (isset($config->authorName) && $config->authorName) {
            // Look here only if the user has set authorName value.
            if (exec("/usr/libexec/PlistBuddy -c \"Print :createdby\" '{$workflowsDir}/{$dir}/info.plist' &2> /dev/null") == $config->authorName) {
                $meta['myWorkflows'][] = $bundle;
            }
        }
        if (file_exists("{$workflowsDir}/{$dir}/packal/package.xml") && in_array($bundle, $manifestBundles)) {
            $meta['fromPackal'][] = $bundle;
        } else {
            if (in_array($bundle, $manifestBundles)) {
                if (isset($config->username) && $config->username) {
                    if (!in_array("{$bundle}", $meta['mineOnPackal'])) {
                        $meta['availableOnPackal'][] = $bundle;
                    }
                } else {
                    $meta['availableOnPackal'][] = $bundle;
                }
            }
        }
    }
    $time = getManifestModTime();
    foreach ($workflows as $k => $v) {
        if (file_exists("{$workflowsDir}/{$v}/packal/package.xml") && in_array($k, $manifestBundles)) {
            $packal[] = $k;
        }
    }
    $connection = checkConnection();
    ?>

<h1>Status</h1>

<div class='status-body'>
    <?php 
    if ($connection !== FALSE) {
        ?>
        <div id="fusion_ad">
          <a href="http://fusionads.net" class='hijack'>Powered by Fusion</a>
        </div>
<?php 
    }
    if ($updates) {
        ?>
<div class='updates-available'>
  <p><h4>Updates are available.</h4></p>
  <p class='clearfix'> </p>
</div>
<?php 
    }
    ?>
<div>
  <p id='manifest-status'>
    The manifest was last updated <strong><?php 
    echo "{$time}";
    ?>
</strong>
    <?php 
    if ($connection !== FALSE) {
        echo "<span class='update-manifest'>(Update)</span>";
    }
    ?>
  </p>
</div>
<p class='clearfix'> </p>
<div><p>You have <strong><?php 
    echo count($workflows);
    ?>
</strong> workflows installed with Bundle IDs.</p></div>
<p class='clearfix'> </p>
<?php 
    if (count($meta['myWorkflows']) > 0) {
        ?>
  <div><p>Of those, <strong><?php 
        echo count($meta['myWorkflows']);
        ?>
</strong> are ones that you wrote.</p>
    <div id='myworkflows' class='detail-accordion'>
      <h3>Details</h3>
      <div class='detail-accordion'>
          <?php 
        foreach ($meta['myWorkflows'] as $m) {
            if (isset($wf[$m]['name'])) {
                $name = $wf[$m]['name'];
            } else {
                $dir = $workflows[$m];
                $name = exec("/usr/libexec/PlistBuddy -c \"Print :name\" '{$workflowsDir}/{$dir}/info.plist' &2> /dev/null");
            }
            echo '<p><strong>' . $name . '</strong> (' . $m . ")</p>";
        }
        ?>
      </div>
    </div>
</div>
<p class='clearfix'> </p>
<?php 
    }
    ?>

<div><p>You have installed <strong><?php 
    echo count($meta['fromPackal']);
    ?>
</strong> from Packal.</p>
<div id='frompackal' class='detail-accordion'>
  <h3>Details</h3>
  <div class='detail-accordion'>
      <?php 
    foreach ($meta['fromPackal'] as $m) {
        echo '<p><strong>' . $wf[$m]['name'] . '</strong> (' . $m . ")</p>";
    }
    ?>
  </div>
</div>
</div>
<?php 
    if (isset($meta['availableOnPackal']) && count($meta['availableOnPackal']) > 0) {
        ?>
<p class='clearfix'> </p>
<div>
  <p>
    Of the others, 
    <strong><?php 
        echo count($meta['availableOnPackal']);
        ?>
</strong>
    can be downloaded and updated from Packal.
  </p>
<div id='availableOnPackal' class='detail-accordion'>
  <h3>Details</h3>
  <div class='detail-accordion2'>
      <?php 
        foreach ($meta['availableOnPackal'] as $m) {
            if (!empty($m)) {
                echo '<div><p><strong>' . $wf[$m]['name'] . '</strong>';
                echo " ({$m})" . "</p><div id='" . $wf[$m]['url'] . "' class='url-open'>View on Packal</div></div>";
            }
        }
        ?>
  </div>
</div>
</div>
<?php 
    }
    ?>
<p class='clearfix'> </p>
  <div>
    <p>
      There are 
      <strong><?php 
    echo count($wf);
    ?>
</strong>
      workflows available on Packal.
    </p>
  </div>
  <p class='clearfix'> </p>
<?php 
    if (count($meta['mineOnPackal']) > 0) {
        ?>
  <div>
    <p>
      You've written 
      <strong><?php 
        echo count($meta['mineOnPackal']);
        ?>
</strong>
      of the ones on Packal.
    </p>
  </div>
<?php 
    }
    ?>
</div>
<?php 
    if ($connection !== FALSE) {
        ?>
  <script type="text/javascript">
    (function(){
      var fusion = document.createElement('script');
      fusion.src = window.location.protocol + '//adn.fusionads.net/api/1.0/ad.js?zoneid=299&rand=' + Math.floor(Math.random()*9999999);
      fusion.async = true;
      (document.head || document.getElementsByTagName('head')[0]).appendChild(fusion);
    })();
    // function tag() {
    //   // 
    //   console.log( 'hello' );
    // }
  </script>
  <script>
    myVar = setTimeout( function() {
      $( '.fusionentire' ).find( 'a' ).each( function() {
        $( this ).addClass( 'hijack' );
      });
      $( '.hijack' ).click( function() {
        event.preventDefault();
        link = $( this ).attr( 'href' );
        $.get( "packal.php", { action: 'openDirectory', 'directory': link } );
      });
        // console.log( document.getElementsByClassName( 'fusionentire' ).querySelectorAll( 'a' ) );
      }, 1500);
  </script>
  <script>

</script>
  <?php 
    }
    ?>
  <script type='text/javascript'>
  $( "#myworkflows" ).accordion({ active: false, collapsible: true });
  $( "#frompackal" ).accordion({ active: false, collapsible: true });
  $( "#availableOnPackal" ).accordion({ active: false, collapsible: true });
  $( '.url-open' ).click( function() {
    dir = $( this ).attr( 'id' );
    $.get( "packal.php", { action: 'openDirectory', 'directory': dir } );
  });
  $( '.update-manifest' ).click( function() {
    $.ajax({
      url: 'packal.php',
      beforeSend: function( xhr ) {
        $( '#updating-overlay' ).show();
      },
      data: { action: 'updateManifest' },
    }).done(function( data ) {
      $( '#updating-overlay' ).hide();
      $( '#manifest-status' ).html( data );
    });
  });
  $( '.updates-available' ).click( function() {
    $( '.pane' ).html("<div class='preloader'><h2>Loading...</h2><img alt='preloader' src='assets/images/preloader.gif' /></div>");
    setTimeout(function() {
      $( '.pane' ).load( 'packal.php', { 'page': 'updates' } );
    }, 1000);
    
  });
  $( document ).ready( function() { 
    if ( <?php 
    echo date('U', mktime()) - date('U', filemtime("{$data}/manifest.xml"));
    ?>
 > 86400 ) {
      console.log( 'test' );
      $.ajax({
        url: 'packal.php',
        beforeSend: function( xhr ) {
          $( '#updating-overlay' ).show();
        },
        data: { action: 'updateManifest' },
        }).done(function( data ) {
          $( '#updating-overlay' ).hide();
          $( '#manifest-status' ).html( data );
      });
    }
  });

  </script>
<?php 
}