Beispiel #1
0
 function Query($query)
 {
     if ($result = mysql_query($query)) {
         return $result;
     } else {
         dp('<p>MySQL Error ' . Database::GetErrorNumber() . ': ' . Database::GetError() . ' in query <code>' . $query . '</code></p>');
         dp();
         return false;
     }
 }
Beispiel #2
0
 public static function flushAllConfig()
 {
     $rows = app()->getDb()->createCommand()->select(array('config_name', 'config_value'))->from(TABLE_CONFIG)->queryAll();
     if (empty($rows)) {
         return false;
     }
     $rows = CHtml::listData($rows, 'config_name', 'config_value');
     $data = "<?php\nreturn " . var_export($rows, true) . ';';
     $filename = dp('setting.config.php');
     return file_put_contents($filename, $data);
 }
Beispiel #3
0
function loginHandler($p)
{
    $session = SessionHandler::getInstance();
    if ($session->id) {
        dp('HACK user ' . $session->name . ' (' . $session->id . ') tried to login user ' . $p['usr']);
        return false;
    }
    if ($session->login($p['usr'], $p['pwd'])) {
        $session->showStartPage();
    }
    return true;
}
Beispiel #4
0
 public static function updateCacheFile()
 {
     $rows = app()->getDb()->createCommand()->select(array('keyword', 'replace'))->from(TABLE_FILTER_KEYWORD)->queryAll();
     if (empty($rows)) {
         return true;
     }
     foreach ($rows as $index => $row) {
         $pattern = '/\\{(\\d+)\\}/is';
         $replacement = '.{0,$1}?';
         $rows[$index]['keyword'] = preg_replace($pattern, $replacement, $row['keyword']);
     }
     $rows = CHtml::listData($rows, 'keyword', 'replace');
     $data = "<?php\nreturn " . var_export($rows, true) . ';';
     $filename = dp('filter_keywords.php');
     return file_put_contents($filename, $data);
 }
Beispiel #5
0
 /**
  * Initializes object from an resource
  *
  * @param $r can be a path to a image file, a GD resource or a File object
  */
 function load($r)
 {
     if ($r instanceof File) {
         $r = File::getUploadPath($r->id);
     }
     if (is_resource($r) && get_resource_type($r) == 'gd') {
         dp($r);
         $this->resource = $r;
         $this->width = imagesx($r);
         $this->height = imagesy($r);
         return;
     }
     if (!is_readable($r)) {
         throw new \Exception('image resource not found: ' . $r);
     }
     $info = getimagesize($r);
     switch ($info['mime']) {
         case 'image/jpeg':
             $im = imagecreatefromjpeg($r);
             break;
         case 'image/png':
             $im = imagecreatefrompng($r);
             break;
         case 'image/gif':
             $im = imagecreatefromgif($r);
             break;
         default:
             throw new \Exception('Unsupported image type ' . $info['mime'] . ' for ' . $r);
     }
     $this->resource = $im;
     $this->width = $info[0];
     $this->height = $info[1];
     $this->mimetype = $info['mime'];
     $this->sha1 = sha1_file($r);
     return;
 }
