Esempio n. 1
0
 /**
  * Fetch an image from the image server.
  *
  * Returns the image resource or false on failure.
  * @param integer $id
  * @param integer $size
  * @return resource|boolean The image resource or false on failure.
  */
 private static function fetchImage($id, $size = 64)
 {
     $url = 'http://' . IMG_SERVER . "/" . "InventoryType" . "/" . $id . "_" . $size . ".png";
     if (function_exists('curl_init')) {
         // in case of a dead eve server we only want to wait 2 seconds
         @ini_set('default_socket_timeout', 2);
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
         $file = curl_exec($ch);
         //list($header, $file) = explode("\n\n", $file, 2);
         $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
         curl_close($ch);
     } else {
         // in case of a dead eve server we only want to wait 2 seconds
         @ini_set('default_socket_timeout', 2);
         // try alternative access via fsockopen
         // happens if allow_url_fopen wrapper is false
         $http = new http_request($url);
         $file = $http->get_content();
         $http_code = $http->get_http_code();
     }
     return @imagecreatefromstring($file);
 }
Esempio n. 2
0
 private function loaddata($id)
 {
     $url = API_SERVER . "/eve/CharacterInfo.xml.aspx?characterID=" . urlencode($id);
     $http = new http_request($url);
     $http->set_useragent("PHPApi");
     return $http->get_content();
 }
Esempio n. 3
0
function get_info($get)
{
    $data['status'] = 0;
    $http_request = new http_request();
    $params = $_GET;
    $data = $http_request->post($params, 'http://api.ex-sandbox.com/php/');
    return $data;
}
Esempio n. 4
0
 /**
  * Fetch a new feed.
  */
 private function fetch()
 {
     if (!$this->url) {
         return false;
     }
     $this->posted = array();
     $this->skipped = array();
     $this->duplicate = array();
     $this->lastReturned = 0;
     $this->time = '';
     $this->cachedTime = '';
     global $idfeedversion;
     $http = new http_request($this->getFullURL());
     $http->set_useragent("EDK IDFeedfetcher " . $idfeedversion);
     $http->set_timeout(300);
     //accept gzip encoding
     $http->set_header('Accept-Encoding: gzip');
     if (strpos($http->get_header(), 'Content-Encoding: gzip') !== false) {
         $this->xml = gzdecode($http->get_content());
     } else {
         $this->xml = $http->get_content();
     }
     if ($http->get_http_code() != 200) {
         trigger_error("HTTP error " . $http->get_http_code() . " while fetching feed from " . $this->url . $options . ".", E_USER_WARNING);
         return false;
     }
     if ($this->xml) {
         return true;
     } else {
         return false;
     }
 }
Esempio n. 5
0
 public static function importhandler($object)
 {
     if (config::get('forward_active') == false) {
         return;
     }
     require_once 'common/includes/class.http.php';
     $req = new http_request(config::get('forward_site') . '?a=post');
     $req->set_postform('password', config::get('forward_pass'));
     $req->set_postform('killmail', stripslashes($object->killmail_));
     $req->request();
 }
Esempio n. 6
0
 public function __construct()
 {
     $this->template = new frontend_model_template();
     if (http_request::isGet('http_error')) {
         $this->http_error = form_inputFilter::isAlphaNumeric($_GET['http_error']);
     }
 }
Esempio n. 7
0
 public function validate($in = false)
 {
     $valid = http_request::getString($this->name, false, false);
     if (($valid == false || $valid == "") && $this->required == true) {
         return false;
     }
     return $valid;
 }
