Example #1
1
function ajoutLieu()
{
    require 'connect.php';
    $requete = $bdd->query("SELECT \n\t\t\t\t\t\t\t\tVILID\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\tcommune");
    $villes = $requete->fetchAll();
    $requete->closeCursor();
    $requete = $bdd->prepare("SELECT \n\t\t\t\t\t\t\t\tLIEUID\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\tLIEU\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tLIEUID=:lieuId\n\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\tVILID=:ville\n\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\tLIEUNOM=:nom");
    $requeteSeconde = $bdd->prepare("INSERT INTO LIEU\n\t\t\t\t\t\t\t\t\t\t(LIEUID,\n\t\t\t\t\t\t\t\t\t\tVILID,\n\t\t\t\t\t\t\t\t\t\tLIEUNOM,\n\t\t\t\t\t\t\t\t\t\tLIEUCOORDGPS)\n\t\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t\t\t(:lieuId,\n\t\t\t\t\t\t\t\t\t\t:ville,\n\t\t\t\t\t\t\t\t\t\t:nom,\n\t\t\t\t\t\t\t\t\t\t:gps)");
    for ($i = 0; $i < 100; $i++) {
        echo $lieuId = $i;
        echo $ville = $villes[rand(0, sizeof($villes) - 1)]['VILID'];
        $lieuT = file('./generateurLieu.txt');
        $lieu = array(trim($lieuT[rand(0, 93)]), trim($lieuT[rand(0, 93)]));
        $lieu = implode("-", $lieu);
        echo $nom = $lieu;
        echo $gps = rand(0, 5000);
        echo "<br />";
        $requete->execute(array("ville" => $ville, "nom" => $nom));
        if ($requete->fetch() == false) {
            $requeteSeconde->execute(array("lieuId" => $lieuId, "ville" => $ville, "nom" => $nom, "gps" => $gps));
        } else {
            $i--;
        }
    }
    $requete->closeCursor();
    $requeteSeconde->closeCursor();
}
function get_lvm_iscsi_deployment_image_rootdevice_identifier($lvm_iscsi_storage_id)
{
    global $OPENQRM_SERVER_BASE_DIR;
    global $OPENQRM_ADMIN;
    global $event;
    // place for the storage stat files
    $StorageDir = $_SERVER["DOCUMENT_ROOT"] . '/openqrm/base/plugins/lvm-storage/storage';
    $rootdevice_identifier_array = array();
    $storage = new storage();
    $storage->get_instance_by_id($lvm_iscsi_storage_id);
    $storage_resource = new resource();
    $storage_resource->get_instance_by_id($storage->resource_id);
    $storage_resource_id = $storage_resource->id;
    $ident_file = "{$StorageDir}/{$storage_resource_id}.lv.lvm-iscsi-deployment.ident";
    if (file_exists($ident_file)) {
        unlink($ident_file);
    }
    // send command
    $resource_command = "{$OPENQRM_SERVER_BASE_DIR}/openqrm/plugins/lvm-storage/bin/openqrm-lvm-storage post_identifier -t lvm-iscsi-deployment -u {$OPENQRM_ADMIN->name} -p {$OPENQRM_ADMIN->password}";
    $storage_resource->send_command($storage_resource->ip, $resource_command);
    if (!lvm_iscsi_deployment_wait_for_identfile($ident_file)) {
        $event->log("get_image_rootdevice_identifier", $_SERVER['REQUEST_TIME'], 2, "image.lvm-iscsi-deployment", "Timeout while requesting image identifier from storage id {$storage->id}", "", "", 0, 0, 0);
        return;
    }
    $fcontent = file($ident_file);
    foreach ($fcontent as $lun_info) {
        $tpos = strpos($lun_info, ",");
        $timage_name = trim(substr($lun_info, 0, $tpos));
        $troot_device = trim(substr($lun_info, $tpos + 1));
        $rootdevice_identifier_array[] = array("value" => "{$troot_device}", "label" => "{$timage_name}");
    }
    return $rootdevice_identifier_array;
}
Example #3
0
 function installLanguage2($f, $l, $m)
 {
     global $php;
     $patt = '/^([A-Z0-9_]+)[\\s]{0,}=[\\s]{0,}[\'"](.*)[\'"];$/';
     foreach (file($f) as $item) {
         $item = trim($item);
         if ($item != '') {
             if (preg_match($patt, $item, $match)) {
                 if (isset($php[$match[1]])) {
                     $php[$match[1]][$l] = addslashes($match[2]);
                 } else {
                     $save = array();
                     if (preg_match('/^[0-9]+$/', $value)) {
                         $save['type'] = 'int';
                     } else {
                         $save['type'] = 'text';
                     }
                     $save['key'] = $match[1];
                     $save['owner'] = $m;
                     $save[$l] = addslashes($match[2]);
                     $save['js'] = 1;
                     $php[$match[1]] = $save;
                 }
             }
         }
     }
 }