Beispiel #6
0
            return;
        }
        $session->requireLoggedIn();
        $f = File::get($this->child);
        if ($session->id != $f->uploader) {
            dp('HACK: tried to rotate photo ' . $this->child . ' which is not uploaded by user ' . $session->id);
            return;
        }
        $im = new ImageRotator($f);
        $im->rotate($this->child2);
        $im->render($im->mimetype, File::getUploadPath($f->id));
        File::sync($fileId);
        //updates tblFiles.size
        js_redirect('u/photo/show/' . $f->id);
        break;
    case 'delete':
        $session->requireLoggedIn();
        if ($this->child && confirmed('Are you sure you want to delete this photo?')) {
            // verify that the owner of the album is current session id
            $im = File::get($this->child);
            if ($im->uploader != $session->id) {
                dp('HACK: tried to delete photo ' . $this->child . ' which is not uploaded by user ' . $session->id);
                return;
            }
            File::delete($this->child);
            js_redirect('u/album/show/' . $session->id . '/' . $im->category);
        }
        break;
    default:
        echo 'no such view: ' . $this->owner;
}
Beispiel #7
0
 function internalErrorHandler($errno, $errstr, $errfile, $errline, $errcontext = '')
 {
     $s = $errstr;
     // http://se.php.net/manual/en/errorfunc.constants.php
     switch ($errno) {
         case E_ERROR:
             $type = 'E_ERROR';
             break;
         case E_WARNING:
             $type = 'E_WARNING';
             break;
         case E_PARSE:
             $type = 'E_PARSE';
             break;
         case E_NOTICE:
             $type = 'E_NOTICE';
             break;
         case E_COMPILE_ERROR:
             $type = 'E_COMPILE_ERROR';
             break;
         case E_USER_ERROR:
             $type = 'E_USER_ERROR';
             break;
         case E_USER_WARNING:
             $type = 'E_USER_WARNING';
             break;
         case E_USER_NOTICE:
             $type = 'E_USER_NOTICE';
             break;
         case E_STRICT:
             $type = 'E_STRICT';
             break;
         case E_RECOVERABLE_ERROR:
             $type = 'E_RECOVERABLE_ERROR';
             break;
         case E_DEPRECATED:
             $type = 'E_DEPRECATED';
             break;
         default:
             $type = 'UNKNOWN';
             $s = 'Unknown error type ' . $errno . ': ' . $errstr;
             break;
     }
     dp('PHP ERROR: ' . $type . ' (' . $errno . ') ' . $s . ' on ' . $errfile . ':' . $errline);
     // Dont display errors that is hidden by error_reporting setting
     if (!(error_reporting() & $errno)) {
         return;
     }
     echo '</div>';
     // HACK to not end up inside a <div style="display:none">
     echo "\n";
     echo '<pre>';
     echo '<b>' . $type . ':</b> ' . $s . ' on ' . $errfile . ':' . $errline;
     echo '</pre>' . "\n";
     // Don't execute PHP internal error handler
     return true;
 }
Beispiel #8
0
 public static function create($username, $password, $type = SESSION_REGULAR, $algo = 'sha512')
 {
     $username = trim($username);
     if (User::getByName($username)) {
         return false;
     }
     $o = new User();
     $o->name = $username;
     $o->type = $type;
     $o->time_created = sql_datetime(now());
     $o->id = $o->store();
     if (!$o->id) {
         return false;
     }
     $session = SessionHandler::getInstance();
     $o->password = Password::encrypt($o->id, $session->getEncryptKey(), $password, $algo);
     $o->store();
     // write again with password encoded using the user id
     dp($session->getUsername() . ' created user ' . $username . ' (' . $o->id . ') of type ' . $type);
     return $o->id;
 }
Beispiel #9
0
/**
 * Translates strings into other languages
 */
function t($s)
{
    if (!$s) {
        throw new \Exception('huh');
    }
    $locale = \cd\LocaleHandler::getInstance();
    switch ($locale->get()) {
        case 'ger':
            return $s;
            // German (Deutsch)   - XXX not translated
        // German (Deutsch)   - XXX not translated
        case 'eng':
            return $s;
            // English (System default)
        // English (System default)
        case 'swe':
            $t = \cd\t_swe($s);
            break;
            // Swedish (Svenska)
        // Swedish (Svenska)
        default:
            die('Unhandled language: ' . $locale->get());
    }
    if (!$t) {
        dp('Untranslated string: ' . $s);
        return '__(' . $s . ')__';
    }
    return $t;
}
Beispiel #10
0
                                               'message'=>'out',
                                               'users' => ''),
                                             null,
                                             $msg->channel);
                             break;
                         */
         default:
             # no code...
             break;
     }
     break 2;
     //exit this sub-loop, only
 }
 $buf = '';
 $buf = @socket_read($changed_socket, null, PHP_NORMAL_READ);
 dp('changed socket: ' . $changed_socket);
 if ($buf === false) {
     // client is off?
     // remove client for $clients array
     $found_socket = array_search($changed_socket, $clients);
     echo "\n\nDESCON:" . $found_socket . "\n\n";
     //log
     terminal('DISCONNECTED', $users[$found_socket]);
     //Apagando o usuário nmo DB
     $db->deleteUser($users[$found_socket]['userid']);
     //notify all users about disconnected connection
     sendMessage(array('type' => 'out', 'id' => $users[$found_socket]['userid'], 'message' => ''), null, $users[$found_socket]['channel']);
     //deleting this user
     unset($clients[$found_socket]);
     unset($users[$found_socket]);
 }