Esempio n. 8
0
 protected function uploadFile($value)
 {
     $uploadPressed = http_request::getString('upload');
     $fileExists = false;
     if ($value == "4d988458b51093c7ee3a4e1582b5fd9b" && $uploadPressed == 'Ladda upp') {
         $value = $imgStr = randomString();
         file::tempName($imgStr);
         $fileExists = true;
     }
     $uploadState = file::append($this->name, $this->mimes, $this->max, $this->dir, $value);
     if ($uploadPressed !== false && $uploadPressed == 'Ladda upp' && $uploadState === false) {
         $this->error = 'Filuppladdningen misslyckades: för stor fil eller bild av ej tillåtet format.';
         $this->value = sprintf('%s/%d.%s', $this->dir, 0, 'png');
         return false;
     }
     $removePressed = http_request::getString('remove');
     $doRemove = $removePressed !== false && in_array($removePressed, array('Ta bort Avatar', 'Ta bort Bild'));
     if ($uploadState !== false) {
         $bajs = fe($uploadState);
         $fileExists = true;
         $this->value = str_replace(ROOT . '/public/', '/', $uploadState);
         $this->uploaded = true;
         if (isset($_SESSION['fileTempName'])) {
             $_SESSION['fileTempName'] = basename($this->value);
         }
         foreach ($this->mimes as $fe) {
             $f = sprintf('%s/%s.%s', $this->dir, $value, $fe);
             if (file_exists($f) && $fe != $bajs) {
                 file::remove($f);
             }
         }
         if ($doRemove === true) {
             file::remove($uploadState);
         }
     } else {
         foreach ($this->mimes as $fe) {
             $f = sprintf('%s/%s.%s', $this->dir, $value, $fe);
             if (file_exists($f)) {
                 if ($doRemove === true) {
                     file::remove($f);
                 }
                 $fileExists = true;
                 $this->value = str_replace(ROOT . '/public/', '/', $f);
                 if (isset($_SESSION['fileTempName'])) {
                     $_SESSION['fileTempName'] = $this->value;
                 }
                 $this->uploaded = true;
                 break;
             }
         }
     }
     if ($fileExists === false) {
         $this->value = sprintf('%s/%d.%s', $this->dir, 0, 'png');
     }
     return $fileExists ? true : false;
 }
Esempio n. 9
0
 static function getModels()
 {
     // registry preparation
     $registry = registry::getInstance();
     // validate input
     $modelId = http_request::getString('model');
     $entityId = http_request::getString('entityId');
     // get all models
     $registry['models'] = new model_dir(ROOT . '/model');
 }
Esempio n. 10
0
 public function validate($in = false)
 {
     $user =& user::getInstance();
     if ($user->isOnline()) {
         if ($this->editable) {
             $this->value = http_request::getString('userid');
         } else {
             $this->value = $user->getId();
         }
     }
     return false;
 }
Esempio n. 11
0
 function http($method, $url, $formdata = array())
 {
     if (class_exists("http_request")) {
         $req = new http_request();
         $req->setMethod($method);
         $req->setURL($url);
         $req->addHeader("Accept", "xml/user-profile, text/boolean, */*; q=0.1");
         if ($formdata) {
             $req->params += $formdata;
             $req->_postData = $formdata;
             // PEAR tries to annoy us
         }
         $r = $req->sendRequest();
         if ($r && $r->getResponseStatus() == 200) {
             return array($r->getResponseBody(), $r->getResponseHeader());
         }
     } elseif ($method == "GET") {
         return array(file_get_contents($url), array());
     } elseif ($method == "POST") {
         // give up
     }
     return array(NULL, NULL);
 }
Esempio n. 12
0
function ewiki_cache_url($url, $cache_min = 1200)
{
    global $ewiki_cache_ctype;
    #-- check if fresh enough in cache (20min)
    $data = ewiki_db::GET($url);
    if (time() <= $data["lastmodified"] + $cache_min) {
        $ewiki_cache_ctype = $data["Content-Type"];
        return $data["content"];
    }
    #-- retrieve
    $req = new http_request("GET", $url);
    $req->header["Accept"] = "application/atom+xml, application/rss+xml, text/rss, xml/*, */*rss*";
    if ($data["meta"]["Last-Modified"]) {
        $req->headers["If-Modified-Since"] = $data["meta"]["Last-Modified"];
    }
    if ($data["meta"]["Etag"]) {
        $req->headers["If-None-Match"] = $data["meta"]["Etag"];
    }
    $result = $req->go();
    #-- create/overwrite cache entry
    if ($result->status == 200) {
        $data = ewiki_db::CREATE($url, 0x0, "ewiki_cache_url");
        $data["flags"] = 0x0;
        $data["content"] = $result->body;
        foreach ($result->headers as $i => $v) {
            $data["meta"][$i] = $v;
        }
        $data["meta"]["class"] = "temp";
        $data["meta"]["kill-after"] = time() + $cache_min;
        if ($t = $data["meta"]["Last-Modified"]) {
            //    $data["lastmodified"] = ewiki_decode_datetime($t);
        }
        ewiki_db::WRITE($data, "_OVERWRITE=1");
    }
    $ewiki_cache_ctype = $data["Content-Type"];
    return $data["content"];
}
Esempio n. 13
0
 public function validate($in = false)
 {
     $passwordNotEditable = http_request::getString('passwdkeptsafe');
     $valid = false;
     if ($passwordNotEditable == 'yes') {
         $this->editable = false;
         $valid = true;
         return $valid;
     } else {
         $isSecure = http_request::getPassword('password_give');
         $valid = http_request::getPassword('password_give', 'password_confirm');
         if ($valid === false) {
             $this->error = "Ditt bekräftande stämmer ej överens med ditt önskade lösenord.";
             return false;
         }
         if ($isSecure === false) {
             $this->error = "Ditt önskade lösenord uppfyller ej kriterierna för att vara ett säkert lösenord.";
             return false;
         }
         if ($isSecure && $valid) {
             return $valid;
         }
     }
 }