Example #4
0
function sendMessage($phoneTo, $textMessage)
{
    $user = "******";
    $password = "******";
    $api_id = "3356658";
    $baseurl = "http://api.clickatell.com";
    $text = urlencode($textMessage);
    $to = $phoneTo;
    // auth call
    $url = "{$baseurl}/http/auth?user={$user}&password={$password}&api_id={$api_id}";
    // do auth call
    $ret = file($url);
    // explode our response. return string is on first line of the data returned
    $sess = explode(":", $ret[0]);
    if ($sess[0] == "OK") {
        $sess_id = trim($sess[1]);
        // remove any whitespace
        $url = "{$baseurl}/http/sendmsg?session_id={$sess_id}&to={$to}&text={$text}";
        // do sendmsg call
        $ret = file($url);
        $send = explode(":", $ret[0]);
        if ($send[0] == "ID") {
            // echo "success\nmessage ID: ". $send[1];
            return true;
        } else {
            // echo "send message failed";
            return false;
        }
    } else {
        // echo "Authentication failure: ". $ret[0];
        return false;
    }
}
Example #5
0
 function __construct($file, $firstLine = true)
 {
     $this->file = $file;
     $this->db = array();
     $this->dbBackup = array();
     $this->firstLine = $firstLine;
     if (file_exists($file)) {
         // Read JSON file.
         $lines = file($file);
         // Remove the first line, the first line is for security reasons.
         if ($firstLine) {
             unset($lines[0]);
         }
         // Regenerate the JSON file.
         $implode = implode($lines);
         // Unserialize, JSON to Array.
         $array = $this->unserialize($implode);
         if (empty($array)) {
             Log::set(__METHOD__ . LOG_SEP . 'Invalid JSON file: ' . $file . ', cannot be decoded. Check the file content.');
         } else {
             $this->db = $array;
             $this->dbBackup = $array;
         }
     } else {
         Log::set(__METHOD__ . LOG_SEP . 'File ' . $file . ' does not exists');
     }
 }
 public function generate($fname, $gender)
 {
     $this->maintemplate = file_get_contents('Template/NCLNameCaseRuTest.main');
     $this->testtemplate = file_get_contents('Template/NCLNameCaseRuTest' . $fname . $gender . '.test');
     $this->resultArr = file('Names/' . $gender . '_full_result.txt');
     $this->count = 0;
     if ($gender == 'boy') {
         $this->gender = 1;
     } else {
         $this->gender = 2;
     }
     //foreach ($this->resultArr as $key=>$value)
     //{
     //$this->gender=$key+1;
     foreach ($this->resultArr as $id => $name) {
         $tmpnames = explode("#", trim(str_replace('ё', 'е', $name)));
         $firstRes = array();
         $secondRes = array();
         $fatherRes = array();
         $c = count($tmpnames);
         for ($i = 0; $i < $c; $i++) {
             $cur = explode(" ", trim($tmpnames[$i]));
             $firstRes[] = trim($cur[1]);
             $secondRes[] = trim($cur[0]);
             $fatherRes[] = trim($cur[2]);
         }
         $this->generateTest($firstRes, $secondRes, $fatherRes);
     }
     //}
     $res = str_replace('{% tests %}', $this->tests, $this->maintemplate);
     $res = str_replace('{% name %}', $fname, $res);
     file_put_contents('../Library/NCLNameCaseRuTest' . $fname . $gender . '.php', $res);
 }