Beispiel #11
0
if (!file_exists($filename)) {
    print 'File ' . $filename . ' not exists!';
    return;
}
// reads all input words separated by new-lines
$words = file($filename, FILE_IGNORE_NEW_LINES + FILE_SKIP_EMPTY_LINES);
$tree = new Tree('!');
$c = '';
// creates first-level tree with first-word-letters children
for ($i = 0; $i < count($words); $i++) {
    $words[$i] = strtolower(trim($words[$i]));
    if ($c != $words[$i][0]) {
        $c = $words[$i][0];
        $tree->addChild($c, $i);
    }
}
// recursively creates children
recurse($tree);
$time_end = microtime(true);
$time = $time_end - $time_start;
print "Create Tree {$time} seconds\n";
$time_start = microtime(true);
// saves binary serialized tree to file
$fp = fopen('tree.txt', 'w+b');
save_tree($tree, $fp);
fclose($fp);
$time_end = microtime(true);
$time = $time_end - $time_start;
print "Save Tree {$time} seconds\n";
dp($tree);
Beispiel #12
0
 /**
  * Parses the content inside a VCARD:BEGIN + VCARD:END couple into a VcardAddress object
  */
 private static function parseVcard($data)
 {
     $data = str_replace("\r\n", "\n", $data);
     $data = str_replace("\r", "\n", $data);
     $rows = explode("\n", $data);
     $adr = new VcardAddress();
     foreach ($rows as $row) {
         $p1 = strpos($row, ':');
         if ($p1 === false) {
             throw new \Exception('invalid vcard format: ' . $row);
         }
         $key = substr($row, 0, $p1);
         $val = explode(';', substr($row, $p1 + 1));
         $params = array();
         $p2 = strpos($key, ';');
         if ($p2 !== false) {
             $params = explode(';', substr($key, $p2 + 1));
             $key = substr($key, 0, $p2);
         }
         switch ($key) {
             case 'BEGIN':
                 break;
             case 'END':
                 break;
             case 'VERSION':
                 if ($val[0] != '2.1') {
                     throw new \Exception('unsupported vcard version ' . $val[0]);
                 }
                 break;
             case 'BDAY':
                 $adr->birthdate = $val[0];
                 break;
             case 'N':
                 //val = Lastname;Firstname;??;??;??
                 $adr->last_name = $val[0];
                 $adr->first_name = $val[1];
                 break;
             case 'FN':
                 // full name.. XXX FIXME parse ONLY if no "N" tag was found
                 break;
             case 'TEL':
                 switch ($params[count($params) - 1]) {
                     case 'CELL':
                         $adr->cellphone = formatMSID($val[0]);
                         break;
                     case 'HOME':
                         $adr->homephone = formatMSID($val[0]);
                         break;
                     case 'WORK':
                         $adr->cellphone = formatMSID($val[0]);
                         break;
                     default:
                         dp('XXX VcardReader unhandled telephone type: ' . $params[count($params) - 1]);
                 }
                 break;
             case 'ADR':
                 switch ($params[0]) {
                     case 'HOME':
                         // val = ;;Terrassebakken 14;Ålgård;;4330;
                         $adr->street = $val[2];
                         $adr->city = $val[3];
                         $adr->zipcode = $val[5];
                         break;
                     case 'WORK':
                         // ADR;WORK:;;Verkensveien 6;Hell;;7517;
                         // XXXX: store work adddress separately?
                         if (!$adr->street) {
                             $adr->street = $val[2];
                             $adr->city = $val[3];
                             $adr->zipcode = $val[5];
                         }
                         break;
                     default:
                         dp('XXX VcardReader unhandled address type: ' . $params[0]);
                 }
                 break;
             default:
                 //echo "key ".$key."\t, params = ".implode('; ', $params)."\t, val = ".implode('; ', $val)."\n";
         }
     }
     return $adr;
 }
