Пример #1
0
 public function formatUser(&$user)
 {
     switch ($user->rank) {
         case 'U':
         default:
             $class = 'info';
             $rank = 'User';
             break;
         case 'M':
             $class = 'success';
             $rank = 'Moderator';
             break;
         case 'A':
             $class = 'danger';
             $rank = 'Admin';
             break;
     }
     $user->userlabel = "<a class='label label-{$class}' href='?action=";
     $user->userlabel .= "viewUser&user={$user->uid}'>{$user->username}</a>";
     $user->rankname = $rank;
     $user->createdlabel = timestamp($user->created);
     if ($user->status) {
         $user->statuslink = "<span class='label label-success'>Active</span> <a class='btn btn-xs btn-danger' href='?action=deactivateUser&user={$user->uid}'><i class='fa fa-times'></i></a>";
     } else {
         $user->statuslink = "<span class='label label-danger'>Inactive</span> <a class='btn btn-xs btn-success' href='?action=activateUser&user={$user->uid}'><i class='fa fa-check'></i></a>";
     }
     return $user;
 }
Пример #2
0
/**
 * html Pour pouvoir masquer les logos sans les downloader en petit ecran
 * il faut le mettre dans un conteneur parent que l'on masque
 * http://timkadlec.com/2012/04/media-query-asset-downloading-results/
 *
 * On utilise un double conteneur :
 * le premier fixe la largeur, le second la hauteur par le ratio hauteur/largeur
 * grace a la technique des intrinsic-ratio ou padding-bottom-hack
 * http://mobile.smashingmagazine.com/2013/09/16/responsive-images-performance-problem-case-study/
 * http://alistapart.com/article/creating-intrinsic-ratios-for-video
 *
 * Le span interieur porte l'image en background CSS
 * Le span conteneur ne porte pas de style display car trop prioritaire.
 * Sans CSS il occupe la largeur complete disponible, car en inline par defaut
 * Il suffit de lui mettre un float:xxx ou un display:block pour qu'il respecte la largeur initiale du logo
 *
 * Pour masquer les logos :
 * .spip_logos {display:none}
 * Pour forcer une taille maxi :
 * .spip_logos {max-width:25%;float:right}
 *
 * @param $logo
 *
 * @return string
 */
function responsive_logo($logo)
{
    if (!function_exists('extraire_balise')) {
        include_spip('inc/filtres');
    }
    if (!$logo or !($img = extraire_balise($logo, "img"))) {
        return $logo;
    }
    list($h, $w) = taille_image($img);
    $src = extraire_attribut($img, "src");
    $class = extraire_attribut($img, "class");
    // timestamper l'url si pas deja fait
    if (strpos($src, "?") == false) {
        $src = timestamp($src);
    }
    if (defined('_STATIC_IMAGES_DOMAIN')) {
        $src = url_absolue($src, _STATIC_IMAGES_DOMAIN);
    }
    $hover = "";
    if ($hover_on = extraire_attribut($img, "onmouseover")) {
        $hover_off = extraire_attribut($img, "onmouseout");
        $hover_on = str_replace("this.src=", "jQuery(this).css('background-image','url('+", $hover_on) . "+')')";
        $hover_off = str_replace("this.src=", "jQuery(this).css('background-image','url('+", $hover_off) . "+')')";
        $hover = " onmouseover=\"{$hover_on}\" onmouseout=\"{$hover_off}\"";
    }
    $ratio = round($h * 100 / $w, 2);
    return "<span class='{$class}' style=\"width:{$w}px;\"><span class=\"img\" style=\"display:block;position:relative;height:0;width:100%;padding-bottom:{$ratio}%;overflow:hidden;background:url({$src}) no-repeat center;background-size:100%;\"{$hover}> </span></span>";
}
Пример #3
0
/**
 * Ecrire la balise CSS pour insérer le fichier compressé
 *
 * C'est cette fonction qui décide ou il est le plus pertinent
 * d'insérer le fichier, et dans quelle forme d'écriture
 *
 * @param string $flux
 *   Contenu du head nettoyé des fichiers qui ont ete compressé
 * @param int $pos
 *   Position initiale du premier fichier inclu dans le fichier compressé
 * @param string $src
 *   Nom du fichier compressé
 * @param string $comments
 *   Commentaires à insérer devant
 * @param string $media
 *   Type de media si précisé (print|screen...)
 * @return string
 *   Code HTML de la balise <link>
 */
