function getWorkingDir()
{
    if ($GLOBALS['WORKING_DIR_FIRST_RUN']) {
        $GLOBALS['SESSION_WORKING_DIR'] = buildPath(WORKING_DIR, md5($_SERVER['REMOTE_ADDR'] . time()));
        mkdir($GLOBALS['SESSION_WORKING_DIR']);
        $GLOBALS['WORKING_DIR_FIRST_RUN'] = false;
    }
    return buildPath($GLOBALS['SESSION_WORKING_DIR']);
}
Exemplo n.º 2
0
function buildPath(&$segments, $id)
{
    if (!$id) {
        return;
    }
    $db = JFactory::getDBO();
    $db->setQuery("SELECT * FROM `#__categories` WHERE extension='com_osdownloads' AND id = " . (int) $id);
    $cate = $db->loadObject();
    if ($cate) {
        $segments[] = $cate->alias;
    }
    if ($cate && $cate->parent_id) {
        buildPath($segments, $cate->parent_id);
    }
}
Exemplo n.º 3
0
/**
 * create a file for the example with the given $content
 * the script die()'s if fopen() fails
 *
 * @param string $directory directory without / at the end
 * @param string $filename filename without path and extension
 * @param string $extension extension of the file without "."
 * @param string $content the content of the file
 * @access public
 * @return void
 */
function createFile($directory, $filename, $extension, $content = "")
{
    $handle = @fopen(buildPath($directory, $filename, $extension), "w");
    if ($handle) {
        fwrite($handle, $content);
        fclose($handle);
    } else {
        die("FAILED to create file\n");
    }
}
 private function setStore()
 {
     $storePath = buildPath(array(APPPATH, 'cache', 'openid'));
     if (!file_exists($storePath) && !mkdir($storePath)) {
         throw new InvalidOpenIDCacheDirectoryException($storePath);
     }
     $this->OpenIDStorage = new Auth_OpenID_FileStore($storePath);
 }
Exemplo n.º 5
0
 /**
  * Sets the track's meta information.
  * $meta is an array of meta fields to set.
  * $mode specifies where to update the meta,
  * false means do it in the cache and in the id3.
  * 
  * @author Ben Dodson
  * @version 10/13/04
  * @since 10/13/04
  */
 function setMeta($meta, $mode = false, $displayOutput = false)
 {
     global $jzSERVICES, $allow_id3_modify, $backend, $hierarchy;
     if (is_array($hierarchy)) {
         $hstring = implode("/", $hierarchy);
     } else {
         $hstring = $hierarchy;
     }
     if ($mode == false) {
         // TODO: add variable to see if user allows ID3 updating.
         $this->setMeta($meta, "file");
         $this->setMeta($meta, "cache");
     }
     if ($mode == "cache") {
         $filecache = $this->readCache();
         if (isset($meta['title'])) {
             $filecache[7] = $meta['title'];
         }
         if (isset($meta['frequency'])) {
             $filecache[8] = $meta['frequency'];
         }
         if (isset($meta['comment'])) {
             $filecache[9] = $meta['comment'];
         }
         if (isset($meta['year'])) {
             $filecache[11] = $meta['year'];
         }
         if (isset($meta['size'])) {
             $filecache[13] = $meta['size'];
         }
         if (isset($meta['length'])) {
             $filecache[14] = $meta['length'];
         }
         if (isset($meta['genre'])) {
             $filecache[15] = $meta['genre'];
         }
         if (isset($meta['artist'])) {
             $filecache[16] = $meta['artist'];
         }
         if (isset($meta['album'])) {
             $filecache[17] = $meta['album'];
         }
         if (isset($meta['type'])) {
             $filecache[18] = $meta['type'];
         }
         if (isset($meta['lyrics'])) {
             $filecache[19] = $meta['lyrics'];
         }
         if (isset($meta['bitrate'])) {
             $filecache[20] = $meta['bitrate'];
         }
         if (isset($meta['number'])) {
             $filecache[21] = $meta['number'];
         }
         $this->writeCache($filecache);
         return true;
     } else {
         if ($mode == "direct") {
             $fname = $this->getPath("String");
         } else {
             $fname = $this->getFileName("host");
         }
         if ($backend == "id3-database" || $backend == "id3-cache") {
             $oldmeta = $this->getMeta("file");
         }
         // Ok, now we need to write the data to this file IF it's an MP3
         if ($allow_id3_modify == "true") {
             $status = $jzSERVICES->setTagData($fname, $meta);
         } else {
             $status = true;
         }
         if (!isset($meta['genre'])) {
             $meta['genre'] = $oldmeta['genre'];
         }
         if (!isset($meta['artist'])) {
             $meta['artist'] = $oldmeta['artist'];
         }
         if (!isset($meta['album'])) {
             $meta['album'] = $oldmeta['album'];
         }
         if (!isset($meta['filename'])) {
             $meta['filename'] = $oldmeta['filename'];
         }
         if ($backend == "id3-database" || $backend == "id3-cache") {
             if ($oldmeta['genre'] != $meta['genre'] && stristr($hstring, "genre") !== false || $oldmeta['artist'] != $meta['artist'] && stristr($hstring, "artist") !== false || $oldmeta['album'] != $meta['album'] && stristr($hstring, "album") !== false || $oldmeta['filename'] != $meta['filename']) {
                 // The media needs to be moved.
                 $arr = buildPath($meta);
                 $newpath = implode("/", $arr);
                 $root = new jzMediaNode();
                 $root->moveMedia($this, $newpath);
                 $this->reconstruct($newpath);
             }
         }
         return $status;
     }
 }