Beispiel #13
0
 /**
  * Sends a email
  */
 function send($msg = '')
 {
     $header = "Date: " . date('r') . "\r\n" . "From: " . (mb_encode_mimeheader(self::$from_name, 'UTF-8') ? mb_encode_mimeheader(self::$from_name, 'UTF-8') . " <" . self::$from_adr . ">" : self::$from_adr) . "\r\n" . "Subject: " . mb_encode_mimeheader(self::$subject, 'UTF-8') . "\r\n" . "User-Agent: " . $this->version . "\r\n" . "MIME-Version: 1.0\r\n";
     if (self::$rply_adr) {
         $header .= "Reply-To: " . (mb_encode_mimeheader(self::$rply_name, 'UTF-8') ? mb_encode_mimeheader(self::$rply_name, 'UTF-8') . " <" . self::$rply_adr . ">" : self::$rply_adr) . "\r\n";
     }
     foreach (self::$to_adr as $to) {
         $header .= "To: " . $to . "\r\n";
     }
     foreach (self::$cc_adr as $cc) {
         $header .= "Cc: " . $cc . "\r\n";
     }
     foreach (self::$bcc_adr as $bcc) {
         $header .= "Bcc: " . $bcc . "\r\n";
     }
     if (count(self::$attachments)) {
         $rnd = md5(mt_rand() . '))<>((' . microtime());
         $boundary = '------------0' . substr($rnd, 0, 23);
         $header .= "Content-Type: multipart/mixed;\r\n" . " boundary=\"" . $boundary . "\"\r\n" . "\r\n" . "This is a multi-part message in MIME format.\r\n" . "\r\n" . "--" . $boundary . "\r\n";
     }
     $header .= "Content-Type: " . (self::$html ? "text/html" : "text/plain") . "; charset=utf-8\r\n" . "Content-Transfer-Encoding: 7bit\r\n" . "\r\n";
     $attachment_data = '';
     foreach (self::$attachments as $a) {
         $attachment_data .= "\r\n" . "--" . $boundary . "\r\n" . "Content-Type: " . $a->mimetype . ";\r\n" . " name=\"" . mb_encode_mimeheader($a->filename, 'UTF-8') . "\"\r\n" . "Content-Transfer-Encoding: base64\r\n" . ($a->content_id ? "Content-ID: <" . $a->content_id . ">\r\n" : "") . "Content-Disposition: " . ($a->content_id ? "inline" : "attachment") . ";\r\n" . " filename=\"" . mb_encode_mimeheader($a->filename, 'UTF-8') . "\"\r\n" . "\r\n" . chunk_split(base64_encode($a->data));
     }
     if (count(self::$attachments)) {
         $attachment_data .= "--" . $boundary . "--";
     }
     if ($this->use_mta) {
         return mail(implode(', ', self::$to_adr), self::$subject, $msg, $header);
     }
     if (!$this->connect()) {
         dp('SendMail failed to send mail because no mail server configured: ' . substr($msg, 0, 200));
         return false;
     }
     if (!$this->smtp->_MAIL_FROM(self::$from_adr)) {
         throw new \Exception('Failed to set from address');
     }
     foreach (self::$to_adr as $to) {
         $this->smtp->_RCPT_TO($to);
     }
     foreach (self::$cc_adr as $cc) {
         $this->smtp->_RCPT_TO($cc);
     }
     foreach (self::$bcc_adr as $bcc) {
         $this->smtp->_RCPT_TO($bcc);
     }
     return $this->smtp->_DATA($header . $msg . "\r\n" . $attachment_data);
 }