Esempio n. 14
0
<?php

/**
 * Basic getter api. Works on every valid model.
 */
if (empty($modelId)) {
    $modelId = http_request::getString('modelId');
}
if (empty($id)) {
    $id = http_request::getString('id');
}
if (empty($pres)) {
    $pres = http_request::getString('format');
}
if (!$modelId) {
    die('NO MODEL');
}
if (!file_exists(sprintf('%s/model/%s.php', ROOT, $modelId))) {
    die('BAD MODEL');
}
$modelstr = 'model_' . strtr($modelId, '/', '_');
$model = new $modelstr();
if ($id) {
    $data = $model->getEntity($id);
} else {
    $data = $model->getSummary();
}
if ($pres == 'atom' || $pres == 'xml') {
    ob_start();
    require LIBRARY . '/view/atom.phtml';
    $out = ob_get_clean();
Esempio n. 15
0
 function loaddata($keystring, $typestring)
 {
     $configvalue = $this->API_characterID_ . '_Standings';
     $UseCaching = config::get('API_UseCache');
     $url = API_SERVER . "/" . $typestring . "/Standings.xml.aspx" . $keystring;
     $path = "/" . $typestring . "/Standings.xml.aspx";
     if (is_file(KB_CACHEDIR . '/api/' . $configvalue . '.xml')) {
         $cacheexists = true;
     } else {
         $cacheexists = false;
     }
     if (strtotime(gmdate("M d Y H:i:s")) - strtotime($CachedTime) > 0 || $UseCaching == 1 || !$cacheexists) {
         $http = new http_request($url);
         $http->set_useragent("PHPApi");
         foreach ($keystring as $key => $val) {
             $http->set_postform($key, $val);
         }
         $contents = $http->get_content();
         $start = strpos($contents, "?>");
         if ($start !== FALSE) {
             $contents = substr($contents, $start + strlen("\r\n\r\n"));
         }
         if ($UseCaching == 0) {
             $file = fopen(KB_CACHEDIR . '/api/' . $configvalue . '.xml', 'w+');
             fwrite($file, $contents);
             fclose($file);
             @chmod(KB_CACHEDIR . '/api/' . $configvalue . '.xml', 0666);
         }
     } else {
         // re-use cached XML
         if ($fp = @fopen(KB_CACHEDIR . '/api/' . $configvalue . '.xml', 'r')) {
             $contents = fread($fp, filesize(KB_CACHEDIR . '/api/' . $configvalue . '.xml'));
             fclose($fp);
         } else {
             return "<i>error loading cached file " . $configvalue . ".xml</i><br><br>";
         }
     }
     return $contents;
 }
Esempio n. 16
0
 function loaddata($keystring)
 {
     $configvalue = $this->CharName_ . '_CharacterSheet';
     $CachedTime = ApiCache::get($configvalue);
     $UseCaching = config::get('API_UseCache');
     $url = API_SERVER . "/char/CharacterSheet.xml.aspx" . $keystring;
     $path = '/char/CharacterSheet.xml.aspx';
     // API Caching system, If we're still under cachetime reuse the last XML, if not download the new one. Helps with Bug hunting and just better all round.
     if ($CachedTime == "") {
         $CachedTime = "2005-01-01 00:00:00";
         // fake date to ensure that it runs first time.
     }
     if (is_file(KB_CACHEDIR . '/api/' . $configvalue . '.xml')) {
         $cacheexists = true;
     } else {
         $cacheexists = false;
     }
     // if API_UseCache = 1 (off) then don't use cache
     if (strtotime(gmdate("M d Y H:i:s")) - strtotime($CachedTime) > 0 || $UseCaching == 1 || !$cacheexists) {
         $http = new http_request($url);
         $http->set_useragent("PHPApi");
         foreach ($keystring as $key => $val) {
             $http->set_postform($key, $val);
         }
         $contents = $http->get_content();
         $start = strpos($contents, "?>");
         if ($start !== FALSE) {
             $contents = substr($contents, $start + strlen("\r\n\r\n"));
         }
         // Save the file if we're caching (0 = true in Thunks world)
         if ($UseCaching == 0) {
             $file = fopen(KB_CACHEDIR . '/api/' . $configvalue . '.xml', 'w+');
             fwrite($file, $contents);
             fclose($file);
             @chmod(KB_CACHEDIR . '/api/' . $configvalue . '.xml', 0666);
         }
     } else {
         // re-use cached XML
         if ($fp = @fopen(KB_CACHEDIR . '/api/' . $configvalue . '.xml', 'r')) {
             $contents = fread($fp, filesize(KB_CACHEDIR . '/api/' . $configvalue . '.xml'));
             fclose($fp);
         } else {
             return "<i>error loading cached file " . $configvalue . ".xml</i><br><br>";
         }
     }
     return $contents;
 }
Esempio n. 17
0
     $author_q = @$dbs->query("SELECT a.author_name, ba.level, a.authority_type, a.auth_list FROM biblio_author AS ba\n            LEFT JOIN mst_author AS a ON ba.author_id=a.author_id\n            WHERE ba.biblio_id={$id} ORDER BY level ASC");
     while ($author_d = $author_q->fetch_row()) {
         $data[$id]['authors'][] = array('name' => $author_d[0], 'level' => $author_d[1], 'type' => $author_d[2], 'auth_list' => $author_d[3]);
     }
     // subject
     $topic_q = @$dbs->query("SELECT t.topic, bt.level, t.topic_type, t.auth_list FROM biblio_topic AS bt\n            LEFT JOIN mst_topic AS t ON bt.topic_id=t.topic_id\n            WHERE bt.biblio_id={$id} ORDER BY level ASC");
     while ($topic_d = $topic_q->fetch_row()) {
         $data[$id]['subjects'][] = array('name' => $topic_d[0], 'level' => $topic_d[1], 'type' => $topic_d[2], 'auth_list' => $topic_d[3]);
     }
 }
 // encode array to json format
 if ($data) {
     $to_sent['node_info'] = $node;
     $to_sent['node_data'] = $data;
     // create HTTP request
     $http_request = new http_request();
     // send HTTP POST request
     $server_addr = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : (isset($_SERVER['LOCAL_ADDR']) ? $_SERVER['LOCAL_ADDR'] : gethostbyname($_SERVER['SERVER_NAME']));
     $http_request->send_http_request($ucs['serveraddr'] . '/ucpoll.php', $server_addr, $to_sent, 'POST', 'text/json');
     // below is for debugging purpose only
     // die(json_encode(array('status' => 'RAW', 'message' => $http_request->body())));
     // check for http request error
     if ($req_error = $http_request->error()) {
         die(json_encode(array('status' => 'HTTP_REQUEST_ERROR', 'message' => $req_error['message'])));
     }
     // print out body of request result
     echo $http_request->body();
     exit;
 } else {
     die(json_encode(array('status' => 'NO_DATA', 'message' => 'No Data to be uploaded to Union Catalog Server')));
 }
     */
    function headers()
    {
        return $this->headers;
    }
    /**
     * Return Raw HTTP Request (note: This is incomplete)
     * @param bool ReBuild the Raw HTTP Request
     */
    function raw($refresh = false)
    {
        if (isset($this->raw) && !$refresh) {
            return $this->raw;
            // return cached
        }
        $headers = $this->headers();
        $this->raw = "{$this->method}\r\n";
        foreach ($headers as $i => $header) {
            $this->raw .= "{$i}: {$header}\r\n";
        }
        $this->raw .= "\r\n{$this->body}";
        return $this->raw;
    }
}
/**
*
* Echos the HTTP Request back the client/browser (in the HTTP Body)
*/
$http_request = new http_request();
$resp = $http_request->raw();
echo $resp;
Esempio n. 19
0
 function decode()
 {
     $t = http_request::type($this->type, 0);
     if ($t == "php") {
         return unserialize($this->content);
     } elseif ($t == "url") {
         parse_str($this->content, $r);
         return $r;
     } elseif ($t == "form") {
         // oh, not yet exactly
     }
 }
