function changeWspUser($login, $old_passwd, $new_passwd, $rights, $add_user = false, $del_user = false) { $status = false; $passwd_file = new File(dirname(__FILE__) . "/../.passwd"); $passwd_file->debug_mode(true); $passwd_data = ""; $line = $passwd_file->read_line(); while ($line != null) { if ($line == "login:"******"\n") { if (!$del_user) { $passwd_data .= "login:"******"\n"; } if ($add_user) { $status = true; } $line = $passwd_file->read_line(); if ($line == "passwd:" . sha1($old_passwd) . "\n" || $del_user) { if (!$del_user) { $passwd_data .= "passwd:" . sha1($new_passwd) . "\n"; } $line = $passwd_file->read_line(); if (!$del_user) { $passwd_data .= "rights:" . $rights . "\n"; } $status = true; } else { $passwd_data .= $line; $passwd_data .= $passwd_file->read_line(); } } else { $passwd_data .= $line; } $line = $passwd_file->read_line(); } $passwd_file->close(); if ($add_user) { if ($status) { $status = false; } else { $passwd_data .= "login:"******"\n"; $passwd_data .= "passwd:" . sha1($new_passwd) . "\n"; $passwd_data .= "rights:" . $rights . "\n"; $status = true; } } if ($status) { $passwd_file = new File(dirname(__FILE__) . "/../.passwd", false, true); $passwd_file->debug_mode(true); $passwd_file->write($passwd_data); $passwd_file->close(); return true; } return false; }
/** * Method render * @access public * @param boolean $ajax_render [default value: false] * @return string html code of object ImageRotator * @since 1.0.35 */ public function render($ajax_render = false) { // remove old cache files $dirname = "wsp/cache/xml/image-rotator/"; $dir = opendir($dirname); while ($file = readdir($dir)) { if ($file != '.' && $file != '..' && !is_dir($dirname . $file)) { $filemtime = @filemtime($dirname . $file); if ($filemtime != false && time() - $filemtime >= 1800) { // > 30 minutes $filedir = $dirname . $file; unlink($filedir); } } } closedir($dir); $file = $dirname . $this->id . "-" . session_id() . ".xml"; $f = new File($file, false, true); $f->debug_mode(true); $data = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $data .= "<playlist version=\"1\" xmlns=\"http://xspf.org/ns/0/\">\n"; $data .= "\t<trackList>\n"; for ($i = 0; $i < sizeof($this->array_img_src); $i++) { $link = new Link($this->array_img_link[$i]); if ($link->getUserHaveRights()) { $data .= "\t\t<track>\n"; $data .= "\t\t\t<title>" . utf8encode($this->array_img_title[$i]) . "</title>\n"; $data .= "\t\t\t<creator>" . utf8encode(SITE_NAME) . "</creator>\n"; $data .= "\t\t\t<location>" . $this->array_img_src[$i] . "</location>\n"; $data .= "\t\t\t<info>" . $this->array_img_link[$i] . "</info>\n"; $data .= "\t\t</track>\n"; } } $data .= "\t</trackList>\n"; $data .= "</playlist>\n"; $f->write($data); $f->close(); $video_object = new SwfObject($this->id, BASE_URL . "wsp/flash/imagerotator.swf", $this->width, $this->height); $video_object->addParam("allowfullscreen", "true"); $video_object->addVariable("file", $file); if ($this->navigation_bar == false) { $video_object->addVariable("shownavigation", "false"); } if ($this->rotate_time != '') { $video_object->addVariable("rotatetime", $this->rotate_time); } if ($this->transition != '') { $video_object->addVariable("transition", $this->transition); } if ($this->is_link) { $video_object->addVariable("linkfromdisplay", 'true'); } $this->object_change = false; return $video_object->render(); }