function tplsadmin_copy_templates_f2db($tplset_to, $whr_append = '1')
{
    global $db;
    // get tplsource
    $result = $db->query("SELECT * FROM " . $db->prefix("tplfile") . "  WHERE tpl_tplset='default' AND ({$whr_append})");
    while ($row = $db->fetchArray($result)) {
        $basefilepath = tplsadmin_get_basefilepath($row['tpl_module'], $row['tpl_type'], $row['tpl_file']);
        $tpl_source = rtrim(implode("", file($basefilepath)));
        $lastmodified = filemtime($basefilepath);
        $drs = $db->query("SELECT tpl_id FROM " . $db->prefix("tplfile") . " WHERE tpl_tplset='" . addslashes($tplset_to) . "' AND ({$whr_append}) AND tpl_file='" . addslashes($row['tpl_file']) . "' AND tpl_refid='" . addslashes($row['tpl_refid']) . "'");
        if (!$db->getRowsNum($drs)) {
            // INSERT mode
            $sql = "INSERT INTO " . $db->prefix("tplfile") . " SET tpl_refid='" . addslashes($row['tpl_refid']) . "',tpl_desc='" . addslashes($row['tpl_desc']) . "',tpl_lastmodified='" . addslashes($lastmodified) . "',tpl_type='" . addslashes($row['tpl_type']) . "',tpl_tplset='" . addslashes($tplset_to) . "',tpl_file='" . addslashes($row['tpl_file']) . "',tpl_module='" . addslashes($row['tpl_module']) . "'";
            $db->query($sql);
            $tpl_id = $db->getInsertId();
            $db->query("INSERT INTO " . $db->prefix("tplsource") . " SET tpl_id='{$tpl_id}', tpl_source='" . addslashes($tpl_source) . "'");
            altsys_template_touch($tpl_id);
        } else {
            while (list($tpl_id) = $db->fetchRow($drs)) {
                // UPDATE mode
                $db->query("UPDATE " . $db->prefix("tplfile") . " SET tpl_lastmodified='" . addslashes($lastmodified) . "' WHERE tpl_id='{$tpl_id}'");
                $db->query("UPDATE " . $db->prefix("tplsource") . " SET tpl_source='" . addslashes($tpl_source) . "' WHERE tpl_id='{$tpl_id}'");
                altsys_template_touch($tpl_id);
            }
        }
    }
}
Example #8
0
 protected function getControllerCode()
 {
     $r = new \ReflectionClass($this->controller[0]);
     $m = $r->getMethod($this->controller[1]);
     $code = file($r->getFilename());
     return '    ' . $m->getDocComment() . "\n" . implode('', array_slice($code, $m->getStartline() - 1, $m->getEndLine() - $m->getStartline() + 1));
 }
Example #9
0
 function loadfont($fontfile)
 {
     $this->fontFile = file($fontfile);
     if (!$this->fontFile) {
         die("Couldnt open fontfile {$fontfile}\n");
     }
     $hp = explode(" ", $this->fontFile[0]);
     // get header
     $this->signature = substr($hp[0], 0, strlen($hp[0]) - 1);
     $this->hardblank = substr($hp[0], strlen($hp[0]) - 1, 1);
     $this->height = $hp[1];
     $this->baseline = $hp[2];
     $this->maxLenght = $hp[3];
     $this->oldLayout = $hp[4];
     $this->commentLines = $hp[5] + 1;
     if (isset($hp[6])) {
         $this->printDirection = $hp[6];
     }
     if (isset($hp[7])) {
         $this->fullLayout = $hp[7];
     }
     if (isset($hp[8])) {
         $this->codeTagCount = $hp[8];
     }
     unset($hp);
     return true;
     if ($this->signature != "flf2a") {
         trigger_error("Unknown font version " . $this->signature . "\n");
         return false;
     } else {
         return true;
     }
 }
Example #10
0
 /**
  * @see LiveTest\Config\Tags\TestSuite.Base::doProcess()
  */
 protected function doProcess(\LiveTest\Config\TestSuite $config, $parameters)
 {
     $config->getCurrentSession()->doNotInherit();
     foreach ($parameters as $file) {
         $config->getCurrentSession()->includePageRequests(Request::createRequestsFromParameters(file($config->getBaseDir() . '/' . $file), $config->getDefaultDomain()));
     }
 }
Example #11
0
function DataRows($FileName, &$Tests, &$Langs, &$Incl, &$Excl, $HasHeading = TRUE)
{
    $data = array();
    $previous = 'not set';
    $test_rows = array();
    $lines = @file($FileName) or die('Cannot open $FileName');
    if ($HasHeading) {
        unset($lines[0]);
    }
    // remove header line
    foreach ($lines as $line) {
        $row = explode(',', $line);
        $test = $row[DATA_TEST];
        $lang = $row[DATA_LANG];
        $key = $test . $lang . $row[DATA_ID];
        // accumulate all acceptable datarows, exclude duplicates
        if (isset($Incl[$test]) && isset($Incl[$lang]) && isset($Langs[$lang]) && !isset($Excl[$key])) {
            if ($previous != $test) {
                // assume ndata.csv is sorted by test
                $data = FastestRows($test_rows, $data);
                $test_rows = array();
            }
            $previous = $test;
            settype($row[DATA_STATUS], 'integer');
            settype($row[DATA_TESTVALUE], 'integer');
            $testvalue = $row[DATA_TESTVALUE];
            settype($row[DATA_TIME], 'double');
            if ($row[DATA_STATUS] == 0) {
                $test_rows[$lang][] = $row;
            }
        }
    }
    $data = FastestRows($test_rows, $data);
    return $data;
}
Example #12
0
 function importDatabaseFile($filename, $block = true)
 {
     # temporary variable, used to store current query
     $tmpline = '';
     # read in entire file
     $lines = file($filename);
     # loop through each line
     foreach ($lines as $line) {
         # skip it if it's a comment
         if (substr($line, 0, 2) == '--' || $line == '') {
             continue;
         }
         # add this line to the current segment
         $tmpline .= $line;
         # if it has a semicolon at the end, it's the end of the query
         if (substr(trim($line), -1, 1) == ';') {
             if (!empty($tmpline)) {
                 $errMsg = $this->query($tmpline);
                 if ($block && $this->error) {
                     return $errMsg;
                 }
             }
             $tmpline = '';
         }
     }
 }