if (!file_exists($jploc . "jpgraph.php")) {
    $string = "Unable to find JPGraph files";
    create_image1($string, $jploc);
    exit;
}
include $jploc . "jpgraph.php";
include $jploc . "jpgraph_line.php";
$clientrawextra = get_raw("{$hostloc}clientrawextra.txt");
//temp=========================================================================
$y = array($clientrawextra['21'], $clientrawextra['22'], $clientrawextra['23'], $clientrawextra['24'], $clientrawextra['25'], $clientrawextra['26'], $clientrawextra['27'], $clientrawextra['28'], $clientrawextra['29'], $clientrawextra['30'], $clientrawextra['31'], $clientrawextra['32'], $clientrawextra['33'], $clientrawextra['34'], $clientrawextra['35'], $clientrawextra['36'], $clientrawextra['37'], $clientrawextra['38'], $clientrawextra['39'], $clientrawextra['40'], $clientrawextra['566'], $clientrawextra['567'], $clientrawextra['568'], $clientrawextra['569']);
$datay = $y;
//hum=============================================================================
$y = array($clientrawextra['611'], $clientrawextra['612'], $clientrawextra['613'], $clientrawextra['614'], $clientrawextra['615'], $clientrawextra['616'], $clientrawextra['617'], $clientrawextra['618'], $clientrawextra['619'], $clientrawextra['620'], $clientrawextra['621'], $clientrawextra['622'], $clientrawextra['623'], $clientrawextra['624'], $clientrawextra['625'], $clientrawextra['626'], $clientrawextra['627'], $clientrawextra['628'], $clientrawextra['629'], $clientrawextra['630'], $clientrawextra['631'], $clientrawextra['632'], $clientrawextra['633'], $clientrawextra['634']);
$datay2 = $y;
//dew=============================================================================
$y = array(dp($datay[0], $datay2[0]), dp($datay[1], $datay2[1]), dp($datay[2], $datay2[2]), dp($datay[3], $datay2[3]), dp($datay[4], $datay2[4]), dp($datay[5], $datay2[5]), dp($datay[6], $datay2[6]), dp($datay[7], $datay2[7]), dp($datay[8], $datay2[8]), dp($datay[9], $datay2[9]), dp($datay[10], $datay2[10]), dp($datay[11], $datay2[11]), dp($datay[12], $datay2[12]), dp($datay[13], $datay2[13]), dp($datay[14], $datay2[14]), dp($datay[15], $datay2[15]), dp($datay[16], $datay2[16]), dp($datay[17], $datay2[17]), dp($datay[18], $datay2[18]), dp($datay[19], $datay2[19]), dp($datay[20], $datay2[20]), dp($datay[21], $datay2[21]), dp($datay[22], $datay2[22]), dp($datay[23], $datay2[23]));
$datay3 = $y;
if ($temp_conv == 1.8) {
    array_walk($datay, "CtoF");
    array_walk($datay3, "CtoF");
}
//Check for negative values in array and do a SetAuotMin(0) if none
array_walk($datay, "NegVal");
$negvalue1 = $negvalue;
// Check for positive values in array
array_walk($datay, "PosVal");
$posvalue1 = $posvalue;
$negvalue = 0;
$posvalue = 0;
//Check for negative values in array and do a SetAuotMin(0) if none
array_walk($datay3, "NegVal");
Beispiel #15
0
 function GetSimpleArray()
 {
     /* Puts the result of a simple 2-fields query into an array using the
     		first field as the index. */
     // Make sure we have exactly two fields
     if (mysql_num_fields($this->GetResult()) != 2) {
         dp($this->GetQueryString());
         dp();
         trigger_error('Query::GetSimpleArray() requires a query with exactly two fields', E_USER_WARNING);
         return false;
     }
     // Build array
     while ($row = mysql_fetch_row($this->GetResult())) {
         $array[$row[0]] = $row[1];
     }
     return $array;
 }