function compresseur_ecrire_balise_css_dist(&$flux, $pos, $src, $comments = "", $media = "")
{
    $src = timestamp($src);
    $comments .= "<link rel='stylesheet'" . ($media ? " media='{$media}'" : "") . " href='{$src}' type='text/css' />";
    // Envoyer aussi un entete http pour demarer le chargement de la CSS plus tot
    // Link: <http://href.here/to/resource.html>;rel="stylesheet prefetch"
    $comments .= "<" . "?php header('Link: <' . url_de_base() . (_DIR_RACINE ? _DIR_RESTREINT_ABS : '') . '{$src}>;rel=\"stylesheet prefetch\"'); ?>";
    $flux = substr_replace($flux, $comments, $pos, 0);
    return $flux;
}
 function insertUser()
 {
     $data = array('username' => $this->input->post('username'), 'picURL' => $this->getUserPicURL($this->input->post('username')), 'active' => 1, 'admin' => 0, 'dateadded' => timestamp());
     $this->db->insert('actorRules', $data);
     if ($this->db->affected_rows() >= 1) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
Пример #5
0
    public static function install(&$package, $params = array())
    {
        // Set the files directory
        $directory = dirname(__FILE__) . '/files';
        // Add the files to the package
        $package->addDir($directory, '', array('ruckusing'));
        // /ruckusing/db/migrate/users
        $package->addFile($directory . '/ruckusing/db/migrate/create_users.php', 'ruckusing/db/migrate/' . timestamp() . '_CreateUsers.php');
        // /ruckusing/db/migrate/add_admin_to_users
        $package->addFile($directory . '/ruckusing/db/migrate/add_admin_to_users.php', 'ruckusing/db/migrate/' . timestamp() . '_AddAdminToUsers.php');
        // /ruckusing/db/migrate/auth_codes
        $package->addFile($directory . '/ruckusing/db/migrate/create_auth_codes.php', 'ruckusing/db/migrate/' . timestamp() . '_CreateAuthCodes.php');
        // /ruckusing/db/migrate/roles
        $package->addFile($directory . '/ruckusing/db/migrate/create_roles.php', 'ruckusing/db/migrate/' . timestamp() . '_CreateRoles.php');
        // Add links to AdminHelper::admin_nav()
        $links[] = <<<EOF
      
  'Manage Users' => array(
    'path' => 'users',
    'auth' => 'admin'
    )
EOF;
        $links[] = <<<EOF
      
  'Manage Auth Codes' => array(
    'path' => 'auth_codes',
    'auth' => 'su'
    )
EOF;
        $links[] = <<<EOF
      
  'Manage Roles' => array(
    'path' => 'roles',
    'auth' => 'admin'
    )
EOF;
        foreach ($links as $link_string) {
            $package->replace('inc/admin/config.php', '/(\\$admin_links = array\\()((?:.+)?)(\\);)/se', "'\\1'.self::global_array_builder('\\2', \"{$link_string}\").'\\3'");
        }
        // Add UserSession initializer
        $user_session_include = <<<EOF

// ===============
// = UserSession =
// ===============
\$session = new UserSession;  
EOF;
        $package->appendPHP('inc/config.php', $user_session_include);
        // Add to inc/helpers.php
        if (!$package->locateName('inc/helpers.php')) {
            $package->addFromString('inc/helpers.php', "<?php\n\n?>");
        }
        $package->appendPHP('inc/helpers.php', "include ROOT.'/inc/helpers/user_management.php';\n");
    }
Пример #6
0
 function addTweets($xml)
 {
     $xml_element = new SimpleXMLElement($xml);
     //prep data for db
     //note that for normal applications, full data for twitter is not available
     //therefore, the URL must be polled to get the full data.
     foreach ($xml_element as $key) {
         $data = array('username' => strval($key->actor), 'tweet' => strval($key->payload->body), 'URL' => strval($key->destinationURL), 'time' => strval($key->at), 'client' => strval($key->source), 'replyto' => strval($key->regardingURL), 'timeadded' => timestamp());
         $status = $this->Gnipdata_model->addTweet($data);
         log_message('debug', 'Added tweet by ' . strval($key->actor) . ' at ' . strval($key->at));
     }
 }
Пример #7
0
/**
 * Inserer jQuery et ses plugins
 *
 * La fonction ajoute les balises scripts dans le texte qui appelent
 * les scripts jQuery ainsi que certains de ses plugins. La liste
 * des js chargée peut être complété par le pipeline 'jquery_plugins'
 *
 * Cette fonction est appelée par le pipeline insert_head
 *
 * @internal
 *     Ne pas vérifier ici qu'on ne doublonne pas `#INSERT_HEAD`
 *     car cela empêche un double appel (multi calcul en cache cool,
 *     ou erreur de l'espace privé)
 *
 * @see f_jQuery_prive()
 * @pipeline insert_head
 * @pipeline_appel jquery_plugins
 *
 * @param string $texte Contenu qui sera inséré dans le head HTML
 * @return string          Contenu qui sera inséré dans le head HTML
 **/
function f_jQuery($texte)
{
    $x = '';
    $jquery_plugins = pipeline('jquery_plugins', array('javascript/jquery.js', 'javascript/jquery.form.js', 'javascript/jquery.autosave.js', 'javascript/jquery.placeholder-label.js', 'javascript/ajaxCallback.js', 'javascript/jquery.cookie.js'));
    foreach (array_unique($jquery_plugins) as $script) {
        if ($script = find_in_path($script)) {
            $script = timestamp($script);
            $x .= "\n<script src=\"{$script}\" type=\"text/javascript\"></script>\n";
        }
    }
    $texte = $x . $texte;
    return $texte;
}
Пример #8
0
    public static function install(&$package, $params = array())
    {
        // Set the files directory
        $directory = dirname(__FILE__) . '/files';
        // Add the files to the package
        $package->addDir($directory, '', array('ruckusing'));
        // /ruckusing/db/migrate/cms_blocks
        $package->addFile($directory . '/ruckusing/db/migrate/create_cms_blocks.php', 'ruckusing/db/migrate/' . timestamp() . '_CreateCMSBlocks.php');
        // /ruckusing/db/migrate/cms_categories
        $package->addFile($directory . '/ruckusing/db/migrate/create_cms_categories.php', 'ruckusing/db/migrate/' . timestamp() . '_CreateCMSCategories.php');
        // /ruckusing/db/migrate/cms_files
        $package->addFile($directory . '/ruckusing/db/migrate/create_cms_files.php', 'ruckusing/db/migrate/' . timestamp() . '_CreateCMSFiles.php');
        // /ruckusing/db/migrate/add_su_to_users
        $package->addFile($directory . '/ruckusing/db/migrate/add_su_to_users.php', 'ruckusing/db/migrate/' . timestamp() . '_AddSuToUsers.php');
        // Add links to AdminHelper::admin_nav()
        $links[] = <<<EOF
      
  'Edit Blocks' => array(
    'path' => 'cms',
    'auth' => 'admin'
    )
EOF;
        $links[] = <<<EOF
      
  'Manage Files' => array(
    'path' => 'cms_files',
    'auth' => 'admin'
    )
EOF;
        $links[] = <<<EOF
      
  'Manage Blocks' => array(
    'path' => 'blocks',
    'auth' => 'su'
    )
EOF;
        foreach ($links as $link_string) {
            $package->replace('inc/admin/config.php', '/(\\$admin_links = array\\()((?:.+)?)(\\);)/se', "'\\1'.self::global_array_builder('\\2', \"{$link_string}\").'\\3'");
        }
        // Add to inc/helpers.php
        if (!$package->locateName('inc/helpers.php')) {
            $package->addFromString('inc/helpers.php', "<?php\n\n?>");
        }
        $package->appendPHP('inc/helpers.php', "include ROOT.'/inc/helpers/basic_cms.php';\n");
    }
Пример #9
0
/**
 * Inserer jQuery et ses plugins pour l'espace privé
 *
 * La fonction ajoute les balises scripts dans le texte qui appelent
 * les scripts jQuery ainsi que certains de ses plugins. La liste
 * des js chargée peut être complété par le pipeline 'jquery_plugins'
 *
 * Cette fonction est appelée par le pipeline header_prive
 *
 * @see f_jQuery()
 * @link http://code.spip.net/@f_jQuery
 * 
 * @param string $texte    Contenu qui sera inséré dans le head HTML
 * @return string          Contenu complété des scripts javascripts, dont jQuery
**/
function f_jQuery_prive($texte)
{
    $x = '';
    $jquery_plugins = pipeline('jquery_plugins', array('prive/javascript/jquery.js', 'prive/javascript/jquery.form.js', 'prive/javascript/jquery.autosave.js', 'prive/javascript/jquery.placeholder-label.js', 'prive/javascript/ajaxCallback.js', 'prive/javascript/jquery.cookie.js', 'prive/javascript/spip_barre.js'));
    foreach (array_unique($jquery_plugins) as $script) {
        if ($script = find_in_path($script)) {
            $script = timestamp($script);
            $x .= "\n<script src=\"{$script}\" type=\"text/javascript\"></script>\n";
        }
    }
    // inserer avant le premier script externe ou a la fin
    if (preg_match(",<script[^><]*src=,", $texte, $match) and $p = strpos($texte, $match[0])) {
        $texte = substr_replace($texte, $x, $p, 0);
    } else {
        $texte .= $x;
    }
    return $texte;
}
 public function parseTicket(&$ticket)
 {
     $ticket->scanned = $ticket->scanned + 0;
     if ('0000-00-00 00:00:00' === $ticket->scanned_at) {
         $ticket->scanned_at = FALSE;
     } else {
         $ticket->scanned_at = timestamp($ticket->scanned_at);
     }
     $ticket->fullStatus = "Not scanned";
     if ($ticket->scanned) {
         $ticket->fullStatus = "Scanned";
     }
     $ticket->scanlink = "<a href='scan.php?user=manualOverride&barcode={$ticket->barcode}&format=html' class='btn btn-success btn-xs'>";
     $ticket->scanlink .= "Manual Check In</a>";
     $ticket->ticketLink = "<span class='glyphicon glyphicon-barcode'></span> ";
     $ticket->ticketLink .= "<a href='viewTicket.php?barcode={$ticket->barcode}'>";
     $ticket->ticketLink .= "<code>{$ticket->barcode}</code></a>";
     return $ticket;
 }
Пример #11
0
function update_acordes($data = array())
{
    global $db, $usuario;
    $timestamp = timestamp();
    $id = $data[id] ? $data[id] : false;
    unset($data[id]);
    foreach ($data as $campo => $valor) {
        $campos[] = $campo . "='" . $valor . "'";
    }
    $campos[] = "id_usuario = '{$usuario['id_usuario']}'";
    $campos[] = "timestamp \t= '{$timestamp}'";
    $updateFields = implode(',', $campos);
    if ($id && $updateFields) {
        $sql = "UPDATE {$db['tbl_acordes']}\n\t\t\t\tSET  {$updateFields}\n\t\t\t\tWHERE id_acorde='{$id}'\n\t\t\t\tLIMIT 1;";
        $resultado = SQLDo($sql) ? true : false;
        return $resultado;
    } else {
        return false;
    }
}
Пример #12
0
 function updateAdminStatus($username, $statusvalue)
 {
     $data = array('admin' => $statusvalue, 'lastupdated' => timestamp());
     $this->db->where('username', $username);
     $this->db->update('actorRules', $data);
     if ($statusvalue == 1) {
         $verificationcode = md5(md5($username) . md5(timestamp()));
         $this->db->select('username');
         $query = $this->db->get_where('admin', array('username' => $username));
         if (!$query->result()) {
             $data = array('username' => $username, 'activationcode' => $verificationcode);
             $this->db->insert('admin', $data);
         }
         return $verificationcode;
     } else {
         // delete user from admin as well
         $this->db->where('username', $username);
         $this->db->delete('admin');
     }
 }
Пример #13
0
 protected function read($params = array())
 {
     // the core of the data is the user object
     $auth = !empty($_SESSION['user']);
     // filter session (fixed fields for now...)
     if ($auth) {
         $this->data['user'] = $this->filter($_SESSION['user']);
         // loop through the token data
         if (!empty($_SESSION['oauth'])) {
             $this->data['oauth'] = array();
             foreach ($_SESSION['oauth'] as $service => $creds) {
                 // save in an array if more than one...
                 $this->data["oauth"][$service] = $this->filter($creds);
             }
         }
     }
     // set the auth flag
     $this->data['auth'] = $auth;
     // set updated attribute (for the client)
     $this->data['updated'] = timestamp();
 }
Пример #14
0
function sql($query, $mysql_data = null)
{
    global $mysql_default;
    if (!$mysql_data) {
        $mysql_data = $mysql_default;
    }
    if ($mysql_data['debug'] & 1) {
        print "<!-- SQL-Query: {$query} -->\n";
    }
    if ($mysql_data['debug'] & 2) {
        global $path_config;
        global $current_user;
        file_put_contents("{$path_config}/.debug.log", timestamp() . "\t" . $current_user->id . ":\n" . $query . "\n", FILE_APPEND | LOCK_EX);
    }
    if (!($res = $mysql_data['linkid']->query($query))) {
        global $path_config;
        global $current_user;
        file_put_contents("{$path_config}/.debug.log", timestamp() . "\t" . $current_user->id . ":\n" . "ERROR executing query \"{$query}\"\n" . print_r($mysql_data['linkid']->errorInfo(), 1) . "\n", FILE_APPEND | LOCK_EX);
        print "<pre>" . print_r($mysql_data['linkid']->errorInfo(), 1) . "</pre>";
        exit;
    }
    return $res;
}
Пример #15
0
function sql($query, $mysql_data = null)
{
    global $mysql_default;
    if (!$mysql_data) {
        $mysql_data = $mysql_default;
    }
    if (!mysql_select_db($mysql_data['db'], $mysql_data['linkid'])) {
        echo "Can't select database!<br>";
        exit;
    }
    if ($mysql_data['debug'] & 1) {
        print "<!-- SQL-Query: {$query} -->\n";
    }
    if ($mysql_data['debug'] & 2) {
        global $path_config;
        global $current_user;
        file_put_contents("{$path_config}/.debug.log", timestamp() . "\t" . $current_user->id . ":\n" . $query . "\n", FILE_APPEND | LOCK_EX);
    }
    if (!($res = mysql_query($query, $mysql_data['linkid']))) {
        echo mysql_error();
        exit;
    }
    return $res;
}
Пример #16
0
function getDifferenceOfTimes($timeA, $timeB)
{
    if (preg_match('/\\d{4}-\\d{1,2}-\\d{1,2}\\s\\d{1,2}:\\d{1,2}:\\d{1,2}/u', $timeA)) {
        $timeA = strtotime($timeA);
    }
    if (preg_match('/\\d{4}-\\d{1,2}-\\d{1,2}\\s\\d{1,2}:\\d{1,2}:\\d{1,2}/u', $timeB)) {
        $timeB = strtotime($timeB);
    }
    $d = $timeA - $timeB;
    return timestamp($d, true);
}
Пример #17
0
 function is_midnight($date)
 {
     $ts = timestamp($date);
     return date('H:i:s', $ts) == '00:00:00';
 }
/**
 * Clôture une série de filtres d'images
 *
 * Ce filtre est automatiquement appelé à la fin d'une série de filtres
 * d'images dans un squelette.
 *
 * @filtre
 * @uses reconstruire_image_intermediaire()
 *     Si l'image finale a déjà été supprimée car considérée comme temporaire
 *     par une autre série de filtres images débutant pareil
 * @uses ramasse_miettes()
 *     Pour déclarer l'image définitive et nettoyer les images intermédiaires.
 *
 * @pipeline_appel post_image_filtrer
 *
 * @param string $img
 *     Code HTML de l'image
 * @return string
 *     Code HTML de l'image
 **/
function image_graver($img)
{
    // appeler le filtre post_image_filtrer qui permet de faire
    // des traitements auto a la fin d'une serie de filtres
    $img = pipeline('post_image_filtrer', $img);
    $fichier_ori = $fichier = extraire_attribut($img, 'src');
    if (($p = strpos($fichier, '?')) !== false) {
        $fichier = substr($fichier, 0, $p);
    }
    if (strlen($fichier) < 1) {
        $fichier = $img;
    }
    # si jamais le fichier final n'a pas ete calcule car suppose temporaire
    if (!@file_exists($fichier)) {
        reconstruire_image_intermediaire($fichier);
    }
    ramasse_miettes($fichier);
    // ajouter le timestamp si besoin
    if (strpos($fichier_ori, "?") === false) {
        // on utilise str_replace pour attraper le onmouseover des logo si besoin
        $img = str_replace($fichier_ori, timestamp($fichier_ori), $img);
    }
    return $img;
}
$start_dateSQL = 'SUBDATE(NOW(), INTERVAL 1 DAY)';
$server = 'https://' . $cfg_web_host . '/';
$class_totals = new class_totals();
// Process the papers in range checking the totals.
$class_totals->process_papers($mysqli, $cfg_cron_user, $cfg_cron_passwd, $rootpath, $userid, $start_dateSQL, $end_dateSQL, $server);
// Get any failures.
$status = 'failure';
$testresult = $mysqli->prepare("SELECT user_id, paper_id, errors FROM class_totals_test_local WHERE status = ? and user_id = {$userid}");
$testresult->bind_param('s', $status);
$testresult->execute();
$testresult->bind_result($user_id, $paper_id, $errors);
// Log and email errors to support.
$message = '';
while ($testresult->fetch()) {
    $errors = strip_tags($errors);
    $message .= 'Failure: user - ' . $user_id . ', paper - ' . $paper_id . ', error - ' . $errors . "\n";
}
$testresult->close();
$headers = "From: {$support_email}\n";
$headers .= "MIME-Version: 1.0\nContent-type: text/plain; charset=UTF-8\n";
$subject = 'Rogo Summative Exam check';
if ($message != '') {
    echo $message;
    $sent = mail($support_email, $subject, $message, $headers);
    if ($sent) {
        echo "Email sent to {$support_email}";
    }
}
$mysqli->close();
echo "\n" . timestamp() . ": Finishing class totals check.\n";
Пример #20
0
function getAllStatus($md5_only, $format)
{
    $ajax = array();
    $meta = array();
    $result = retAllStatus();
    //Doors
    foreach ($result["result"] as $i2 => $v2) {
        $statusType = $v2["Type"];
        $statusHardware = $v2["HardwareName"];
        $statusName = $v2["Name"];
        if (($statusType == "Lighting 1" or $statusType == "Lighting 2" or $statusType == "Light/Switch") and strpos($statusName, "Door") == true and $statusHardware == "MySensors") {
            $ajax["doors"][$v2["idx"]]["Status"] = $v2["Status"];
            $ajax["doors"][$v2["idx"]]["Type"] = $v2["Type"];
            $ajax["doors"][$v2["idx"]]["Name"] = $v2["Name"];
        }
    }
    //Comfort
    foreach ($result["result"] as $i2 => $v2) {
        $statusType = $v2["Type"];
        $statusHardware = $v2["HardwareName"];
        $statusName = $v2["Name"];
        if ($statusType == "Temp + Humidity") {
            $ajax["comfort"][$v2["idx"]]["Type"] = $v2["Type"];
            $ajax["comfort"][$v2["idx"]]["Name"] = $v2["Name"];
            $ajax["comfort"][$v2["idx"]]["Temperature"] = number_format((double) $v2["Temp"], 2, '.', '');
            $ajax["comfort"][$v2["idx"]]["Humidity"] = $v2["Humidity"];
            $ajax["comfort"][$v2["idx"]]["ComfortLevel"] = $v2["HumidityStatus"];
        }
    }
    //Dummy
    foreach ($result["result"] as $i2 => $v2) {
        $statusType = $v2["Type"];
        $statusHardware = $v2["HardwareName"];
        $statusName = $v2["Name"];
        if ($statusHardware == "Hardware Dummy") {
            if (strpos($v2["Status"], "Set") !== false) {
                $ajax["dummy"][$v2["idx"]]["Status"] = "Transition";
            } else {
                $ajax["dummy"][$v2["idx"]]["Status"] = $v2["Status"];
            }
            if ($v2["Status"] == "Off") {
                $ajax["dummy"][$v2["idx"]]["Level"] = "0";
            } else {
                $ajax["dummy"][$v2["idx"]]["Level"] = $v2["Level"];
            }
            $ajax["dummy"][$v2["idx"]]["Type"] = $v2["Type"];
            $ajax["dummy"][$v2["idx"]]["Name"] = $v2["Name"];
        }
    }
    //Security - must enable this
    if (defined('SECURITY_ENABLE')) {
        foreach ($result["result"] as $i2 => $v2) {
            $security_idx = $v2["idx"];
            if ($security_idx == SECURITY_ID) {
                $securityStatus = $v2["Status"];
                $ajax["security"]["Normal"]["Name"] = "Normal";
                $ajax["security"]["Normal"]["Status"] = "disabled";
                $ajax["security"]["ArmAway"]["Name"] = "Arm Away";
                $ajax["security"]["ArmAway"]["Status"] = "disabled";
                $ajax["security"]["ArmHome"]["Name"] = "Arm Home";
                $ajax["security"]["ArmHome"]["Status"] = "disabled";
                if ($securityStatus == "Normal") {
                    $ajax["security"]["Normal"]["Status"] = "enabled";
                } elseif ($securityStatus == "Arm Away") {
                    $ajax["security"]["ArmAway"]["Status"] = "enabled";
                } elseif ($securityStatus == "Arm Home") {
                    $ajax["security"]["ArmHome"]["Status"] = "enabled";
                }
            }
        }
    }
    //Lights
    foreach ($result["result"] as $i2 => $v2) {
        $statusType = $v2["Type"];
        $statusHardware = $v2["HardwareName"];
        $statusName = $v2["Name"];
        if (($statusType == "Lighting 1" or $statusType == "Lighting 2" or $statusType == "Light/Switch") and strpos($statusName, "Aux") == false and strpos($statusName, "Bath") == false and strpos($statusName, "Fan") == false and $statusHardware == "Z-Wave") {
            if (strpos($v2["Status"], "Set") !== false) {
                $ajax["lights"][$v2["idx"]]["Status"] = "Transition";
            } else {
                $ajax["lights"][$v2["idx"]]["Status"] = $v2["Status"];
            }
            if ($v2["Status"] == "Off") {
                $ajax["lights"][$v2["idx"]]["Level"] = "0";
            } else {
                $ajax["lights"][$v2["idx"]]["Level"] = $v2["Level"];
            }
            $ajax["lights"][$v2["idx"]]["Type"] = $v2["Type"];
            $ajax["lights"][$v2["idx"]]["Name"] = $v2["Name"];
        }
    }
    $md5Lights = md5(print_r($ajax["lights"], true));
    //Fans
    foreach ($result["result"] as $i2 => $v2) {
        $statusType = $v2["Type"];
        $statusHardware = $v2["HardwareName"];
        $statusName = $v2["Name"];
        if (strpos($statusName, "Fan") == true and strpos($statusName, "Bath") == false and $statusHardware == "Z-Wave") {
            if (strpos($v2["Status"], "Set") !== false) {
                $ajax["fans"][$v2["idx"]]["Status"] = "Transition";
            } else {
                $ajax["fans"][$v2["idx"]]["Status"] = $v2["Status"];
            }
            $ajax["fans"][$v2["idx"]]["Level"] = $v2["Level"];
            $ajax["fans"][$v2["idx"]]["Type"] = $v2["Type"];
            $ajax["fans"][$v2["idx"]]["Name"] = $v2["Name"];
        }
    }
    $curlScene = curl_init(DOMOTICZ_JSON_URL . "?type=scenes");
    curl_setopt($curlScene, CURLOPT_RETURNTRANSFER, 1);
    $sceneResult = json_decode(curl_exec($curlScene), true);
    curl_close($curlScene);
    foreach ($sceneResult["result"] as $i3 => $v3) {
        $ajax["scenes"][$v3["idx"]]["Name"] = $v3["Name"];
        $pos = strpos($v3["Description"], $md5Lights);
        if ($pos === false) {
            $ajax["scenes"][$v3["idx"]]["Status"] = "Deactivated";
        } else {
            $ajax["scenes"][$v3["idx"]]["Status"] = "Activated";
        }
    }
    $md5 = md5(print_r($ajax, true));
    if ($md5_only == "true") {
        return $md5;
    } else {
        $ajax["meta"]["md5"] = $md5;
        $meta["meta"]["md5"] = $md5;
        $ajax["meta"]["lightd5"] = $md5Lights;
        $meta["meta"]["lightd5"] = $md5Lights;
        $timestamp = timestamp();
        $ajax["meta"]["timestamp"] = $timestamp;
        $meta["meta"]["timestamp"] = $timestamp;
        $ret_md5 = $_GET["md5"];
        if ($ret_md5 == $md5) {
            if ($format == "array") {
                return $meta;
            } else {
                return json_encode($meta);
            }
        } else {
            if ($format == "array") {
                return $ajax;
            } else {
                return json_encode($ajax);
            }
        }
    }
}
Пример #21
0
if (!$metrics) {
    header("Content-Type: image/" . IMGFMT);
    echo $canvas;
}
// Generate thumbnail image of the title for UI purposes.
$thumb = $canvas->clone();
if ($player) {
    $thumb->cropImage(427, 240, 350, 795);
    $thumb->resizeImage(72, 40, Imagick::FILTER_TRIANGLE, 1);
    $thumb->writeImage(realpath('thumbs') . '/' . $filename . '.' . IMGFMT);
    // headshotless title generation for animation
    $noHeadshot = getStatscard($player, ["emptyHeadshot" => true]);
    $noHeadshotCanvas = new Imagick();
    $noHeadshotCanvas->newImage(1920, 1080, "none", IMGFMT);
    $noHeadshotCanvas->setImageDepth(8);
    $noHeadshotCanvas->setimagecolorspace(imagick::COLORSPACE_SRGB);
    foreach ($noHeadshot['geos'] as $geo) {
        addGeoToCanvas($noHeadshotCanvas, $geo, $bustCache);
    }
    $noHeadshotCanvas->writeImage(realpath('out') . '/' . $filename . '_noHeadshot.' . IMGFMT);
} else {
    //$thumb->cropImage(1440, 1080, 0, 0);
    $thumb->resizeImage(72, 40, Imagick::FILTER_TRIANGLE, 1);
    $thumb->writeImage(realpath('thumbs') . '/' . $filename . '.' . IMGFMT);
}
timestamp('post thumbs');
// Generate the output file of the title.
$canvas->writeImage(realpath('out') . '/' . $filename . '.' . IMGFMT);
dbquery("REPLACE INTO cache SET `key`='{$key}', `hash`='" . getHashForTitle($title) . "';");
timestamp('post out');
Пример #22
0
            <tr>
              <td><?php 
        echo $log->id;
        ?>
</td>
              <td><?php 
        echo $log->what;
        ?>
</td>
              <td><?php 
        echo $log->data;
        ?>
</td>
              <td><?php 
        echo $log->from;
        ?>
</td>
              <td><?php 
        echo timestamp($log->timestamp);
        ?>
</td>
            </tr>
          <?php 
    }
    ?>
        </tbody>
      </table>
    </div>
  </div>