Example #13
0
function checkUpdateFile($filename_update)
{
    global $server_offline;
    global $update_failed;
    global $downloadfacut;
    if (!file_exists($filename_update)) {
        $server_offline = true;
        global $cccam_host;
        global $webinfo_port;
        $update_failed = "<FONT COLOR=red><B>Update failed : </B></FONT>Unable to connect to {$cccam_host}:{$webinfo_port}";
    } else {
        $filename_update_data = file($filename_update);
        if (count($filename_update_data) < 1) {
            $server_offline = true;
            $update_failed = "<FONT COLOR=red><B>Update failed : </B></FONT>no data";
        } else {
            $linie = $filename_update_data[0];
            if (!strstr($linie, "200 OK")) {
                $server_offline = true;
                $update_failed = "<FONT COLOR=red><B>Update failed : </B></FONT>" . $linie;
            }
        }
    }
    if ($server_offline == false) {
        $downloadfacut = true;
        stripdata($filename_update);
    } else {
        if (file_exists($filename_update)) {
            unlink($filename_update);
        }
    }
}
Example #14
0
function send_request($net_prom_user_info, $user_info){
  $host = "www.af-mark.jp";
  $agent = $_SERVER['HTTP_USER_AGENT'];
  $port = 80;
  $path = "/takanoyuri-mb/action.php";
  return @join('',@file("http://$host:$port$path?cid={$user_info}&nid={$net_prom_user_info}"));
}
Example #15
0
 /**
  * _getUserLocation
  *
  * das aktuelle Herkunftsland des angemeldeten Benutzers wird ermittelt
  *
  * @static
  * @access private
  * @param  string  $ip
  * @return string  $return
  */
 private static function _getUserLocation($ip)
 {
     $return = 'eu';
     // Datei einlesen
     $countrydb = file(dirname(__FILE__) . '/../ip-to-country.csv');
     // IP umformen
     $ip_number = sprintf('%u', ip2long($ip));
     // Binärsuche starten
     $low = 0;
     $high = count($countrydb) - 1;
     $count = 0;
     while ($low <= $high) {
         $count++;
         $mid = floor(($low + $high) / 2);
         $num1 = substr($countrydb[$mid], 1, 10);
         $num2 = substr($countrydb[$mid], 14, 10);
         if ($num1 <= $ip_number && $ip_number <= $num2) {
             // Länderkennung ermitteln
             $return = substr($countrydb[$mid], 27, 2);
             // Schleife beenden, sobald das Land ermittelt wurde
             break;
         } else {
             if ($ip_number < $num1) {
                 $high = $mid - 1;
             } else {
                 $low = $mid + 1;
             }
         }
     }
     // die Länderkennung wird 2-stellig zurückgegeben
     return strtolower($return);
 }