Esempio n. 20
0
 /**
  * Execution des scripts pour les sessions et le login
  */
 public function run()
 {
     $header = new http_header();
     $create = new admin_model_template();
     if (http_request::isGet('newlogin')) {
     } else {
         $this->tokenInitSession();
         $this->getAuth($create, true);
         $create->display('login/index.phtml');
     }
 }
Esempio n. 21
0
            $biblioID = (int) $itemID;
            $biblioIDS .= $biblioID . ',';
        }
        // remove last comma
        $biblioIDS = substr_replace($biblioIDS, '', -1);
    } else {
        $biblioIDS = (int) $_POST['itemID'];
    }
    // node data
    if ($_POST['nodeOperation'] == 'delete') {
        $data = array('operation' => 'delete', 'biblio' => $biblioIDS);
    }
    // encode array to json format
    $to_sent['node_info'] = $node;
    $to_sent['node_data'] = $data;
    // create HTTP request
    $http_request = new http_request();
    // send HTTP POST request
    $http_request->send_http_request($ucs['serveraddr'] . '/uc-ops.php', $_SERVER['SERVER_ADDR'], $to_sent, 'POST', 'text/json');
    // below is for debugging purpose only
    // die(json_encode(array('status' => 'RAW', 'message' => $http_request->body())));
    // check for http request error
    if ($req_error = $http_request->error()) {
        die(json_encode(array('status' => 'HTTP_REQUEST_ERROR', 'message' => $req_error['message'])));
    }
    // print out body of request result
    echo $http_request->body();
    exit;
} else {
    die(json_encode(array('status' => 'NO_BIBLIO_SELECTED', 'message' => 'Please select bibliographic data to update!')));
}
Esempio n. 22
0
<?php

