/** * Constructor. * * @param Horde_Vcs_Base $rep A repository object. * @param string $dn Path to the directory. * @param array $opts Any additional options: * * @throws Horde_Vcs_Exception */ public function __construct(Horde_Vcs_Base $rep, $dn, $opts = array()) { parent::__construct($rep, $dn, $opts); $cmd = $rep->getCommand() . ' ls ' . escapeshellarg($rep->sourceroot . $this->_dirName); $dir = proc_open($cmd, array(1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes); if (!$dir) { throw new Horde_Vcs_Exception('Failed to execute svn ls: ' . $cmd); } if ($error = stream_get_contents($pipes[2])) { proc_close($dir); throw new Horde_Vcs_Exception($error); } /* Create two arrays - one of all the files, and the other of all the * dirs. */ $errors = array(); while (!feof($pipes[1])) { $line = chop(fgets($pipes[1], 1024)); if (!strlen($line)) { continue; } if (substr($line, 0, 4) == 'svn:') { $errors[] = $line; } elseif (substr($line, -1) == '/') { $this->_dirs[] = substr($line, 0, -1); } else { $this->_files[] = $rep->getFile($this->_dirName . '/' . $line); } } proc_close($dir); }
/** * @ignore */ public static function isRequired($uValue) { if (strlen(chop($uValue)) === 0) { return false; } return true; }
function before($route) { $lang_mapping = array('fr' => 'fr_FR'); if (!isset($_SESSION['locale'])) { $locale = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); $_SESSION['locale'] = strtolower(substr(chop($locale[0]), 0, 2)); } $lang = $_SESSION['locale']; // Convert simple language code into full language code if (array_key_exists($lang, $lang_mapping)) { $lang = $lang_mapping[$lang]; } $lang = "{$lang}.utf8"; $textdomain = "localization"; putenv("LANGUAGE={$lang}"); putenv("LANG={$lang}"); putenv("LC_ALL={$lang}"); putenv("LC_MESSAGES={$lang}"); setlocale(LC_ALL, $lang); setlocale(LC_CTYPE, $lang); $locales_dir = dirname(__FILE__) . '/i18n'; bindtextdomain($textdomain, $locales_dir); bind_textdomain_codeset($textdomain, 'UTF-8'); textdomain($textdomain); set('locale', $lang); }
public function testSerialization() { $msg = new XPSoapMessage(); $msg->createCall('Test', 'testSerialization'); $this->assertEquals('Test', $msg->action); $this->assertEquals('testSerialization', $msg->method); $this->assertEquals('SOAP-ENV:Envelope', $msg->root()->getName()); $this->assertNotEmpty($msg->root()->getAttributes()); $msg->setData(array('int' => 1, 'float' => 6.1, 'string' => 'Binford', 'string2' => '"<&>"', 'bool' => true, 'date' => \util\Date::fromString('1977-12-14 11:55AM Europe/Berlin'), 'null' => null, 'array' => array(2, 3), 'hash' => array('class' => 'Test', 'method' => 'testSerialization'))); // Let's be somewhat forgiving on whitespace $src = trim(chop($msg->getSource(0))); $this->assertEquals('<SOAP-ENV:Envelope', substr($src, 0, 18)); $this->assertEquals('</SOAP-ENV:Envelope>', substr($src, -20)); $this->assertContains($src, '<int xsi:type="xsd:int">1</int>', 'integer'); $this->assertContains($src, '<float xsi:type="xsd:float">6.1</float>', 'float'); $this->assertContains($src, '<string xsi:type="xsd:string">Binford</string>', 'string'); $this->assertContains($src, '<string2 xsi:type="xsd:string">"<&>"</string2>', 'escaping'); $this->assertContains($src, '<bool xsi:type="xsd:boolean">true</bool>', 'bool'); $this->assertContains($src, '<date xsi:type="xsd:dateTime">1977-12-14T11:55:00+01:00</date>', 'date'); $this->assertContains($src, '<null xsi:nil="true"/>', 'null'); $this->assertContains($src, '<array xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[2]">', 'array'); $this->assertContains($src, '<item xsi:type="xsd:int">2</item>', 'array.inner'); $this->assertContains($src, '<item xsi:type="xsd:int">3</item>', 'array.inner'); $this->assertContains($src, '<hash xsi:type="xsd:struct">', 'hash'); $this->assertContains($src, '<class xsi:type="xsd:string">Test</class>', 'hash.inner'); $this->assertContains($src, '<method xsi:type="xsd:string">testSerialization</method>', 'hash.inner'); return $src; }
function walk($item1) { $item1 = str_replace(' ', '|', $item1); $item1 = str_replace('"', '', $item1); $item1 = str_replace("\n", '', $item1); $item1 = str_replace("\r", '', $item1); //$item1 = str_replace("",'',$item1); $item1 = str_replace('"', '\\"', $item1); $item1 = str_replace("'", '\\"', $item1); // echo $item1."<br>"; $item1 = chop($item1); echo $item1 . "<br>"; $items = explode("|", $item1); $products_id = $items[0]; $products_model = $items[1]; $products_name = $items[2]; $products_tax_class_id = $items[3]; $products_status = $items[4]; $products_price = $items[5]; $dbconn =& oosDBGetConn(); $oostable =& oosDBGetTables(); $tax_ratestable = $oostable['tax_rates']; $query = "SELECT tax_rate FROM {$tax_ratestable} WHERE tax_class_id = '" . intval($products_tax_class_id) . "'"; $tax = $dbconn->GetOne($query); $price = $products_price / ($tax + 100) * 100; $productstable = $oostable['products']; $dbconn->Execute("UPDATE {$productstable} set products_price = '" . $price . "', products_status = '" . intval($products_status) . "' where products_id = '" . intval($products_id) . "'"); }
/** * @param $className * @return bool */ public function sanitizeClassName($className) { if (trim(substr($className, -1)) == 's') { $className = chop($className, 's'); } return ucfirst($className); }
function getMemberForm($str, $type, $flag) { global $DB_CONNECT, $MemberType_Array; if (!$MemberType_Array) { $Group_Data = db_query("SELECT * FROM kimsmall7_members_group ORDER BY MG_TYPE", $DB_CONNECT); while ($MEMBER_GROUP = db_fetch_array($Group_Data)) { $MemberType_Array[] = $MEMBER_GROUP[MG_NAME]; } } $g_num = sizeof($MemberType_Array); if ($str) { $ret_code = "<option value=''>{$str}</option>\n"; } for ($i = 0; $i < $g_num && chop($MemberType_Array[$i]); $i++) { if ($type != $i + 1) { $ret_code .= "<option value='" . ($i + 1) . "'>[" . ($i + 1) . "]{$MemberType_Array[$i]}</option>\n"; } else { $ret_code .= "<option value='" . ($i + 1) . "' selected>[" . ($i + 1) . "]{$MemberType_Array[$i]}</option>\n"; } } if ($flag) { $g_num++; $ret_code = "<option value='0' style='background:#6CCFF8;'>[0]비회원</option>" . $ret_code; $ret_code .= $type == $g_num ? "<option value='" . $g_num . "' selected style='background:gold;'>[" . $g_num . "]관리자</option>" : "<option value='" . $g_num . "' style='background:gold;'>[" . $g_num . "]관리자</option>"; return $ret_code; } else { return $ret_code; } }
function doPost($uri, $postdata, $host) { $da = fsockopen($host, 80, $errno, $errstr); if (!$da) { echo "{$errstr} ({$errno})<br/>\n"; echo $da; } else { $salida = "POST {$uri} HTTP/1.1\r\n"; $salida .= "Host: {$host}\r\n"; $salida .= "User-Agent: PHP Script\r\n"; $salida .= "Content-Type: application/x-www-form-urlencoded\r\n"; $salida .= "Content-Length: " . strlen($postdata) . "\r\n"; $salida .= "Connection: close\r\n\r\n"; $salida .= $postdata; fwrite($da, $salida); while (!feof($da)) { $response .= fgets($da, 128); } $response = split("\r\n\r\n", $response); $header = $response[0]; $responsecontent = $response[1]; if (!(strpos($header, "Transfer-Encoding: chunked") === false)) { $aux = split("\r\n", $responsecontent); for ($i = 0; $i < count($aux); $i++) { if ($i == 0 || $i % 2 == 0) { $aux[$i] = ""; } } $responsecontent = implode("", $aux); } //if return chop($responsecontent); } //else }
function get_layers($tiles, $zoom) { global $attribution, $attrib_plain; $needed = explode('|', $tiles); $result = array(); $attribution = 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a>'; $file = @fopen('tiles.txt', 'r'); if ($file) { while (($line = fgets($file)) !== false) { $layer = explode(',', chop($line)); if (in_array($layer[0], $needed) && (count($result) ? $layer[1] : !$layer[1]) && $layer[2] <= $zoom && $layer[3] >= $zoom) { $result[] = $layer[4]; if (strlen($layer[5])) { $attribution .= ', ' . $layer[5]; } } if (count($result) >= 4) { break; } } fclose($file); } if (!count($result)) { $result[] = 'http://tile.openstreetmap.org/!z/!x/!y.png'; } $attrib_plain = str_replace('©', '(c)', preg_replace('/<[^>]+>/', '', $attribution)); return $result; }
protected function git($Provider) { if ($Provider->getHook() != 'pre-rebase') { return true; } $argv = $_SERVER['argv']; $rebaseBranch = $argv[0]; if (!empty($argv[1])) { $topicBranch = 'refs/heads/' . $argv[1]; } else { $topicBranch = chop($Provider->execute('git symbolic-ref HEAD')); } $shas = explode("\n", $Provider->execute("git rev-list {$rebaseBranch}..{$topicBranch}")); $refs = array_map('trim', explode("\n", $Provider->execute("git branch -r"))); foreach ($shas as $sha) { foreach ($refs as $ref) { $pushed = chop($Provider->execute("git rev-list ^{$sha}^@ refs/remotes/{$ref}")) == $sha; if ($pushed) { $this->output("Commit {$sha} has already been pushed to {$ref}", true, true); return; } } } $message = "Rebase of {$rebaseBranch} does not overwrite any of {$topicBranch} remote commits"; $this->output($message); return true; }
function read_wiki() { global $wiki_stylesheet; global $columns; $data=array(); $f=fopen($wiki_stylesheet, "r"); unset($this_part); while($r=fgets($f)) { $r=chop($r); if(ereg("==([^=]+)==", $r, $m)) { $mode=0; $part=trim($m[1]); } if(substr($r, 0, 1)=="|") { $this_row=get_row($r, $f); if($this_row&&($columns[$part])) { $src=array(); foreach($this_row as $i=>$r2) { $src[$columns[$part][$i]]=trim($r2); } $data[$part][]=$src; } } } fclose($f); return $data; }
function CreatLinks() { global $TMP_FOLDER, $DOCUMENT_ROOT, $SUB_FOLDER; $File = "symlinks.txt"; $COPY_FOLDER = $DOCUMENT_ROOT . $SUB_FOLDER; # сколько ссылок создно, сколько всего ссылок $result = array("links" => 0, "total" => 0); $fp = fopen($TMP_FOLDER . $File, "r"); while (!feof($fp)) { $string = chop(fgets($fp, 4096)); if (strlen($string) == 0) { break; } $From = strtok($string, " "); $To = strtok(" "); $directory = dirname($To); $tmpDirectory = $COPY_FOLDER; $tok = strtok($directory, "/"); while ($tok) { $tmpDirectory .= "/" . $tok; @mkdir($tmpDirectory, 0775); $tok = strtok("/"); } # Для Windows-платформ эта функция не реализована. $linked = @symlink($COPY_FOLDER . "/" . $From, $COPY_FOLDER . "/" . $To); if ($linked) { $result["links"]++; } $result["total"]++; } fclose($fp); return $result; }
function ansispan($string) { if (preg_match("/(#[0-f][0-f][0-f][0-f][0-f][0-f]|[+][a-z0-9]+)(\\/(#[0-f][0-f][0-f][0-f][0-f][0-f]|[+][a-z0-9]+))?/", $string[1])) { $temp = preg_replace("/((#[0-f][0-f][0-f][0-f][0-f][0-f])|[+]([a-z0-9]+))/", "\\2\\3", $string[1]); return "<span style=\"color:{$temp}\">"; } $fg = 'n'; $bg = 'n'; $bold = 0; $invert = 0; $result = ""; $result_array = str_split($string[1]); foreach ($result_array as $char) { if (preg_match("/[A-Z]/", $char)) { $bg = strtolower($char); } elseif ($char == 'i') { $invert = 1; } elseif ($char == 'h') { $bold = 1; } elseif ($char == 'f') { $result .= "flash "; } elseif ($char == 'u') { $result .= "underline "; } else { $fg = $char; } } $fg = ($invert ? "bg_" : "fg_") . $fg; $bg = ($invert ? "fg_" : "bg_") . $bg; $fg = $bold ? "bold_" . $fg : $fg; $result = chop($result); return "{$inverta}<span class=\"{$result} {$fg} {$bg} ++ {$string['1']}\">"; }
function updatebiz_categoriesData($setArray, $conditionArray) { $set = ''; $condition = ''; /* Setting up setArray */ if ($setArray != '1') { while (list($key, $val) = each($setArray)) { $set .= $key . "='" . $val . "',"; } $set = chop($set, ","); } else { $set = $setArray; } /* Setting up conditionArray */ if ($conditionArray != '1') { while (list($key, $val) = each($conditionArray)) { $condition .= $key . "='" . $val . "',"; } $condition = chop($condition, ","); } else { $condition = $conditionArray; } $updateQuery = "UPDATE biz_categories "; $updateQuery .= "SET " . $set; $updateQuery .= "WHERE " . $condition; $this->logger->info("[func - updatebiz_categoriesData()] Query : " . $updateQuery); $dbObject = new Database(); $conn = $dbObject->dbinteraction($biz_sname, $biz_dbname, $biz_user, $biz_pwd); $dbObject->addupdateData($conn, $updateQuery); $conn->close(); }
public function createPods($eventId) { $this->t = new Transaction(); $sql = 'UPDATE event SET started = TRUE WHERE id = ' . Q($eventId); $this->t->execute($sql); $players = (new Events())->players($eventId); shuffle($players); $pods = []; $podNums = $this->determinePods(count($players)); foreach ($podNums as $podCount) { $podId = $this->createPod($eventId); $pod = []; for ($seat = 1; $seat <= $podCount; $seat++) { $player = array_pop($players); $player['seat'] = $seat; $pod[] = $player; } $sql = 'INSERT INTO player_pod (pod_id, player_id, seat) VALUES '; foreach ($pod as $player) { $sql .= ' (' . Q($podId) . ', ' . Q($player['player_id']) . ', ' . Q($player['seat']) . '), '; } $sql = chop($sql, ', '); $this->t->execute($sql); } $this->t->commit(); }
function perform_handshaking($receved_header, $client_conn, $host, $port) { //se crea un arreglo para guardar los datos enviados del cliente $headers = array(); //divide el contenido enviado por el cliente en array,por medio de la expresion regular //crea los array apartir el retorno de carro (\r) y salto de linea (\n). $lines = preg_split("/\r\n/", $receved_header); //recorre el arreglo LINES para meterlo en el arreglo HEADERS foreach ($lines as $line) { $line = chop($line); //elimina los espacios en blanco //Aqui se crea un arreglo matches donde se anexara al arreglo HEADERS donde el indicide de //headers tendra el valor de maches[1] y su valor sera el de matches[2] if (preg_match('/\\A(\\S+): (.*)\\z/', $line, $matches)) { $headers[$matches[1]] = $matches[2]; } } $secKey = $headers['Sec-WebSocket-Key']; // se obtiene el balor de Sec-WebSocket-Key //genera el encriptado base64 para responder al cliente //sha1 calcula el has del string //pack empaqueta el sha1 a una cadena binaria donde H* indica que debe ser todo el texto //en cadena hexadecimal. //base64_encode codifica el paquete binario en base64 $secAccept = base64_encode(pack('H*', sha1($secKey . '258EAFA5-E914-47DA-95CA-C5AB0DC85B11'))); //hand shaking header -- Crea el mensaje para el cliente y se extablesca la conexion $upgrade = "HTTP/1.1 101 Web Socket Protocol Handshake\r\n" . "Upgrade: websocket\r\n" . "Connection: Upgrade\r\n" . "WebSocket-Origin: {$host}\r\n" . "WebSocket-Location: ws://{$host}:{$port}/servidor.php\r\n" . "Sec-WebSocket-Accept:{$secAccept}\r\n\r\n"; //envia al cliente la respuesta para establecer la comunicacion entre cliente y socket socket_write($client_conn, $upgrade, strlen($upgrade)); }
function updateuser_accountsData($setArray, $conditionArray) { $set = ''; $condition = ''; /* Setting up setArray */ if ($setArray != '1') { while (list($key, $val) = each($setArray)) { $set .= $key . "='" . $val . "',"; } $set = chop($set, ","); } else { $set = $setArray; } /* Setting up conditionArray */ if ($conditionArray != '1') { while (list($key, $val) = each($conditionArray)) { $condition .= $key . "='" . $val . "',"; } $condition = chop($condition, ","); } else { $condition = $conditionArray; } $updateQuery = "UPDATE user_accounts "; $updateQuery .= "SET " . $set; $updateQuery .= "WHERE " . $condition; $this->logger->info("[func - updateuser_accountsData()] Query : " . $updateQuery); $dbObject = new Database(); $conn = $dbObject->dbinteraction(constant("USER_SNAME"), constant("USER_DBNAME"), constant("USER_USER"), constant("USER_PWD")); $res = $dbObject->addupdateData($conn, $updateQuery); $conn->close(); return $res; }
private function parseLogFile($logFile, $formData) { $pattern = '/\\[(?P<date>.*)\\] (?P<logger>\\w+).(?P<level>\\w+): (?P<message>.*)$/'; $log = array(); $message = array(); foreach (array_reverse(file($logFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)) as $line) { // 上限に達した場合、処理を抜ける if (count($log) >= $formData['line_max']) { break; } $line = chop($line); if (preg_match($pattern, $line, $data)) { $message[] = $data['message']; // messageをここで分解し直す // 改行コードにするとややこしいのでbrで改行する preg_match('/(?P<message>.*[^ ]+) (?P<context>[^ ]+) (?P<extra>[^ ]+)/', implode("<br>", array_reverse($message)), $res); $message = array(); $log[] = array('date' => \DateTime::createFromFormat('Y-m-d H:i:s', $data['date']), 'logger' => $data['logger'], 'level' => $data['level'], 'message' => $res['message'], 'context' => var_export(json_decode($res['context'], true), true), 'extra' => var_export(json_decode($res['extra'], true), true)); } else { // 内容が改行されている場合がある $message[] = $line; } } return $log; }
function updateuser_commentsData($setArray, $conditionArray) { $set = ''; $condition = ''; /* Setting up setArray */ if ($setArray != '1') { while (list($key, $val) = each($setArray)) { $set .= $key . "='" . $val . "',"; } $set = chop($set, ","); } else { $set = $setArray; } /* Setting up conditionArray */ if ($conditionArray != '1') { while (list($key, $val) = each($conditionArray)) { $condition .= $key . "='" . $val . "',"; } $condition = chop($condition, ","); } else { $condition = $conditionArray; } $updateQuery = "UPDATE user_comments "; $updateQuery .= "SET " . $set; $updateQuery .= "WHERE " . $condition; $this->logger->info("[func - updateuser_commentsData()] Query : " . $updateQuery); $dbObject = new Database(); $dbObject->addupdateData($updateQuery); }
function cache_get_new_data($back_url, $entries) { $rdf = parse_url($back_url); $fp = fsockopen($rdf['host'], 80, $errno, $errstr, 15); if (!$fp) { rssfail("Can't connect to host."); } else { // print("<p>fsockopen ".$rdf['host']."\n"); fputs($fp, "GET " . $rdf['path'] . "?" . $rdf['query'] . " HTTP/1.0\r\n"); fputs($fp, "HOST: " . $rdf['host'] . "\r\n\r\n"); $string = ""; while (!feof($fp)) { $pagetext = fgets($fp, 228); $string .= chop($pagetext); } fputs($fp, "Connection: close\r\n\r\n"); fclose($fp); // print("<p>fsockclose ".$rdf['host']."\n"); $items = explode("</item>", $string); $content = "<span class=\"small\">"; for ($i = 0; $i < $entries; $i++) { $link = ereg_replace(".*<link>", "", $items[$i]); $link = ereg_replace("</link>.*", "", $link); $title2 = ereg_replace(".*<title>", "", $items[$i]); $title2 = ereg_replace("</title>.*", "", $title2); if (strcmp($link, $title2)) { $content .= "<li><a href=\"{$link}\" target=\"_blank\">{$title2}</a></li>\n"; } } $content .= "</span>"; } $content = FixQuotes($content); return $content; }
function processa_canal_com_link($tabela, $campo, $canal) { $id_campo = busca_id_campo($tabela, $canal); $values .= "'" . $id_campo . "','"; foreach ($campo as $item) { $ipos = strpos($item, '('); $fpos = strpos($item, ')'); if ($ipos !== false && $fpos !== false) { $estenome = trim(htmlentities(substr($item, 0, $ipos - 1), ENT_QUOTES)); $esteurl = trim(htmlentities(substr($item, $ipos + 1, -1), ENT_QUOTES)); // busca o id do campo na tabela auxiliar $id_dado = busca_campo_canal($tabela, $estenome, $esteurl); $values .= $id_dado . ","; } else { //die ("Formato incompativel: linha ".$i.", campo ".$thisfield); $item = trim(htmlentities($item, ENT_QUOTES)); //echo "<br>Ator: $item\n"; $id_dado = busca_campo_canal($tabela, $item, ''); $values .= $id_dado . ","; } //echo "<li>$item\n"; } $values = chop($values, ","); $values .= "'"; return $values; }
function decrypt($key, $c_t) { $c_t = trim(chop(base64_decode($c_t))); $iv = substr(md5($key), 0, mcrypt_get_iv_size(MCRYPT_CAST_256, MCRYPT_MODE_CFB)); $p_t = mcrypt_cfb(MCRYPT_CAST_256, $key, $c_t, MCRYPT_DECRYPT, $iv); return trim(chop($p_t)); }
function onGetMessage($mynumber, $from, $id, $type, $time, $name, $body) { $from = chop($from, '@s.whatsapp.net'); $body = strtoupper($body); $dbservername = "us-cdbr-iron-east-01.cleardb.net"; $dbusername = "******"; $dbpassword = "******"; $dbname = "heroku_3d91432389d0eb8"; $conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM messages WHERE sender = '" . $from . "'"; $result = mysqli_query($conn, $sql); $lastmessage = mysqli_fetch_array($result, MYSQLI_ASSOC); if (!$lastmessage) { $sql = "INSERT INTO messages (sender, time_sent, message, new) VALUES ('" . $from . "', " . $time . ", '" . $body . "', 1)"; if ($conn->query($sql) === TRUE) { echo "New record created successfully<br/>"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } } else { $sql = "UPDATE messages SET time_sent='" . $time . "', message='" . $body . "', prev_message='" . $lastmessage['message'] . "', new=1 WHERE sender='" . $from . "'"; if ($conn->query($sql) === TRUE) { echo "Record updated successfully<br/>"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } } $conn->close(); }
/** * @return array|int|string */ private function initLang() { $CollectionTools = new collections_ArrayTools(); $langCollection = $CollectionTools->defaultLanguage(); $language = explode(",", $_SERVER['HTTP_ACCEPT_LANGUAGE']); $language = strtolower(substr(chop($language[0]), 0, 2)); foreach ($langCollection as $key => $value) { if (array_key_exists($key, $langCollection)) { switch ($language) { case $key: $language = $key; break; default: $language = 'fr'; break; } } else { $language = 'fr'; } } if (empty($_SESSION[self::$setParams]) || !empty(self::$getLanguage)) { return $_SESSION[self::$setParams] = empty(self::$getLanguage) ? $language : self::$getLanguage; } else { if (http_request::isGet(self::$setParams)) { return self::$getLanguage = $language; } } }
/** * Combines the Files from the given array to on file, named by given filename * * @param array $pFiles * @param string $pFileName */ private function combineFiles($pFiles, $pFileName) { //foreach about all files we wanna combine foreach ($pFiles as $lMyFile) { //now we get the content of the current-file as an array (every line = one field in the array) $lArray = file($lMyFile); //var_dump(trim(chop($lArray[0])));die(); foreach ($lArray as $lKey => $lValue) { //remove all spaces $lValue = trim(chop(str_replace(" ", "", $lValue))); //if(sfConfig::get('app_settings_dev') == false && strpos($lValue, 'debug.log') !== false) { if (strpos($lValue, 'debug.log') !== false) { unset($lArray[$lKey]); } //if there is a @combine in the file if (strpos($lValue, '*@combine') !== false) { //build the current set filename $lNewName = str_replace('*@combine', "", $lValue) . '-' . $pFileName; //open or build the file with the new name $lWholeFile = fopen(dirname(__FILE__) . '/../../web/js/100_main/include/' . $lNewName, 'a+'); //get the content $lContent = file_get_contents($lMyFile); if (sfConfig::get('app_settings_dev') == false) { $lContent = str_replace('debug.log', "//debug.log", $lContent); } //and write to the end of the new file $lDone = fwrite($lWholeFile, $lContent); echo basename($lMyFile) . " combined to " . $lNewName; echo "\n\r"; } } } // at least, close the new combine-file fclose($lWholeFile); }
function makejpg($pic) { //if png, turn into jpg $path_parts = pathinfo($pic); $ext = $path_parts['extension']; if ($ext == 'png') { $filePath = chop($pic, '.png'); $image = imagecreatefrompng($pic); $bg = imagecreatetruecolor(imagesx($image), imagesy($image)); imagefill($bg, 0, 0, imagecolorallocate($bg, 255, 255, 255)); imagealphablending($bg, TRUE); imagecopy($bg, $image, 0, 0, 0, 0, imagesx($image), imagesy($image)); imagedestroy($image); $quality = 100; // 0 = worst / smaller file, 100 = better / bigger file imagejpeg($bg, $filePath . ".jpg", $quality); //imagejpeg($bg, $_FILES['file']['tmp_name'], $quality); imagedestroy($bg); unlink($pic); } if ($ext == 'jpeg') { //does this matter? //do jpeg to jpg conversion here...gif too? nah...thats dumb } }
public static function getAuthSubSessionToken($token, $client = null, $request_uri = self::AUTHSUB_SESSION_TOKEN_URI) { $client = self::getHttpClient($token, $client); if ($client instanceof Zend_Gdata_HttpClient) { $filterResult = $client->filterHttpRequest('GET', $request_uri); $url = $filterResult['url']; $headers = $filterResult['headers']; $client->setHeaders($headers); $client->setUri($url); } else { $client->setUri($request_uri); } try { $response = $client->request('GET'); } catch (Zend_Http_Client_Exception $e) { require_once 'Zend/Gdata/App/HttpException.php'; throw new Zend_Gdata_App_HttpException($e->getMessage(), $e); } // Parse Google's response if ($response->isSuccessful()) { $goog_resp = array(); foreach (explode("\n", $response->getBody()) as $l) { $l = chop($l); if ($l) { list($key, $val) = explode('=', chop($l), 2); $goog_resp[$key] = $val; } } return $goog_resp['Token']; } else { require_once 'Zend/Gdata/App/AuthException.php'; throw new Zend_Gdata_App_AuthException('Token upgrade failed. Reason: ' . $response->getBody()); } }
function axiom_ini_get_values($file) { $rez = array(); if (!is_array($file)) { if (file_exists($file)) { $file = axiom_fga($file); } else { return $rez; } } for ($i = 0; $i < count($file); $i++) { $file[$i] = trim(chop($file[$i])); if (($pos = axiom_strpos($file[$i], ';')) !== false) { $file[$i] = trim(axiom_substr($file[$i], 0, $pos)); } $parts = explode('=', $file[$i]); if (count($parts) != 2) { continue; } $key = trim(chop($parts[0])); $rez[$key] = trim($parts[1]); if (axiom_substr($rez[$key], 0, 1) == '"') { $rez[$key] = axiom_substr($rez[$key], 1, axiom_strlen($rez[$key]) - 2); } else { $rez[$key] *= 1; } } return $rez; }
/** * function display home backend * */ private function loadGlobalLang() { $langue = explode(",", $_SERVER['HTTP_ACCEPT_LANGUAGE']); $langue = strtolower(substr(chop($langue[0]), 0, 2)); switch ($langue) { case 'en': $langue = 'en'; break; case 'fr': $langue = 'fr'; break; case 'de': $langue = 'de'; break; case 'nl': $langue = 'nl'; break; case 'es': $langue = 'es'; break; case 'it': $langue = 'it'; break; default: $langue = 'fr'; } if (empty($_SESSION['strLangue']) || !empty($this->loadlang)) { return $_SESSION['strLangue'] = empty($this->loadlang) ? $langue : $this->loadlang; } else { if (isset($this->loadlang)) { return $this->loadlang = $langue; } } }
function LoadFile($dbi, $filename, $text, $mtime) { set_time_limit(30); // Reset watchdog. if (!$mtime) { $mtime = time(); } // Last resort. $defaults = array('author' => 'The PhpWiki programming team', 'pagename' => rawurldecode($filename), 'created' => $mtime, 'flags' => 0, 'lastmodified' => $mtime, 'refs' => array(), 'version' => 1); if (!($parts = ParseMimeifiedPages($text))) { // Can't parse MIME: assume plain text file. $page = $defaults; $page['pagename'] = rawurldecode($filename); $page['content'] = preg_split('/[ \\t\\r]*\\n/', chop($text)); SavePage($dbi, $page, "text file"); } else { for (reset($parts); $page = current($parts); next($parts)) { // Fill in defaults for missing values? // Should we do more sanity checks here? reset($defaults); while (list($key, $val) = each($defaults)) { if (!isset($page[$key])) { $page[$key] = $val; } } if ($page['pagename'] != rawurldecode($filename)) { printf("<b>Warning:</b> " . "pagename (%s) doesn't match filename (%s)" . " (using pagename)<br>\n", htmlspecialchars($page['pagename']), htmlspecialchars(rawurldecode($filename))); } SavePage($dbi, $page, "MIME file"); } } }