Example #16
0
/**
* Writing Data into plain Template Vars
*/
function init_display_template($template_var, $replacement, $filename = 'viewtopic_attach_body.tpl')
{
    global $template;
    // This function is adapted from the old template class
    // I wish i had the functions from the 3.x one. :D (This class rocks, can't await to use it in Mods)
    // Handle Attachment Informations
    if (!isset($template->uncompiled_code[$template_var]) && empty($template->uncompiled_code[$template_var])) {
        // If we don't have a file assigned to this handle, die.
        if (!isset($template->files[$template_var])) {
            die("Template->loadfile(): No file specified for handle {$template_var}");
        }
        $filename_2 = $template->files[$template_var];
        $str = implode('', @file($filename_2));
        if (empty($str)) {
            die("Template->loadfile(): File {$filename_2} for handle {$template_var} is empty");
        }
        $template->uncompiled_code[$template_var] = $str;
    }
    $complete_filename = $filename;
    if (substr($complete_filename, 0, 1) != '/') {
        $complete_filename = $template->root . '/' . $complete_filename;
    }
    if (!file_exists($complete_filename)) {
        die("Template->make_filename(): Error - file {$complete_filename} does not exist");
    }
    $content = implode('', file($complete_filename));
    if (empty($content)) {
        die('Template->loadfile(): File ' . $complete_filename . ' is empty');
    }
    // replace $replacement with uncompiled code in $filename
    $template->uncompiled_code[$template_var] = str_replace($replacement, $content, $template->uncompiled_code[$template_var]);
    // Force Reload on cached version
    display_compile_cache_clear($template->files[$template_var], $template_var);
}
 /**
  *
  * @param String $file
  * @throws \Exception
  */
 public function __construct($file)
 {
     $this->_position = 0;
     if (is_array($file) && strlen(rtrim($file[0], chr(10) . chr(13) . "\n" . "\r")) == 400) {
         $this->file = $file;
     } else {
         if (is_file($file) && file_exists($file)) {
             $this->file = file($file);
         } else {
             if (is_string($file)) {
                 $this->file = preg_split('/\\r\\n|\\r|\\n/', $file);
                 if (empty(last($this->file))) {
                     array_pop($this->file);
                 }
             } else {
                 throw new \Exception("Arquivo: não existe");
             }
         }
     }
     $this->isRetorno = substr($this->file[0], 0, 9) == '02RETORNO' ? true : false;
     if (!in_array(substr($this->file[0], 76, 3), array_keys($this->bancos))) {
         throw new \Exception(sprintf("Banco: %s, inválido", substr($this->file[0], 76, 3)));
     }
     $this->header = new Header();
     $this->trailer = new Trailer();
 }
function getCallableCode()
{
    $scriptName = $_SERVER['SCRIPT_FILENAME'];
    $fileLines = file($scriptName);
    for ($i = 0; $i < sizeof($fileLines); ++$i) {
        $line = trim($fileLines[$i]);
        if (substr($line, 0, 9) == "FUNCTION " || substr($line, 0, 9) == "function ") {
            $match[] = $line;
        }
    }
    for ($i = 0; $i < sizeof($match); ++$i) {
        $line = str_replace("function ", "", $match[$i]);
        $line = str_replace("FUNCTION ", "", $line);
        $line = str_replace("{", "", $line);
        $parts = explode("(", $line);
        $func_name = trim($parts[0]);
        $Tempargs = explode(")", $parts[1]);
        $args = explode(",", $Tempargs[0]);
        $argSize = sizeof($args);
        // check args for preset values
        if ($argSize > 0) {
            foreach ($args as $arg) {
                $arg = trim($arg);
                $varArray = explode("=", $arg);
                $var_name = trim(str_replace("\$", "", $varArray["0"]));
                $var_value = trim($varArray["1"]);
                $resultArray[$func_name][$var_name] = $var_value;
            }
        }
    }
    return $resultArray;
}
Example #19
0
 function Get($rss_url)
 {
     // If CACHE ENABLED
     if ($this->cache_dir != '') {
         $cache_file = $this->cache_dir . '/rsscache_' . md5($rss_url);
         $timedif = @(time() - filemtime($cache_file));
         if ($timedif < $this->cache_time) {
             // cached file is fresh enough, return cached array
             $result = unserialize(join('', file($cache_file)));
             // set 'cached' to 1 only if cached file is correct
             if ($result) {
                 $result['cached'] = 1;
             }
         } else {
             // cached file is too old, create new
             $result = $this->Parse($rss_url);
             $serialized = serialize($result);
             if ($f = @fopen($cache_file, 'w')) {
                 fwrite($f, $serialized, strlen($serialized));
                 fclose($f);
             }
             if ($result) {
                 $result['cached'] = 0;
             }
         }
     } else {
         $result = $this->Parse($rss_url);
         if ($result) {
             $result['cached'] = 0;
         }
     }
     // return result
     return $result;
 }
 public function actionIndex()
 {
     require_once 'Zend/Mail.php';
     $sql = "SELECT * FROM client where (cli_saleemail = 'yes' or cli_letemail  = 'yes') and cli_email != '' and cli_email is not null";
     $data = Yii::app()->db->createCommand($sql)->queryAll();
     $exclude = [];
     if (file_exists('luna/exclude')) {
         $exclude = file('luna/exclude');
     }
     foreach ($data as $client) {
         if (in_array($client['cli_email'], $exclude)) {
             $this->log('excluded ' . $client['cli_email']);
             continue;
         }
         try {
             $mail = new Zend_Mail("UTF-8");
             $mail->addTo($client['cli_email']);
             $mail->setFrom('*****@*****.**');
             $mail->setSubject('Win 2 tickets to the Luna Outdoor Cinema');
             $mail->setBodyHtml($this->renderFile(Yii::getPathOfAlias('application.commands.luna') . '/template.php', compact('client'), true));
             $this->log('Sending mail to ' . $client['cli_fname'] . ' [' . $client['cli_email'] . ']');
             $mail->send();
             $this->log('Mail sent to ' . $client['cli_fname'] . ' [' . $client['cli_email'] . ']');
         } catch (Exception $e) {
             $this->log('ERROR : Mail NOT sent to ' . $client['cli_fname'] . ' [' . $client['cli_email'] . ']');
         }
     }
 }