Beispiel #16
0
 function parse($data)
 {
     if (is_url($data)) {
         $u = new HttpClient($data);
         $u->setCacheTime(60 * 60);
         //1h
         $data = $u->getBody();
         //FIXME check http client return code for 404
         if (substr($data, 0, 5) != '<asx ') {
             dp('input_asx->parse FAIL: cant parse playlist from ' . $u->getUrl());
             return false;
         }
     }
     $reader = new XMLReader();
     if ($this->getDebug()) {
         echo 'Parsing ASX: ' . $data . ln();
     }
     $reader->xml($data);
     $item = new VideoResource();
     while ($reader->read()) {
         if ($reader->nodeType == XMLReader::END_ELEMENT && $reader->name == 'asx') {
             $this->items[] = $item;
             $item = new VideoResource();
         }
         if ($reader->nodeType != XMLReader::ELEMENT) {
             continue;
         }
         switch ($reader->name) {
             case 'asx':
                 if ($reader->getAttribute('version') != '3.0') {
                     die('XXX FIXME unsupported ASX version ' . $reader->getAttribute('version'));
                 }
                 break;
             case 'entry':
                 while ($reader->read()) {
                     if ($reader->nodeType == XMLReader::END_ELEMENT && $reader->name == 'entry') {
                         break;
                     }
                     if ($reader->nodeType != XMLReader::ELEMENT) {
                         continue;
                     }
                     switch ($reader->name) {
                         case 'author':
                             break;
                             //<author>svt.se</author>
                         //<author>svt.se</author>
                         case 'copyright':
                             break;
                             //<copyright>Sveriges Television AB 2009</copyright>
                         //<copyright>Sveriges Television AB 2009</copyright>
                         case 'starttime':
                             break;
                             //<starttime value="00:00:00.00"/>
                         //<starttime value="00:00:00.00"/>
                         case 'ref':
                             //<ref href="mms://wm0.c90901.cdn.qbrick.com/90901/kluster/20091026/aekonomi920.wmv"/>
                             $item->setUrl($reader->getAttribute('href'));
                             break;
                         case 'duration':
                             //<duration value="00:03:39.00"/>
                             $item->setDuration($reader->getAttribute('value'));
                             break;
                         default:
                             echo "bad entry " . $reader->name . ln();
                     }
                 }
                 break;
             default:
                 echo "unknown " . $reader->name . ln();
                 break;
         }
     }
     $reader->close();
     return true;
 }
Beispiel #17
0
<?php

/**
 * This is the application handler
 * all webpage requests is sent here from a RewriteRule in .htaccess
 */
require_once 'config.php';
require_once 'RequestHandler.php';
try {
    $front = RequestHandler::getInstance();
    $front->excludeSession(array('api'));
    //exclude session handling for these controllers
    $front->route();
    $page = XmlDocumentHandler::getInstance();
    echo $page->render();
} catch (Exception $e) {
    echo '<pre>';
    echo $e->__toString();
    dp($e->__toString());
    //because the exception is caught it is not written to error log
    echo '</pre>';
}
Beispiel #18
0
 static function parseStatus($s, $started, $ended)
 {
     switch (strval($s)) {
         case 'Ended':
         case 'Canceled/Ended':
             return $started . ' - ' . $ended . ' (ended)';
             break;
         case 'Final Season':
         case 'Returning Series':
         case 'New Series':
             return $started . ' - now (running)';
             break;
         case 'On Hiatus':
         case 'TBD/On The Bubble':
             return $started . ' - now (pause)';
             break;
         case 'Never Aired':
         case 'Pilot Rejected':
         case 'In Development':
             return '(not aired)';
             break;
         default:
             dp('FIXME TvRageClient: unhandled status: ' . strval($s));
             return 'XXX-ODDSTATUS ' . strval($s);
     }
 }