<?php 
}
Пример #23
0
function add_command($device, $command)
{
    $db = get_connection();
    $db->queue->save(array("device_udid" => $device["udid"], "command" => $command, "created" => timestamp()));
}
Пример #24
0
function log_activity($_message, $_file_name)
{
    $log_file = '/var/log/' . $_file_name;
    $activity = timestamp() . ' ' . $_message . "\n";
    if ($handle = fopen($log_file, 'a')) {
        if (fwrite($handle, $activity) === FALSE) {
            $errmsg = $timestamp . " Cannot write to " . $logFile . "\n";
            fwrite(STDERR, $activity);
            exit;
        }
    } else {
        $errmsg = $timestamp . " " . $log_file . " is not writable\n";
        fwrite(STDERR, $errmsg);
        exit;
    }
}
 public function transform($data)
 {
     return ['_id' => (string) $data->_id, 'party_name' => $data->party_name, 'party_name_english' => $data->party_name_english, 'abbreviation' => $data->abbreviation, 'member_count' => $data->member_count, 'leadership' => $data->leadership, 'chairman' => $data->chairman, 'establishment_date' => timestamp($data->establishment_date), 'establishment_approval_date' => timestamp($data->establishment_approval_date), 'registration_application_date' => timestamp($data->registration_application_date), 'registration_approval_date' => timestamp($data->registration_approval_date), 'approved_party_number' => $data->approved_party_number, 'party_flag' => $data->party_flag, 'party_seal' => $data->party_seal, 'region' => $data->region, 'ST_PCODE' => $data->ST_PCODE, 'DT_PCODE' => $data->DT_PCODE, 'headquarters' => $data->headquarters, 'contact' => $data->contact, 'policy' => $data->policy];
 }