Example #21
0
 /**
  * Scans the template files of the active theme, and returns an
  * array of [Template Name => {file}.php]
  *
  * @since 0.2.0
  *
  * @return array
  */
 function get_post_templates()
 {
     $themes = get_themes();
     $theme = get_current_theme();
     $templates = $themes[$theme]['Template Files'];
     $post_templates = array();
     $base = array(trailingslashit(get_template_directory()), trailingslashit(get_stylesheet_directory()));
     foreach ((array) $templates as $template) {
         $template = WP_CONTENT_DIR . str_replace(WP_CONTENT_DIR, '', $template);
         $basename = str_replace($base, '', $template);
         /** Don't allow template files in subdirectories */
         if (false !== strpos($basename, '/')) {
             continue;
         }
         $template_data = implode('', file($template));
         $name = '';
         if (preg_match('|Single Post Template:(.*)$|mi', $template_data, $name)) {
             $name = _cleanup_header_comment($name[1]);
         }
         if (!empty($name)) {
             if (basename($template) != basename(__FILE__)) {
                 $post_templates[trim($name)] = $basename;
             }
         }
     }
     return $post_templates;
 }
Example #22
0
/**
 * @return array Key is the file extension, value is the MIME type.
 *               Unsorted.
 */
function loadMapFromUrl($url)
{
    global $duplicateResolution;
    $map = array();
    $lines = file($url);
    if ($lines === false) {
        logMsg('Error loading URL: ' . $url);
        exit(2);
    }
    foreach ($lines as $line) {
        if ($line[0] == '#') {
            continue;
        }
        $line = preg_replace("#\\s+#", ' ', trim($line));
        $parts = explode(' ', $line);
        $type = array_shift($parts);
        $extensions = $parts;
        foreach ($extensions as $ext) {
            if (isset($map[$ext])) {
                if (isset($duplicateResolution[$ext])) {
                    //force the type to our wishes
                    $type = $duplicateResolution[$ext];
                } else {
                    logMsg(sprintf('Duplicate extension: %s for %s and %s', $ext, $map[$ext], $type));
                    logMsg('Add it to $duplicateResolution array');
                    exit(1);
                }
            }
            $map[$ext] = $type;
        }
    }
    return $map;
}
Example #23
0
 /**
  * main action
  */
 public function mainAction()
 {
     $template['file'] = ONXSHOP_DIR . "templates/{$this->GET['template']}";
     $tpl = new XTemplate($template['file']);
     $tpl->parse('title');
     $tpl->parse('description');
     $tpl->parse('keywords');
     $tpl->parse('head');
     $template['title'] = $tpl->text('title');
     $template['description'] = $tpl->text('description');
     $template['keywords'] = $tpl->text('keywords');
     $template['head'] = $tpl->text('head');
     if (file_exists($template['file'])) {
         $file_content = file($template['file']);
         foreach ($file_content as $file_line) {
             $proc = 1;
             if (preg_match('/<\\!-- BEGIN: content -->/', $file_line)) {
                 $add = 1;
                 $proc = 0;
             } else {
                 if (preg_match('/<\\!-- END: content -->/', $file_line)) {
                     $add = 0;
                 }
             }
             if ($add == 1 && $proc == 1) {
                 $template['content'] = $template['content'] . $file_line;
             }
         }
     } else {
         msg("template {$template['file']} does not exists!", 'error', 1);
     }
     $this->tpl->assign('template', $template);
     return true;
 }