<?php

function buildPath($path, $username, $password)
{
    if ($_SERVER["OS"] == "Windows_NT") {
        $path = str_replace("\\", "/", $path);
    } else {
        $path = str_replace("\\\\", "/", $path);
    }
    if (substr($path, 0, 6) != "smb://") {
        $path = "smb:" . $path;
        $path = substr($path, 0, 6) . $username . ":" . $password . "@" . substr($path, 6);
    }
    return addslashes($path);
}
if (isset($_POST["bt_add"])) {
    if (isset($_POST["tf_add"])) {
        $pfad = buildPath($_POST["tf_add"], $_POST["tf_add_name"], $_POST["tf_add_password"]);
    }
    $mysql->query("insert into " . $cfg["table_suchpfade"] . " (pfad) values('" . $pfad . "')");
    $util->searchPath($path);
}
if (isset($_GET["del"])) {
    $mysql->query("delete from " . $cfg["table_suchpfade"] . " where id=" . $_GET["del"] . " limit 1");
}
Exemplo n.º 7
0
<?php

function buildPath()
{
    return implode(DIRECTORY_SEPARATOR, func_get_args());
}
gc_disable();
define('TEST_DATA_DIR', buildPath(__DIR__, 'data'));
if (getenv('MATH_LIB') === false) {
    echo 'MATH_LIB env var is not defined, defaulting to GMP' . PHP_EOL;
    define('MATH_LIB', 'gmp');
} else {
    define('MATH_LIB', getenv('MATH_LIB'));
}
include buildPath(__DIR__, '..', 'vendor', 'autoload.php');
$requiredNestingLevel = 150;
if (extension_loaded('xdebug')) {
    $currentNestingLevel = intval(ini_get('xdebug.max_nesting_level'));
    if ($currentNestingLevel < $requiredNestingLevel) {
        fwrite(STDERR, <<<TEXT

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IMPORTANT NOTICE:
It seems like you have the xdebug extension loaded.
To use phpecc you have to increase the maximum nesting level from {$currentNestingLevel} to at least {$requiredNestingLevel}
You can do this by adding the following line to your php.ini:

xdebug.max_nesting_level = {$requiredNestingLevel}

The tests will now run with this setting.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	function buildPath($elements, $id, $path = ''){
	
		foreach ($elements as $element) {
		
            if ($element['id'] == $id) {
                
				$path = $element['url'] . "/" . $path;				
				$id = $element['parent_id'];				
				$path = buildPath($elements, $id, $path);
            }
        }
		
        return $path;
	}
Exemplo n.º 9
0
            flush();
        }
        fclose($hd);
        break;
    case 'upload':
        if (!strlen($_SERVER['HTTP_X_FILE_NAME'])) {
            // classic upload
            foreach ($_FILES as $file) {
                $destfile = $file['name'];
                checkVar($destfile);
                $target = buildPath($BASE_PATH, $destfile);
                checkFileExtension($target);
                if (move_uploaded_file($file['tmp_name'], $target)) {
                    $success = true;
                }
            }
        } else {
            // HTML5 single file upload
            $destfile = $_SERVER['HTTP_X_FILE_NAME'];
            checkVar($destfile);
            $target = buildPath($BASE_PATH, $destfile);
            checkFileExtension($target);
            if (!@file_put_contents($target, file_get_contents("php://input"))) {
                print jsonResponse(false, 'cannot create file');
                break;
            }
            $success = true;
        }
        print jsonResponse($success);
        break;
}
Exemplo n.º 10
0
 /**
  *  Injects a leaf or a node into $this.
  * Updated parameters for Jinzora 3.0.
  * 
  * $pathArray can set the following fields:
  * genre, subgenre, artist, album, disk, track
  * If anything is not set, this function will try and pull
  * the information from $this.
  * 
  * @author Ben Dodson
  * @since version - Jul 28, 2006
  */
 function inject($pathArray, $filename, $meta = false)
 {
     if (!isset($pathArray['genre']) && false !== ($info = getInformation($this, "genre"))) {
         $pathArray['genre'] = $info;
     }
     if (!isset($pathArray['subgenre']) && false !== ($info = getInformation($this, "subgenre"))) {
         $pathArray['subgenre'] = $info;
     }
     if (!isset($pathArray['artist']) && false !== ($info = getInformation($this, "artist"))) {
         $pathArray['artist'] = $info;
     }
     if (!isset($pathArray['album']) && false !== ($info = getInformation($this, "album"))) {
         $pathArray['album'] = $info;
     }
     if (!isset($pathArray['disk']) && false !== ($info = getInformation($this, "disk"))) {
         $pathArray['disk'] = $info;
     }
     $mpath = buildPath($pathArray);
     $root = new jzMediaNode();
     $res = $root->oldInject($mpath, $filename);
     if (is_object($res) and $res->isLeaf()) {
         $be = new jzBackend();
         $be->registerFile($filename, $mpath);
         if (is_array($meta) && sizeof($meta) > 0) {
             $res->setMeta($meta, "cache");
             $res->playpath = $filename;
         }
     }
     return $res;
 }
	protected function page() {
	
		switch($this->method) {
		
			case 'GET':
			
				if(empty($this->args) && empty($this->verb)) {
			
					$result = $this->db->query("select id, title, meta_title, url, keywords, description, prev_text, full_text, category, post_status from content");								// all pages
					
					return array("success" => 1, "items" => $result->rows);
				
				} else if(empty($this->verb) && count($this->args) == 1) {
					
					$id = htmlspecialchars(strip_tags($this->args[0]));
				
					$result = $this->db->query("select id, title, meta_title, url, keywords, description, prev_text, full_text, category, post_status from content where id = '".$id."'");			// single page by id
					
					return array("success" => 1, "items" => $result->rows);
										
				} else if(count($this->args) == 1 && $this->verb == 'category'){
					
					$id = htmlspecialchars(strip_tags($this->args[0]));
					
					$result = $this->db->query("select id, title, meta_title, url, keywords, description, prev_text, full_text, category, post_status from content where category = '".$id."'");	// pages by category
					
					return array("success" => 1, "items" => $result->rows);
					
				} else {
					return array("success" => 0, "error_message" => "BAD REQUEST");									
				}
				
				break;
			
			case 'POST':		
				
				if(empty($this->args) && empty($this->verb)){
			
					$data = $this->unsafe_request;
					$exceptions = array("prev_text", "full_text");
					stripFields($data, $exceptions);				
					
					$date = date_create();
					
					$data['created'] = date_timestamp_get($date);
					
					$cat_id = $data['category'];
					$result = $this->db->query("select id, parent_id, url from category");

					$path = buildPath($result->rows, $cat_id);
										
					$query = "insert into content (title, meta_title, url, cat_url, keywords, description, prev_text, full_text, category, post_status, author, publish_date, created, updated, lang, lang_alias) VALUES (";
					$query .= "'".$data['title']."', '".$data['meta_title']."', '".$data['url']."', '".$path."', '".$data['keywords']."', '".$data['description']."', '".$data['prev_text']."', '".$data['full_text']."', '".$data['category']."', '".$data['post_status']."', '".$data['author']."', '".$data['created']."', '".$data['created']."', '".$data['created']."', '3', '0')";
							
					$result = $this->db->query($query);
					
					if($result->errno)
						return array("success" => 0, "error_message" => "INCORRECT DATA");
					else{ 
						$lastId = $this->db->getLastId();
						$this->log("Создана страница. Id: ".$lastId, $data['username'], $data['device']);
						return array("success" => 1, "insert_id" => $lastId);
					}
					
				} else {
					return array("success" => 0, "error_message" => "BAD REQUEST");
				}
				
				break;
							
			case 'PUT':				
				
				if(empty($this->verb) && count($this->args) == 1){
				
					$id = htmlspecialchars(strip_tags($this->args[0]));
					$data = $this->unsafe_request;
					
					$exceptions = array("prev_text", "full_text");
					stripFields($data, $exceptions);
					
					$date = date_create();
					
					$cat_id = $data['category'];
					$result = $this->db->query("select id, parent_id, url from category");

					$path = buildPath($result->rows, $cat_id);
					
					$data['updated'] = date_timestamp_get($date);
					$data['cat_url'] = $path;
					
					$query = "update content set title = '".$data['title']."', meta_title = '".$data['meta_title']."', url = '".$data['url']."', cat_url = '".$data['cat_url']."', keywords = '".$data['keywords']."', description = '".$data['description']."', prev_text = '".$data['prev_text']."', full_text = '".$data['full_text']."', category = '".$data['category']."', updated = '".$data['updated']."', post_status='".$data['post_status']."' where id = '".$id."'";
											
					$result = $this->db->query($query);
					
					if($result->errno)
						return array("success" => 0, "error_message" => "INCORRECT DATA");
					else{
						$this->log("Изменена страница. Id: ".$id, $data['username'], $data['device']);
						return array("success" => 1);
					}
						
				} else {
					return array("success" => 0, "error_message" => "BAD REQUEST");
				}
				
				break;
			
			case 'DELETE':			
				
				if(empty($this->verb) && count($this->args) == 1){
					
					$id = htmlspecialchars(strip_tags($this->args[0]));
	
					$result = $this->db->query("delete from content where id = '".$id."'");
					
					if($result->errno)
						return array("success" => 0, "error_message" => "PAGE NOT FOUND");	
					else {	
						$data = $this->request;
						$this->log("Удалена страница. Id: ".$id, $data['username'], $data['device']);
						$result = $this->db->query("delete from comments where item_id = '".$id."'");
						return array("success" => 1);
					}						
					
				} else {
					return array("success" => 0, "error_message" => "BAD REQUEST");
				}	
				
				break;
				
			default:
			
				break;
		}
	}