function open($mode = 'w') { if ($this->_dbh) { return; } // already open. $watchdog = $this->_timeout; global $ErrorManager; $this->_dba_open_error = false; $ErrorManager->pushErrorHandler(new WikiMethodCb($this, '_dba_open_error_handler')); // oops, you don't have DBA support. if (!function_exists("dba_open")) { echo "You don't seem to have DBA support compiled into PHP."; } // lock supported since 4.3.0: if (check_php_version(4, 3, 0) and strlen($mode) == 1) { // PHP 4.3.x Windows lock bug workaround: http://bugs.php.net/bug.php?id=23975 if (isWindows()) { $mode .= "-"; // suppress locking, or } elseif ($this->_handler != 'gdbm') { // gdbm does it internally $mode .= "d"; // else use internal locking } } while (($dbh = dba_open($this->_file, $mode, $this->_handler)) < 1) { if ($watchdog <= 0) { break; } flush(); // "c" failed, try "w" instead. if (substr($mode, 0, 1) == "c" and file_exists($this->_file)) { $mode = "w"; } // conflict: wait some random time to unlock (see ethernet) $secs = 0.5 + (double) rand(1, 32767) / 32767; sleep($secs); $watchdog -= $secs; if (strlen($mode) == 2) { $mode = substr($mode, 0, -1); } } $ErrorManager->popErrorHandler(); if (!$dbh) { if ($error = $this->_dba_open_error) { $error->errno = E_USER_ERROR; $error->errstr .= "\nfile: " . $this->_file . "\nmode: " . $mode . "\nhandler: " . $this->_handler; $ErrorManager->handleError($error); } else { trigger_error("dba_open failed", E_USER_ERROR); } } $this->_dbh = $dbh; return !empty($dbh); }
function runCmd($command, $debug = false) { $nl = PHP_EOL; if (isWindows() && strpos(phpversion(), "5.2") !== false) { $command = "\"" . $command . "\""; } if ($debug) { echo '-Running Command: ' . $nl . ' ' . $command . $nl; } $output = array(); $status = 1; @exec($command, $output, $status); if ($debug) { echo '-Command Output: ' . $nl . ' ' . implode($nl . ' ', $output) . $nl; } return $output; }
function serverload($int = false) { if ($int == false) { $unknown = '-'; } else { $unknown = -1; } if (isWindows() == true) { return $unknown; } if (@file_exists("/proc/loadavg")) { $load = @file_get_contents("/proc/loadavg"); $serverload = explode(" ", $load); $serverload[0] = round($serverload[0], 4); } if (viscacha_function_exists('sys_getloadavg')) { $serverload = @sys_getloadavg(); } if (empty($serverload[0]) && viscacha_function_exists('exec') == true) { $load = @exec("uptime"); $load = preg_split("~load averages?: ~i", $load); if (isset($load[1])) { $serverload = explode(",", $load[1]); } } if (isset($serverload[0])) { $returnload = trim($serverload[0]); } if (empty($returnload)) { $returnload = $unknown; } return $returnload; }
function error_and_exit() { global $errors, $tikipath; $PHP_CONFIG_FILE_PATH = PHP_CONFIG_FILE_PATH; $httpd_conf = 'httpd.conf'; /* ob_start(); phpinfo (INFO_MODULES); if (preg_match('/Server Root<\/b><\/td><td\s+align="left">([^<]*)</', ob_get_contents(), $m)) { $httpd_conf = $m[1] . '/' . $httpd_conf; } ob_end_clean(); */ print "<html><body>\n<h2><IMG SRC=\"img/tiki/Tiki_WCG.png\" ALT=\"\" BORDER=0><br /\\>\n\t<font color='red'>Tiki Installer cannot proceed</font></h2>\n<pre>\n{$errors}"; if (!isWindows()) { print "<br /><br />Your options:\n\n\n1- With FTP access:\n\ta) Change the permissions (chmod) of the directories to 777.\n\tb) Create any missing directories\n\tc) <a href='tiki-install.php'>Execute the Tiki installer again</a> (Once you have executed these commands, this message will disappear!)\n\nor\n\n2- With shell (SSH) access, you can run the command below.\n\n\ta) To run setup.sh, follow the instructions:\n\t\t\$ cd {$tikipath}\n\t\t\$ sh setup.sh\n\n\t\tThe script will offer you options depending on your server configuration.\n\n\tb) <a href='tiki-install.php'>Execute the Tiki installer again</a> (Once you have executed these commands, this message will disappear!)\n\n\n<hr>\nIf you have problems accessing a directory, check the open_basedir entry in\n{$PHP_CONFIG_FILE_PATH}/php.ini or {$httpd_conf}.\n\n<hr>\n\n<a href='http://doc.tiki.org/Installation' target='_blank'>Consult the tiki.org installation guide</a> if you need more help or <a href='http://tiki.org/tiki-forums.php' target='_blank'>visit the forums</a>\n\n"; } print "</pre></body></html>"; exit; }
/** * The system-dependent path-separator character. On UNIX systems, * this character is ':'; on Win32 systems it is ';'. * Fixme: * On Mac it cannot be : because this is the seperator there! * * @access private * @return string path_separator. */ function _get_ini_separator() { return isWindows() ? ';' : ':'; // return preg_match('/^Windows/', php_uname()) }
public function glob($pattern, $handle = null) { $path = null; $output = null; if(isWindows() == true) { $slash='\\'; } else { $slash='/'; } $lastpos = strrpos($pattern, $slash); if($lastpos !== false) { $path = substr($pattern, 0, -$lastpos-1); $pattern = substr($pattern, $lastpos); } else { $path = getcwd(); } if(is_array($handle) && !empty($handle)) { while($dir = each($handle)) { if($this->glob_pattern_match($pattern, $dir)) { $output[] = $dir; } } } else { $handle = @opendir($path); if($handle === false) { return false; } while($dir = readdir($handle)) { if($this->glob_pattern_match($pattern, $dir)) { $output[] = $dir; } } closedir($handle); } if(is_array($output)) { return $output; } else { return false; } }
* Administrative actions: * [Watch] WatchPage - add a page, or delete watch handlers into the users * pref[notifyPages] slot. * My WatchList - view or edit list/regex of pref[notifyPages]. * EMailConfirm methods: send and verify * * Helper functions: * getPageChangeEmails * MailAdmin * ? handle emailed confirmation links (EmailSignup, ModeratedPage) * * @package MailNotify * @author Reini Urban */ if (!defined("MAILER_LOG")) { if (isWindows()) { define("MAILER_LOG", 'c:/wikimail.log'); } else { define("MAILER_LOG", '/var/log/wikimail.log'); } } class MailNotify { function MailNotify($pagename) { $this->pagename = $pagename; /* which page */ $this->emails = array(); /* to which addresses */ $this->userids = array(); /* corresponding array of displayed names,
function link($link, $linktext = false) { global $WikiTheme; list($moniker, $page) = explode(":", $link, 2); if (!isset($this->_map[$moniker])) { return HTML::span(array('class' => 'bad-interwiki'), $linktext ? $linktext : $link); } $url = $this->_map[$moniker]; // localize Upload:links for WIKIDUMP if (!empty($WikiTheme->DUMP_MODE) and $moniker == 'Upload') { global $request; include_once "lib/config.php"; $url = getUploadFilePath(); // calculate to a relative local path to /uploads for pdf images. $doc_root = $request->get("DOCUMENT_ROOT"); $ldir = NormalizeLocalFileName($url); $wikiroot = NormalizeLocalFileName(''); if (isWindows()) { $ldir = strtolower($ldir); $doc_root = strtolower($doc_root); $wikiroot = strtolower($wikiroot); } if (string_starts_with($ldir, $doc_root)) { $link_prefix = substr($url, strlen($doc_root)); } elseif (string_starts_with($ldir, $wikiroot)) { $link_prefix = NormalizeWebFileName(substr($url, strlen($wikiroot))); } } // Urlencode page only if it's a query arg. // FIXME: this is a somewhat broken heuristic. if ($moniker == 'Upload') { $page_enc = $page; $page = rawurldecode($page); } else { $page_enc = strstr($url, '?') ? rawurlencode($page) : $page; } if (strstr($url, '%s')) { $url = sprintf($url, $page_enc); } else { $url .= $page_enc; } $link = HTML::a(array('href' => $url)); if (!$linktext) { $link->pushContent(PossiblyGlueIconToText('interwiki', "{$moniker}:"), HTML::span(array('class' => 'wikipage'), $page)); $link->setAttr('class', 'interwiki'); } else { $link->pushContent(PossiblyGlueIconToText('interwiki', $linktext)); $link->setAttr('class', 'named-interwiki'); } return $link; }
function fixConfigIni($match, $new) { $file = FindFile("config/config.ini"); $found = false; if (is_writable($file)) { $in = fopen($file, "rb"); $out = fopen($tmp = tempnam(FindFile("uploads"), "cfg"), "wb"); if (isWindows()) { $tmp = str_replace("/", "\\", $tmp); } while ($s = fgets($in)) { if (preg_match($match, $s)) { $s = $new . (isWindows() ? "\r\n" : "\n"); $found = true; } fputs($out, $s); } fclose($in); fclose($out); if (!$found) { echo " <b><font color=\"red\">", _("FAILED"), "</font></b>: ", sprintf(_("%s not found"), $match); unlink($out); } else { @unlink("{$file}.bak"); @rename($file, "{$file}.bak"); if (rename($tmp, $file)) { echo " <b>", _("FIXED"), "</b>"; } else { echo " <b>", _("FAILED"), "</b>: "; sprintf(_("couldn't move %s to %s"), $tmp, $file); return false; } } return $found; } else { echo " <b><font color=\"red\">", _("FAILED"), "</font></b>: ", sprintf(_("%s is not writable"), $file); return false; } }
function getUploadedFile($postname) { global $HTTP_POST_FILES; // Against php5 with !ini_get('register-long-arrays'). See Bug #1180115 if (empty($HTTP_POST_FILES) and !empty($_FILES)) { $HTTP_POST_FILES =& $_FILES; } if (!isset($HTTP_POST_FILES[$postname])) { return false; } $fileinfo =& $HTTP_POST_FILES[$postname]; if ($fileinfo['error']) { // See https://sourceforge.net/forum/message.php?msg_id=3093651 $err = (int) $fileinfo['error']; // errmsgs by Shilad Sen switch ($err) { case 1: trigger_error(_("Upload error: file too big"), E_USER_WARNING); break; case 2: trigger_error(_("Upload error: file too big"), E_USER_WARNING); break; case 3: trigger_error(_("Upload error: file only partially recieved"), E_USER_WARNING); break; case 4: trigger_error(_("Upload error: no file selected"), E_USER_WARNING); break; default: trigger_error(_("Upload error: unknown error #") . $err, E_USER_WARNING); } return false; } // With windows/php 4.2.1 is_uploaded_file() always returns false. // Be sure that upload_tmp_dir ends with a slash! if (!is_uploaded_file($fileinfo['tmp_name'])) { if (isWindows()) { if (!($tmp_file = get_cfg_var('upload_tmp_dir'))) { $tmp_file = dirname(tempnam('', '')); } $tmp_file .= '/' . basename($fileinfo['tmp_name']); /* but ending slash in php.ini upload_tmp_dir is required. */ if (realpath(ereg_replace('/+', '/', $tmp_file)) != realpath($fileinfo['tmp_name'])) { trigger_error(sprintf("Uploaded tmpfile illegal: %s != %s.", $tmp_file, $fileinfo['tmp_name']) . "\n" . "Probably illegal TEMP environment or upload_tmp_dir setting.", E_USER_ERROR); return false; } else { /* trigger_error(sprintf("Workaround for PHP/Windows is_uploaded_file() problem for %s.", $fileinfo['tmp_name'])."\n". "Probably illegal TEMP environment or upload_tmp_dir setting.", E_USER_NOTICE); */ } } else { trigger_error(sprintf("Uploaded tmpfile %s not found.", $fileinfo['tmp_name']) . "\n" . " Probably illegal TEMP environment or upload_tmp_dir setting.", E_USER_WARNING); } } return new Request_UploadedFile($fileinfo); }
function ShellWhoAmI() { // By virtue of this small change this function needs to be renamed. // if (isWindows()) { // This will fail in IIS so run this from the command line. echo "Is windows\n"; return $this->zzArraySafe($_SERVER, "USERNAME", ""); } else { echo "Not windows\n"; return $this->ShellExec('whoami'); } }
function setPath() { $path = ini_get("include_path"); $base = substr(__FILE__, 0, strrpos(__FILE__, DIRECTORY_SEPARATOR)); $delimiter = ":"; if (isWindows()) { $delimiter = ";"; } /* add locations */ $path .= $delimiter . $base; $path .= $delimiter . $base . DIRECTORY_SEPARATOR . "admin"; $path .= $delimiter . $base . DIRECTORY_SEPARATOR . "custom"; $path .= $delimiter . $base . DIRECTORY_SEPARATOR . "display"; $path .= $delimiter . $base . DIRECTORY_SEPARATOR . "display" . DIRECTORY_SEPARATOR . "templates"; $path .= $delimiter . $base . DIRECTORY_SEPARATOR . "language"; $path .= $delimiter . $base . DIRECTORY_SEPARATOR . "templates"; /* update path */ ini_set("include_path", $path); }
function open($mode = 'w') { if ($this->_dbh) { return; } // already open. $watchdog = $this->_timeout; global $ErrorManager; $this->_dba_open_error = false; $ErrorManager->pushErrorHandler(new WikiMethodCb($this, '_dba_open_error_handler')); // oops, you don't have DBA support. if (!function_exists("dba_open")) { echo "You don't seem to have DBA support compiled into PHP."; } if (READONLY) { $mode = 'r'; } if (strlen($mode) == 1) { // PHP 4.3.x Windows lock bug workaround: http://bugs.php.net/bug.php?id=23975 if (isWindows()) { $mode .= "-"; // suppress locking, or } elseif ($this->_handler != 'gdbm') { // gdbm does it internally $mode .= "d"; // else use internal locking } } while (($dbh = dba_open($this->_file, $mode, $this->_handler)) < 1) { if ($watchdog <= 0) { break; } // "c" failed, try "w" instead. if ($mode == "w" and file_exists($this->_file) and (isWindows() or !is_writable($this->_file))) { // try to continue with read-only if (!defined("READONLY")) { define("READONLY", true); } $GLOBALS['request']->_dbi->readonly = true; $this->readonly = true; $mode = "r"; } if (substr($mode, 0, 1) == "c" and file_exists($this->_file) and !READONLY) { $mode = "w"; } // conflict: wait some random time to unlock (as with ethernet) $secs = 0.5 + (double) rand(1, 32767) / 32767; sleep($secs); $watchdog -= $secs; if (strlen($mode) == 2) { $mode = substr($mode, 0, -1); } } $ErrorManager->popErrorHandler(); if (!$dbh) { if ($error = $this->_dba_open_error) { $error->errno = E_USER_ERROR; $error->errstr .= "\nfile: " . $this->_file . "\nmode: " . $mode . "\nhandler: " . $this->_handler; // try to continue with read-only if (!defined("READONLY")) { define("READONLY", true); } $GLOBALS['request']->_dbi->readonly = true; $this->readonly = true; if (!file_exists($this->_file)) { $ErrorManager->handleError($error); flush(); } } else { trigger_error("dba_open failed", E_USER_ERROR); } } $this->_dbh = $dbh; return !empty($dbh); }
/** * Execute system command until the outfile $until exists. * * @param cmd string command to be invoked * @param until string expected output filename * @return boolean error status; true=ok; false=error */ function execute($cmd, $until = false) { // cmd must redirect stderr to stdout though! $errstr = exec($cmd); //, $outarr, $returnval); // normally 127 //$errstr = join('',$outarr); $ok = empty($errstr); if (!$ok) { trigger_error("\n" . $cmd . " failed: {$errstr}", E_USER_WARNING); } elseif ($GLOBALS['request']->getArg('debug')) { trigger_error("\n" . $cmd . ": success\n", E_USER_NOTICE); } if (!isWindows()) { if ($until) { $loop = 100000; while (!file_exists($until) and $loop > 0) { $loop -= 100; usleep(100); } } else { usleep(5000); } } if ($until) { return file_exists($until); } return $ok; }
function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter = true) { if (isWindows() == true) { // ----- Look for potential disk letter if ($p_remove_disk_letter && ($v_position = strpos($p_path, ':')) != false) { $p_path = substr($p_path, $v_position + 1); } // ----- Change potential windows directory separator if (strpos($p_path, '\\') > 0 || substr($p_path, 0, 1) == '\\') { $p_path = strtr($p_path, '\\', '/'); } } return $p_path; }
function text2png($args) { extract($args); /** * Basic image creation and caching * * You MUST delete the image cache yourself in /images if you * change the drawing routines! */ $filename = urlencode($text) . ".png"; // protect by urlencode!!! /** * FIXME: need something more elegant, and a way to gettext a * different language depending on any individual * user's locale preferences. */ if ($l == "C") { $l = "en"; //english=C } else { $l = urlencode($l); // who on earth forgot his? } $basedir = "text2png-image"; $filepath = getUploadFilePath() . "{$basedir}/{$l}"; if ($_force or !file_exists($filepath . $filename)) { if (!file_exists($filepath)) { $oldumask = umask(0); // permissions affected by user the www server is running as mkdir(getUploadFilePath() . $basedir, 0777); mkdir($filepath, 0777); umask($oldumask); } $filepath .= "/"; /** * prepare a new image * * FIXME: needs a dynamic image size depending on text * width and height */ // got this logic from GraphViz if (defined('TTFONT')) { $ttfont = TTFONT; } elseif (PHP_OS == "Darwin") { // Mac OS X $ttfont = "/System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Home/lib/fonts/LucidaSansRegular.ttf"; } elseif (isWindows()) { $ttfont = $_ENV['windir'] . '\\Fonts\\Arial.ttf'; } else { $ttfont = 'luximr'; // This is the only what sourceforge offered. //$ttfont = 'Helvetica'; } /* http://download.php.net/manual/en/function.imagettftext.php * array imagettftext (int im, int size, int angle, int x, int y, * int col, string fontfile, string text) */ // get ready to draw $s = ImageTTFBBox($fontsize, 0, $ttfont, $text); $im = @ImageCreate(abs($s[4]) + 20, abs($s[7]) + 10); if (empty($im)) { $error_html = _("PHP was unable to create a new GD image stream. Read 'lib/plugin/text2png.php' for details."); // FIXME: Error manager does not transform URLs passed // through it. $link = "http://www.php.net/manual/en/function.imagecreate.php"; $error_html .= sprintf(_("See %s"), $link) . "."; trigger_error($error_html, E_USER_NOTICE); return; } $rgb = $this->hexcolor($backcolor, array(255, 255, 255)); $bg_color = ImageColorAllocate($im, $rgb[0], $rgb[1], $rgb[2]); if ($with_shadow) { $rgb = $this->hexcolor($shadowcolor, array(175, 175, 175)); $text_color = ImageColorAllocate($im, $rgb[0], $rgb[1], $rgb[2]); // shadow is 1 pixel down and 2 pixels right ImageTTFText($im, $fontsize, 0, 12, abs($s[7]) + 6, $text_color, $ttfont, $text); } // draw text $rgb = $this->hexcolor($fontcolor, array(0, 0, 0)); $text_color = ImageColorAllocate($im, $rgb[0], $rgb[1], $rgb[2]); ImageTTFText($im, $fontsize, 0, 10, abs($s[7]) + 5, $text_color, $ttfont, $text); /** * An alternate text drawing method in case ImageTTFText * doesn't work. **/ //ImageString($im, 2, 10, 40, $text, $text_color); // To dump directly to browser: //header("Content-type: image/png"); //ImagePng($im); // to save to file: $success = ImagePng($im, $filepath . $filename); } else { $filepath .= "/"; $success = 2; } // create an <img src= tag to show the image! $html = HTML(); if ($success > 0) { if (defined('text2png_debug')) { switch ($success) { case 1: trigger_error(sprintf(_("Image saved to cache file: %s"), $filepath . $filename), E_USER_NOTICE); case 2: trigger_error(sprintf(_("Image loaded from cache file: %s"), $filepath . $filename), E_USER_NOTICE); } } $url = getUploadDataPath() . "{$basedir}/" . urlencode($l) . "/" . urlencode($filename); $html->pushContent(HTML::img(array('src' => $url, 'alt' => $text, 'title' => '"' . $text . '"' . _(" produced by ") . $this->getName()))); } else { trigger_error(sprintf(_("couldn't open file '%s' for writing"), $filepath . $filename), E_USER_NOTICE); } return $html; }
function fileSet($directory, $filepattern = false) { $this->_fileList = array(); $this->_pattern = $filepattern; if ($filepattern) { $this->_pcre_pattern = glob_to_pcre($this->_pattern); } $this->_case = !isWindows(); $this->_pathsep = '/'; if (empty($directory)) { trigger_error(sprintf(_("%s is empty."), 'directoryname'), E_USER_NOTICE); return; // early return } @($dir_handle = opendir($dir = $directory)); if (empty($dir_handle)) { trigger_error(sprintf(_("Unable to open directory '%s' for reading"), $dir), E_USER_NOTICE); return; // early return } while ($filename = readdir($dir_handle)) { if ($filename[0] == '.' || filetype($dir . $this->_pathsep . $filename) != 'file') { continue; } if ($this->_filenameSelector($filename)) { array_push($this->_fileList, "{$filename}"); //trigger_error(sprintf(_("found file %s"), $filename), // E_USER_NOTICE); //debugging } } closedir($dir_handle); }
</th> <th class="colDelete"> </th> </tr> </thead> <tbody> </tbody> </table> </div> <?php } if (ZM_WEB_SOUND_ON_ALARM) { $soundSrc = ZM_DIR_SOUNDS . '/' . ZM_WEB_ALARM_SOUND; ?> <div id="alarmSound" class="hidden"> <?php if (ZM_WEB_USE_OBJECT_TAGS && isWindows()) { ?> <object id="MediaPlayer" width="0" height="0" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902"> <param name="FileName" value="<?php echo $soundSrc; ?> "/> <param name="autoStart" value="0"/> <param name="loop" value="1"/> <param name="hidden" value="1"/> <param name="showControls" value="0"/> <embed src="<?php echo $soundSrc; ?>
/** * Retrieve all pages. * * Gets the set of all pages with non-default contents. * * @access public * * @param boolean $include_defaulted Normally pages whose most * recent revision has empty content are considered to be * non-existant. Unless $include_defaulted is set to true, those * pages will not be returned. * * @return WikiDB_PageIterator A WikiDB_PageIterator which contains all pages * in the WikiDB which have non-default contents. */ function getAllPages($include_empty = false, $sortby = false, $limit = false, $exclude = false) { // HACK: memory_limit=8M will fail on too large pagesets. old php on unix only! if (USECACHE) { $mem = ini_get("memory_limit"); if ($mem and !$limit and !isWindows() and !check_php_version(4, 3)) { $limit = 450; $GLOBALS['request']->setArg('limit', $limit); $GLOBALS['request']->setArg('paging', 'auto'); } } $result = $this->_backend->get_all_pages($include_empty, $sortby, $limit, $exclude); return new WikiDB_PageIterator($this, $result, array('include_empty' => $include_empty, 'exclude' => $exclude, 'limit' => $limit)); }
/** * The user has requested that we download the latest * version of each application from its respective * * */ function mainPull() { # Don't hold up the system Session_write_close(); $rows = svnVersions(); $dir = fsDirTop() . 'pkg-apps/'; x_echoFlush('<pre>'); x_EchoFlush('<h2>Pulling Software Updates From SVN</h2>'); // Loop through the apps. foreach ($rows as $row) { x_EchoFlush(""); x_echoFlush("<b>Application: " . $row['application'] . "</b>"); if ($row['svn_url'] == '') { x_echoFlush(" No SVN repository, skipping."); continue; } # Add a trailing slash to svn_url $row['svn_url'] = AddSlash(trim($row['svn_url'])); # If there is a username and password both, use those $urlDisplay = $row['svn_url']; $url = $row['svn_url']; if ($row['svn_uid'] != '' && $row['svn_pwd'] != '') { list($proto, $urlstub) = explode("//", $url); $uid = $row['svn_uid']; $pwd = $row['svn_pwd']; $url = "{$proto}//{$uid}:{$pwd}@{$urlstub}"; $urlDisplay = "{$proto}//{$uid}:*****@{$urlstub}"; } x_echoFlush(" Complete URL: " . $urlDisplay); # Now pull the list of versions x_echoFlush(" Querying for latest version"); $rawtext = @file_get_contents($url); if ($rawtext) { $matches = array(); preg_match_all('!\\<li\\>\\<a.*\\>(.*)\\</a\\>\\</li\\>!U', $rawtext, $matches); $versions = $matches[1]; foreach ($versions as $key => $version) { if ($version == '..') { unset($versions[$key]); } } if (count($versions) == 0) { x_EchoFlush(" No versions listed, nothing to pull."); continue; } } else { x_EchoFlush("Unable to get a release list from the svn server."); continue; } # Work out what the latest was and report it $latest = array_pop($versions); if (substr($latest, -1) == '/') { $latest = substr($latest, 0, strlen($latest) - 1); } x_echoFlush(" Latest version is: " . $latest); x_EchoFlush(" Local version is: " . $row['local']); # Decide if we need to continue if ($latest == $row['local']) { x_EchoFlush(" Local version is latest, nothing do to."); continue; } # Determine some stub values and pass processing to # the recursive file puller. If no uid & pwd, use subversion x_EchoFlush(" Local version is out of date, pulling latest"); $dirv = $dir . trim($row['application']) . '-VER-' . $latest . '/'; if ($row['svn_uid'] != '' && $row['svn_pwd'] != '') { mkdir($dirv); $this->svnWalk("{$url}/{$latest}/", $dirv); } else { $command = "svn export {$url}{$latest} {$dirv}"; x_echoFlush(" Pulling code now, this make take a minute or three..."); x_EchoFlush($command); `{$command}`; x_echoFlush(" Code pulled, finished with this application."); } x_echoFlush(" Copying files into application directory"); $basedir = str_replace('andro/', '', fsDirTop()); if (isWindows()) { $command = 'xcopy /y /e /c /k /o ' . $dirv . '* ' . $basedir . trim($row['application']) . '/'; } else { $command2 = 'cp -Rf ' . $dirv . '* ' . $basedir . trim($row['application']) . '/'; } echo $command2; `{$command2}`; } x_echoFlush("<hr/>"); x_EchoFlush("<h3>Processing Complete</h3>"); $this->flag_buffer = false; }
function exeversion($file) { if (!isWindows()) { return "?"; } if (class_exists('ffi') or loadPhpExtension('ffi')) { return $this->exeversion_ffi($file); } if (function_exists('res_list_type') or loadPhpExtension('win32std')) { return $this->exeversion_resopen($file); } return exeversion_showver($file); return ''; }
function _DumpHtmlToDir($target, $page_iter, $exclude = false) { global $WikiTheme, $request, $ErrorManager; $silent = true; $zip = false; $directory = false; if ($WikiTheme->DUMP_MODE == 'HTML') { $directory = $target; $silent = false; } elseif ($WikiTheme->DUMP_MODE == 'PDFHTML') { $directory = $target; } elseif (is_object($target)) { // $WikiTheme->DUMP_MODE == 'ZIPHTML' $zip = $target; } $request->_TemplatesProcessed = array(); if ($exclude) { // exclude which pagenames $excludeList = explodePageList($exclude); } else { $excludeList = array('DebugAuthInfo', 'DebugGroupInfo', 'AuthInfo'); } $WikiTheme->VALID_LINKS = array(); if ($request->getArg('format')) { // pagelist $page_iter_sav = $page_iter; foreach ($page_iter_sav->asArray() as $handle) { $WikiTheme->VALID_LINKS[] = is_string($handle) ? $handle : $handle->getName(); } $page_iter_sav->reset(); } if (defined('HTML_DUMP_SUFFIX')) { $WikiTheme->HTML_DUMP_SUFFIX = HTML_DUMP_SUFFIX; } $_bodyAttr = @$WikiTheme->_MoreAttr['body']; unset($WikiTheme->_MoreAttr['body']); $ErrorManager->pushErrorHandler(new WikiFunctionCb('_dump_error_handler')); // check if the dumped file will be accessible from outside $doc_root = $request->get("DOCUMENT_ROOT"); if ($WikiTheme->DUMP_MODE == 'HTML') { $ldir = NormalizeLocalFileName($directory); $wikiroot = NormalizeLocalFileName(''); if (string_starts_with($ldir, $doc_root)) { $link_prefix = substr($directory, strlen($doc_root)) . "/"; } elseif (string_starts_with($ldir, $wikiroot)) { $link_prefix = NormalizeWebFileName(substr($directory, strlen($wikiroot))) . "/"; } else { $prefix = ''; if (isWindows()) { $prefix = '/'; // . substr($doc_root,0,2); // add drive where apache is installed } $link_prefix = "file://" . $prefix . $directory . "/"; } } else { $link_prefix = ""; } $request_args = $request->args; $timeout = !$request->getArg('start_debug') ? 60 : 240; if ($directory) { if (isWindows()) { $directory = str_replace("\\", "/", $directory); } // no Win95 support. @mkdir("{$directory}/images"); } $already = array(); $outfiles = array(); $already_images = array(); while ($page = $page_iter->next()) { if (is_string($page)) { $pagename = $page; $page = $request->_dbi->getPage($pagename); } else { $pagename = $page->getName(); } if (empty($firstpage)) { $firstpage = $pagename; } if (array_key_exists($pagename, $already)) { continue; } $already[$pagename] = 1; $current = $page->getCurrentRevision(); //if ($current->getVersion() == 0) // continue; $request->args = $request_args; // some plugins might change them (esp. on POST) longer_timeout($timeout); // Reset watchdog if ($zip) { $attrib = array('mtime' => $current->get('mtime'), 'is_ascii' => 1); if ($page->get('locked')) { $attrib['write_protected'] = 1; } } elseif (!$silent) { if (!isa($request, 'MockRequest')) { PrintXML(HTML::br(), $pagename, ' ... '); flush(); } } if (in_array($pagename, $excludeList)) { if (!$silent and !isa($request, 'MockRequest')) { PrintXML(_("Skipped.")); flush(); } continue; } $relative_base = ''; if ($WikiTheme->DUMP_MODE == 'PDFHTML') { $request->setArg('action', 'pdf'); } // to omit cache headers $request->setArg('pagename', $pagename); // Template::_basepage fix $filename = FilenameForPage($pagename) . $WikiTheme->HTML_DUMP_SUFFIX; $args = array('revision' => $current, 'CONTENT' => $current->getTransformedContent(), 'relative_base' => $relative_base); // For every %2F will need to mkdir -p dirname($pagename) if (preg_match("/(%2F|\\/)/", $filename)) { // mkdir -p and set relative base for subdir pages $filename = preg_replace("/%2F/", "/", $filename); $count = substr_count($filename, "/"); $dirname = dirname($filename); if ($directory) { mkdir_p($directory . "/" . $dirname); } // Fails with "XX / YY", "XX" is created, "XX / YY" cannot be written // if (isWindows()) // interesting Windows bug: cannot mkdir "bla " // Since dumps needs to be copied, we have to disallow this for all platforms. $filename = preg_replace("/ \\//", "/", $filename); $relative_base = "../"; while ($count > 1) { $relative_base .= "../"; $count--; } $args['relative_base'] = $relative_base; } $msg = HTML(); $DUMP_MODE = $WikiTheme->DUMP_MODE; $data = GeneratePageasXML(new Template('browse', $request, $args), $pagename, $current, $args); $WikiTheme->DUMP_MODE = $DUMP_MODE; if (preg_match_all("/<img .*?src=\"(\\/.+?)\"/", $data, $m)) { // fix to local relative path for uploaded images, so that pdf will work foreach ($m[1] as $img_file) { $base = basename($img_file); $data = str_replace('src="' . $img_file . '"', 'src="images/' . $base . '"', $data); if (array_key_exists($img_file, $already_images)) { continue; } $already_images[$img_file] = 1; // resolve src from webdata to file $src = $doc_root . $img_file; if (file_exists($src) and $base) { if ($directory) { $target = "{$directory}/images/{$base}"; if (copy($src, $target)) { if (!$silent) { _copyMsg($img_file, fmt("... copied to %s", $target)); } } else { if (!$silent) { _copyMsg($img_file, fmt("... not copied to %s", $target)); } } } else { $target = "images/{$base}"; $zip->addSrcFile($target, $src); } } } } if ($directory) { $outfile = $directory . "/" . $filename; if (!($fd = fopen($outfile, "wb"))) { $msg->pushContent(HTML::strong(fmt("couldn't open file '%s' for writing", $outfile))); $request->finish($msg); } $len = strlen($data); $num = fwrite($fd, $data, $len); if ($pagename != $filename) { $link = LinkURL($link_prefix . $filename, $filename); $msg->pushContent(HTML::small(_("saved as "), $link, " ... ")); } $msg->pushContent(HTML::small(fmt("%s bytes written", $num), "\n")); if (!$silent) { if (!isa($request, 'MockRequest')) { PrintXML($msg); } flush(); $request->chunkOutput(); } assert($num == $len); fclose($fd); $outfiles[] = $outfile; } else { $zip->addRegularFile($filename, $data, $attrib); } if (USECACHE) { $request->_dbi->_cache->invalidate_cache($pagename); unset($request->_dbi->_cache->_pagedata_cache); unset($request->_dbi->_cache->_versiondata_cache); unset($request->_dbi->_cache->_glv_cache); } unset($request->_dbi->_cache->_backend->_page_data); unset($msg); unset($current->_transformedContent); unset($current); if (!empty($template)) { unset($template->_request); unset($template); } unset($data); } $page_iter->free(); $attrib = false; //array('is_ascii' => 0); if (!empty($WikiTheme->dumped_images) and is_array($WikiTheme->dumped_images)) { // @mkdir("$directory/images"); foreach ($WikiTheme->dumped_images as $img_file) { if (array_key_exists($img_file, $already_images)) { continue; } $already_images[$img_file] = 1; if ($img_file and $from = $WikiTheme->_findFile($img_file, true) and basename($from)) { if ($directory) { $target = "{$directory}/images/" . basename($from); if ($silent) { copy($WikiTheme->_path . $from, $target); } else { if (copy($WikiTheme->_path . $from, $target)) { _copyMsg($from, fmt("... copied to %s", $target)); } else { _copyMsg($from, fmt("... not copied to %s", $target)); } } } else { $target = "images/" . basename($from); $zip->addSrcFile($target, $WikiTheme->_path . $from); } } elseif (!$silent) { _copyMsg($from, _("... not found")); } } } if (!empty($WikiTheme->dumped_buttons) and is_array($WikiTheme->dumped_buttons)) { // Buttons also if ($directory) { @mkdir("{$directory}/images/buttons"); } foreach ($WikiTheme->dumped_buttons as $text => $img_file) { if (array_key_exists($img_file, $already_images)) { continue; } $already_images[$img_file] = 1; if ($img_file and $from = $WikiTheme->_findFile($img_file, true) and basename($from)) { if ($directory) { $target = "{$directory}/images/buttons/" . basename($from); if ($silent) { copy($WikiTheme->_path . $from, $target); } else { if (copy($WikiTheme->_path . $from, $target)) { _copyMsg($from, fmt("... copied to %s", $target)); } else { _copyMsg($from, fmt("... not copied to %s", $target)); } } } else { $target = "images/buttons/" . basename($from); $zip->addSrcFile($target, $WikiTheme->_path . $from); } } elseif (!$silent) { _copyMsg($from, _("... not found")); } } } if (!empty($WikiTheme->dumped_css) and is_array($WikiTheme->dumped_css)) { foreach ($WikiTheme->dumped_css as $css_file) { if (array_key_exists($css_file, $already_images)) { continue; } $already_images[$css_file] = 1; if ($css_file and $from = $WikiTheme->_findFile(basename($css_file), true) and basename($from)) { // TODO: fix @import url(main.css); if ($directory) { $target = "{$directory}/" . basename($css_file); if ($silent) { copy($WikiTheme->_path . $from, $target); } else { if (copy($WikiTheme->_path . $from, $target)) { _copyMsg($from, fmt("... copied to %s", $target)); } else { _copyMsg($from, fmt("... not copied to %s", $target)); } } } else { //$attrib = array('is_ascii' => 0); $target = basename($css_file); $zip->addSrcFile($target, $WikiTheme->_path . $from); } } elseif (!$silent) { _copyMsg($from, _("... not found")); } } } if ($zip) { $zip->finish(); } if ($WikiTheme->DUMP_MODE == 'PDFHTML') { if (USE_EXTERNAL_HTML2PDF and $outfiles) { $cmd = EXTERNAL_HTML2PDF_PAGELIST . ' "' . join('" "', $outfiles) . '"'; $filename = FilenameForPage($firstpage); if (DEBUG) { $tmpfile = $directory . "/createpdf.bat"; $fp = fopen($tmpfile, "wb"); fwrite($fp, $cmd . " > {$filename}.pdf"); fclose($fp); } if (!headers_sent()) { Header('Content-Type: application/pdf'); passthru($cmd); } else { $tmpdir = getUploadFilePath(); $s = passthru($cmd . " > {$tmpdir}/{$filename}.pdf"); $errormsg = "<br />\nGenerated <a href=\"" . getUploadDataPath() . "{$filename}.pdf\">Upload:{$filename}.pdf</a>\n"; $errormsg .= $s; echo $errormsg; } if (!DEBUG) { foreach ($outfiles as $f) { unlink($f); } } } if (!empty($errormsg)) { $request->discardOutput(); $GLOBALS['ErrorManager']->_postponed_errors = array(); } } $ErrorManager->popErrorHandler(); $WikiTheme->HTML_DUMP_SUFFIX = ''; $WikiTheme->DUMP_MODE = false; $WikiTheme->_MoreAttr['body'] = $_bodyAttr; }
/** * Dump all pages as XHTML to a directory, as pagename.html. * Copies all used css files to the directory, all used images to a * "images" subdirectory, and all used buttons to a "images/buttons" subdirectory. * The webserver must have write permissions to these directories. * chown httpd HTML_DUMP_DIR; chmod u+rwx HTML_DUMP_DIR * should be enough. * * @param string directory (optional) path to dump to. Default: HTML_DUMP_DIR * @param string pages (optional) Comma-seperated of glob-style pagenames to dump * @param string exclude (optional) Comma-seperated of glob-style pagenames to exclude */ function DumpHtmlToDir(&$request) { $directory = $request->getArg('directory'); if (empty($directory)) { $directory = HTML_DUMP_DIR; } // See lib/plugin/WikiForm.php:87 if (empty($directory)) { $request->finish(_("You must specify a directory to dump to")); } // see if we can access the directory the user wants us to use if (!file_exists($directory)) { if (!mkdir($directory, 0755)) { $request->finish(fmt("Cannot create directory '%s'", $directory)); } else { $html = HTML::p(fmt("Created directory '%s' for the page dump...", $directory)); } } else { $html = HTML::p(fmt("Using directory '%s'", $directory)); } $request->_TemplatesProcessed = array(); StartLoadDump($request, _("Dumping Pages"), $html); $thispage = $request->getArg('pagename'); // for "Return to ..." $dbi =& $request->_dbi; if ($exclude = $request->getArg('exclude')) { // exclude which pagenames $excludeList = explodePageList($exclude); } else { $excludeList = array(); } if ($pages = $request->getArg('pages')) { // which pagenames if ($pages == '[]') { // current page $pages = $thispage; } $page_iter = new WikiDB_Array_PageIterator(explodePageList($pages)); // not at admin page: dump only the current page } elseif ($thispage != _("PhpWikiAdministration")) { $page_iter = new WikiDB_Array_PageIterator(array($thispage)); } else { $page_iter = $dbi->getAllPages(false, false, false, $excludeList); } global $WikiTheme; if (defined('HTML_DUMP_SUFFIX')) { $WikiTheme->HTML_DUMP_SUFFIX = HTML_DUMP_SUFFIX; } $WikiTheme->DUMP_MODE = 'HTML'; $_bodyAttr = @$WikiTheme->_MoreAttr['body']; unset($WikiTheme->_MoreAttr['body']); // check if the dumped file will be accessible from outside $doc_root = $request->get("DOCUMENT_ROOT"); $ldir = NormalizeLocalFileName($directory); $wikiroot = NormalizeLocalFileName(''); if (string_starts_with($ldir, $doc_root)) { $link_prefix = substr($directory, strlen($doc_root)) . "/"; } elseif (string_starts_with($ldir, $wikiroot)) { $link_prefix = NormalizeWebFileName(substr($directory, strlen($wikiroot))) . "/"; } else { $prefix = ''; if (isWindows()) { $prefix = '/' . substr($doc_root, 0, 2); // add drive where apache is installed } $link_prefix = "file://" . $prefix . $directory . "/"; } $request_args = $request->args; $timeout = !$request->getArg('start_debug') ? 20 : 240; while ($page = $page_iter->next()) { $request->args = $request_args; // some plugins might change them (esp. on POST) longer_timeout($timeout); // Reset watchdog $pagename = $page->getName(); if (!isa($request, 'MockRequest')) { PrintXML(HTML::br(), $pagename, ' ... '); flush(); } if (in_array($pagename, $excludeList)) { if (!isa($request, 'MockRequest')) { PrintXML(_("Skipped.")); flush(); } continue; } $request->setArg('pagename', $pagename); // Template::_basepage fix $filename = FilenameForPage($pagename) . $WikiTheme->HTML_DUMP_SUFFIX; $msg = HTML(); $revision = $page->getCurrentRevision(); $template = new Template('browse', $request, array('revision' => $revision, 'CONTENT' => $revision->getTransformedContent())); $data = GeneratePageasXML($template, $pagename); if (!($fd = fopen($directory . "/" . $filename, "wb"))) { $msg->pushContent(HTML::strong(fmt("couldn't open file '%s' for writing", "{$directory}/{$filename}"))); $request->finish($msg); } $num = fwrite($fd, $data, strlen($data)); if ($page->getName() != $filename) { $link = LinkURL($link_prefix . $filename, $filename); $msg->pushContent(HTML::small(_("saved as "), $link, " ... ")); } $msg->pushContent(HTML::small(fmt("%s bytes written", $num), "\n")); if (!isa($request, 'MockRequest')) { PrintXML($msg); } flush(); $request->chunkOutput(); assert($num == strlen($data)); fclose($fd); if (USECACHE) { $request->_dbi->_cache->invalidate_cache($pagename); unset($request->_dbi->_cache->_pagedata_cache); unset($request->_dbi->_cache->_versiondata_cache); unset($request->_dbi->_cache->_glv_cache); } unset($request->_dbi->_cache->_backend->_page_data); unset($msg); unset($revision->_transformedContent); unset($revision); unset($template->_request); unset($template); unset($data); } $page_iter->free(); if (!empty($WikiTheme->dumped_images) and is_array($WikiTheme->dumped_images)) { @mkdir("{$directory}/images"); foreach ($WikiTheme->dumped_images as $img_file) { if ($img_file and $from = $WikiTheme->_findFile($img_file, true) and basename($from)) { $target = "{$directory}/images/" . basename($img_file); if (copy($WikiTheme->_path . $from, $target)) { _copyMsg($from, fmt("... copied to %s", $target)); } else { _copyMsg($from, fmt("... not copied to %s", $target)); } } else { _copyMsg($from, _("... not found")); } } } if (!empty($WikiTheme->dumped_buttons) and is_array($WikiTheme->dumped_buttons)) { // Buttons also @mkdir("{$directory}/images/buttons"); foreach ($WikiTheme->dumped_buttons as $text => $img_file) { if ($img_file and $from = $WikiTheme->_findFile($img_file, true) and basename($from)) { $target = "{$directory}/images/buttons/" . basename($img_file); if (copy($WikiTheme->_path . $from, $target)) { _copyMsg($from, fmt("... copied to %s", $target)); } else { _copyMsg($from, fmt("... not copied to %s", $target)); } } else { _copyMsg($from, _("... not found")); } } } if (!empty($WikiTheme->dumped_css) and is_array($WikiTheme->dumped_css)) { foreach ($WikiTheme->dumped_css as $css_file) { if ($css_file and $from = $WikiTheme->_findFile(basename($css_file), true) and basename($from)) { $target = "{$directory}/" . basename($css_file); if (copy($WikiTheme->_path . $from, $target)) { _copyMsg($from, fmt("... copied to %s", $target)); } else { _copyMsg($from, fmt("... not copied to %s", $target)); } } else { _copyMsg($from, _("... not found")); } } } $WikiTheme->HTML_DUMP_SUFFIX = ''; $WikiTheme->DUMP_MODE = false; $WikiTheme->_MoreAttr['body'] = $_bodyAttr; $request->setArg('pagename', $thispage); // Template::_basepage fix EndLoadDump($request); }
/** * Constructor * * @param object $request The global WikiRequest object. */ function GroupLdap() { //$this->request = &$GLOBALS['request']; $this->username = $this->_getUserName(); $this->membership = array(); if (!defined("LDAP_AUTH_HOST")) { trigger_error(sprintf(_("%s not defined"), "LDAP_AUTH_HOST"), E_USER_WARNING); return false; } // We should ignore multithreaded environments, not generally windows. // CGI does work. if (!function_exists('ldap_connect') and (!isWindows() or isCGI())) { // on MacOSX >= 4.3 you'll need PHP_SHLIB_SUFFIX instead. dl("ldap" . defined('PHP_SHLIB_SUFFIX') ? PHP_SHLIB_SUFFIX : DLL_EXT); if (!function_exists('ldap_connect')) { trigger_error(_("No LDAP in this PHP version"), E_USER_WARNING); return false; } } if (!defined("LDAP_BASE_DN")) { define("LDAP_BASE_DN", ''); } $this->base_dn = LDAP_BASE_DN; // if no users ou (organizational unit) is defined, // then take out the ou= from the base_dn (if exists) and append a default // from users and group if (!LDAP_OU_USERS) { if (strstr(LDAP_BASE_DN, "ou=")) { $this->base_dn = preg_replace("/(ou=\\w+,)?()/", "\$2", LDAP_BASE_DN); } } if (!isset($this->user) or !isa($this->user, '_LDAPPassUser')) { $this->_user = new _LDAPPassUser('LdapGroupTest'); } else { $this->_user =& $this->user; } }
/** * getDocRoot fixes a problem with Windows where PHP does not have $_SERVER['DOCUMENT_ROOT'] * built in. getDocRoot returns what $_SERVER['DOCUMENT_ROOT'] should have. It should work on * other builds, such as Unix, but is best used with Windows. There are two return cases for * Windows, one is the document root for the server's web files (c:/inetpub/wwwroot), the * other version is the first folder beyond that point (if documents are stored in user folders). * * @author Allan Bogh - Buckwheat469@hotmail.com * @version 1.0 - based on research on www.helicron.net/php * * @param $folderFix - This optional parameter tells the function to include the first folder in * the return (c:/inetpub/wwwroot/userfolder instead of c:/inetpub/wwwroot). * Set to true if folder should be returned. * @return The document root string. **/ function getDocumentRoot() { //sets up the localpath $localpath = getenv("SCRIPT_NAME"); $localpath = substr($localpath, strpos($localpath, '/', iif(strlen($localpath) >= 1, 1, 0)), strlen($localpath)); //realpath sometimes doesn't work, but gets the full path of the file $absolutepath = realpath($localpath); if ((!isset($absolutepath) || $absolutepath == "") && isset($_SERVER['ORIG_PATH_TRANSLATED'])) { $absolutepath = $_SERVER['ORIG_PATH_TRANSLATED']; } //checks if Windows is being used to replace the \ to / if (isWindows() == true) { $absolutepath = str_replace("\\", "/", $absolutepath); } //prepares the document root string $docroot = substr($absolutepath, 0, strpos($absolutepath, $localpath)); return $docroot; }
function outputVideoStream($id, $src, $width, $height, $format, $title = "") { if (file_exists($src)) { $mimeType = getMimeType($src); } else { switch ($format) { case 'asf': $mimeType = "video/x-ms-asf"; break; case 'avi': case 'wmv': $mimeType = "video/x-msvideo"; break; case 'mov': $mimeType = "video/quicktime"; break; case 'mpg': case 'mpeg': $mimeType = "video/mpeg"; break; case 'swf': $mimeType = "application/x-shockwave-flash"; break; case '3gp': $mimeType = "video/3gpp"; break; default: $mimeType = "video/{$format}"; break; } } if (!$mimeType || $mimeType == 'application/octet-stream') { $mimeType = 'video/' . $format; } $objectTag = false; if (ZM_WEB_USE_OBJECT_TAGS) { switch ($mimeType) { case "video/x-ms-asf": case "video/x-msvideo": case "video/mp4": if (isWindows()) { ?> <object id="<?php echo $id; ?> " width="<?php echo validNum($width); ?> " height="<?php echo validNum($height); ?> " classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,902" standby="Loading Microsoft Windows Media Player components..." type="<?php echo $mimeType; ?> "> <param name="FileName" value="<?php echo $src; ?> "/> <param name="autoStart" value="1"/> <param name="showControls" value="0"/> <embed type="<?php echo $mimeType; ?> " pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="<?php echo $src; ?> " name="<?php echo validHtmlStr($title); ?> " width="<?php echo validNum($width); ?> " height="<?php echo validInt($height); ?> " autostart="1" showcontrols="0"> </embed> </object> <?php $objectTag = true; } break; case "video/quicktime": ?> <object id="<?php echo $id; ?> " width="<?php echo $width; ?> " height="<?php echo $height; ?> " classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" type="<?php echo $mimeType; ?> "> <param name="src" value="<?php echo $src; ?> "/> <param name="autoplay" VALUE="true"/> <param name="controller" VALUE="false"/> <embed type="<?php echo $mimeType; ?> " src="<?php echo $src; ?> " pluginspage="http://www.apple.com/quicktime/download/" name="<?php echo validHtmlStr($title); ?> " width="<?php echo validInt($width); ?> " height="<?php echo validInt($height); ?> " autoplay="true" controller="true"> </embed> </object> <?php $objectTag = true; break; case "application/x-shockwave-flash": ?> <object id="<?php echo $id; ?> " width="<?php echo $width; ?> " height="<?php echo $height; ?> " classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" type="<?php echo $mimeType; ?> "> <param name="movie" value="<?php echo $src; ?> "/> <param name="quality" value="high"/> <param name="bgcolor" value="#ffffff"/> <embed type="<?php echo $mimeType; ?> " pluginspage="http://www.macromedia.com/go/getflashplayer" src="<?php echo $src; ?> " name="<?php echo validHtmlStr($title); ?> " width="<?php echo validInt($width); ?> " height="<?php echo validInt($height); ?> " quality="high" bgcolor="#ffffff"> </embed> </object> <?php $objectTag = true; break; } } if (!$objectTag) { ?> <embed<?php echo isset($mimeType) ? ' type="' . $mimeType . '"' : ""; ?> src="<?php echo $src; ?> " name="<?php echo validHtmlStr($title); ?> " width="<?php echo validInt($width); ?> " height="<?php echo validInt($height); ?> " autostart="1" autoplay="1" showcontrols="0" controller="0"> </embed> <?php } }
function glob_regexp($pattern, $probe) { return isWindows() != true ? ereg($pattern, $probe) : eregi($pattern, $probe); }
function glob_regexp($pattern, $probe) { return isWindows() != true ? preg_match("~{$pattern}~", $probe) : preg_match("~{$pattern}~i", $probe); }
/** Check for valid email address fixed version from http://www.zend.com/zend/spotlight/ev12apr.php Note: too strict, Bug #1053681 */ function ValidateMail($email, $noconnect = false) { global $EMailHosts; $HTTP_HOST = $GLOBALS['request']->get('HTTP_HOST'); // if this check is too strict (like invalid mail addresses in a local network only) // uncomment the following line: //return array(true,"not validated"); // see http://sourceforge.net/tracker/index.php?func=detail&aid=1053681&group_id=6121&atid=106121 $result = array(); // This is Paul Warren's (pdw@ex-parrot.com) monster regex for RFC822 // addresses, from the Perl module Mail::RFC822::Address, reduced to // accept single RFC822 addresses without comments only. (The original // accepts groups and properly commented addresses also.) $lwsp = "(?:(?:\\r\\n)?[ \\t])"; $specials = '()<>@,;:\\\\".\\[\\]'; $controls = '\\000-\\031'; $dtext = "[^\\[\\]\\r\\\\]"; $domain_literal = "\\[(?:{$dtext}|\\\\.)*\\]{$lwsp}*"; $quoted_string = "\"(?:[^\\\"\\r\\\\]|\\\\.|{$lwsp})*\"{$lwsp}*"; $atom = "[^{$specials} {$controls}]+(?:{$lwsp}+|\\Z|(?=[\\[\"{$specials}]))"; $word = "(?:{$atom}|{$quoted_string})"; $localpart = "{$word}(?:\\.{$lwsp}*{$word})*"; $sub_domain = "(?:{$atom}|{$domain_literal})"; $domain = "{$sub_domain}(?:\\.{$lwsp}*{$sub_domain})*"; $addr_spec = "{$localpart}\\@{$lwsp}*{$domain}"; $phrase = "{$word}*"; $route = "(?:\\@{$domain}(?:,\\@{$lwsp}*{$domain})*:{$lwsp}*)"; $route_addr = "\\<{$lwsp}*{$route}?{$addr_spec}\\>{$lwsp}*"; $mailbox = "(?:{$addr_spec}|{$phrase}{$route_addr})"; $rfc822re = "/{$lwsp}*{$mailbox}/"; unset($domain, $route_addr, $route, $phrase, $addr_spec, $sub_domain, $localpart, $atom, $word, $quoted_string); unset($dtext, $controls, $specials, $lwsp, $domain_literal); if (!preg_match($rfc822re, $email)) { $result[0] = false; $result[1] = sprintf(_("E-Mail address '%s' is not properly formatted"), $email); return $result; } if ($noconnect) { return array(true, sprintf(_("E-Mail address '%s' is properly formatted"), $email)); } list($Username, $Domain) = explode("@", $email); //Todo: getmxrr workaround on windows or manual input field to verify it manually if (!isWindows() and getmxrr($Domain, $MXHost)) { // avoid warning on Windows. $ConnectAddress = $MXHost[0]; } else { $ConnectAddress = $Domain; if (isset($EMailHosts[$Domain])) { $ConnectAddress = $EMailHosts[$Domain]; } } $Connect = @fsockopen($ConnectAddress, 25); if ($Connect) { if (ereg("^220", $Out = fgets($Connect, 1024))) { fputs($Connect, "HELO {$HTTP_HOST}\r\n"); $Out = fgets($Connect, 1024); fputs($Connect, "MAIL FROM: <" . $email . ">\r\n"); $From = fgets($Connect, 1024); fputs($Connect, "RCPT TO: <" . $email . ">\r\n"); $To = fgets($Connect, 1024); fputs($Connect, "QUIT\r\n"); fclose($Connect); if (!ereg("^250", $From)) { $result[0] = false; $result[1] = "Server rejected address: " . $From; return $result; } if (!ereg("^250", $To)) { $result[0] = false; $result[1] = "Server rejected address: " . $To; return $result; } } else { $result[0] = false; $result[1] = "No response from server"; return $result; } } else { $result[0] = false; $result[1] = "Can not connect E-Mail server."; return $result; } $result[0] = true; $result[1] = "E-Mail address '{$email}' appears to be valid."; return $result; }
/** * PHP構文チェック * * @param array $check チェック対象文字列 * @return bool */ public function phpValidSyntax($check) { if (empty($check[key($check)])) { return true; } if (!function_exists('exec')) { return true; } if (isWindows()) { $tmpName = tempnam(TMP, "syntax"); $tmp = new File($tmpName); $tmp->open("w"); $tmp->write($check[key($check)]); $tmp->close(); $command = sprintf("php -l %s 2>&1", escapeshellarg($tmpName)); exec($command, $output, $exit); $tmp->delete(); } else { $format = 'echo %s | php -l 2>&1'; $command = sprintf($format, escapeshellarg($check[key($check)])); exec($command, $output, $exit); } if ($exit === 0) { return true; } $message = 'PHPの構文エラーです: ' . PHP_EOL . implode(' ' . PHP_EOL, $output); return $message; }