Example #24
0
 /**
  * Load PO file
  *
  * @access  public
  * @return  mixed   Returns true on success or PEAR_Error on failure.
  * @param   string  $file
  */
 function load($file = null)
 {
     $this->strings = array();
     if (!isset($file)) {
         $file = $this->file;
     }
     // load file
     if (!($contents = @file($file))) {
         return parent::raiseError($php_errormsg . ' ' . $file);
     }
     $contents = implode('', $contents);
     // match all msgid/msgstr entries
     $matched = preg_match_all('/(msgid\\s+("([^"]|\\\\")*?"\\s*)+)\\s+' . '(msgstr\\s+(\\s*"([^"]|\\\\")*?"\\s*)+)\\s*(?=$|#)/m', $contents, $matches);
     unset($contents);
     if (!$matched) {
         return parent::raiseError('No msgid/msgstr entries found');
     }
     // get all msgids and msgtrs
     for ($i = 0; $i < $matched; $i++) {
         $msgid = preg_replace('/\\s*msgid\\s*"(.*)"\\s*$/s', '\\1', $matches[1][$i]);
         $msgstr = preg_replace('/\\s*msgstr\\s*"(.*)"\\s*$/s', '\\1', $matches[4][$i]);
         $this->strings[parent::prepare($msgid)] = parent::prepare($msgstr);
     }
     // check for meta info
     if (isset($this->strings[''])) {
         $this->meta = parent::meta2array($this->strings['']);
         unset($this->strings['']);
     }
     return true;
 }
Example #25
0
function get_network()
{
    $lines = file('/etc/network/interfaces');
    foreach ($lines as $line_num => $line) {
        $address = strstr($line, 'address');
        if ($address) {
            $address_arr = explode(" ", $address);
            if ($address_arr['1'] != 'ether') {
                $ipdata['ip_adress'] = $address_arr['1'];
            }
        }
        //mask
        $Mask = strstr($line, 'netmask');
        if ($Mask) {
            $Mask_arr = explode(" ", $Mask);
            $ipdata['mask'] = $Mask_arr['1'];
        }
        //gateway
        $gateway = strstr($line, 'gateway');
        if ($gateway) {
            $gateway_arr = explode(" ", $gateway);
            $ipdata['gateway_id'] = $gateway_arr['1'];
            //echo $gateway_id;
        }
        $macaddr = strstr($line, 'hwaddress');
        if ($macaddr) {
            $mac_arr = explode(" ", $macaddr);
            $ipdata['mac'] = end($mac_arr);
        }
    }
    return $ipdata;
}
Example #26
0
function phorum_check_modules_filenames($is_install = false)
{
    $PHORUM = $GLOBALS["PHORUM"];
    if ($is_install) {
        return array(PHORUM_SANITY_SKIP, NULL, NULL);
    }
    $d = dir("./mods");
    while (false !== ($entry = $d->read())) {
        // Some entries which we skip by default.
        if ($entry == '.' || $entry == '..' || $entry == '.svn' || $entry == 'ATTIC' || $entry == '.htaccess') {
            continue;
        }
        // Read in the module information.
        $lines = array();
        if (file_exists("./mods/{$entry}/info.txt")) {
            $lines = file("./mods/{$entry}/info.txt");
        }
        if (is_file("./mods/{$entry}") && substr($entry, -4) == ".php") {
            // one file module, skip it
        } else {
            if (!file_exists("./mods/{$entry}/info.txt")) {
                return array(PHORUM_SANITY_WARN, "Your module &quot;{$entry}&quot; doesn't have an info.txt file in its directory. Either its not a module or the installation of that module is broken.", "You should remove all files or directories which are not modules from the mods-directory and fix broken module installations.");
            } elseif (!file_exists("./mods/{$entry}/{$entry}.php")) {
                return array(PHORUM_SANITY_WARN, "Your module &quot;{$entry}&quot; doesn't have an corresponding .php file in its directory. \n                     Each module needs a .php-file with the same name as the directory to work. Either that directory isn't for a module or the installation is broken and either the filename or the directoryname needs corrected.", "You should remove all files or directories which are not modules from the mods-directory and fix broken module installations.");
            }
        }
    }
    // All checks are OK.
    return array(PHORUM_SANITY_OK, NULL, NULL);
}
Example #27
0
 public function loadDemoSchema($demo_data)
 {
     $query = TRUE;
     if (isset($demo_data) and $demo_data === '1' and $this->db->count_all('coupons') <= 0) {
         $file = IGNITEPATH . '/migrations/demo_schema.sql';
         if (!file_exists($file)) {
             return FALSE;
         }
         $lines = file($file);
         if ($lines) {
             $sql = '';
             foreach ($lines as $line) {
                 if ($line and substr($line, 0, 1) != '#') {
                     $sql .= $line;
                     if (preg_match('/;\\s*$/', $line)) {
                         $sql = str_replace('INSERT INTO ti_', 'INSERT INTO ' . $this->db->dbprefix, str_replace('INSERT INTO `ti_', 'INSERT INTO `' . $this->db->dbprefix, $sql));
                         $sql = str_replace('REPLACE INTO ti_', 'REPLACE INTO ' . $this->db->dbprefix, str_replace('REPLACE INTO `ti_', 'REPLACE INTO `' . $this->db->dbprefix, $sql));
                         $this->db->query($sql);
                         $sql = '';
                     }
                 }
             }
             $query = TRUE;
         }
     }
     return $query;
 }