Пример #26
0
 /**
  * Set Etag
  * 
  * if it's empty, set a valid Etag in the entries table
  * 
  * @author Brian Hendrickson <*****@*****.**>
  * @access public
  * @return string[]
  */
 function set_etag($person_id = NULL)
 {
     global $db;
     $Entry =& $db->get_table('entries');
     $atomentry = $Entry->find_by(array('resource' => $this->table, 'record_id' => $this->id), $this->id);
     if ($atomentry) {
         return true;
     }
     $atomentry = $Entry->base();
     if ($person_id == NULL) {
         $person_id = get_person_id();
     }
     if ($atomentry) {
         $id = $this->primary_key;
         $atomentry->set_value('etag', getEtag($this->{$id}));
         $atomentry->set_value('resource', $this->table);
         $atomentry->set_value('record_id', $this->{$id});
         $atomentry->set_value('content_type', 'text/html');
         $atomentry->set_value('last_modified', timestamp());
         $atomentry->set_value('person_id', $person_id);
         $aresult = $atomentry->save_changes();
         if ($aresult && array_key_exists('entry_id', $this->attributes)) {
             $this->set_value('entry_id', $atomentry->id);
             $this->save_changes();
         }
     }
 }
Пример #27
0
    $timestamp = date('YmdHis', strtotime('+' . $x . ' seconds'));
    ++$x;
    return $timestamp;
}
// ========================
// = Build/Add Form Files =
// ========================
$builder = new FormBuilderTool($_POST);
$builder->build_form();
$zip = new ZipArchive();
$filename = ROOT . "/tools/_shared/tmp/form-" . time() . ".zip";
if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) {
    exit("cannot open <{$filename}>\n");
}
if ($builder->database) {
    $zip->addFromString('ruckusing/db/migrate/' . timestamp() . '_Create' . $builder->form_name->migration . '.php', $builder->migration);
}
if ($builder->contact) {
    $zip->addFromString('inc/mailers/' . $builder->form_name->computer . '.html.php', $builder->mailer);
}
$zip->close();
// ===================
// = Save to History =
// ===================
// $template_name = (!empty($_POST['form_name'])) ? addslashes($_POST['form_name']) : date('r');
// $template = str_replace(array('\n', '\r'), array('\\\n', '\\\r'), addslashes(json_encode($_POST)));
// $timestamp = date('Y-m-d H:i:s');
//
// $query = "INSERT INTO `history` ";
// $query .= "(`user_id`, `tool`, `template_name`, `template`, `created_at`, `updated_at`)";
// $query .= " VALUES (";
Пример #28
0
                        $v = floor($m / $s);
                        $n = "{$v} {$u}" . ($v == 1 ? '' : 'a') . ' pärast';
                        break;
                    case 'kuu':
                        $v = floor($m / $s);
                        $n = "{$v} {$u}" . ($v == 1 ? '' : '') . ' pärast';
                        break;
                    case 'aasta':
                        $v = floor($m / $s);
                        $n = "{$v} {$u}" . ($v == 1 ? '' : '') . ' pärast';
                        break;
                }
            }
        }
        return $n;
    }
    // 	if ($language === 'english') {
    // 		return $o;
    // 	}
    // 	elseif ($language === 'estonian') {
    // 		return $n;
    // 	}
}
$languageInFuture = 'english';
$languageInPast = 'estonian';
$timeInFuture = '2032-04-08 21:30:15';
$timeInPast = '1978-04-08 21:30:15';
// @formatter:off
echo ' <br/>126: ', sprintf('The incident is going to take place in %1$s.', timestamp(strtotime($timeInFuture), $languageInFuture));
echo ' <br/>130: ', sprintf('Intsident toimus %1$s.', timestamp(strtotime($timeInPast), $languageInPast));
// @formatter:on
Пример #29
0
 }
 if ($sql_dir) {
     $load_files = dir_read($sql_dir, null, array('.sql'), 'date_desc');
 }
 $load_assoc = array();
 if ($sql_dir) {
     foreach ($load_files as $file) {
         $file_path = $file;
         $file = basename($file);
         $load_assoc[$file] = '(' . substr(file_date($file_path), 0, 10) . ')' . ' ' . $file;
     }
 }
 if ($sql_dir && 'load' == $post['perform']) {
     $file = $sql_dir . '/' . $post['load_from'];
     if (array_key_exists($post['load_from'], $load_assoc) && file_exists($file)) {
         $msg .= sprintf('<div>Sql loaded: %s (%s)</div>', basename($file), timestamp(file_date($file)));
         $post['sql'] = file_get($file);
         $post['save_as'] = basename($file);
         $post['save_as'] = str_replace('.sql', '', $post['save_as']);
     } else {
         error('<div>File not found: %s</div>', $file);
     }
 }
 // after load - md5 may change
 $md5 = md5($post['sql']);
 if ($sql_dir && 'load' == $post['perform'] && !error()) {
     $md5_tmp = sprintf($sql_dir . '/zzz_%s.dat', $md5);
     file_put($md5_tmp, $post['sql']);
 }
 $is_sel = false;
 $queries = preg_split("#;(\\s*--[ \t\\S]*)?(\r\n|\n|\r)#U", $post['sql']);
function userEntitled($entitlement)
{
    // the userEntitled() method is what should be called at login to determine
    // if the user is entitled, based on the current time and the start & end timestamps
    $now = timestamp();
    $isEntitled = $entitlement->startTimestamp < $now && (null == $entitlement->endTimestamp || $entitlement->endTimestamp > $now);
    logMsg("userEntitled(): Entitlement " . $entitlement->merchantEntitlementId . " for Account " . $entitlement->account->merchantAccountId . ", from Product " . $entitlement->merchantProductId . ", from AutoBill " . $entitlement->merchantAutoBillId . ",\n\tsource: " . $entitlement->source . ", dynamic status: " . ($isEntitled ? "Entitled" : "Not Entitled") . ", " . dateString("entitlement begins", $entitlement->startTimestamp) . " " . dateString("until", $entitlement->endTimestamp) . "\n");
    return $isEntitled;
}