Beispiel #19
0
 public static function filterText($text)
 {
     static $keywords = null;
     if ($keywords === null) {
         $filename = dp('filter_keywords.php');
         if (file_exists($filename) && is_readable($filename)) {
             $keywords = (require $filename);
         } else {
             return $text;
         }
     }
     //         var_dump($keywords);exit;
     if (empty($keywords)) {
         return $text;
     }
     try {
         $patterns = array_keys($keywords);
         foreach ($patterns as $index => $pattern) {
             $patterns[$index] = '/' . $pattern . '/is';
         }
         $replacement = array_values($keywords);
         foreach ($replacement as $index => $word) {
             $replacement[$index] = empty($word) ? param('filterKeywordReplacement') : $word;
         }
         $result = preg_replace($patterns, $replacement, $text);
         $newText = $result === null ? $text : $result;
     } catch (Exception $e) {
         $newText = $text;
     }
     return $newText;
 }
 /** Logs out the user */
 function logout()
 {
     dp($this->username . ' logged out');
     if (!$this->id) {
         throw new \Exception('already logged out');
     }
     Sql::pUpdate('UPDATE tblUsers SET time_last_logout = NOW() WHERE id = ?', 'i', $this->id);
     $params = session_get_cookie_params();
     setcookie(session_name(), '', time() - 604800, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
     $page = XmlDocumentHandler::getInstance();
     $show_page = $this->logged_out_start_page ? $this->logged_out_start_page : $page->getRelativeUrl();
     header('Location: ' . $show_page);
     $this->end();
     die;
 }
Beispiel #21
0
         $a->rel = 'lightbox[album]';
         $a->content = showThumb($im->id, $im->name, 150, 150);
         echo $a->render();
         echo ahref('u/photo/show/' . $im->id, 'Details');
         echo '<br/><br/>';
     }
     $lb = new YuiLightbox();
     echo $lb->render();
     break;
 case 'delete':
     $session->requireLoggedIn();
     if ($this->child && confirmed('Are you sure you want to delete this photo album?')) {
         // verify that the owner of the album is current session id
         $album = PhotoAlbum::get($this->child);
         if (!$album->owner || $album->owner != $session->id) {
             dp('HACK: tried to delete photo album ' . $this->child . ' which is not owned by user ' . $session->id);
             return;
         }
         PhotoAlbum::delete($this->child);
         js_redirect('u/album/overview');
     }
     break;
 case 'upload':
     // child = album id
     $session->requireLoggedIn();
     function handleUpload($p)
     {
         $session = SessionHandler::getInstance();
         //XXX SECURITY: verify that destination album is owned by current user
         $fileId = File::importImage(USER, $p['img'], $p['album']);
         if ($fileId) {
$datay = $y;
//humidity
$y2 = array();
$ii = 0;
$jj = 241;
while ($ii < 60) {
    $y2[$ii] = $clientrawhour[$jj];
    $ii = $ii + 1;
    $jj = $jj + 1;
}
$datay2 = $y2;
//dew point Calculated
$y3 = array();
$ii = 0;
while ($ii < 60) {
    $y3[$ii] = dp($datay[$ii], $datay2[$ii]);
    $ii = $ii + 1;
}
$datay3 = $y3;
if ($temp_conv == 1.8) {
    array_walk($datay, "CtoF");
    array_walk($datay3, "CtoF");
}
//Check for negative values in array and do a SetAuotMin(0) if none
array_walk($datay, "NegVal");
$negvalue1 = $negvalue;
// Check for positive values in array
array_walk($datay, "PosVal");
$posvalue1 = $posvalue;
//Check for negative values in array and do a SetAuotMin(0) if none
array_walk($datay3, "NegVal");