$user = user::getInstance();
$registry = registry::getInstance();
// validate model and construct if correct.
$registry['modelLabel'] = http_request::getString('model');
if ($registry['modelLabel'] == false || !file_exists(ROOT . '/model/' . $registry['modelLabel'] . ".php")) {
    throw new Exception("the model <b>" . $registry['modelLabel'] . "</b> does not exist in this application. It could have been removed, or has ever existed. Check the spelling and try again.");
}
$qryModel = "model_" . $registry['modelLabel'];
$model = new $qryModel();
// needed for the page header.
admin::getModels();
$registry['controls'] = $model->getEntityProperties();
// setup page
$registry['entities'] = $model->getSummary();
$registry['title'] = $registry['modelLabel'];
$registry['bclass'] = $registry['modelLabel'] . " list model";
//see if there is any custom template. Else,fall back on default.
$ct = sprintf("%s/view/cms/list/%s.phtml", ROOT, $registry['modelLabel']);
if (!file_exists($ct)) {
    $ct = sprintf("%s/list/%s.phtml", VIEW, $registry['modelLabel']);
}
if (file_exists($ct)) {
    $view = new view($ct);
    $view->isFragment();
    $registry['customList'] = $view->compile();
}
Esempio n. 23
0
    $html .= '  Please issue a "chmod 777 ' . KB_CACHEDIR . '" and "chmod 777 ' . KB_CACHEDIR . '/*" on the commandline inside of this directory<br />';
    $trouble['Graphics'][] = array('passed' => false, 'text' => $html);
}
// connectivity
$sections['Connectivity'] = 'Connectivity';
$url = 'http://www.evekb.org/';
if (ini_get('allow_url_fopen')) {
    if (count(file($url))) {
        $html = '  allow_url_fopen is available.<br />';
        $trouble['Connectivity'][] = array('passed' => true, 'text' => $html);
    } else {
        $html = '  I could not get the file, this might be a firewall related issue or the eve-dev server is not available.<br />';
        $trouble['Connectivity'][] = array('passed' => false, 'text' => $html);
    }
}
$http = new http_request($url);
if ($http->get_content()) {
    $html = '  Socket Connect is available.';
    $trouble['Connectivity'][] = array('passed' => true, 'text' => $html);
} else {
    $html = '  I could not get the file, this might be a firewall related issue or the eve-dev server is not available.<br />';
    $trouble['Connectivity'][] = array('passed' => false, 'text' => $html);
}
if (extension_loaded('openssl')) {
    $html = '  OpenSSL module is installed.<br />';
    $trouble['Connectivity'][] = array('passed' => true, 'text' => $html);
} else {
    $html = '  OpenSSL module is not installed<br />';
    $trouble['Connectivity'][] = array('passed' => false, 'text' => $html);
}
if (array_search('https', stream_get_wrappers())) {
Esempio n. 24
0
 /**
  * Constructor
  */
 public function __construct()
 {
     if (http_request::isGet('getHeader')) {
         $this->getHeader = form_inputFilter::isNumeric($_GET['getHeader']);
     }
 }
Esempio n. 25
0
 /**
  * Retourne la langue en cours de session sinon retourne fr par défaut
  * @return string
  * @access public 
  * @static
  */
 public static function currentLanguage()
 {
     if (http_request::isGet('strLangue')) {
         $lang = self::getLanguage();
     } else {
         if (self::$collectionsLang instanceof component_collections_language) {
             if (http_request::isSession('strLangue')) {
                 $lang = form_inputFilter::isAlphaNumericMax($_SESSION['strLangue'], 3);
             } else {
                 $data = self::$collectionsLang->setDefault();
                 if ($data != null) {
                     $lang = $data['iso'];
                 }
             }
         }
     }
     return $lang;
 }
Esempio n. 26
0
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */
require 'ucsysconfig.inc.php';
require 'ucserver.inc.php';
require LIB_DIR . 'http_request.inc.php';
require INC_DIR . 'ucs_nodes_poll.inc.php';
// check total node poll
$total_conn = ucs_nodes_poll::check_poll($dbs);
if ($total_conn >= $sysconf['server']['max_node_all']) {
    die(json_encode(array('status' => 'POLL_MAX', 'message' => 'Sorry for inconvinience, server connection poll is busy right now. Please try again later')));
}
// create http request object
$http_request = new http_request();
$http_request->get_http_request();
// get http content
$referer = trim($http_request->headers('REFERER'));
$body = trim($http_request->body());
// sent HTTP header
header('Content-type: text/json');
// check content
if ($body) {
    // encode to PHP array
    $biblio = json_decode($body, true);
    if (function_exists('json_last_error')) {
        // Define the errors.
        $json_errors = array(JSON_ERROR_DEPTH => 'JSON error: The maximum stack depth has been exceeded', JSON_ERROR_CTRL_CHAR => 'JSON error: Control character error, possibly incorrectly encoded', JSON_ERROR_SYNTAX => 'JSON error: Syntax error');
        // get json error
        $json_error = json_last_error();
Esempio n. 27
0
<?php

/**
 * fotoalbum.php
 * 
 * photoalbum admin page
 * @author Anders Ytterström <*****@*****.**>
 * @since 2007-12-29
 */
require '../../../init.php';
$registry =& registry::getInstance();
$user =& user::getInstance();
$view = new view(ROOT . '/view/admin/photos/edit.phtml');
$model = new model_photos();
if (!$user->isOnline()) {
    http_response::redir('/login.php');
}
$imageName = http_request::getString('image');
if ($imageName !== false) {
    $registry['imagedata'] = $model->getImage($imageName);
}
$formId = 'editPhoto';
$formNames = array('alt', 'body');
form::getSF($formId, $formNames);
$registry['sidebar'] = false;
echo $view->compile();
Esempio n. 28
0
 public static function xajax_req()
 {
     // if the xajax call gets aborted, ignore that
     @ignore_user_abort(true);
     @set_time_limit(0);
     $state = config::get('ajcron_running');
     if (!is_array($state)) {
         $state = array();
         config::set('ajcron_running', $state);
     }
     // check for blocking
     if (config::get('ajcron_blocking')) {
         // if there is already something running, give up
         if (count($state) >= 1) {
             return;
         }
     }
     // load up our crontasks
     $jobs = ajcron::parseJobs();
     // if there are no jobs just quit
     if (!count($jobs)) {
         return;
     }
     // see which one should be started now
     $sorttable = array();
     foreach ($jobs as $job) {
         $sorttable[$job['id']] = $job['nextrun'];
     }
     asort($sorttable);
     foreach ($sorttable as $id => $nextrun) {
         // this bypasses already running jobs
         if (isset($state[$id])) {
             continue;
         }
         break;
     }
     if (!$id) {
         // no id found we could run as all are running
         return;
     }
     // set current id to running
     $state[$id] = 'running';
     $currentJob = null;
     config::set('ajcron_running', $state);
     foreach ($jobs as $job) {
         if ($job['id'] == $id) {
             $currentJob = $job;
         }
     }
     // run the job (finally)
     $http = new http_request($currentJob['url']);
     $http->set_timeout(120);
     $data = $http->get_content();
     // job done, clean up
     // we need to refresh our variable to prevent overwriting of
     // other running jobs
     $db = DBFactory::getDBQuery(true);
     $db->execute('select * from kb3_config where cfg_site=\'' . KB_SITE . '\' and cfg_key=\'ajcron_running\'');
     $row = $db->getRow();
     $state = unserialize($row['cfg_value']);
     unset($state[$id]);
     config::set('ajcron_running', $state);
     // calculate when next to insert ajax
     ajcron::getNextRuntime();
     // testfun!
     $objResponse = new xajaxResponse();
     #$objResponse->Assign("header", "innerHTML", nl2br(var_export($sorttable[key($sorttable)], true)));
     #sleep(15);
     return $objResponse;
 }
Esempio n. 29
0
<?php

/**
 * do.login.php
 * 
 * login script
 * @author Anders Ytterström <*****@*****.**>
 * @since 2007-08-13
 */
require '../../../init.php';
$registry =& registry::getInstance();
$user =& user::getInstance();
$model = new model_photos();
$name = http_request::getString('id');
$alt = http_request::getString('alt');
$body = http_request::getString('body');
if (!$user->isOnline()) {
    http_response::redir('/login.php');
}
if (!$alt || !$body) {
    form::setSF('editPhoto', array('alt' => $alt, 'body' => $body));
    $_SESSION['msg'] = "badData";
    http_response::redir('/admin/fotoalbum/redigera.php?id=' . $name);
}
$model->update($name, $alt, $body);
form::clearSF('editPhoto');
$_SESSION['success'] = true;
http_response::redir('/admin/fotoalbum/');
Esempio n. 30
0
    $author_q = @$dbs->query("SELECT a.author_name, ba.level, a.authority_type, a.auth_list FROM biblio_author AS ba\r\n        LEFT JOIN mst_author AS a ON ba.author_id=a.author_id\r\n        WHERE ba.biblio_id={$id} ORDER BY level ASC");
    while ($author_d = $author_q->fetch_row()) {
        $data[$id]['authors'][] = array('name' => $author_d[0], 'level' => $author_d[1], 'type' => $author_d[2], 'auth_list' => $author_d[3]);
    }
    // subject
    $topic_q = @$dbs->query("SELECT t.topic, bt.level, t.topic_type, t.auth_list FROM biblio_topic AS bt\r\n        LEFT JOIN mst_topic AS t ON bt.topic_id=t.topic_id\r\n        WHERE bt.biblio_id={$id} ORDER BY level ASC");
    while ($topic_d = $topic_q->fetch_row()) {
        $data[$id]['subjects'][] = array('name' => $topic_d[0], 'level' => $topic_d[1], 'type' => $topic_d[2], 'auth_list' => $topic_d[3]);
    }
}
// encode array to json format
if ($data) {
    $to_sent['node_info'] = $node;
    $to_sent['node_data'] = $data;
    // create HTTP request
    $http_request = new http_request();
    // send HTTP POST request
    $http_request->send_http_request($ucs['serveraddr'] . '/ucpoll.php', @gethostbyaddr(), $to_sent, 'POST', 'text/json');
    // below is for debugging purpose only
    // die($http_request->body());
    // check for http request error
    if ($req_error = $http_request->error()) {
        echo $req_error['message'] . "\n";
        exit(6);
    }
    // print out body of request result
    $response = json_decode($http_request->body(), true);
    echo $response['message'] . "\n";
    exit(0);
} else {
    exit(0);