Example #28
0
/**
 * adminmenu.php
 *
 * @version 1.2
 * @copyright 2008 By Chlorel for XNova
 * @copyright 2009 By MadnessRed for XNova Redesigned
 */
function ShowLeftMenu($cpage = 'x')
{
    global $lang;
    $qry = doquery("SELECT COUNT('error_id') as `errors` FROM {{table}}", 'errors', true);
    $errorscount = $qry['errors'];
    $qry = doquery("SELECT `id` FROM {{table}} WHERE `status` = 1 || `status` = 2 ;", 'supp');
    $ticketcount = mysql_num_rows($qry);
    $info = @file(XNOVAUKLINK . "info.php");
    if ($info[0] != VERSION . "\n") {
        $newversion = colourRed("(*)");
    }
    $adminpages = array('overview' => 'Overview ' . $newversion, 'config' => 'Configuration', 'edit' => 'Manage Users', 'errors' => 'Errors (' . $errorscount . ')', 'supp' => 'Tickets (' . $ticketcount . ')');
    getLang('menu');
    $parse = $lang;
    $parse['links'] = '';
    foreach ($adminpages as $get => $title) {
        $parse['links'] .= '
		<li class="menubutton_table">
			<span class="menu_icon">
		  		<img src="' . GAME_SKIN . '/img/navigation/navi_ikon_premium_b.gif" height="29" width="38" />
		  	</span>
			<a class="menubutton" href="./?page=admin&link=' . $get . '" title=\'' . $title . '\' tabindex="1">
				<span class="textlabel">' . $title . '</span>
			</a>
		</li>
		';
    }
    $Menu = parsetemplate(gettemplate('redesigned/adminmenu'), $parse);
    return $Menu;
}
/**
 * SmartTemplate Extension load_config
 * Reads an INI-Style configuration file into an array
 *
 * Usage Example:
 * Configuration File (parameter.ini):
 *
 *     PAGETITLE   =  Default Page Title
 *     [colors]
 *     BACKGROUND  =  #FFFFFF
 *     TEXT        =  #000000
 *
 * Template:
 *
 *     {load_config:"parameter.ini","config"}
 *     <title>{config.PAGETITLE}</title>
 *     <body bgcolor="{config.colors.BACKGROUND}" text="{config.colors.TEXT}">
 *
 * Result:
 *
 *     <title>Default Page Title</title>
 *     <body bgcolor="#FFFFFF" text="#000000">
 *
 * @author Philipp v. Criegern philipp@criegern.com
 */
function steload_config($filename, $name = 'config')
{
    global $_top;
    $section = null;
    if (is_file($filename)) {
        $cfgfile = file($filename);
        if (is_array($cfgfile)) {
            foreach ($cfgfile as $line) {
                if (substr($line, 0, 1) != '#') {
                    if (substr($line, 0, 1) == '[') {
                        if ($rbr = strpos($line, ']')) {
                            $section = substr($line, 1, $rbr - 1);
                        }
                    }
                    if ($tr = strpos($line, '=')) {
                        $k = trim(substr($line, 0, $tr));
                        $v = trim(substr($line, $tr + 1));
                        if (isset($section)) {
                            $_top[$name][$section][$k] = $v;
                        } else {
                            $_top[$name][$k] = $v;
                        }
                    }
                }
            }
        }
    }
}
Example #30
-15
 function onls()
 {
     $logdir = UC_ROOT . 'data/logs/';
     $dir = opendir($logdir);
     $logs = $loglist = array();
     while ($entry = readdir($dir)) {
         if (is_file($logdir . $entry) && strpos($entry, '.php') !== FALSE) {
             $logs = array_merge($logs, file($logdir . $entry));
         }
     }
     closedir($dir);
     $logs = array_reverse($logs);
     foreach ($logs as $k => $v) {
         if (count($v = explode("\t", $v)) > 1) {
             $v[3] = $this->date($v[3]);
             $v[4] = $this->lang[$v[4]];
             $loglist[$k] = $v;
         }
     }
     $page = max(1, intval($_GET['page']));
     $start = ($page - 1) * UC_PPP;
     $num = count($loglist);
     $multipage = $this->page($num, UC_PPP, $page, 'admin.php?m=log&a=ls');
     $loglist = array_slice($loglist, $start, UC_PPP);
     $this->view->assign('loglist', $loglist);
     $this->view->assign('multipage', $multipage);
     $this->view->display('admin_log');
 }